snowflake-cli 2.8.2__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 +17 -0
- snowflake/cli/__init__.py +13 -0
- snowflake/cli/api/__init__.py +48 -0
- snowflake/cli/api/cli_global_context.py +390 -0
- snowflake/cli/api/commands/__init__.py +13 -0
- snowflake/cli/api/commands/alias.py +23 -0
- snowflake/cli/api/commands/decorators.py +354 -0
- snowflake/cli/api/commands/execution_metadata.py +40 -0
- snowflake/cli/api/commands/experimental_behaviour.py +19 -0
- snowflake/cli/api/commands/flags.py +662 -0
- snowflake/cli/api/commands/project_initialisation.py +65 -0
- snowflake/cli/api/commands/snow_typer.py +237 -0
- snowflake/cli/api/commands/typer_pre_execute.py +26 -0
- snowflake/cli/api/config.py +348 -0
- snowflake/cli/api/console/__init__.py +17 -0
- snowflake/cli/api/console/abc.py +89 -0
- snowflake/cli/api/console/console.py +134 -0
- snowflake/cli/api/console/enum.py +17 -0
- snowflake/cli/api/constants.py +79 -0
- snowflake/cli/api/errno.py +27 -0
- snowflake/cli/api/exceptions.py +164 -0
- snowflake/cli/api/feature_flags.py +55 -0
- snowflake/cli/api/identifiers.py +167 -0
- snowflake/cli/api/output/__init__.py +13 -0
- snowflake/cli/api/output/formats.py +20 -0
- snowflake/cli/api/output/types.py +118 -0
- snowflake/cli/api/plugins/__init__.py +13 -0
- snowflake/cli/api/plugins/command/__init__.py +72 -0
- snowflake/cli/api/plugins/command/plugin_hook_specs.py +21 -0
- snowflake/cli/api/plugins/plugin_config.py +32 -0
- snowflake/cli/api/project/__init__.py +13 -0
- snowflake/cli/api/project/definition.py +84 -0
- snowflake/cli/api/project/definition_manager.py +134 -0
- snowflake/cli/api/project/errors.py +56 -0
- snowflake/cli/api/project/project_verification.py +23 -0
- snowflake/cli/api/project/schemas/__init__.py +13 -0
- snowflake/cli/api/project/schemas/entities/application_entity.py +44 -0
- snowflake/cli/api/project/schemas/entities/application_package_entity.py +66 -0
- snowflake/cli/api/project/schemas/entities/common.py +78 -0
- snowflake/cli/api/project/schemas/entities/entities.py +30 -0
- snowflake/cli/api/project/schemas/identifier_model.py +49 -0
- snowflake/cli/api/project/schemas/native_app/__init__.py +13 -0
- snowflake/cli/api/project/schemas/native_app/application.py +62 -0
- snowflake/cli/api/project/schemas/native_app/native_app.py +93 -0
- snowflake/cli/api/project/schemas/native_app/package.py +78 -0
- snowflake/cli/api/project/schemas/native_app/path_mapping.py +65 -0
- snowflake/cli/api/project/schemas/project_definition.py +199 -0
- snowflake/cli/api/project/schemas/snowpark/__init__.py +13 -0
- snowflake/cli/api/project/schemas/snowpark/argument.py +28 -0
- snowflake/cli/api/project/schemas/snowpark/callable.py +69 -0
- snowflake/cli/api/project/schemas/snowpark/snowpark.py +36 -0
- snowflake/cli/api/project/schemas/streamlit/__init__.py +13 -0
- snowflake/cli/api/project/schemas/streamlit/streamlit.py +46 -0
- snowflake/cli/api/project/schemas/template.py +77 -0
- snowflake/cli/api/project/schemas/updatable_model.py +194 -0
- snowflake/cli/api/project/util.py +261 -0
- snowflake/cli/api/rendering/__init__.py +13 -0
- snowflake/cli/api/rendering/jinja.py +112 -0
- snowflake/cli/api/rendering/project_definition_templates.py +39 -0
- snowflake/cli/api/rendering/project_templates.py +98 -0
- snowflake/cli/api/rendering/sql_templates.py +60 -0
- snowflake/cli/api/rest_api.py +172 -0
- snowflake/cli/api/sanitizers.py +43 -0
- snowflake/cli/api/secure_path.py +362 -0
- snowflake/cli/api/secure_utils.py +29 -0
- snowflake/cli/api/sql_execution.py +260 -0
- snowflake/cli/api/utils/__init__.py +13 -0
- snowflake/cli/api/utils/cursor.py +34 -0
- snowflake/cli/api/utils/definition_rendering.py +383 -0
- snowflake/cli/api/utils/dict_utils.py +73 -0
- snowflake/cli/api/utils/error_handling.py +23 -0
- snowflake/cli/api/utils/graph.py +97 -0
- snowflake/cli/api/utils/models.py +63 -0
- snowflake/cli/api/utils/naming_utils.py +13 -0
- snowflake/cli/api/utils/path_utils.py +36 -0
- snowflake/cli/api/utils/templating_functions.py +144 -0
- snowflake/cli/api/utils/types.py +35 -0
- snowflake/cli/app/__init__.py +22 -0
- snowflake/cli/app/__main__.py +31 -0
- snowflake/cli/app/api_impl/__init__.py +13 -0
- snowflake/cli/app/api_impl/plugin/__init__.py +13 -0
- snowflake/cli/app/api_impl/plugin/plugin_config_provider_impl.py +66 -0
- snowflake/cli/app/build_and_push.sh +8 -0
- snowflake/cli/app/cli_app.py +243 -0
- snowflake/cli/app/commands_registration/__init__.py +33 -0
- snowflake/cli/app/commands_registration/builtin_plugins.py +54 -0
- snowflake/cli/app/commands_registration/command_plugins_loader.py +169 -0
- snowflake/cli/app/commands_registration/commands_registration_with_callbacks.py +105 -0
- snowflake/cli/app/commands_registration/exception_logging.py +26 -0
- snowflake/cli/app/commands_registration/threadsafe.py +48 -0
- snowflake/cli/app/commands_registration/typer_registration.py +153 -0
- snowflake/cli/app/constants.py +19 -0
- snowflake/cli/app/dev/__init__.py +13 -0
- snowflake/cli/app/dev/commands_structure.py +48 -0
- snowflake/cli/app/dev/docs/__init__.py +13 -0
- snowflake/cli/app/dev/docs/commands_docs_generator.py +100 -0
- snowflake/cli/app/dev/docs/generator.py +35 -0
- snowflake/cli/app/dev/docs/project_definition_docs_generator.py +58 -0
- snowflake/cli/app/dev/docs/project_definition_generate_json_schema.py +227 -0
- snowflake/cli/app/dev/docs/template_utils.py +23 -0
- snowflake/cli/app/dev/docs/templates/definition_description.rst.jinja2 +38 -0
- snowflake/cli/app/dev/docs/templates/overview.rst.jinja2 +9 -0
- snowflake/cli/app/dev/docs/templates/usage.rst.jinja2 +57 -0
- snowflake/cli/app/dev/pycharm_remote_debug.py +46 -0
- snowflake/cli/app/loggers.py +199 -0
- snowflake/cli/app/main_typer.py +62 -0
- snowflake/cli/app/printing.py +181 -0
- snowflake/cli/app/snow_connector.py +243 -0
- snowflake/cli/app/telemetry.py +189 -0
- snowflake/cli/plugins/__init__.py +13 -0
- snowflake/cli/plugins/connection/__init__.py +13 -0
- snowflake/cli/plugins/connection/commands.py +330 -0
- snowflake/cli/plugins/connection/plugin_spec.py +30 -0
- snowflake/cli/plugins/connection/util.py +179 -0
- snowflake/cli/plugins/cortex/__init__.py +13 -0
- snowflake/cli/plugins/cortex/commands.py +327 -0
- snowflake/cli/plugins/cortex/constants.py +17 -0
- snowflake/cli/plugins/cortex/manager.py +189 -0
- snowflake/cli/plugins/cortex/plugin_spec.py +30 -0
- snowflake/cli/plugins/cortex/types.py +22 -0
- snowflake/cli/plugins/git/__init__.py +13 -0
- snowflake/cli/plugins/git/commands.py +354 -0
- snowflake/cli/plugins/git/manager.py +105 -0
- snowflake/cli/plugins/git/plugin_spec.py +30 -0
- snowflake/cli/plugins/init/__init__.py +13 -0
- snowflake/cli/plugins/init/commands.py +248 -0
- snowflake/cli/plugins/init/plugin_spec.py +30 -0
- snowflake/cli/plugins/nativeapp/__init__.py +13 -0
- snowflake/cli/plugins/nativeapp/artifacts.py +742 -0
- snowflake/cli/plugins/nativeapp/codegen/__init__.py +13 -0
- snowflake/cli/plugins/nativeapp/codegen/artifact_processor.py +91 -0
- snowflake/cli/plugins/nativeapp/codegen/compiler.py +130 -0
- snowflake/cli/plugins/nativeapp/codegen/sandbox.py +306 -0
- snowflake/cli/plugins/nativeapp/codegen/setup/native_app_setup_processor.py +172 -0
- snowflake/cli/plugins/nativeapp/codegen/setup/setup_driver.py.source +56 -0
- snowflake/cli/plugins/nativeapp/codegen/snowpark/callback_source.py.jinja +181 -0
- snowflake/cli/plugins/nativeapp/codegen/snowpark/extension_function_utils.py +217 -0
- snowflake/cli/plugins/nativeapp/codegen/snowpark/models.py +61 -0
- snowflake/cli/plugins/nativeapp/codegen/snowpark/python_processor.py +528 -0
- snowflake/cli/plugins/nativeapp/commands.py +439 -0
- snowflake/cli/plugins/nativeapp/common_flags.py +44 -0
- snowflake/cli/plugins/nativeapp/constants.py +27 -0
- snowflake/cli/plugins/nativeapp/exceptions.py +122 -0
- snowflake/cli/plugins/nativeapp/feature_flags.py +24 -0
- snowflake/cli/plugins/nativeapp/init.py +345 -0
- snowflake/cli/plugins/nativeapp/manager.py +823 -0
- snowflake/cli/plugins/nativeapp/plugin_spec.py +30 -0
- snowflake/cli/plugins/nativeapp/policy.py +50 -0
- snowflake/cli/plugins/nativeapp/project_model.py +195 -0
- snowflake/cli/plugins/nativeapp/run_processor.py +389 -0
- snowflake/cli/plugins/nativeapp/teardown_processor.py +301 -0
- snowflake/cli/plugins/nativeapp/utils.py +98 -0
- snowflake/cli/plugins/nativeapp/v2_conversions/v2_to_v1_decorator.py +135 -0
- snowflake/cli/plugins/nativeapp/version/__init__.py +13 -0
- snowflake/cli/plugins/nativeapp/version/commands.py +170 -0
- snowflake/cli/plugins/nativeapp/version/version_processor.py +362 -0
- snowflake/cli/plugins/notebook/__init__.py +13 -0
- snowflake/cli/plugins/notebook/commands.py +85 -0
- snowflake/cli/plugins/notebook/exceptions.py +20 -0
- snowflake/cli/plugins/notebook/manager.py +71 -0
- snowflake/cli/plugins/notebook/plugin_spec.py +30 -0
- snowflake/cli/plugins/notebook/types.py +15 -0
- snowflake/cli/plugins/object/__init__.py +13 -0
- snowflake/cli/plugins/object/command_aliases.py +95 -0
- snowflake/cli/plugins/object/commands.py +181 -0
- snowflake/cli/plugins/object/common.py +85 -0
- snowflake/cli/plugins/object/manager.py +97 -0
- snowflake/cli/plugins/object/plugin_spec.py +30 -0
- snowflake/cli/plugins/object_stage_deprecated/__init__.py +15 -0
- snowflake/cli/plugins/object_stage_deprecated/commands.py +122 -0
- snowflake/cli/plugins/object_stage_deprecated/plugin_spec.py +32 -0
- snowflake/cli/plugins/snowpark/__init__.py +13 -0
- snowflake/cli/plugins/snowpark/commands.py +546 -0
- snowflake/cli/plugins/snowpark/common.py +307 -0
- snowflake/cli/plugins/snowpark/manager.py +109 -0
- snowflake/cli/plugins/snowpark/models.py +157 -0
- snowflake/cli/plugins/snowpark/package/__init__.py +13 -0
- snowflake/cli/plugins/snowpark/package/anaconda_packages.py +233 -0
- snowflake/cli/plugins/snowpark/package/commands.py +256 -0
- snowflake/cli/plugins/snowpark/package/manager.py +44 -0
- snowflake/cli/plugins/snowpark/package/utils.py +26 -0
- snowflake/cli/plugins/snowpark/package_utils.py +354 -0
- snowflake/cli/plugins/snowpark/plugin_spec.py +30 -0
- snowflake/cli/plugins/snowpark/snowpark_package_paths.py +65 -0
- snowflake/cli/plugins/snowpark/snowpark_shared.py +95 -0
- snowflake/cli/plugins/snowpark/zipper.py +81 -0
- snowflake/cli/plugins/spcs/__init__.py +35 -0
- snowflake/cli/plugins/spcs/common.py +99 -0
- snowflake/cli/plugins/spcs/compute_pool/__init__.py +13 -0
- snowflake/cli/plugins/spcs/compute_pool/commands.py +241 -0
- snowflake/cli/plugins/spcs/compute_pool/manager.py +121 -0
- snowflake/cli/plugins/spcs/image_registry/__init__.py +13 -0
- snowflake/cli/plugins/spcs/image_registry/commands.py +65 -0
- snowflake/cli/plugins/spcs/image_registry/manager.py +105 -0
- snowflake/cli/plugins/spcs/image_repository/__init__.py +13 -0
- snowflake/cli/plugins/spcs/image_repository/commands.py +202 -0
- snowflake/cli/plugins/spcs/image_repository/manager.py +84 -0
- snowflake/cli/plugins/spcs/jobs/__init__.py +13 -0
- snowflake/cli/plugins/spcs/jobs/commands.py +78 -0
- snowflake/cli/plugins/spcs/jobs/manager.py +53 -0
- snowflake/cli/plugins/spcs/plugin_spec.py +30 -0
- snowflake/cli/plugins/spcs/services/__init__.py +13 -0
- snowflake/cli/plugins/spcs/services/commands.py +312 -0
- snowflake/cli/plugins/spcs/services/manager.py +170 -0
- snowflake/cli/plugins/sql/__init__.py +13 -0
- snowflake/cli/plugins/sql/commands.py +83 -0
- snowflake/cli/plugins/sql/manager.py +92 -0
- snowflake/cli/plugins/sql/plugin_spec.py +30 -0
- snowflake/cli/plugins/sql/snowsql_templating.py +28 -0
- snowflake/cli/plugins/stage/__init__.py +13 -0
- snowflake/cli/plugins/stage/commands.py +263 -0
- snowflake/cli/plugins/stage/diff.py +326 -0
- snowflake/cli/plugins/stage/manager.py +577 -0
- snowflake/cli/plugins/stage/md5.py +160 -0
- snowflake/cli/plugins/stage/plugin_spec.py +30 -0
- snowflake/cli/plugins/streamlit/__init__.py +13 -0
- snowflake/cli/plugins/streamlit/commands.py +179 -0
- snowflake/cli/plugins/streamlit/manager.py +222 -0
- snowflake/cli/plugins/streamlit/plugin_spec.py +30 -0
- snowflake/cli/plugins/workspace/__init__.py +13 -0
- snowflake/cli/plugins/workspace/commands.py +35 -0
- snowflake/cli/plugins/workspace/plugin_spec.py +30 -0
- snowflake/cli/templates/default_snowpark/.gitignore +4 -0
- snowflake/cli/templates/default_snowpark/app/__init__.py +0 -0
- snowflake/cli/templates/default_snowpark/app/common.py +2 -0
- snowflake/cli/templates/default_snowpark/app/functions.py +15 -0
- snowflake/cli/templates/default_snowpark/app/procedures.py +22 -0
- snowflake/cli/templates/default_snowpark/requirements.txt +1 -0
- snowflake/cli/templates/default_snowpark/snowflake.yml +23 -0
- snowflake/cli/templates/default_streamlit/.gitignore +4 -0
- snowflake/cli/templates/default_streamlit/common/hello.py +2 -0
- snowflake/cli/templates/default_streamlit/environment.yml +6 -0
- snowflake/cli/templates/default_streamlit/pages/my_page.py +3 -0
- snowflake/cli/templates/default_streamlit/snowflake.yml +10 -0
- snowflake/cli/templates/default_streamlit/streamlit_app.py +4 -0
- snowflake_cli-2.8.2.dist-info/METADATA +325 -0
- snowflake_cli-2.8.2.dist-info/RECORD +240 -0
- snowflake_cli-2.8.2.dist-info/WHEEL +4 -0
- snowflake_cli-2.8.2.dist-info/entry_points.txt +2 -0
- snowflake_cli-2.8.2.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Copyright (c) 2024 Snowflake Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
VERSION = "2.8.2"
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Copyright (c) 2024 Snowflake Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Copyright (c) 2024 Snowflake Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
from typing import Optional
|
|
18
|
+
|
|
19
|
+
from snowflake.cli.api.plugins.plugin_config import PluginConfigProvider
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class Api:
|
|
23
|
+
def __init__(
|
|
24
|
+
self,
|
|
25
|
+
plugin_config_provider: PluginConfigProvider,
|
|
26
|
+
):
|
|
27
|
+
self.plugin_config_provider = plugin_config_provider
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class ApiNotInitializedError(RuntimeError):
|
|
31
|
+
"""There was a try to use CLI's API while it is still not initialized."""
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class ApiProvider:
|
|
35
|
+
def __init__(self):
|
|
36
|
+
self._api: Optional[Api] = None
|
|
37
|
+
|
|
38
|
+
def register_api(self, api: Api) -> None:
|
|
39
|
+
self._api = api
|
|
40
|
+
|
|
41
|
+
def api(self) -> Api:
|
|
42
|
+
if self._api:
|
|
43
|
+
return self._api
|
|
44
|
+
else:
|
|
45
|
+
raise ApiNotInitializedError()
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
api_provider = ApiProvider()
|
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
# Copyright (c) 2024 Snowflake Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import re
|
|
18
|
+
from pathlib import Path
|
|
19
|
+
from typing import Callable, Optional
|
|
20
|
+
|
|
21
|
+
from snowflake.cli.api.exceptions import InvalidSchemaError
|
|
22
|
+
from snowflake.cli.api.output.formats import OutputFormat
|
|
23
|
+
from snowflake.cli.api.project.schemas.project_definition import ProjectDefinition
|
|
24
|
+
from snowflake.connector import SnowflakeConnection
|
|
25
|
+
|
|
26
|
+
schema_pattern = re.compile(r".+\..+")
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class _ConnectionContext:
|
|
30
|
+
def __init__(self):
|
|
31
|
+
self._cached_connection: Optional[SnowflakeConnection] = None
|
|
32
|
+
|
|
33
|
+
self._connection_name: Optional[str] = None
|
|
34
|
+
self._account: Optional[str] = None
|
|
35
|
+
self._database: Optional[str] = None
|
|
36
|
+
self._role: Optional[str] = None
|
|
37
|
+
self._schema: Optional[str] = None
|
|
38
|
+
self._user: Optional[str] = None
|
|
39
|
+
self._password: Optional[str] = None
|
|
40
|
+
self._authenticator: Optional[str] = None
|
|
41
|
+
self._private_key_path: Optional[str] = None
|
|
42
|
+
self._warehouse: Optional[str] = None
|
|
43
|
+
self._mfa_passcode: Optional[str] = None
|
|
44
|
+
self._enable_diag: Optional[bool] = False
|
|
45
|
+
self._diag_log_path: Optional[Path] = None
|
|
46
|
+
self._diag_allowlist_path: Optional[Path] = None
|
|
47
|
+
self._temporary_connection: bool = False
|
|
48
|
+
self._session_token: Optional[str] = None
|
|
49
|
+
self._master_token: Optional[str] = None
|
|
50
|
+
self._token_file_path: Optional[Path] = None
|
|
51
|
+
|
|
52
|
+
def __setattr__(self, key, value):
|
|
53
|
+
"""
|
|
54
|
+
We invalidate connection cache every time connection attributes change.
|
|
55
|
+
"""
|
|
56
|
+
super().__setattr__(key, value)
|
|
57
|
+
if key != "_cached_connection":
|
|
58
|
+
self._cached_connection = None
|
|
59
|
+
|
|
60
|
+
@property
|
|
61
|
+
def connection_name(self) -> Optional[str]:
|
|
62
|
+
return self._connection_name
|
|
63
|
+
|
|
64
|
+
def set_connection_name(self, value: Optional[str]):
|
|
65
|
+
self._connection_name = value
|
|
66
|
+
|
|
67
|
+
@property
|
|
68
|
+
def account(self) -> Optional[str]:
|
|
69
|
+
return self._account
|
|
70
|
+
|
|
71
|
+
def set_account(self, value: Optional[str]):
|
|
72
|
+
self._account = value
|
|
73
|
+
|
|
74
|
+
@property
|
|
75
|
+
def database(self) -> Optional[str]:
|
|
76
|
+
return self._database
|
|
77
|
+
|
|
78
|
+
def set_database(self, value: Optional[str]):
|
|
79
|
+
self._database = value
|
|
80
|
+
|
|
81
|
+
@property
|
|
82
|
+
def role(self) -> Optional[str]:
|
|
83
|
+
return self._role
|
|
84
|
+
|
|
85
|
+
def set_role(self, value: Optional[str]):
|
|
86
|
+
self._role = value
|
|
87
|
+
|
|
88
|
+
@property
|
|
89
|
+
def schema(self) -> Optional[str]:
|
|
90
|
+
return self._schema
|
|
91
|
+
|
|
92
|
+
def set_schema(self, value: Optional[str]):
|
|
93
|
+
if (
|
|
94
|
+
value
|
|
95
|
+
and not (value.startswith('"') and value.endswith('"'))
|
|
96
|
+
# if schema is fully qualified name (db.schema)
|
|
97
|
+
and schema_pattern.match(value)
|
|
98
|
+
):
|
|
99
|
+
raise InvalidSchemaError(value)
|
|
100
|
+
self._schema = value
|
|
101
|
+
|
|
102
|
+
@property
|
|
103
|
+
def user(self) -> Optional[str]:
|
|
104
|
+
return self._user
|
|
105
|
+
|
|
106
|
+
def set_user(self, value: Optional[str]):
|
|
107
|
+
self._user = value
|
|
108
|
+
|
|
109
|
+
@property
|
|
110
|
+
def password(self) -> Optional[str]:
|
|
111
|
+
return self._password
|
|
112
|
+
|
|
113
|
+
def set_password(self, value: Optional[str]):
|
|
114
|
+
self._password = value
|
|
115
|
+
|
|
116
|
+
@property
|
|
117
|
+
def authenticator(self) -> Optional[str]:
|
|
118
|
+
return self._authenticator
|
|
119
|
+
|
|
120
|
+
def set_authenticator(self, value: Optional[str]):
|
|
121
|
+
self._authenticator = value
|
|
122
|
+
|
|
123
|
+
@property
|
|
124
|
+
def private_key_path(self) -> Optional[str]:
|
|
125
|
+
return self._private_key_path
|
|
126
|
+
|
|
127
|
+
def set_private_key_path(self, value: Optional[str]):
|
|
128
|
+
self._private_key_path = value
|
|
129
|
+
|
|
130
|
+
@property
|
|
131
|
+
def warehouse(self) -> Optional[str]:
|
|
132
|
+
return self._warehouse
|
|
133
|
+
|
|
134
|
+
def set_warehouse(self, value: Optional[str]):
|
|
135
|
+
self._warehouse = value
|
|
136
|
+
|
|
137
|
+
@property
|
|
138
|
+
def mfa_passcode(self) -> Optional[str]:
|
|
139
|
+
return self._mfa_passcode
|
|
140
|
+
|
|
141
|
+
def set_mfa_passcode(self, value: Optional[str]):
|
|
142
|
+
self._mfa_passcode = value
|
|
143
|
+
|
|
144
|
+
@property
|
|
145
|
+
def enable_diag(self) -> Optional[bool]:
|
|
146
|
+
return self._enable_diag
|
|
147
|
+
|
|
148
|
+
def set_enable_diag(self, value: Optional[bool]):
|
|
149
|
+
self._enable_diag = value
|
|
150
|
+
|
|
151
|
+
@property
|
|
152
|
+
def diag_log_path(self) -> Optional[Path]:
|
|
153
|
+
return self._diag_log_path
|
|
154
|
+
|
|
155
|
+
def set_diag_log_path(self, value: Optional[Path]):
|
|
156
|
+
self._diag_log_path = value
|
|
157
|
+
|
|
158
|
+
@property
|
|
159
|
+
def diag_allowlist_path(self) -> Optional[Path]:
|
|
160
|
+
return self._diag_allowlist_path
|
|
161
|
+
|
|
162
|
+
def set_diag_allowlist_path(self, value: Optional[Path]):
|
|
163
|
+
self._diag_allowlist_path = value
|
|
164
|
+
|
|
165
|
+
@property
|
|
166
|
+
def temporary_connection(self) -> bool:
|
|
167
|
+
return self._temporary_connection
|
|
168
|
+
|
|
169
|
+
def set_temporary_connection(self, value: bool):
|
|
170
|
+
self._temporary_connection = value
|
|
171
|
+
|
|
172
|
+
@property
|
|
173
|
+
def session_token(self) -> Optional[str]:
|
|
174
|
+
return self._session_token
|
|
175
|
+
|
|
176
|
+
def set_session_token(self, value: Optional[str]):
|
|
177
|
+
self._session_token = value
|
|
178
|
+
|
|
179
|
+
@property
|
|
180
|
+
def master_token(self) -> Optional[str]:
|
|
181
|
+
return self._master_token
|
|
182
|
+
|
|
183
|
+
def set_master_token(self, value: Optional[str]):
|
|
184
|
+
self._master_token = value
|
|
185
|
+
|
|
186
|
+
@property
|
|
187
|
+
def token_file_path(self) -> Optional[Path]:
|
|
188
|
+
return self._token_file_path
|
|
189
|
+
|
|
190
|
+
def set_token_file_path(self, value: Optional[Path]):
|
|
191
|
+
self._token_file_path = value
|
|
192
|
+
|
|
193
|
+
@property
|
|
194
|
+
def connection(self) -> SnowflakeConnection:
|
|
195
|
+
if not self._cached_connection:
|
|
196
|
+
self._cached_connection = self._build_connection()
|
|
197
|
+
return self._cached_connection
|
|
198
|
+
|
|
199
|
+
def _collect_not_empty_connection_attributes(self):
|
|
200
|
+
return {
|
|
201
|
+
"account": self.account,
|
|
202
|
+
"user": self.user,
|
|
203
|
+
"password": self.password,
|
|
204
|
+
"authenticator": self.authenticator,
|
|
205
|
+
"private_key_path": self.private_key_path,
|
|
206
|
+
"database": self.database,
|
|
207
|
+
"schema": self.schema,
|
|
208
|
+
"role": self.role,
|
|
209
|
+
"warehouse": self.warehouse,
|
|
210
|
+
"session_token": self.session_token,
|
|
211
|
+
"master_token": self.master_token,
|
|
212
|
+
"token_file_path": self.token_file_path,
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
def _build_connection(self):
|
|
216
|
+
from snowflake.cli.app.snow_connector import connect_to_snowflake
|
|
217
|
+
|
|
218
|
+
return connect_to_snowflake(
|
|
219
|
+
temporary_connection=self.temporary_connection,
|
|
220
|
+
mfa_passcode=self._mfa_passcode,
|
|
221
|
+
enable_diag=self._enable_diag,
|
|
222
|
+
diag_log_path=self._diag_log_path,
|
|
223
|
+
diag_allowlist_path=self._diag_allowlist_path,
|
|
224
|
+
connection_name=self.connection_name,
|
|
225
|
+
**self._collect_not_empty_connection_attributes(),
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
class _CliGlobalContextManager:
|
|
230
|
+
def __init__(self):
|
|
231
|
+
self._connection_context = _ConnectionContext()
|
|
232
|
+
self._enable_tracebacks = True
|
|
233
|
+
self._output_format = OutputFormat.TABLE
|
|
234
|
+
self._verbose = False
|
|
235
|
+
self._experimental = False
|
|
236
|
+
self._project_definition = None
|
|
237
|
+
self._project_root = None
|
|
238
|
+
self._project_path_arg = None
|
|
239
|
+
self._project_env_overrides_args = {}
|
|
240
|
+
self._typer_pre_execute_commands = []
|
|
241
|
+
self._template_context = None
|
|
242
|
+
self._silent: bool = False
|
|
243
|
+
|
|
244
|
+
def reset(self):
|
|
245
|
+
self.__init__()
|
|
246
|
+
|
|
247
|
+
@property
|
|
248
|
+
def enable_tracebacks(self) -> bool:
|
|
249
|
+
return self._enable_tracebacks
|
|
250
|
+
|
|
251
|
+
def set_enable_tracebacks(self, value: bool):
|
|
252
|
+
self._enable_tracebacks = value
|
|
253
|
+
|
|
254
|
+
@property
|
|
255
|
+
def output_format(self) -> OutputFormat:
|
|
256
|
+
return self._output_format
|
|
257
|
+
|
|
258
|
+
def set_output_format(self, value: OutputFormat):
|
|
259
|
+
self._output_format = value
|
|
260
|
+
|
|
261
|
+
@property
|
|
262
|
+
def verbose(self) -> bool:
|
|
263
|
+
return self._verbose
|
|
264
|
+
|
|
265
|
+
def set_verbose(self, value: bool):
|
|
266
|
+
self._verbose = value
|
|
267
|
+
|
|
268
|
+
@property
|
|
269
|
+
def experimental(self) -> bool:
|
|
270
|
+
return self._experimental
|
|
271
|
+
|
|
272
|
+
def set_experimental(self, value: bool):
|
|
273
|
+
self._experimental = value
|
|
274
|
+
|
|
275
|
+
@property
|
|
276
|
+
def project_definition(self) -> Optional[ProjectDefinition]:
|
|
277
|
+
return self._project_definition
|
|
278
|
+
|
|
279
|
+
def set_project_definition(self, value: ProjectDefinition):
|
|
280
|
+
self._project_definition = value
|
|
281
|
+
|
|
282
|
+
@property
|
|
283
|
+
def project_root(self):
|
|
284
|
+
return self._project_root
|
|
285
|
+
|
|
286
|
+
def set_project_root(self, project_root: Path):
|
|
287
|
+
self._project_root = project_root
|
|
288
|
+
|
|
289
|
+
@property
|
|
290
|
+
def project_path_arg(self) -> Optional[str]:
|
|
291
|
+
return self._project_path_arg
|
|
292
|
+
|
|
293
|
+
def set_project_path_arg(self, project_path_arg: str):
|
|
294
|
+
self._project_path_arg = project_path_arg
|
|
295
|
+
|
|
296
|
+
@property
|
|
297
|
+
def project_env_overrides_args(self) -> dict[str, str]:
|
|
298
|
+
return self._project_env_overrides_args
|
|
299
|
+
|
|
300
|
+
def set_project_env_overrides_args(
|
|
301
|
+
self, project_env_overrides_args: dict[str, str]
|
|
302
|
+
):
|
|
303
|
+
self._project_env_overrides_args = project_env_overrides_args
|
|
304
|
+
|
|
305
|
+
@property
|
|
306
|
+
def template_context(self) -> dict:
|
|
307
|
+
return self._template_context
|
|
308
|
+
|
|
309
|
+
def set_template_context(self, template_context: dict):
|
|
310
|
+
self._template_context = template_context
|
|
311
|
+
|
|
312
|
+
@property
|
|
313
|
+
def typer_pre_execute_commands(self) -> list[Callable[[], None]]:
|
|
314
|
+
return self._typer_pre_execute_commands
|
|
315
|
+
|
|
316
|
+
def add_typer_pre_execute_commands(
|
|
317
|
+
self, typer_pre_execute_command: Callable[[], None]
|
|
318
|
+
):
|
|
319
|
+
self._typer_pre_execute_commands.append(typer_pre_execute_command)
|
|
320
|
+
|
|
321
|
+
@property
|
|
322
|
+
def connection_context(self) -> _ConnectionContext:
|
|
323
|
+
return self._connection_context
|
|
324
|
+
|
|
325
|
+
@property
|
|
326
|
+
def connection(self) -> SnowflakeConnection:
|
|
327
|
+
return self.connection_context.connection
|
|
328
|
+
|
|
329
|
+
@property
|
|
330
|
+
def silent(self) -> bool:
|
|
331
|
+
return self._silent
|
|
332
|
+
|
|
333
|
+
def set_silent(self, value: bool):
|
|
334
|
+
self._silent = value
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
class _CliGlobalContextAccess:
|
|
338
|
+
def __init__(self, manager: _CliGlobalContextManager):
|
|
339
|
+
self._manager = manager
|
|
340
|
+
|
|
341
|
+
@property
|
|
342
|
+
def connection(self) -> SnowflakeConnection:
|
|
343
|
+
return self._manager.connection
|
|
344
|
+
|
|
345
|
+
@property
|
|
346
|
+
def connection_context(self) -> _ConnectionContext:
|
|
347
|
+
return self._manager.connection_context
|
|
348
|
+
|
|
349
|
+
@property
|
|
350
|
+
def enable_tracebacks(self) -> bool:
|
|
351
|
+
return self._manager.enable_tracebacks
|
|
352
|
+
|
|
353
|
+
@property
|
|
354
|
+
def output_format(self) -> OutputFormat:
|
|
355
|
+
return self._manager.output_format
|
|
356
|
+
|
|
357
|
+
@property
|
|
358
|
+
def verbose(self) -> bool:
|
|
359
|
+
return self._manager.verbose
|
|
360
|
+
|
|
361
|
+
@property
|
|
362
|
+
def experimental(self) -> bool:
|
|
363
|
+
return self._manager.experimental
|
|
364
|
+
|
|
365
|
+
@property
|
|
366
|
+
def project_definition(self) -> ProjectDefinition | None:
|
|
367
|
+
return self._manager.project_definition
|
|
368
|
+
|
|
369
|
+
@property
|
|
370
|
+
def project_root(self):
|
|
371
|
+
return self._manager.project_root
|
|
372
|
+
|
|
373
|
+
@property
|
|
374
|
+
def template_context(self) -> dict:
|
|
375
|
+
return self._manager.template_context
|
|
376
|
+
|
|
377
|
+
@property
|
|
378
|
+
def silent(self) -> bool:
|
|
379
|
+
if self._should_force_mute_intermediate_output:
|
|
380
|
+
return True
|
|
381
|
+
return self._manager.silent
|
|
382
|
+
|
|
383
|
+
@property
|
|
384
|
+
def _should_force_mute_intermediate_output(self) -> bool:
|
|
385
|
+
"""Computes whether cli_console output should be muted."""
|
|
386
|
+
return self._manager.output_format == OutputFormat.JSON
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
cli_context_manager: _CliGlobalContextManager = _CliGlobalContextManager()
|
|
390
|
+
cli_context: _CliGlobalContextAccess = _CliGlobalContextAccess(cli_context_manager)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Copyright (c) 2024 Snowflake Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Copyright (c) 2024 Snowflake Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
from copy import deepcopy
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def build_alias(main_app, name: str, help_str: str):
|
|
19
|
+
alias = deepcopy(main_app)
|
|
20
|
+
alias.info.name = name
|
|
21
|
+
alias.info.help = help_str
|
|
22
|
+
alias.info.hidden = True
|
|
23
|
+
return alias
|