snowflake-cli 3.4.1__py3-none-any.whl → 3.6.0__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.
- snowflake/cli/__about__.py +13 -1
- snowflake/cli/_app/cli_app.py +1 -10
- snowflake/cli/_app/commands_registration/builtin_plugins.py +7 -1
- snowflake/cli/_app/commands_registration/command_plugins_loader.py +3 -1
- snowflake/cli/_app/commands_registration/commands_registration_with_callbacks.py +3 -3
- snowflake/cli/_app/printing.py +2 -2
- snowflake/cli/_app/snow_connector.py +5 -4
- snowflake/cli/_app/telemetry.py +3 -15
- snowflake/cli/_app/version_check.py +4 -4
- snowflake/cli/_plugins/auth/__init__.py +11 -0
- snowflake/cli/_plugins/auth/keypair/__init__.py +0 -0
- snowflake/cli/_plugins/auth/keypair/commands.py +151 -0
- snowflake/cli/_plugins/auth/keypair/manager.py +331 -0
- snowflake/cli/_plugins/auth/keypair/plugin_spec.py +30 -0
- snowflake/cli/_plugins/connection/commands.py +79 -5
- snowflake/cli/_plugins/helpers/commands.py +3 -4
- snowflake/cli/_plugins/nativeapp/entities/application.py +4 -1
- snowflake/cli/_plugins/nativeapp/sf_sql_facade.py +33 -6
- snowflake/cli/_plugins/notebook/commands.py +3 -4
- snowflake/cli/_plugins/object/command_aliases.py +3 -1
- snowflake/cli/_plugins/object/manager.py +4 -2
- snowflake/cli/_plugins/plugin/commands.py +79 -0
- snowflake/cli/_plugins/plugin/manager.py +74 -0
- snowflake/cli/_plugins/plugin/plugin_spec.py +30 -0
- snowflake/cli/_plugins/project/__init__.py +0 -0
- snowflake/cli/_plugins/project/commands.py +173 -0
- snowflake/cli/{_app/api_impl/plugin/__init__.py → _plugins/project/feature_flags.py} +9 -0
- snowflake/cli/_plugins/project/manager.py +76 -0
- snowflake/cli/_plugins/project/plugin_spec.py +30 -0
- snowflake/cli/_plugins/project/project_entity_model.py +40 -0
- snowflake/cli/_plugins/snowpark/commands.py +2 -1
- snowflake/cli/_plugins/spcs/compute_pool/commands.py +70 -10
- snowflake/cli/_plugins/spcs/compute_pool/compute_pool_entity.py +8 -0
- snowflake/cli/_plugins/spcs/compute_pool/compute_pool_entity_model.py +37 -0
- snowflake/cli/_plugins/spcs/compute_pool/manager.py +45 -0
- snowflake/cli/_plugins/spcs/image_repository/commands.py +29 -0
- snowflake/cli/_plugins/spcs/image_repository/image_repository_entity.py +8 -0
- snowflake/cli/_plugins/spcs/image_repository/image_repository_entity_model.py +8 -0
- snowflake/cli/_plugins/spcs/image_repository/manager.py +1 -1
- snowflake/cli/_plugins/spcs/services/commands.py +53 -0
- snowflake/cli/_plugins/spcs/services/manager.py +114 -0
- snowflake/cli/_plugins/spcs/services/service_entity.py +6 -0
- snowflake/cli/_plugins/spcs/services/service_entity_model.py +45 -0
- snowflake/cli/_plugins/spcs/services/service_project_paths.py +15 -0
- snowflake/cli/_plugins/sql/manager.py +42 -51
- snowflake/cli/_plugins/sql/source_reader.py +230 -0
- snowflake/cli/_plugins/stage/manager.py +10 -4
- snowflake/cli/_plugins/streamlit/commands.py +9 -24
- snowflake/cli/_plugins/streamlit/manager.py +5 -36
- snowflake/cli/api/artifacts/upload.py +51 -0
- snowflake/cli/api/commands/flags.py +35 -10
- snowflake/cli/api/commands/snow_typer.py +12 -0
- snowflake/cli/api/commands/utils.py +2 -0
- snowflake/cli/api/config.py +15 -10
- snowflake/cli/api/constants.py +2 -0
- snowflake/cli/api/errno.py +1 -0
- snowflake/cli/api/exceptions.py +15 -1
- snowflake/cli/api/feature_flags.py +2 -0
- snowflake/cli/api/plugins/plugin_config.py +43 -4
- snowflake/cli/api/project/definition_helper.py +31 -0
- snowflake/cli/api/project/schemas/entities/entities.py +26 -0
- snowflake/cli/api/rest_api.py +2 -3
- snowflake/cli/{_app → api}/secret.py +4 -1
- snowflake/cli/api/secure_path.py +16 -4
- snowflake/cli/api/sql_execution.py +7 -3
- {snowflake_cli-3.4.1.dist-info → snowflake_cli-3.6.0.dist-info}/METADATA +12 -12
- {snowflake_cli-3.4.1.dist-info → snowflake_cli-3.6.0.dist-info}/RECORD +71 -50
- snowflake/cli/_app/api_impl/plugin/plugin_config_provider_impl.py +0 -66
- snowflake/cli/api/__init__.py +0 -48
- /snowflake/cli/{_app/api_impl → _plugins/plugin}/__init__.py +0 -0
- {snowflake_cli-3.4.1.dist-info → snowflake_cli-3.6.0.dist-info}/WHEEL +0 -0
- {snowflake_cli-3.4.1.dist-info → snowflake_cli-3.6.0.dist-info}/entry_points.txt +0 -0
- {snowflake_cli-3.4.1.dist-info → snowflake_cli-3.6.0.dist-info}/licenses/LICENSE +0 -0
snowflake/cli/__about__.py
CHANGED
|
@@ -14,4 +14,16 @@
|
|
|
14
14
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
from enum import Enum, unique
|
|
18
|
+
|
|
19
|
+
VERSION = "3.6.0"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@unique
|
|
23
|
+
class CLIInstallationSource(Enum):
|
|
24
|
+
BINARY = "binary"
|
|
25
|
+
PYPI = "pypi"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# This variable is changed in binary release script
|
|
29
|
+
INSTALLATION_SOURCE = CLIInstallationSource.PYPI
|
snowflake/cli/_app/cli_app.py
CHANGED
|
@@ -25,9 +25,6 @@ import click
|
|
|
25
25
|
import typer
|
|
26
26
|
from click import Context as ClickContext
|
|
27
27
|
from snowflake.cli import __about__
|
|
28
|
-
from snowflake.cli._app.api_impl.plugin.plugin_config_provider_impl import (
|
|
29
|
-
PluginConfigProviderImpl,
|
|
30
|
-
)
|
|
31
28
|
from snowflake.cli._app.commands_registration.commands_registration_with_callbacks import (
|
|
32
29
|
CommandsRegistrationWithCallbacks,
|
|
33
30
|
)
|
|
@@ -42,7 +39,6 @@ from snowflake.cli._app.version_check import (
|
|
|
42
39
|
get_new_version_msg,
|
|
43
40
|
show_new_version_banner_callback,
|
|
44
41
|
)
|
|
45
|
-
from snowflake.cli.api import Api, api_provider
|
|
46
42
|
from snowflake.cli.api.config import config_init, get_feature_flags_section
|
|
47
43
|
from snowflake.cli.api.output.formats import OutputFormat
|
|
48
44
|
from snowflake.cli.api.output.types import CollectionResult
|
|
@@ -63,12 +59,7 @@ def _do_not_execute_on_completion(callback):
|
|
|
63
59
|
|
|
64
60
|
class CliAppFactory:
|
|
65
61
|
def __init__(self):
|
|
66
|
-
|
|
67
|
-
self._api = api
|
|
68
|
-
self._commands_registration = CommandsRegistrationWithCallbacks(
|
|
69
|
-
api.plugin_config_provider
|
|
70
|
-
)
|
|
71
|
-
api_provider.register_api(api)
|
|
62
|
+
self._commands_registration = CommandsRegistrationWithCallbacks()
|
|
72
63
|
self._app: Optional[SnowCliMainTyper] = None
|
|
73
64
|
self._click_context: Optional[ClickContext] = None
|
|
74
65
|
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
+
from snowflake.cli._plugins.auth.keypair import plugin_spec as auth_plugin_spec
|
|
15
16
|
from snowflake.cli._plugins.connection import plugin_spec as connection_plugin_spec
|
|
16
17
|
from snowflake.cli._plugins.cortex import plugin_spec as cortex_plugin_spec
|
|
17
18
|
from snowflake.cli._plugins.git import plugin_spec as git_plugin_spec
|
|
@@ -20,6 +21,8 @@ from snowflake.cli._plugins.init import plugin_spec as init_plugin_spec
|
|
|
20
21
|
from snowflake.cli._plugins.nativeapp import plugin_spec as nativeapp_plugin_spec
|
|
21
22
|
from snowflake.cli._plugins.notebook import plugin_spec as notebook_plugin_spec
|
|
22
23
|
from snowflake.cli._plugins.object import plugin_spec as object_plugin_spec
|
|
24
|
+
from snowflake.cli._plugins.plugin import plugin_spec as plugin_plugin_spec
|
|
25
|
+
from snowflake.cli._plugins.project import plugin_spec as project_plugin_spec
|
|
23
26
|
from snowflake.cli._plugins.snowpark import plugin_spec as snowpark_plugin_spec
|
|
24
27
|
from snowflake.cli._plugins.spcs import plugin_spec as spcs_plugin_spec
|
|
25
28
|
from snowflake.cli._plugins.sql import plugin_spec as sql_plugin_spec
|
|
@@ -31,11 +34,13 @@ from snowflake.cli._plugins.workspace import plugin_spec as workspace_plugin_spe
|
|
|
31
34
|
# plugin name to plugin spec
|
|
32
35
|
def get_builtin_plugin_name_to_plugin_spec():
|
|
33
36
|
plugin_specs = {
|
|
37
|
+
"auth": auth_plugin_spec,
|
|
34
38
|
"connection": connection_plugin_spec,
|
|
35
39
|
"helpers": migrate_plugin_spec,
|
|
36
40
|
"spcs": spcs_plugin_spec,
|
|
37
|
-
"
|
|
41
|
+
"app": nativeapp_plugin_spec,
|
|
38
42
|
"object": object_plugin_spec,
|
|
43
|
+
"project": project_plugin_spec,
|
|
39
44
|
"snowpark": snowpark_plugin_spec,
|
|
40
45
|
"stage": stage_plugin_spec,
|
|
41
46
|
"sql": sql_plugin_spec,
|
|
@@ -45,6 +50,7 @@ def get_builtin_plugin_name_to_plugin_spec():
|
|
|
45
50
|
"cortex": cortex_plugin_spec,
|
|
46
51
|
"init": init_plugin_spec,
|
|
47
52
|
"workspace": workspace_plugin_spec,
|
|
53
|
+
"plugin": plugin_plugin_spec,
|
|
48
54
|
}
|
|
49
55
|
|
|
50
56
|
return plugin_specs
|
|
@@ -47,7 +47,9 @@ class CommandPluginsLoader:
|
|
|
47
47
|
self._loaded_command_paths: Dict[CommandPath, LoadedCommandPlugin] = {}
|
|
48
48
|
|
|
49
49
|
def register_builtin_plugins(self) -> None:
|
|
50
|
-
for plugin_name, plugin in
|
|
50
|
+
for plugin_name, plugin in sorted(
|
|
51
|
+
get_builtin_plugin_name_to_plugin_spec().items()
|
|
52
|
+
):
|
|
51
53
|
try:
|
|
52
54
|
self._plugin_manager.register(plugin=plugin, name=plugin_name)
|
|
53
55
|
except Exception as ex:
|
|
@@ -33,8 +33,8 @@ class CommandRegistrationConfig:
|
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
class CommandsRegistrationWithCallbacks:
|
|
36
|
-
def __init__(self
|
|
37
|
-
self.
|
|
36
|
+
def __init__(self):
|
|
37
|
+
self._plugin_config_manager = PluginConfigProvider()
|
|
38
38
|
self._callbacks_after_registration: List[Callable[[], None]] = []
|
|
39
39
|
self._commands_registration_config: CommandRegistrationConfig = (
|
|
40
40
|
CommandRegistrationConfig(enable_external_command_plugins=True)
|
|
@@ -58,7 +58,7 @@ class CommandsRegistrationWithCallbacks:
|
|
|
58
58
|
|
|
59
59
|
def _register_builtin_and_enabled_external_plugin_commands(self):
|
|
60
60
|
enabled_external_plugins = (
|
|
61
|
-
self.
|
|
61
|
+
self._plugin_config_manager.get_enabled_plugin_names()
|
|
62
62
|
)
|
|
63
63
|
loaded_command_plugins = load_builtin_and_external_command_plugins(
|
|
64
64
|
enabled_external_plugins
|
snowflake/cli/_app/printing.py
CHANGED
|
@@ -16,7 +16,7 @@ from __future__ import annotations
|
|
|
16
16
|
|
|
17
17
|
import json
|
|
18
18
|
import sys
|
|
19
|
-
from datetime import datetime
|
|
19
|
+
from datetime import date, datetime
|
|
20
20
|
from json import JSONEncoder
|
|
21
21
|
from pathlib import Path
|
|
22
22
|
from textwrap import indent
|
|
@@ -57,7 +57,7 @@ class CustomJSONEncoder(JSONEncoder):
|
|
|
57
57
|
return o.result
|
|
58
58
|
if isinstance(o, (CollectionResult, MultipleResults)):
|
|
59
59
|
return list(o.result)
|
|
60
|
-
if isinstance(o, datetime):
|
|
60
|
+
if isinstance(o, (date, datetime)):
|
|
61
61
|
return o.isoformat()
|
|
62
62
|
if isinstance(o, Path):
|
|
63
63
|
return str(o)
|
|
@@ -21,12 +21,11 @@ from typing import Dict, Optional
|
|
|
21
21
|
|
|
22
22
|
import snowflake.connector
|
|
23
23
|
from click.exceptions import ClickException
|
|
24
|
-
from snowflake.cli
|
|
24
|
+
from snowflake.cli import __about__
|
|
25
25
|
from snowflake.cli._app.constants import (
|
|
26
26
|
INTERNAL_APPLICATION_NAME,
|
|
27
27
|
PARAM_APPLICATION_NAME,
|
|
28
28
|
)
|
|
29
|
-
from snowflake.cli._app.secret import SecretType
|
|
30
29
|
from snowflake.cli._app.telemetry import command_info
|
|
31
30
|
from snowflake.cli.api.config import (
|
|
32
31
|
get_connection_dict,
|
|
@@ -38,6 +37,7 @@ from snowflake.cli.api.exceptions import (
|
|
|
38
37
|
SnowflakeConnectionError,
|
|
39
38
|
)
|
|
40
39
|
from snowflake.cli.api.feature_flags import FeatureFlag
|
|
40
|
+
from snowflake.cli.api.secret import SecretType
|
|
41
41
|
from snowflake.cli.api.secure_path import SecurePath
|
|
42
42
|
from snowflake.connector import SnowflakeConnection
|
|
43
43
|
from snowflake.connector.errors import DatabaseError, ForbiddenError
|
|
@@ -56,6 +56,7 @@ SUPPORTED_ENV_OVERRIDES = [
|
|
|
56
56
|
"authenticator",
|
|
57
57
|
"private_key_file",
|
|
58
58
|
"private_key_path",
|
|
59
|
+
"private_key_raw",
|
|
59
60
|
"database",
|
|
60
61
|
"schema",
|
|
61
62
|
"role",
|
|
@@ -247,7 +248,7 @@ def _update_internal_application_info(connection_parameters: Dict):
|
|
|
247
248
|
"""Update internal application data if ENABLE_SEPARATE_AUTHENTICATION_POLICY_ID is enabled."""
|
|
248
249
|
if FeatureFlag.ENABLE_SEPARATE_AUTHENTICATION_POLICY_ID.is_enabled():
|
|
249
250
|
connection_parameters["internal_application_name"] = INTERNAL_APPLICATION_NAME
|
|
250
|
-
connection_parameters["internal_application_version"] = VERSION
|
|
251
|
+
connection_parameters["internal_application_version"] = __about__.VERSION
|
|
251
252
|
|
|
252
253
|
|
|
253
254
|
def _load_pem_from_file(private_key_file: str) -> SecretType:
|
|
@@ -273,7 +274,7 @@ def _load_pem_to_der(private_key_pem: SecretType) -> SecretType:
|
|
|
273
274
|
and private_key_passphrase.value is None
|
|
274
275
|
):
|
|
275
276
|
raise ClickException(
|
|
276
|
-
"Encrypted private key, you must provide the"
|
|
277
|
+
"Encrypted private key, you must provide the "
|
|
277
278
|
"passphrase in the environment variable PRIVATE_KEY_PASSPHRASE"
|
|
278
279
|
)
|
|
279
280
|
|
snowflake/cli/_app/telemetry.py
CHANGED
|
@@ -22,7 +22,7 @@ from typing import Any, Dict, Union
|
|
|
22
22
|
|
|
23
23
|
import click
|
|
24
24
|
import typer
|
|
25
|
-
from snowflake.cli
|
|
25
|
+
from snowflake.cli import __about__
|
|
26
26
|
from snowflake.cli._app.constants import PARAM_APPLICATION_NAME
|
|
27
27
|
from snowflake.cli.api.cli_global_context import (
|
|
28
28
|
_CliGlobalContextAccess,
|
|
@@ -40,12 +40,6 @@ from snowflake.connector.telemetry import (
|
|
|
40
40
|
from snowflake.connector.time_util import get_time_millis
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
@unique
|
|
44
|
-
class CLIInstallationSource(Enum):
|
|
45
|
-
BINARY = "binary"
|
|
46
|
-
PYPI = "pypi"
|
|
47
|
-
|
|
48
|
-
|
|
49
43
|
@unique
|
|
50
44
|
class CLITelemetryField(Enum):
|
|
51
45
|
# Basic information
|
|
@@ -172,12 +166,6 @@ def _get_definition_version() -> str | None:
|
|
|
172
166
|
return None
|
|
173
167
|
|
|
174
168
|
|
|
175
|
-
def _get_installation_source() -> CLIInstallationSource:
|
|
176
|
-
if getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS"):
|
|
177
|
-
return CLIInstallationSource.BINARY
|
|
178
|
-
return CLIInstallationSource.PYPI
|
|
179
|
-
|
|
180
|
-
|
|
181
169
|
def _get_ci_environment_type() -> str:
|
|
182
170
|
if "GITHUB_ACTIONS" in os.environ:
|
|
183
171
|
return "GITHUB_ACTIONS"
|
|
@@ -214,8 +202,8 @@ class CLITelemetryClient:
|
|
|
214
202
|
) -> Dict[str, Any]:
|
|
215
203
|
data = {
|
|
216
204
|
CLITelemetryField.SOURCE: PARAM_APPLICATION_NAME,
|
|
217
|
-
CLITelemetryField.INSTALLATION_SOURCE:
|
|
218
|
-
CLITelemetryField.VERSION_CLI: VERSION,
|
|
205
|
+
CLITelemetryField.INSTALLATION_SOURCE: __about__.INSTALLATION_SOURCE.value,
|
|
206
|
+
CLITelemetryField.VERSION_CLI: __about__.VERSION,
|
|
219
207
|
CLITelemetryField.VERSION_OS: platform.platform(),
|
|
220
208
|
CLITelemetryField.VERSION_PYTHON: python_version(),
|
|
221
209
|
CLITelemetryField.COMMAND_CI_ENVIRONMENT: _get_ci_environment_type(),
|
|
@@ -8,6 +8,8 @@ from snowflake.cli.api.console import cli_console
|
|
|
8
8
|
from snowflake.cli.api.secure_path import SecurePath
|
|
9
9
|
from snowflake.connector.config_manager import CONFIG_MANAGER
|
|
10
10
|
|
|
11
|
+
REPOSITORY_URL = "https://pypi.org/pypi/snowflake-cli/json"
|
|
12
|
+
|
|
11
13
|
|
|
12
14
|
def get_new_version_msg() -> str | None:
|
|
13
15
|
last = _VersionCache().get_last_version()
|
|
@@ -45,9 +47,7 @@ class _VersionCache:
|
|
|
45
47
|
@staticmethod
|
|
46
48
|
def _get_version_from_pypi() -> str | None:
|
|
47
49
|
headers = {"Content-Type": "application/vnd.pypi.simple.v1+json"}
|
|
48
|
-
response = requests.get(
|
|
49
|
-
"https://pypi.org/pypi/snowflake-cli-labs/json", headers=headers, timeout=3
|
|
50
|
-
)
|
|
50
|
+
response = requests.get(REPOSITORY_URL, headers=headers, timeout=3)
|
|
51
51
|
response.raise_for_status()
|
|
52
52
|
return response.json()["info"]["version"]
|
|
53
53
|
|
|
@@ -60,7 +60,7 @@ class _VersionCache:
|
|
|
60
60
|
|
|
61
61
|
def _read_latest_version(self) -> Version | None:
|
|
62
62
|
if self._cache_file.exists():
|
|
63
|
-
data = json.loads(self._cache_file.read_text())
|
|
63
|
+
data = json.loads(self._cache_file.read_text(file_size_limit_mb=1))
|
|
64
64
|
now = time.time()
|
|
65
65
|
if data[_VersionCache._last_time] > now - 60 * 60:
|
|
66
66
|
return Version(data[_VersionCache._version])
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from snowflake.cli._plugins.auth.keypair.commands import app as keypair_app
|
|
2
|
+
from snowflake.cli.api.commands.snow_typer import SnowTyperFactory
|
|
3
|
+
from snowflake.cli.api.feature_flags import FeatureFlag
|
|
4
|
+
|
|
5
|
+
app = SnowTyperFactory(
|
|
6
|
+
name="auth",
|
|
7
|
+
help="Manages authentication methods.",
|
|
8
|
+
is_hidden=lambda: FeatureFlag.ENABLE_AUTH_KEYPAIR.is_disabled(),
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
app.add_typer(keypair_app)
|
|
File without changes
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
import typer
|
|
4
|
+
from snowflake.cli._plugins.auth.keypair.manager import AuthManager, PublicKeyProperty
|
|
5
|
+
from snowflake.cli.api.commands.flags import SecretTypeParser
|
|
6
|
+
from snowflake.cli.api.commands.snow_typer import SnowTyperFactory
|
|
7
|
+
from snowflake.cli.api.output.types import (
|
|
8
|
+
CollectionResult,
|
|
9
|
+
CommandResult,
|
|
10
|
+
MessageResult,
|
|
11
|
+
SingleQueryResult,
|
|
12
|
+
)
|
|
13
|
+
from snowflake.cli.api.secret import SecretType
|
|
14
|
+
from snowflake.cli.api.secure_path import SecurePath
|
|
15
|
+
|
|
16
|
+
app = SnowTyperFactory(
|
|
17
|
+
name="keypair",
|
|
18
|
+
help="Manages authentication.",
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
KEY_PAIR_DEFAULT_PATH = "~/.ssh"
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _show_connection_name_prompt(ctx: typer.Context, value: str):
|
|
26
|
+
for param in ctx.command.params:
|
|
27
|
+
if param.name == "connection_name":
|
|
28
|
+
if value:
|
|
29
|
+
param.prompt = "Enter connection name"
|
|
30
|
+
break
|
|
31
|
+
return value
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
_new_connection_option = typer.Option(
|
|
35
|
+
True,
|
|
36
|
+
help="Create a new connection.",
|
|
37
|
+
prompt="Create a new connection?",
|
|
38
|
+
callback=_show_connection_name_prompt,
|
|
39
|
+
show_default=False,
|
|
40
|
+
hidden=True,
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
_connection_name_option = typer.Option(
|
|
45
|
+
None,
|
|
46
|
+
help="The new connection name.",
|
|
47
|
+
prompt=False,
|
|
48
|
+
show_default=False,
|
|
49
|
+
hidden=True,
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
_key_length_option = typer.Option(
|
|
54
|
+
2048,
|
|
55
|
+
"--key-length",
|
|
56
|
+
help="The RSA key length.",
|
|
57
|
+
prompt="Enter key length",
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
_output_path_option = typer.Option(
|
|
62
|
+
KEY_PAIR_DEFAULT_PATH,
|
|
63
|
+
"--output-path",
|
|
64
|
+
help="The output path for private and public keys",
|
|
65
|
+
prompt="Enter output path",
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
_private_key_passphrase_option = typer.Option(
|
|
70
|
+
"",
|
|
71
|
+
"--private-key-passphrase",
|
|
72
|
+
help="The private key passphrase.",
|
|
73
|
+
click_type=SecretTypeParser(),
|
|
74
|
+
prompt="Enter private key passphrase",
|
|
75
|
+
hide_input=True,
|
|
76
|
+
show_default=False,
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
@app.command("setup", requires_connection=True)
|
|
81
|
+
def setup(
|
|
82
|
+
new_connection: bool = _new_connection_option,
|
|
83
|
+
connection_name: str = _connection_name_option,
|
|
84
|
+
key_length: int = _key_length_option,
|
|
85
|
+
output_path: Path = _output_path_option,
|
|
86
|
+
private_key_passphrase: SecretType = _private_key_passphrase_option,
|
|
87
|
+
**options,
|
|
88
|
+
):
|
|
89
|
+
"""
|
|
90
|
+
Generates the key pair, sets the public key for the user in Snowflake, and creates or updates the connection.
|
|
91
|
+
"""
|
|
92
|
+
AuthManager().setup(
|
|
93
|
+
connection_name=connection_name,
|
|
94
|
+
key_length=key_length,
|
|
95
|
+
output_path=SecurePath(output_path),
|
|
96
|
+
private_key_passphrase=private_key_passphrase,
|
|
97
|
+
)
|
|
98
|
+
return MessageResult(f"Setup completed.")
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
@app.command("rotate", requires_connection=True)
|
|
102
|
+
def rotate(
|
|
103
|
+
key_length: int = _key_length_option,
|
|
104
|
+
output_path: Path = _output_path_option,
|
|
105
|
+
private_key_passphrase: SecretType = _private_key_passphrase_option,
|
|
106
|
+
**options,
|
|
107
|
+
):
|
|
108
|
+
"""
|
|
109
|
+
Rotates the key for the connection. Generates the key pair, sets the public key for the user in Snowflake, and creates or updates the connection.
|
|
110
|
+
"""
|
|
111
|
+
AuthManager().rotate(
|
|
112
|
+
key_length=key_length,
|
|
113
|
+
output_path=SecurePath(output_path),
|
|
114
|
+
private_key_passphrase=private_key_passphrase,
|
|
115
|
+
)
|
|
116
|
+
return MessageResult(f"Rotate completed.")
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
@app.command("list", requires_connection=True)
|
|
120
|
+
def list_keys(**options) -> CommandResult:
|
|
121
|
+
"""
|
|
122
|
+
Lists the public keys set for the user.
|
|
123
|
+
"""
|
|
124
|
+
return CollectionResult(AuthManager().list_keys())
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
@app.command("remove", requires_connection=True)
|
|
128
|
+
def remove(
|
|
129
|
+
public_key_property: PublicKeyProperty = typer.Option(
|
|
130
|
+
...,
|
|
131
|
+
"--key-id",
|
|
132
|
+
help=f"Local path to the template directory or a URL to Git repository with templates.",
|
|
133
|
+
show_default=False,
|
|
134
|
+
),
|
|
135
|
+
**options,
|
|
136
|
+
):
|
|
137
|
+
"""
|
|
138
|
+
Removes the public key for the user.
|
|
139
|
+
"""
|
|
140
|
+
return SingleQueryResult(
|
|
141
|
+
AuthManager().remove_public_key(public_key_property=public_key_property)
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
@app.command("status", requires_connection=True)
|
|
146
|
+
def status(**options):
|
|
147
|
+
"""
|
|
148
|
+
Verifies the key pair configuration and tests the connection.
|
|
149
|
+
"""
|
|
150
|
+
AuthManager().status()
|
|
151
|
+
return MessageResult("Status check completed.")
|