amsdal_cli 0.5.9__py3-none-any.whl → 0.5.10__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- amsdal_cli/__about__.py +1 -1
- amsdal_cli/commands/cloud/command.py +1 -0
- amsdal_cli/commands/cloud/external_connections/__init__.py +3 -0
- amsdal_cli/commands/cloud/external_connections/app.py +11 -0
- amsdal_cli/commands/cloud/external_connections/command.py +5 -0
- amsdal_cli/commands/cloud/external_connections/sub_commands/__init__.py +11 -0
- amsdal_cli/commands/cloud/external_connections/sub_commands/connection_add.py +123 -0
- amsdal_cli/commands/cloud/external_connections/sub_commands/connection_list.py +146 -0
- amsdal_cli/commands/cloud/external_connections/sub_commands/connection_remove.py +82 -0
- amsdal_cli/commands/cloud/external_connections/sub_commands/connection_update.py +104 -0
- {amsdal_cli-0.5.9.dist-info → amsdal_cli-0.5.10.dist-info}/METADATA +1 -1
- {amsdal_cli-0.5.9.dist-info → amsdal_cli-0.5.10.dist-info}/RECORD +15 -7
- {amsdal_cli-0.5.9.dist-info → amsdal_cli-0.5.10.dist-info}/WHEEL +0 -0
- {amsdal_cli-0.5.9.dist-info → amsdal_cli-0.5.10.dist-info}/entry_points.txt +0 -0
- {amsdal_cli-0.5.9.dist-info → amsdal_cli-0.5.10.dist-info}/licenses/LICENSE.txt +0 -0
amsdal_cli/__about__.py
CHANGED
|
@@ -3,6 +3,7 @@ from amsdal_cli.commands.cloud.app import cloud_sub_app
|
|
|
3
3
|
from amsdal_cli.commands.cloud.dependency.command import * # noqa
|
|
4
4
|
from amsdal_cli.commands.cloud.deploy.command import * # noqa
|
|
5
5
|
from amsdal_cli.commands.cloud.environments.command import * # noqa
|
|
6
|
+
from amsdal_cli.commands.cloud.external_connections.command import * # noqa
|
|
6
7
|
from amsdal_cli.commands.cloud.secret.command import * # noqa
|
|
7
8
|
from amsdal_cli.commands.cloud.security.command import * # noqa
|
|
8
9
|
from amsdal_cli.commands.cloud.sub_commands import * # noqa
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import typer
|
|
2
|
+
|
|
3
|
+
from amsdal_cli.utils.alias_group import AliasGroup
|
|
4
|
+
|
|
5
|
+
external_connections_sub_app = typer.Typer(
|
|
6
|
+
help=(
|
|
7
|
+
'Manage external connections for your Cloud Server app. '
|
|
8
|
+
'Without any sub-command, it will list all external connections.'
|
|
9
|
+
),
|
|
10
|
+
cls=AliasGroup,
|
|
11
|
+
)
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
from amsdal_cli.commands.cloud.app import cloud_sub_app
|
|
2
|
+
from amsdal_cli.commands.cloud.external_connections.app import external_connections_sub_app
|
|
3
|
+
from amsdal_cli.commands.cloud.external_connections.sub_commands import * # noqa
|
|
4
|
+
|
|
5
|
+
cloud_sub_app.add_typer(external_connections_sub_app, name='external-connections, ext-conn, ec')
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from amsdal_cli.commands.cloud.external_connections.sub_commands.connection_add import connection_add_command
|
|
2
|
+
from amsdal_cli.commands.cloud.external_connections.sub_commands.connection_list import connection_list_callback
|
|
3
|
+
from amsdal_cli.commands.cloud.external_connections.sub_commands.connection_remove import connection_remove_command
|
|
4
|
+
from amsdal_cli.commands.cloud.external_connections.sub_commands.connection_update import connection_update_command
|
|
5
|
+
|
|
6
|
+
__all__ = [
|
|
7
|
+
'connection_add_command',
|
|
8
|
+
'connection_list_callback',
|
|
9
|
+
'connection_remove_command',
|
|
10
|
+
'connection_update_command',
|
|
11
|
+
]
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import tempfile
|
|
2
|
+
import typing
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
import typer
|
|
6
|
+
from rich import print as rprint
|
|
7
|
+
from typer import Option
|
|
8
|
+
|
|
9
|
+
from amsdal_cli.commands.cloud.external_connections.app import external_connections_sub_app
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def parse_credentials(credential_options: list[str]) -> dict[str, str]:
|
|
13
|
+
"""
|
|
14
|
+
Parse credential key=value pairs into a dictionary.
|
|
15
|
+
|
|
16
|
+
Args:
|
|
17
|
+
credential_options: Tuple of strings in format "key=value"
|
|
18
|
+
|
|
19
|
+
Returns:
|
|
20
|
+
Dictionary mapping credential keys to values
|
|
21
|
+
|
|
22
|
+
Raises:
|
|
23
|
+
typer.BadParameter: If credential format is invalid
|
|
24
|
+
"""
|
|
25
|
+
credentials = {}
|
|
26
|
+
for cred in credential_options:
|
|
27
|
+
if '=' not in cred:
|
|
28
|
+
msg = f"Invalid credential format: '{cred}'. Expected 'key=value'"
|
|
29
|
+
raise typer.BadParameter(msg)
|
|
30
|
+
key, value = cred.split('=', 1)
|
|
31
|
+
credentials[key.strip()] = value.strip()
|
|
32
|
+
return credentials
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@external_connections_sub_app.command(name='add, a')
|
|
36
|
+
def connection_add_command(
|
|
37
|
+
ctx: typer.Context,
|
|
38
|
+
connection_name: str,
|
|
39
|
+
backend: str,
|
|
40
|
+
credentials: typing.Annotated[
|
|
41
|
+
typing.Optional[list[str]], # noqa: UP007
|
|
42
|
+
Option('--credential', '-c', help='Credential in key=value format. Can be specified multiple times.'),
|
|
43
|
+
] = None,
|
|
44
|
+
env_name: typing.Annotated[
|
|
45
|
+
typing.Optional[str], # noqa: UP007
|
|
46
|
+
Option('--env', help='Environment name. Default is the current environment from configuration.'),
|
|
47
|
+
] = None,
|
|
48
|
+
) -> None:
|
|
49
|
+
"""
|
|
50
|
+
Adds a new external connection to your Cloud Server app.
|
|
51
|
+
"""
|
|
52
|
+
from amsdal.errors import AmsdalCloudError
|
|
53
|
+
from amsdal.manager import AmsdalManager
|
|
54
|
+
from amsdal.manager import AsyncAmsdalManager
|
|
55
|
+
from amsdal_utils.config.manager import AmsdalConfigManager
|
|
56
|
+
|
|
57
|
+
from amsdal_cli.commands.build.services.builder import AppBuilder
|
|
58
|
+
from amsdal_cli.commands.cloud.environments.utils import get_current_env
|
|
59
|
+
from amsdal_cli.utils.cli_config import CliConfig
|
|
60
|
+
from amsdal_cli.utils.text import rich_error
|
|
61
|
+
from amsdal_cli.utils.text import rich_highlight
|
|
62
|
+
from amsdal_cli.utils.text import rich_info
|
|
63
|
+
from amsdal_cli.utils.text import rich_success
|
|
64
|
+
|
|
65
|
+
cli_config: CliConfig = ctx.meta['config']
|
|
66
|
+
env_name = env_name or get_current_env(cli_config)
|
|
67
|
+
|
|
68
|
+
# Parse credentials
|
|
69
|
+
if not credentials or len(credentials) == 0:
|
|
70
|
+
rprint(rich_error('At least one credential must be provided using --credential/-c'))
|
|
71
|
+
raise typer.Exit(1)
|
|
72
|
+
|
|
73
|
+
try:
|
|
74
|
+
credentials_dict = parse_credentials(credentials)
|
|
75
|
+
except typer.BadParameter as e:
|
|
76
|
+
rprint(rich_error(str(e)))
|
|
77
|
+
raise typer.Exit(1) from e
|
|
78
|
+
|
|
79
|
+
if cli_config.verbose:
|
|
80
|
+
rprint(
|
|
81
|
+
rich_info(
|
|
82
|
+
f'Adding external connection {rich_highlight(connection_name)} '
|
|
83
|
+
f'with backend {rich_highlight(backend)} '
|
|
84
|
+
f'to environment: {rich_highlight(env_name)}'
|
|
85
|
+
)
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
with tempfile.TemporaryDirectory() as _temp_dir:
|
|
89
|
+
output_path: Path = Path(_temp_dir)
|
|
90
|
+
|
|
91
|
+
app_builder = AppBuilder(
|
|
92
|
+
cli_config=cli_config,
|
|
93
|
+
config_path=cli_config.config_path,
|
|
94
|
+
)
|
|
95
|
+
app_builder.build(output_path, is_silent=True)
|
|
96
|
+
manager: AsyncAmsdalManager | AmsdalManager
|
|
97
|
+
|
|
98
|
+
manager = AsyncAmsdalManager() if AmsdalConfigManager().get_config().async_mode else AmsdalManager()
|
|
99
|
+
|
|
100
|
+
manager.authenticate()
|
|
101
|
+
|
|
102
|
+
try:
|
|
103
|
+
manager.cloud_actions_manager.add_external_connection(
|
|
104
|
+
connection_name=connection_name,
|
|
105
|
+
backend=backend,
|
|
106
|
+
credentials=credentials_dict,
|
|
107
|
+
env_name=env_name,
|
|
108
|
+
application_uuid=cli_config.application_uuid,
|
|
109
|
+
application_name=cli_config.application_name,
|
|
110
|
+
)
|
|
111
|
+
except AmsdalCloudError as e:
|
|
112
|
+
rprint(rich_error(str(e)))
|
|
113
|
+
raise typer.Exit(1) from e
|
|
114
|
+
else:
|
|
115
|
+
config_dir: Path = cli_config.app_directory / '.amsdal'
|
|
116
|
+
config_dir.mkdir(exist_ok=True, parents=True)
|
|
117
|
+
_connections_path: Path = config_dir / '.external_connections'
|
|
118
|
+
_connections_path.touch(exist_ok=True)
|
|
119
|
+
_connections = set(_connections_path.read_text().split('\n'))
|
|
120
|
+
_connections.add(connection_name)
|
|
121
|
+
_connections_path.write_text('\n'.join(_connections))
|
|
122
|
+
|
|
123
|
+
rprint(rich_success(f'External connection {rich_highlight(connection_name)} added successfully.'))
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import tempfile
|
|
3
|
+
import typing
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import Annotated
|
|
6
|
+
|
|
7
|
+
import typer
|
|
8
|
+
from rich import print as rprint
|
|
9
|
+
from rich.table import Table
|
|
10
|
+
from typer import Option
|
|
11
|
+
|
|
12
|
+
from amsdal_cli.commands.cloud.enums import OutputFormat
|
|
13
|
+
from amsdal_cli.commands.cloud.external_connections.app import external_connections_sub_app
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def connection_list_command(
|
|
17
|
+
ctx: typer.Context,
|
|
18
|
+
output: Annotated[OutputFormat, typer.Option('--output', '-o')] = OutputFormat.default,
|
|
19
|
+
env_name: typing.Annotated[
|
|
20
|
+
typing.Optional[str], # noqa: UP007
|
|
21
|
+
Option('--env', help='Environment name. Default is the current environment from configuration.'),
|
|
22
|
+
] = None,
|
|
23
|
+
*,
|
|
24
|
+
sync: bool = Option(
|
|
25
|
+
False,
|
|
26
|
+
'--sync',
|
|
27
|
+
help='Sync the external connections from the Cloud Server to ".external_connections".',
|
|
28
|
+
),
|
|
29
|
+
) -> None:
|
|
30
|
+
"""
|
|
31
|
+
List the app external connections on the Cloud Server.
|
|
32
|
+
|
|
33
|
+
Args:
|
|
34
|
+
ctx (typer.Context): The Typer context object.
|
|
35
|
+
output (Annotated[OutputFormat, typer.Option]): The output format for the list.
|
|
36
|
+
Defaults to OutputFormat.default.
|
|
37
|
+
env_name (typing.Annotated[typing.Optional[str], Option]): The name of the environment. Defaults to the current
|
|
38
|
+
environment from configuration.
|
|
39
|
+
sync (bool): Whether to sync the external connections from the Cloud Server to ".external_connections".
|
|
40
|
+
Defaults to False.
|
|
41
|
+
|
|
42
|
+
Returns:
|
|
43
|
+
None
|
|
44
|
+
"""
|
|
45
|
+
from amsdal.errors import AmsdalCloudError
|
|
46
|
+
from amsdal.manager import AmsdalManager
|
|
47
|
+
from amsdal.manager import AsyncAmsdalManager
|
|
48
|
+
from amsdal_utils.config.manager import AmsdalConfigManager
|
|
49
|
+
|
|
50
|
+
from amsdal_cli.commands.build.services.builder import AppBuilder
|
|
51
|
+
from amsdal_cli.commands.cloud.environments.utils import get_current_env
|
|
52
|
+
from amsdal_cli.utils.cli_config import CliConfig
|
|
53
|
+
from amsdal_cli.utils.text import rich_error
|
|
54
|
+
from amsdal_cli.utils.text import rich_highlight
|
|
55
|
+
from amsdal_cli.utils.text import rich_info
|
|
56
|
+
|
|
57
|
+
cli_config: CliConfig = ctx.meta['config']
|
|
58
|
+
env_name = env_name or get_current_env(cli_config)
|
|
59
|
+
|
|
60
|
+
if cli_config.verbose:
|
|
61
|
+
rprint(rich_info(f'Listing external connections for environment: {rich_highlight(env_name)}'))
|
|
62
|
+
|
|
63
|
+
with tempfile.TemporaryDirectory() as _temp_dir:
|
|
64
|
+
output_path: Path = Path(_temp_dir)
|
|
65
|
+
app_builder = AppBuilder(
|
|
66
|
+
cli_config=cli_config,
|
|
67
|
+
config_path=cli_config.config_path,
|
|
68
|
+
)
|
|
69
|
+
app_builder.build(output_path, is_silent=True)
|
|
70
|
+
manager: AsyncAmsdalManager | AmsdalManager
|
|
71
|
+
|
|
72
|
+
manager = AsyncAmsdalManager() if AmsdalConfigManager().get_config().async_mode else AmsdalManager()
|
|
73
|
+
|
|
74
|
+
manager.authenticate()
|
|
75
|
+
|
|
76
|
+
try:
|
|
77
|
+
list_response = manager.cloud_actions_manager.list_external_connections(
|
|
78
|
+
env_name=env_name,
|
|
79
|
+
application_uuid=cli_config.application_uuid,
|
|
80
|
+
application_name=cli_config.application_name,
|
|
81
|
+
)
|
|
82
|
+
except AmsdalCloudError as e:
|
|
83
|
+
rprint(rich_error(str(e)))
|
|
84
|
+
raise typer.Exit(1) from e
|
|
85
|
+
|
|
86
|
+
if not list_response or not list_response.details:
|
|
87
|
+
return
|
|
88
|
+
|
|
89
|
+
if sync and list_response.details.connections:
|
|
90
|
+
config_dir: Path = cli_config.app_directory / '.amsdal'
|
|
91
|
+
config_dir.mkdir(exist_ok=True, parents=True)
|
|
92
|
+
_connections_path: Path = config_dir / '.external_connections'
|
|
93
|
+
_connections_path.touch(exist_ok=True)
|
|
94
|
+
_connections_path.write_text(
|
|
95
|
+
'\n'.join([connection.name for connection in list_response.details.connections]),
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
if output == OutputFormat.json:
|
|
99
|
+
rprint(json.dumps(list_response.model_dump(), indent=4))
|
|
100
|
+
return
|
|
101
|
+
|
|
102
|
+
if not list_response.details.connections:
|
|
103
|
+
rprint('No external connections found.')
|
|
104
|
+
return
|
|
105
|
+
|
|
106
|
+
data_table = Table()
|
|
107
|
+
data_table.add_column('Connection Name', justify='center')
|
|
108
|
+
data_table.add_column('Backend', justify='center')
|
|
109
|
+
data_table.add_column('Credentials', justify='center')
|
|
110
|
+
|
|
111
|
+
for connection in list_response.details.connections:
|
|
112
|
+
# Show only credential keys, not values for security
|
|
113
|
+
credential_keys = ', '.join(connection.credentials.keys()) if connection.credentials else ''
|
|
114
|
+
data_table.add_row(connection.name, connection.backend, credential_keys)
|
|
115
|
+
|
|
116
|
+
rprint(data_table)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
@external_connections_sub_app.callback(invoke_without_command=True)
|
|
120
|
+
def connection_list_callback(
|
|
121
|
+
ctx: typer.Context,
|
|
122
|
+
output: Annotated[OutputFormat, typer.Option('--output', '-o')] = OutputFormat.default,
|
|
123
|
+
env_name: typing.Annotated[
|
|
124
|
+
typing.Optional[str], # noqa: UP007
|
|
125
|
+
Option('--env', help='Environment name. Default is the current environment from configuration.'),
|
|
126
|
+
] = None,
|
|
127
|
+
*,
|
|
128
|
+
sync: bool = Option(
|
|
129
|
+
False,
|
|
130
|
+
'--sync',
|
|
131
|
+
help='Sync the external connections from the Cloud Server to ".external_connections".',
|
|
132
|
+
),
|
|
133
|
+
) -> None:
|
|
134
|
+
"""
|
|
135
|
+
Lists the app external connections on the Cloud Server.
|
|
136
|
+
"""
|
|
137
|
+
|
|
138
|
+
if ctx.invoked_subcommand is not None:
|
|
139
|
+
return
|
|
140
|
+
|
|
141
|
+
connection_list_command(
|
|
142
|
+
ctx=ctx,
|
|
143
|
+
output=output,
|
|
144
|
+
env_name=env_name,
|
|
145
|
+
sync=sync,
|
|
146
|
+
)
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import tempfile
|
|
2
|
+
import typing
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
import typer
|
|
6
|
+
from rich import print as rprint
|
|
7
|
+
from typer import Option
|
|
8
|
+
|
|
9
|
+
from amsdal_cli.commands.cloud.external_connections.app import external_connections_sub_app
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@external_connections_sub_app.command(name='remove, rm, r')
|
|
13
|
+
def connection_remove_command(
|
|
14
|
+
ctx: typer.Context,
|
|
15
|
+
connection_name: str,
|
|
16
|
+
env_name: typing.Annotated[
|
|
17
|
+
typing.Optional[str], # noqa: UP007
|
|
18
|
+
Option('--env', help='Environment name. Default is the current environment from configuration.'),
|
|
19
|
+
] = None,
|
|
20
|
+
) -> None:
|
|
21
|
+
"""
|
|
22
|
+
Removes an external connection from the Cloud Server app.
|
|
23
|
+
"""
|
|
24
|
+
from amsdal.errors import AmsdalCloudError
|
|
25
|
+
from amsdal.manager import AmsdalManager
|
|
26
|
+
from amsdal.manager import AsyncAmsdalManager
|
|
27
|
+
from amsdal_utils.config.manager import AmsdalConfigManager
|
|
28
|
+
|
|
29
|
+
from amsdal_cli.commands.build.services.builder import AppBuilder
|
|
30
|
+
from amsdal_cli.commands.cloud.environments.utils import get_current_env
|
|
31
|
+
from amsdal_cli.utils.cli_config import CliConfig
|
|
32
|
+
from amsdal_cli.utils.text import rich_error
|
|
33
|
+
from amsdal_cli.utils.text import rich_highlight
|
|
34
|
+
from amsdal_cli.utils.text import rich_info
|
|
35
|
+
from amsdal_cli.utils.text import rich_success
|
|
36
|
+
|
|
37
|
+
cli_config: CliConfig = ctx.meta['config']
|
|
38
|
+
env_name = env_name or get_current_env(cli_config)
|
|
39
|
+
|
|
40
|
+
if cli_config.verbose:
|
|
41
|
+
rprint(
|
|
42
|
+
rich_info(
|
|
43
|
+
f'Removing external connection {rich_highlight(connection_name)} '
|
|
44
|
+
f'from environment: {rich_highlight(env_name)}'
|
|
45
|
+
)
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
with tempfile.TemporaryDirectory() as _temp_dir:
|
|
49
|
+
output_path: Path = Path(_temp_dir)
|
|
50
|
+
app_builder = AppBuilder(
|
|
51
|
+
cli_config=cli_config,
|
|
52
|
+
config_path=cli_config.config_path,
|
|
53
|
+
)
|
|
54
|
+
app_builder.build(output_path, is_silent=True)
|
|
55
|
+
manager: AsyncAmsdalManager | AmsdalManager
|
|
56
|
+
|
|
57
|
+
manager = AsyncAmsdalManager() if AmsdalConfigManager().get_config().async_mode else AmsdalManager()
|
|
58
|
+
|
|
59
|
+
manager.authenticate()
|
|
60
|
+
|
|
61
|
+
try:
|
|
62
|
+
manager.cloud_actions_manager.remove_external_connection(
|
|
63
|
+
connection_name=connection_name,
|
|
64
|
+
env_name=env_name,
|
|
65
|
+
application_uuid=cli_config.application_uuid,
|
|
66
|
+
application_name=cli_config.application_name,
|
|
67
|
+
)
|
|
68
|
+
except AmsdalCloudError as e:
|
|
69
|
+
rprint(rich_error(str(e)))
|
|
70
|
+
raise typer.Exit(1) from e
|
|
71
|
+
else:
|
|
72
|
+
config_dir: Path = cli_config.app_directory / '.amsdal'
|
|
73
|
+
config_dir.mkdir(exist_ok=True, parents=True)
|
|
74
|
+
_connections_path: Path = config_dir / '.external_connections'
|
|
75
|
+
_connections_path.touch(exist_ok=True)
|
|
76
|
+
_connections = set(_connections_path.read_text().split('\n'))
|
|
77
|
+
|
|
78
|
+
if connection_name in _connections:
|
|
79
|
+
_connections.remove(connection_name)
|
|
80
|
+
_connections_path.write_text('\n'.join(_connections))
|
|
81
|
+
|
|
82
|
+
rprint(rich_success(f'External connection {rich_highlight(connection_name)} removed successfully.'))
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import tempfile
|
|
2
|
+
import typing
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
import typer
|
|
6
|
+
from rich import print as rprint
|
|
7
|
+
from typer import Option
|
|
8
|
+
|
|
9
|
+
from amsdal_cli.commands.cloud.external_connections.app import external_connections_sub_app
|
|
10
|
+
from amsdal_cli.commands.cloud.external_connections.sub_commands.connection_add import parse_credentials
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@external_connections_sub_app.command(name='update, u')
|
|
14
|
+
def connection_update_command(
|
|
15
|
+
ctx: typer.Context,
|
|
16
|
+
connection_name: str,
|
|
17
|
+
backend: typing.Annotated[
|
|
18
|
+
typing.Optional[str], # noqa: UP007
|
|
19
|
+
Option('--backend', '-b', help='New backend type for the connection.'),
|
|
20
|
+
] = None,
|
|
21
|
+
credentials: typing.Annotated[
|
|
22
|
+
typing.Optional[list[str]], # noqa: UP007
|
|
23
|
+
Option('--credential', '-c', help='Credential in key=value format. Can be specified multiple times.'),
|
|
24
|
+
] = None,
|
|
25
|
+
env_name: typing.Annotated[
|
|
26
|
+
typing.Optional[str], # noqa: UP007
|
|
27
|
+
Option('--env', help='Environment name. Default is the current environment from configuration.'),
|
|
28
|
+
] = None,
|
|
29
|
+
) -> None:
|
|
30
|
+
"""
|
|
31
|
+
Updates an existing external connection in your Cloud Server app.
|
|
32
|
+
"""
|
|
33
|
+
from amsdal.errors import AmsdalCloudError
|
|
34
|
+
from amsdal.manager import AmsdalManager
|
|
35
|
+
from amsdal.manager import AsyncAmsdalManager
|
|
36
|
+
from amsdal_utils.config.manager import AmsdalConfigManager
|
|
37
|
+
|
|
38
|
+
from amsdal_cli.commands.build.services.builder import AppBuilder
|
|
39
|
+
from amsdal_cli.commands.cloud.environments.utils import get_current_env
|
|
40
|
+
from amsdal_cli.utils.cli_config import CliConfig
|
|
41
|
+
from amsdal_cli.utils.text import rich_error
|
|
42
|
+
from amsdal_cli.utils.text import rich_highlight
|
|
43
|
+
from amsdal_cli.utils.text import rich_info
|
|
44
|
+
from amsdal_cli.utils.text import rich_success
|
|
45
|
+
|
|
46
|
+
cli_config: CliConfig = ctx.meta['config']
|
|
47
|
+
env_name = env_name or get_current_env(cli_config)
|
|
48
|
+
|
|
49
|
+
# Validate that at least one update parameter is provided
|
|
50
|
+
if not backend and (not credentials or len(credentials) == 0):
|
|
51
|
+
rprint(rich_error('No updates specified. Provide --backend or --credential.'))
|
|
52
|
+
raise typer.Exit(1)
|
|
53
|
+
|
|
54
|
+
# Parse credentials if provided
|
|
55
|
+
credentials_dict = None
|
|
56
|
+
if credentials:
|
|
57
|
+
try:
|
|
58
|
+
credentials_dict = parse_credentials(credentials)
|
|
59
|
+
except typer.BadParameter as e:
|
|
60
|
+
rprint(rich_error(str(e)))
|
|
61
|
+
raise typer.Exit(1) from e
|
|
62
|
+
|
|
63
|
+
if cli_config.verbose:
|
|
64
|
+
update_info = []
|
|
65
|
+
if backend:
|
|
66
|
+
update_info.append(f'backend to {rich_highlight(backend)}')
|
|
67
|
+
if credentials_dict:
|
|
68
|
+
update_info.append('credentials')
|
|
69
|
+
rprint(
|
|
70
|
+
rich_info(
|
|
71
|
+
f'Updating external connection {rich_highlight(connection_name)} '
|
|
72
|
+
f'({", ".join(update_info)}) '
|
|
73
|
+
f'in environment: {rich_highlight(env_name)}'
|
|
74
|
+
)
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
with tempfile.TemporaryDirectory() as _temp_dir:
|
|
78
|
+
output_path: Path = Path(_temp_dir)
|
|
79
|
+
|
|
80
|
+
app_builder = AppBuilder(
|
|
81
|
+
cli_config=cli_config,
|
|
82
|
+
config_path=cli_config.config_path,
|
|
83
|
+
)
|
|
84
|
+
app_builder.build(output_path, is_silent=True)
|
|
85
|
+
manager: AsyncAmsdalManager | AmsdalManager
|
|
86
|
+
|
|
87
|
+
manager = AsyncAmsdalManager() if AmsdalConfigManager().get_config().async_mode else AmsdalManager()
|
|
88
|
+
|
|
89
|
+
manager.authenticate()
|
|
90
|
+
|
|
91
|
+
try:
|
|
92
|
+
manager.cloud_actions_manager.update_external_connection(
|
|
93
|
+
connection_name=connection_name,
|
|
94
|
+
env_name=env_name,
|
|
95
|
+
backend=backend,
|
|
96
|
+
credentials=credentials_dict,
|
|
97
|
+
application_uuid=cli_config.application_uuid,
|
|
98
|
+
application_name=cli_config.application_name,
|
|
99
|
+
)
|
|
100
|
+
except AmsdalCloudError as e:
|
|
101
|
+
rprint(rich_error(str(e)))
|
|
102
|
+
raise typer.Exit(1) from e
|
|
103
|
+
|
|
104
|
+
rprint(rich_success(f'External connection {rich_highlight(connection_name)} updated successfully.'))
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
amsdal_cli/Third-Party Materials - AMSDAL Dependencies - License Notices.md,sha256=uHJlGG0D4tbpUi8cq-497NNO9ltQ67a5448k-T14HTw,68241
|
|
2
|
-
amsdal_cli/__about__.py,sha256=
|
|
2
|
+
amsdal_cli/__about__.py,sha256=2PfW0mPI4DYZrdult5d2mMRHPOJDirOQvIzkUq-Vwks,125
|
|
3
3
|
amsdal_cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
amsdal_cli/app.py,sha256=_ucuLT5ospf1ifFKEG0IMfVnxKjnvPUQ4iMhkvOfCrc,466
|
|
5
5
|
amsdal_cli/main.py,sha256=LtH-BD1eJrAUecjKzC8Gx7kYFUstOMH1erdeJUVqFB8,144
|
|
@@ -54,7 +54,7 @@ amsdal_cli/commands/clean/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJW
|
|
|
54
54
|
amsdal_cli/commands/clean/command.py,sha256=a4h0ZB7B9pRSyUaJF5d1eD33cwgvmexm_z8W3Ws71_Q,934
|
|
55
55
|
amsdal_cli/commands/cloud/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
56
56
|
amsdal_cli/commands/cloud/app.py,sha256=PKtcnIoByDMn0vGPSQrr9lfhg90Za2S2X9Z0C-zM430,174
|
|
57
|
-
amsdal_cli/commands/cloud/command.py,sha256=
|
|
57
|
+
amsdal_cli/commands/cloud/command.py,sha256=L5Es2Xukqs6WPdskVC_jDzqroEVUL-HxPUnCzvp1nwo,601
|
|
58
58
|
amsdal_cli/commands/cloud/enums.py,sha256=mQJzdRDSeWgm9D2zTaXMbG0_EKcQ_ff-79iZE57kAME,612
|
|
59
59
|
amsdal_cli/commands/cloud/dependency/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
60
60
|
amsdal_cli/commands/cloud/dependency/app.py,sha256=m2pcB5z3257uU7pKt9XoOdQn7J3PUys6elCs9c9qc2o,230
|
|
@@ -80,6 +80,14 @@ amsdal_cli/commands/cloud/environments/sub_commands/env_checkout.py,sha256=S4wh-
|
|
|
80
80
|
amsdal_cli/commands/cloud/environments/sub_commands/env_delete.py,sha256=4OlTKASd0fKCh7Pv7AUcMJlgiQYVViID1GwlQsmOsgc,1773
|
|
81
81
|
amsdal_cli/commands/cloud/environments/sub_commands/env_list.py,sha256=7QT-cVuBVQ3ddjlCLVIXf-D9PI1lkaUn96K1THW6A-Q,2789
|
|
82
82
|
amsdal_cli/commands/cloud/environments/sub_commands/env_new.py,sha256=GzemfFXc623OU1PakUhMAJ8vcJhXopXSghTSMx0joPs,1761
|
|
83
|
+
amsdal_cli/commands/cloud/external_connections/__init__.py,sha256=BFs3y_xV8DORVjNcHoTgFVbZCtpFR6_Q7szDC47juPI,136
|
|
84
|
+
amsdal_cli/commands/cloud/external_connections/app.py,sha256=NHsG9-wnE2COpeD0PJEhmmKnlzK2y6bC9-2qJF_fArI,291
|
|
85
|
+
amsdal_cli/commands/cloud/external_connections/command.py,sha256=o9Q1PXqj16LhGTbRasFpV2X4VHYmqMFOraWLCjhHOGY,328
|
|
86
|
+
amsdal_cli/commands/cloud/external_connections/sub_commands/__init__.py,sha256=QERWNr1qYFlqyDSkBnSjkJ6H-v2ipJxANRZJNtSQJU4,598
|
|
87
|
+
amsdal_cli/commands/cloud/external_connections/sub_commands/connection_add.py,sha256=m3TlrjL-uKUlVzboWtF0zQ3oNAWUcMc9r-aIej-zT1U,4372
|
|
88
|
+
amsdal_cli/commands/cloud/external_connections/sub_commands/connection_list.py,sha256=c-k5OrlTAHmw93werYEc7ykRQMslURTLLPR45u8GAaI,5203
|
|
89
|
+
amsdal_cli/commands/cloud/external_connections/sub_commands/connection_remove.py,sha256=XCxrSPP1vKMoK2asEZKswqdEHUUHe2QVQjq54h1Z8r4,3037
|
|
90
|
+
amsdal_cli/commands/cloud/external_connections/sub_commands/connection_update.py,sha256=68qMy3n4e6RRYn0ew0MNeXuj27H0dAZM8Kb9i9RqI1Y,3883
|
|
83
91
|
amsdal_cli/commands/cloud/secret/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
84
92
|
amsdal_cli/commands/cloud/secret/app.py,sha256=0GnTkNYAUQwGpccton4Ndy2NYTEGox53I7UteHTXX-Y,224
|
|
85
93
|
amsdal_cli/commands/cloud/secret/command.py,sha256=mvEjNIiuxowlHkxK_BNOT6dh0cYaaabkuXc4sEj48N0,253
|
|
@@ -224,8 +232,8 @@ amsdal_cli/utils/vcs/base.py,sha256=jC05ExJZDnyHAsW7_4IDf8gQcYgK4dXq3zNlFIX66T4,
|
|
|
224
232
|
amsdal_cli/utils/vcs/dummy.py,sha256=Lk8MT-b0YlHHUsiXsq5cvmPwcl4jTYdo8piN5_C8ORA,434
|
|
225
233
|
amsdal_cli/utils/vcs/enums.py,sha256=tYR9LN1IOr8BZFbSeX_vDlhn8fPl4IU-Yakii8lRDYs,69
|
|
226
234
|
amsdal_cli/utils/vcs/git.py,sha256=xHynbZcV6p2D3RFCwu1MGGpV9D7eK-pGUtO8kVexTQM,1269
|
|
227
|
-
amsdal_cli-0.5.
|
|
228
|
-
amsdal_cli-0.5.
|
|
229
|
-
amsdal_cli-0.5.
|
|
230
|
-
amsdal_cli-0.5.
|
|
231
|
-
amsdal_cli-0.5.
|
|
235
|
+
amsdal_cli-0.5.10.dist-info/METADATA,sha256=tT-PolxQpK1kAtb8Pu09ZphgzxrFfhkVDLrypcbjMqM,57165
|
|
236
|
+
amsdal_cli-0.5.10.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
237
|
+
amsdal_cli-0.5.10.dist-info/entry_points.txt,sha256=GC-8LZsD3W--Pd9_gD4W3tw3ZZyPbSvkZ-qWc9Fx0NI,47
|
|
238
|
+
amsdal_cli-0.5.10.dist-info/licenses/LICENSE.txt,sha256=hG-541PFYfNJi9WRZi_hno91UyqNg7YLK8LR3vLblZA,27355
|
|
239
|
+
amsdal_cli-0.5.10.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|