snowflake-cli-labs 2.8.0rc1__py3-none-any.whl → 3.0.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 +1 -1
- snowflake/cli/{app → _app}/__main__.py +1 -1
- snowflake/cli/{app → _app}/cli_app.py +22 -13
- snowflake/cli/{app → _app}/commands_registration/builtin_plugins.py +15 -19
- snowflake/cli/{app → _app}/commands_registration/command_plugins_loader.py +9 -9
- snowflake/cli/{app → _app}/commands_registration/commands_registration_with_callbacks.py +4 -4
- snowflake/cli/{app → _app}/commands_registration/exception_logging.py +2 -2
- snowflake/cli/{app → _app}/commands_registration/typer_registration.py +2 -2
- snowflake/cli/{app → _app}/dev/docs/commands_docs_generator.py +30 -12
- snowflake/cli/{app → _app}/dev/docs/generator.py +3 -3
- snowflake/cli/{app → _app}/dev/docs/project_definition_docs_generator.py +4 -4
- snowflake/cli/{app → _app}/dev/docs/templates/usage.rst.jinja2 +14 -4
- snowflake/cli/{app → _app}/main_typer.py +2 -2
- snowflake/cli/{app → _app}/printing.py +2 -2
- snowflake/cli/_app/secret.py +9 -0
- snowflake/cli/{app → _app}/snow_connector.py +127 -61
- snowflake/cli/{app → _app}/telemetry.py +38 -7
- snowflake/cli/_app/version_check.py +74 -0
- snowflake/cli/{plugins → _plugins}/connection/commands.py +34 -11
- snowflake/cli/_plugins/connection/plugin_spec.py +30 -0
- snowflake/cli/{plugins → _plugins}/connection/util.py +16 -0
- snowflake/cli/{plugins → _plugins}/cortex/commands.py +54 -49
- snowflake/cli/{plugins → _plugins}/cortex/constants.py +1 -1
- snowflake/cli/{plugins → _plugins}/cortex/manager.py +5 -5
- snowflake/cli/{plugins → _plugins}/cortex/plugin_spec.py +1 -1
- snowflake/cli/{plugins → _plugins}/git/commands.py +79 -26
- snowflake/cli/{plugins → _plugins}/git/manager.py +72 -17
- snowflake/cli/{plugins → _plugins}/git/plugin_spec.py +1 -1
- snowflake/cli/_plugins/helpers/commands.py +90 -0
- snowflake/cli/{plugins/notebook → _plugins/helpers}/plugin_spec.py +1 -1
- snowflake/cli/{plugins → _plugins}/init/commands.py +10 -6
- snowflake/cli/{plugins → _plugins}/init/plugin_spec.py +1 -1
- snowflake/cli/{plugins → _plugins}/nativeapp/artifacts.py +24 -9
- snowflake/cli/_plugins/nativeapp/bundle_context.py +31 -0
- snowflake/cli/{plugins → _plugins}/nativeapp/codegen/artifact_processor.py +4 -4
- snowflake/cli/{plugins → _plugins}/nativeapp/codegen/compiler.py +37 -18
- snowflake/cli/_plugins/nativeapp/codegen/setup/native_app_setup_processor.py +249 -0
- snowflake/cli/{plugins → _plugins}/nativeapp/codegen/setup/setup_driver.py.source +5 -2
- snowflake/cli/{plugins → _plugins}/nativeapp/codegen/snowpark/extension_function_utils.py +5 -5
- snowflake/cli/{plugins → _plugins}/nativeapp/codegen/snowpark/models.py +1 -1
- snowflake/cli/{plugins → _plugins}/nativeapp/codegen/snowpark/python_processor.py +29 -34
- snowflake/cli/_plugins/nativeapp/codegen/templates/templates_processor.py +114 -0
- snowflake/cli/{plugins → _plugins}/nativeapp/commands.py +252 -132
- snowflake/cli/{plugins → _plugins}/nativeapp/common_flags.py +1 -1
- snowflake/cli/_plugins/nativeapp/entities/application.py +878 -0
- snowflake/cli/_plugins/nativeapp/entities/application_package.py +1392 -0
- snowflake/cli/{plugins → _plugins}/nativeapp/exceptions.py +3 -12
- snowflake/cli/_plugins/nativeapp/manager.py +415 -0
- snowflake/cli/{plugins/connection → _plugins/nativeapp}/plugin_spec.py +1 -1
- snowflake/cli/{plugins → _plugins}/nativeapp/policy.py +3 -0
- snowflake/cli/{plugins → _plugins}/nativeapp/project_model.py +36 -20
- snowflake/cli/_plugins/nativeapp/run_processor.py +184 -0
- snowflake/cli/_plugins/nativeapp/same_account_install_method.py +70 -0
- snowflake/cli/_plugins/nativeapp/teardown_processor.py +70 -0
- snowflake/cli/_plugins/nativeapp/v2_conversions/v2_to_v1_decorator.py +262 -0
- snowflake/cli/{plugins → _plugins}/nativeapp/version/commands.py +20 -49
- snowflake/cli/_plugins/nativeapp/version/version_processor.py +98 -0
- snowflake/cli/{plugins → _plugins}/notebook/commands.py +8 -6
- snowflake/cli/{plugins → _plugins}/notebook/manager.py +14 -14
- snowflake/cli/{plugins/nativeapp → _plugins/notebook}/plugin_spec.py +1 -1
- snowflake/cli/{plugins → _plugins}/notebook/types.py +0 -1
- snowflake/cli/{plugins → _plugins}/object/command_aliases.py +6 -5
- snowflake/cli/{plugins → _plugins}/object/commands.py +16 -10
- snowflake/cli/{plugins → _plugins}/object/manager.py +43 -21
- snowflake/cli/{plugins → _plugins}/object/plugin_spec.py +1 -1
- snowflake/cli/_plugins/snowpark/commands.py +450 -0
- snowflake/cli/_plugins/snowpark/common.py +268 -0
- snowflake/cli/{plugins → _plugins}/snowpark/models.py +2 -8
- snowflake/cli/{plugins → _plugins}/snowpark/package/anaconda_packages.py +2 -36
- snowflake/cli/{plugins → _plugins}/snowpark/package/commands.py +13 -74
- snowflake/cli/{plugins → _plugins}/snowpark/package/manager.py +4 -3
- snowflake/cli/{plugins → _plugins}/snowpark/package_utils.py +5 -5
- snowflake/cli/_plugins/snowpark/plugin_spec.py +30 -0
- snowflake/cli/_plugins/snowpark/snowpark_entity.py +29 -0
- snowflake/cli/_plugins/snowpark/snowpark_entity_model.py +173 -0
- snowflake/cli/_plugins/snowpark/snowpark_project_paths.py +109 -0
- snowflake/cli/{plugins → _plugins}/snowpark/snowpark_shared.py +0 -36
- snowflake/cli/{plugins → _plugins}/snowpark/zipper.py +16 -8
- snowflake/cli/{plugins → _plugins}/spcs/__init__.py +5 -7
- snowflake/cli/{plugins → _plugins}/spcs/compute_pool/commands.py +29 -28
- snowflake/cli/{plugins → _plugins}/spcs/compute_pool/manager.py +3 -3
- snowflake/cli/{plugins → _plugins}/spcs/image_registry/commands.py +3 -3
- snowflake/cli/{plugins → _plugins}/spcs/image_repository/commands.py +25 -19
- snowflake/cli/{plugins → _plugins}/spcs/image_repository/manager.py +1 -1
- snowflake/cli/{plugins → _plugins}/spcs/plugin_spec.py +1 -1
- snowflake/cli/{plugins → _plugins}/spcs/services/commands.py +66 -32
- snowflake/cli/{plugins → _plugins}/spcs/services/manager.py +43 -5
- snowflake/cli/{plugins → _plugins}/sql/commands.py +20 -17
- snowflake/cli/{plugins → _plugins}/sql/manager.py +1 -1
- snowflake/cli/{plugins → _plugins}/sql/plugin_spec.py +1 -1
- snowflake/cli/{plugins → _plugins}/stage/commands.py +20 -17
- snowflake/cli/{plugins → _plugins}/stage/diff.py +1 -47
- snowflake/cli/{plugins → _plugins}/stage/manager.py +62 -24
- snowflake/cli/{plugins → _plugins}/stage/plugin_spec.py +1 -1
- snowflake/cli/_plugins/stage/utils.py +54 -0
- snowflake/cli/{plugins → _plugins}/streamlit/commands.py +71 -62
- snowflake/cli/{plugins → _plugins}/streamlit/manager.py +68 -70
- snowflake/cli/_plugins/streamlit/plugin_spec.py +30 -0
- snowflake/cli/_plugins/streamlit/streamlit_entity.py +12 -0
- snowflake/cli/_plugins/streamlit/streamlit_entity_model.py +66 -0
- snowflake/cli/_plugins/workspace/action_context.py +18 -0
- snowflake/cli/_plugins/workspace/commands.py +306 -0
- snowflake/cli/_plugins/workspace/manager.py +74 -0
- snowflake/cli/_plugins/workspace/plugin_spec.py +30 -0
- snowflake/cli/api/cli_global_context.py +152 -295
- snowflake/cli/api/commands/common.py +25 -0
- snowflake/cli/api/commands/decorators.py +19 -4
- snowflake/cli/api/commands/experimental_behaviour.py +2 -3
- snowflake/cli/api/commands/flags.py +143 -222
- snowflake/cli/api/commands/overrideable_parameter.py +143 -0
- snowflake/cli/api/commands/snow_typer.py +21 -11
- snowflake/cli/api/commands/utils.py +18 -0
- snowflake/cli/api/config.py +44 -12
- snowflake/cli/api/connections.py +216 -0
- snowflake/cli/api/console/abc.py +8 -3
- snowflake/cli/api/constants.py +11 -0
- snowflake/cli/api/entities/common.py +56 -0
- snowflake/cli/api/entities/utils.py +370 -0
- snowflake/cli/api/errno.py +1 -0
- snowflake/cli/api/exceptions.py +31 -5
- snowflake/cli/api/feature_flags.py +0 -1
- snowflake/cli/api/identifiers.py +45 -9
- snowflake/cli/api/metrics.py +92 -0
- snowflake/cli/api/project/definition.py +48 -6
- snowflake/cli/api/project/definition_conversion.py +400 -0
- snowflake/cli/api/project/definition_manager.py +16 -5
- snowflake/cli/api/project/project_verification.py +3 -3
- snowflake/cli/api/project/schemas/entities/common.py +91 -16
- snowflake/cli/api/project/schemas/entities/entities.py +37 -6
- snowflake/cli/api/project/schemas/project_definition.py +180 -49
- snowflake/cli/api/project/schemas/updatable_model.py +11 -3
- snowflake/cli/api/project/schemas/v1/__init__.py +0 -0
- snowflake/cli/api/project/schemas/{identifier_model.py → v1/identifier_model.py} +3 -1
- snowflake/cli/api/project/schemas/v1/native_app/__init__.py +0 -0
- snowflake/cli/api/project/schemas/{native_app → v1/native_app}/application.py +8 -9
- snowflake/cli/api/project/schemas/{native_app → v1/native_app}/native_app.py +4 -4
- snowflake/cli/api/project/schemas/{native_app → v1/native_app}/package.py +7 -1
- snowflake/cli/api/project/schemas/v1/snowpark/__init__.py +0 -0
- snowflake/cli/api/project/schemas/{snowpark → v1/snowpark}/callable.py +2 -2
- snowflake/cli/api/project/schemas/{snowpark → v1/snowpark}/snowpark.py +2 -2
- snowflake/cli/api/project/schemas/v1/streamlit/__init__.py +0 -0
- snowflake/cli/api/project/schemas/{streamlit → v1/streamlit}/streamlit.py +2 -1
- snowflake/cli/api/project/util.py +23 -6
- snowflake/cli/api/rendering/jinja.py +14 -8
- snowflake/cli/api/rendering/project_definition_templates.py +5 -1
- snowflake/cli/api/rendering/sql_templates.py +56 -11
- snowflake/cli/api/rest_api.py +11 -5
- snowflake/cli/api/secure_path.py +16 -18
- snowflake/cli/api/secure_utils.py +90 -1
- snowflake/cli/api/sql_execution.py +47 -27
- snowflake/cli/api/utils/definition_rendering.py +45 -13
- {snowflake_cli_labs-2.8.0rc1.dist-info → snowflake_cli_labs-3.0.0.dist-info}/METADATA +20 -18
- snowflake_cli_labs-3.0.0.dist-info/RECORD +242 -0
- snowflake_cli_labs-3.0.0.dist-info/entry_points.txt +2 -0
- snowflake/cli/api/commands/project_initialisation.py +0 -65
- snowflake/cli/api/commands/typer_pre_execute.py +0 -26
- snowflake/cli/api/project/schemas/entities/application_entity.py +0 -44
- snowflake/cli/api/project/schemas/entities/application_package_entity.py +0 -66
- snowflake/cli/app/build_and_push.sh +0 -8
- snowflake/cli/plugins/nativeapp/codegen/setup/native_app_setup_processor.py +0 -172
- snowflake/cli/plugins/nativeapp/init.py +0 -345
- snowflake/cli/plugins/nativeapp/manager.py +0 -823
- snowflake/cli/plugins/nativeapp/run_processor.py +0 -389
- snowflake/cli/plugins/nativeapp/teardown_processor.py +0 -301
- snowflake/cli/plugins/nativeapp/v2_conversions/v2_to_v1_decorator.py +0 -135
- snowflake/cli/plugins/nativeapp/version/version_processor.py +0 -362
- snowflake/cli/plugins/object_stage_deprecated/__init__.py +0 -15
- snowflake/cli/plugins/object_stage_deprecated/commands.py +0 -122
- snowflake/cli/plugins/object_stage_deprecated/plugin_spec.py +0 -32
- snowflake/cli/plugins/snowpark/commands.py +0 -548
- snowflake/cli/plugins/snowpark/common.py +0 -307
- snowflake/cli/plugins/snowpark/manager.py +0 -109
- snowflake/cli/plugins/snowpark/plugin_spec.py +0 -30
- snowflake/cli/plugins/snowpark/snowpark_package_paths.py +0 -65
- snowflake/cli/plugins/spcs/jobs/commands.py +0 -78
- snowflake/cli/plugins/spcs/jobs/manager.py +0 -53
- snowflake/cli/plugins/streamlit/__init__.py +0 -13
- snowflake/cli/plugins/streamlit/plugin_spec.py +0 -30
- snowflake/cli/plugins/workspace/__init__.py +0 -13
- snowflake/cli/plugins/workspace/commands.py +0 -35
- snowflake/cli/plugins/workspace/plugin_spec.py +0 -30
- snowflake/cli/templates/default_snowpark/.gitignore +0 -4
- snowflake/cli/templates/default_snowpark/app/common.py +0 -2
- snowflake/cli/templates/default_snowpark/app/functions.py +0 -15
- snowflake/cli/templates/default_snowpark/app/procedures.py +0 -22
- snowflake/cli/templates/default_snowpark/requirements.txt +0 -1
- snowflake/cli/templates/default_snowpark/snowflake.yml +0 -23
- snowflake/cli/templates/default_streamlit/.gitignore +0 -4
- snowflake/cli/templates/default_streamlit/common/hello.py +0 -2
- snowflake/cli/templates/default_streamlit/environment.yml +0 -6
- snowflake/cli/templates/default_streamlit/pages/my_page.py +0 -3
- snowflake/cli/templates/default_streamlit/snowflake.yml +0 -10
- snowflake/cli/templates/default_streamlit/streamlit_app.py +0 -4
- snowflake_cli_labs-2.8.0rc1.dist-info/RECORD +0 -240
- snowflake_cli_labs-2.8.0rc1.dist-info/entry_points.txt +0 -2
- /snowflake/cli/{app → _app}/__init__.py +0 -0
- /snowflake/cli/{api/project/schemas/native_app → _app/api_impl}/__init__.py +0 -0
- /snowflake/cli/{api/project/schemas/snowpark → _app/api_impl/plugin}/__init__.py +0 -0
- /snowflake/cli/{app → _app}/api_impl/plugin/plugin_config_provider_impl.py +0 -0
- /snowflake/cli/{app → _app}/commands_registration/__init__.py +0 -0
- /snowflake/cli/{app → _app}/commands_registration/threadsafe.py +0 -0
- /snowflake/cli/{app → _app}/constants.py +0 -0
- /snowflake/cli/{api/project/schemas/streamlit → _app/dev}/__init__.py +0 -0
- /snowflake/cli/{app → _app}/dev/commands_structure.py +0 -0
- /snowflake/cli/{app/api_impl → _app/dev/docs}/__init__.py +0 -0
- /snowflake/cli/{app → _app}/dev/docs/project_definition_generate_json_schema.py +0 -0
- /snowflake/cli/{app → _app}/dev/docs/template_utils.py +0 -0
- /snowflake/cli/{app → _app}/dev/docs/templates/definition_description.rst.jinja2 +0 -0
- /snowflake/cli/{app → _app}/dev/docs/templates/overview.rst.jinja2 +0 -0
- /snowflake/cli/{app → _app}/dev/pycharm_remote_debug.py +0 -0
- /snowflake/cli/{app → _app}/loggers.py +0 -0
- /snowflake/cli/{app/api_impl/plugin → _plugins}/__init__.py +0 -0
- /snowflake/cli/{app/dev → _plugins/connection}/__init__.py +0 -0
- /snowflake/cli/{app/dev/docs → _plugins/cortex}/__init__.py +0 -0
- /snowflake/cli/{plugins → _plugins}/cortex/types.py +0 -0
- /snowflake/cli/{plugins → _plugins/git}/__init__.py +0 -0
- /snowflake/cli/{plugins/connection → _plugins/helpers}/__init__.py +0 -0
- /snowflake/cli/{plugins/cortex → _plugins/init}/__init__.py +0 -0
- /snowflake/cli/{plugins/git → _plugins/nativeapp}/__init__.py +0 -0
- /snowflake/cli/{plugins/init → _plugins/nativeapp/codegen}/__init__.py +0 -0
- /snowflake/cli/{plugins → _plugins}/nativeapp/codegen/sandbox.py +0 -0
- /snowflake/cli/{plugins → _plugins}/nativeapp/codegen/snowpark/callback_source.py.jinja +0 -0
- /snowflake/cli/{plugins → _plugins}/nativeapp/constants.py +0 -0
- /snowflake/cli/{templates/default_snowpark/app → _plugins/nativeapp/entities}/__init__.py +0 -0
- /snowflake/cli/{plugins → _plugins}/nativeapp/feature_flags.py +0 -0
- /snowflake/cli/{plugins → _plugins}/nativeapp/utils.py +0 -0
- /snowflake/cli/{plugins/nativeapp → _plugins/nativeapp/version}/__init__.py +0 -0
- /snowflake/cli/{plugins/nativeapp/codegen → _plugins/notebook}/__init__.py +0 -0
- /snowflake/cli/{plugins → _plugins}/notebook/exceptions.py +0 -0
- /snowflake/cli/{plugins/nativeapp/version → _plugins/object}/__init__.py +0 -0
- /snowflake/cli/{plugins → _plugins}/object/common.py +0 -0
- /snowflake/cli/{plugins/notebook → _plugins/snowpark}/__init__.py +0 -0
- /snowflake/cli/{plugins/object → _plugins/snowpark/package}/__init__.py +0 -0
- /snowflake/cli/{plugins → _plugins}/snowpark/package/utils.py +0 -0
- /snowflake/cli/{plugins → _plugins}/spcs/common.py +0 -0
- /snowflake/cli/{plugins/snowpark → _plugins/spcs/compute_pool}/__init__.py +0 -0
- /snowflake/cli/{plugins/snowpark/package → _plugins/spcs/image_registry}/__init__.py +0 -0
- /snowflake/cli/{plugins → _plugins}/spcs/image_registry/manager.py +0 -0
- /snowflake/cli/{plugins/spcs/compute_pool → _plugins/spcs/image_repository}/__init__.py +0 -0
- /snowflake/cli/{plugins/spcs/image_registry → _plugins/spcs/services}/__init__.py +0 -0
- /snowflake/cli/{plugins/spcs/image_repository → _plugins/sql}/__init__.py +0 -0
- /snowflake/cli/{plugins → _plugins}/sql/snowsql_templating.py +0 -0
- /snowflake/cli/{plugins/spcs/jobs → _plugins/stage}/__init__.py +0 -0
- /snowflake/cli/{plugins → _plugins}/stage/md5.py +0 -0
- /snowflake/cli/{plugins/spcs/services → _plugins/streamlit}/__init__.py +0 -0
- /snowflake/cli/{plugins/sql → _plugins/workspace}/__init__.py +0 -0
- /snowflake/cli/{plugins/stage → api/project/schemas/entities}/__init__.py +0 -0
- /snowflake/cli/api/project/schemas/{native_app → v1/native_app}/path_mapping.py +0 -0
- /snowflake/cli/api/project/schemas/{snowpark → v1/snowpark}/argument.py +0 -0
- {snowflake_cli_labs-2.8.0rc1.dist-info → snowflake_cli_labs-3.0.0.dist-info}/WHEEL +0 -0
- {snowflake_cli_labs-2.8.0rc1.dist-info → snowflake_cli_labs-3.0.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -19,27 +19,22 @@ from typing import Optional
|
|
|
19
19
|
|
|
20
20
|
import typer
|
|
21
21
|
from click import MissingParameter
|
|
22
|
-
from snowflake.cli.
|
|
22
|
+
from snowflake.cli._plugins.nativeapp.common_flags import ForceOption, InteractiveOption
|
|
23
|
+
from snowflake.cli._plugins.nativeapp.run_processor import NativeAppRunProcessor
|
|
24
|
+
from snowflake.cli._plugins.nativeapp.v2_conversions.v2_to_v1_decorator import (
|
|
25
|
+
nativeapp_definition_v2_to_v1,
|
|
26
|
+
)
|
|
27
|
+
from snowflake.cli._plugins.nativeapp.version.version_processor import (
|
|
28
|
+
NativeAppVersionCreateProcessor,
|
|
29
|
+
NativeAppVersionDropProcessor,
|
|
30
|
+
)
|
|
31
|
+
from snowflake.cli.api.cli_global_context import get_cli_context
|
|
23
32
|
from snowflake.cli.api.commands.decorators import (
|
|
24
33
|
with_project_definition,
|
|
25
34
|
)
|
|
26
35
|
from snowflake.cli.api.commands.snow_typer import SnowTyperFactory
|
|
27
36
|
from snowflake.cli.api.output.types import CommandResult, MessageResult, QueryResult
|
|
28
37
|
from snowflake.cli.api.project.project_verification import assert_project_type
|
|
29
|
-
from snowflake.cli.plugins.nativeapp.common_flags import ForceOption, InteractiveOption
|
|
30
|
-
from snowflake.cli.plugins.nativeapp.policy import (
|
|
31
|
-
AllowAlwaysPolicy,
|
|
32
|
-
AskAlwaysPolicy,
|
|
33
|
-
DenyAlwaysPolicy,
|
|
34
|
-
)
|
|
35
|
-
from snowflake.cli.plugins.nativeapp.run_processor import NativeAppRunProcessor
|
|
36
|
-
from snowflake.cli.plugins.nativeapp.v2_conversions.v2_to_v1_decorator import (
|
|
37
|
-
nativeapp_definition_v2_to_v1,
|
|
38
|
-
)
|
|
39
|
-
from snowflake.cli.plugins.nativeapp.version.version_processor import (
|
|
40
|
-
NativeAppVersionCreateProcessor,
|
|
41
|
-
NativeAppVersionDropProcessor,
|
|
42
|
-
)
|
|
43
38
|
|
|
44
39
|
app = SnowTyperFactory(
|
|
45
40
|
name="version",
|
|
@@ -51,7 +46,7 @@ log = logging.getLogger(__name__)
|
|
|
51
46
|
|
|
52
47
|
@app.command(requires_connection=True)
|
|
53
48
|
@with_project_definition()
|
|
54
|
-
@nativeapp_definition_v2_to_v1
|
|
49
|
+
@nativeapp_definition_v2_to_v1()
|
|
55
50
|
def create(
|
|
56
51
|
version: Optional[str] = typer.Argument(
|
|
57
52
|
None,
|
|
@@ -82,41 +77,24 @@ def create(
|
|
|
82
77
|
if version is None and patch is not None:
|
|
83
78
|
raise MissingParameter("Cannot provide a patch without version!")
|
|
84
79
|
|
|
85
|
-
|
|
86
|
-
if force:
|
|
87
|
-
policy = AllowAlwaysPolicy()
|
|
88
|
-
elif interactive:
|
|
89
|
-
is_interactive = True
|
|
90
|
-
policy = AskAlwaysPolicy()
|
|
91
|
-
else:
|
|
92
|
-
policy = DenyAlwaysPolicy()
|
|
93
|
-
|
|
94
|
-
if skip_git_check:
|
|
95
|
-
git_policy = DenyAlwaysPolicy()
|
|
96
|
-
else:
|
|
97
|
-
git_policy = AllowAlwaysPolicy()
|
|
98
|
-
|
|
80
|
+
cli_context = get_cli_context()
|
|
99
81
|
processor = NativeAppVersionCreateProcessor(
|
|
100
82
|
project_definition=cli_context.project_definition.native_app,
|
|
101
83
|
project_root=cli_context.project_root,
|
|
102
84
|
)
|
|
103
|
-
|
|
104
|
-
# We need build_bundle() to (optionally) find version in manifest.yml and create an application package
|
|
105
|
-
bundle_map = processor.build_bundle()
|
|
106
85
|
processor.process(
|
|
107
|
-
bundle_map=bundle_map,
|
|
108
86
|
version=version,
|
|
109
87
|
patch=patch,
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
88
|
+
force=force,
|
|
89
|
+
interactive=interactive,
|
|
90
|
+
skip_git_check=skip_git_check,
|
|
113
91
|
)
|
|
114
92
|
return MessageResult(f"Version create is now complete.")
|
|
115
93
|
|
|
116
94
|
|
|
117
95
|
@app.command("list", requires_connection=True)
|
|
118
96
|
@with_project_definition()
|
|
119
|
-
@nativeapp_definition_v2_to_v1
|
|
97
|
+
@nativeapp_definition_v2_to_v1()
|
|
120
98
|
def version_list(
|
|
121
99
|
**options,
|
|
122
100
|
) -> CommandResult:
|
|
@@ -126,6 +104,7 @@ def version_list(
|
|
|
126
104
|
|
|
127
105
|
assert_project_type("native_app")
|
|
128
106
|
|
|
107
|
+
cli_context = get_cli_context()
|
|
129
108
|
processor = NativeAppRunProcessor(
|
|
130
109
|
project_definition=cli_context.project_definition.native_app,
|
|
131
110
|
project_root=cli_context.project_root,
|
|
@@ -136,7 +115,7 @@ def version_list(
|
|
|
136
115
|
|
|
137
116
|
@app.command(requires_connection=True)
|
|
138
117
|
@with_project_definition()
|
|
139
|
-
@nativeapp_definition_v2_to_v1
|
|
118
|
+
@nativeapp_definition_v2_to_v1()
|
|
140
119
|
def drop(
|
|
141
120
|
version: Optional[str] = typer.Argument(
|
|
142
121
|
None,
|
|
@@ -153,18 +132,10 @@ def drop(
|
|
|
153
132
|
|
|
154
133
|
assert_project_type("native_app")
|
|
155
134
|
|
|
156
|
-
|
|
157
|
-
if force:
|
|
158
|
-
policy = AllowAlwaysPolicy()
|
|
159
|
-
elif interactive:
|
|
160
|
-
is_interactive = True
|
|
161
|
-
policy = AskAlwaysPolicy()
|
|
162
|
-
else:
|
|
163
|
-
policy = DenyAlwaysPolicy()
|
|
164
|
-
|
|
135
|
+
cli_context = get_cli_context()
|
|
165
136
|
processor = NativeAppVersionDropProcessor(
|
|
166
137
|
project_definition=cli_context.project_definition.native_app,
|
|
167
138
|
project_root=cli_context.project_root,
|
|
168
139
|
)
|
|
169
|
-
processor.process(version,
|
|
140
|
+
processor.process(version, force, interactive)
|
|
170
141
|
return MessageResult(f"Version drop is now complete.")
|
|
@@ -0,0 +1,98 @@
|
|
|
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 pathlib import Path
|
|
18
|
+
from typing import Dict, Optional
|
|
19
|
+
|
|
20
|
+
from snowflake.cli._plugins.nativeapp.entities.application_package import (
|
|
21
|
+
ApplicationPackageEntity,
|
|
22
|
+
)
|
|
23
|
+
from snowflake.cli._plugins.nativeapp.manager import (
|
|
24
|
+
NativeAppCommandProcessor,
|
|
25
|
+
NativeAppManager,
|
|
26
|
+
)
|
|
27
|
+
from snowflake.cli._plugins.nativeapp.run_processor import NativeAppRunProcessor
|
|
28
|
+
from snowflake.cli.api.console import cli_console as cc
|
|
29
|
+
from snowflake.cli.api.project.schemas.v1.native_app.native_app import NativeApp
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class NativeAppVersionCreateProcessor(NativeAppRunProcessor):
|
|
33
|
+
def __init__(self, project_definition: Dict, project_root: Path):
|
|
34
|
+
super().__init__(project_definition, project_root)
|
|
35
|
+
|
|
36
|
+
def process(
|
|
37
|
+
self,
|
|
38
|
+
version: Optional[str],
|
|
39
|
+
patch: Optional[int],
|
|
40
|
+
force: bool,
|
|
41
|
+
interactive: bool,
|
|
42
|
+
skip_git_check: bool,
|
|
43
|
+
*args,
|
|
44
|
+
**kwargs,
|
|
45
|
+
):
|
|
46
|
+
return ApplicationPackageEntity.version_create(
|
|
47
|
+
console=cc,
|
|
48
|
+
project_root=self.project_root,
|
|
49
|
+
deploy_root=self.deploy_root,
|
|
50
|
+
bundle_root=self.bundle_root,
|
|
51
|
+
generated_root=self.generated_root,
|
|
52
|
+
artifacts=self.artifacts,
|
|
53
|
+
package_name=self.package_name,
|
|
54
|
+
package_role=self.package_role,
|
|
55
|
+
package_distribution=self.package_distribution,
|
|
56
|
+
prune=True,
|
|
57
|
+
recursive=True,
|
|
58
|
+
paths=None,
|
|
59
|
+
print_diff=True,
|
|
60
|
+
validate=True,
|
|
61
|
+
stage_fqn=self.stage_fqn,
|
|
62
|
+
package_warehouse=self.package_warehouse,
|
|
63
|
+
post_deploy_hooks=self.package_post_deploy_hooks,
|
|
64
|
+
package_scripts=self.package_scripts,
|
|
65
|
+
version=version,
|
|
66
|
+
patch=patch,
|
|
67
|
+
force=force,
|
|
68
|
+
interactive=interactive,
|
|
69
|
+
skip_git_check=skip_git_check,
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class NativeAppVersionDropProcessor(NativeAppManager, NativeAppCommandProcessor):
|
|
74
|
+
def __init__(self, project_definition: NativeApp, project_root: Path):
|
|
75
|
+
super().__init__(project_definition, project_root)
|
|
76
|
+
|
|
77
|
+
def process(
|
|
78
|
+
self,
|
|
79
|
+
version: Optional[str],
|
|
80
|
+
force: bool,
|
|
81
|
+
interactive: bool,
|
|
82
|
+
*args,
|
|
83
|
+
**kwargs,
|
|
84
|
+
):
|
|
85
|
+
return ApplicationPackageEntity.version_drop(
|
|
86
|
+
console=cc,
|
|
87
|
+
project_root=self.project_root,
|
|
88
|
+
deploy_root=self.deploy_root,
|
|
89
|
+
bundle_root=self.bundle_root,
|
|
90
|
+
generated_root=self.generated_root,
|
|
91
|
+
artifacts=self.artifacts,
|
|
92
|
+
package_name=self.package_name,
|
|
93
|
+
package_role=self.package_role,
|
|
94
|
+
package_distribution=self.package_distribution,
|
|
95
|
+
version=version,
|
|
96
|
+
force=force,
|
|
97
|
+
interactive=interactive,
|
|
98
|
+
)
|
|
@@ -15,11 +15,12 @@
|
|
|
15
15
|
import logging
|
|
16
16
|
|
|
17
17
|
import typer
|
|
18
|
+
from snowflake.cli._plugins.notebook.manager import NotebookManager
|
|
19
|
+
from snowflake.cli._plugins.notebook.types import NotebookStagePath
|
|
18
20
|
from snowflake.cli.api.commands.flags import identifier_argument
|
|
19
21
|
from snowflake.cli.api.commands.snow_typer import SnowTyperFactory
|
|
22
|
+
from snowflake.cli.api.identifiers import FQN
|
|
20
23
|
from snowflake.cli.api.output.types import MessageResult
|
|
21
|
-
from snowflake.cli.plugins.notebook.manager import NotebookManager
|
|
22
|
-
from snowflake.cli.plugins.notebook.types import NotebookName, NotebookStagePath
|
|
23
24
|
from typing_extensions import Annotated
|
|
24
25
|
|
|
25
26
|
app = SnowTyperFactory(
|
|
@@ -33,12 +34,13 @@ NotebookFile: NotebookStagePath = typer.Option(
|
|
|
33
34
|
"--notebook-file",
|
|
34
35
|
"-f",
|
|
35
36
|
help="Stage path with notebook file. For example `@stage/path/to/notebook.ipynb`",
|
|
37
|
+
show_default=False,
|
|
36
38
|
)
|
|
37
39
|
|
|
38
40
|
|
|
39
41
|
@app.command(requires_connection=True)
|
|
40
42
|
def execute(
|
|
41
|
-
identifier:
|
|
43
|
+
identifier: FQN = NOTEBOOK_IDENTIFIER,
|
|
42
44
|
**options,
|
|
43
45
|
):
|
|
44
46
|
"""
|
|
@@ -51,7 +53,7 @@ def execute(
|
|
|
51
53
|
|
|
52
54
|
@app.command(requires_connection=True)
|
|
53
55
|
def get_url(
|
|
54
|
-
identifier:
|
|
56
|
+
identifier: FQN = NOTEBOOK_IDENTIFIER,
|
|
55
57
|
**options,
|
|
56
58
|
):
|
|
57
59
|
"""Return a url to a notebook."""
|
|
@@ -61,7 +63,7 @@ def get_url(
|
|
|
61
63
|
|
|
62
64
|
@app.command(name="open", requires_connection=True)
|
|
63
65
|
def open_cmd(
|
|
64
|
-
identifier:
|
|
66
|
+
identifier: FQN = NOTEBOOK_IDENTIFIER,
|
|
65
67
|
**options,
|
|
66
68
|
):
|
|
67
69
|
"""Opens a notebook in default browser"""
|
|
@@ -72,7 +74,7 @@ def open_cmd(
|
|
|
72
74
|
|
|
73
75
|
@app.command(requires_connection=True)
|
|
74
76
|
def create(
|
|
75
|
-
identifier: Annotated[
|
|
77
|
+
identifier: Annotated[FQN, NOTEBOOK_IDENTIFIER],
|
|
76
78
|
notebook_file: Annotated[NotebookStagePath, NotebookFile],
|
|
77
79
|
**options,
|
|
78
80
|
):
|
|
@@ -15,28 +15,28 @@
|
|
|
15
15
|
from pathlib import Path
|
|
16
16
|
from textwrap import dedent
|
|
17
17
|
|
|
18
|
-
from snowflake.cli.
|
|
18
|
+
from snowflake.cli._plugins.connection.util import make_snowsight_url
|
|
19
|
+
from snowflake.cli._plugins.notebook.exceptions import NotebookStagePathError
|
|
20
|
+
from snowflake.cli._plugins.notebook.types import NotebookStagePath
|
|
21
|
+
from snowflake.cli.api.cli_global_context import get_cli_context
|
|
19
22
|
from snowflake.cli.api.identifiers import FQN
|
|
20
23
|
from snowflake.cli.api.sql_execution import SqlExecutionMixin
|
|
21
|
-
from snowflake.cli.plugins.connection.util import make_snowsight_url
|
|
22
|
-
from snowflake.cli.plugins.notebook.exceptions import NotebookStagePathError
|
|
23
|
-
from snowflake.cli.plugins.notebook.types import NotebookName, NotebookStagePath
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
class NotebookManager(SqlExecutionMixin):
|
|
27
|
-
def execute(self, notebook_name:
|
|
28
|
-
query = f"EXECUTE NOTEBOOK {notebook_name}()"
|
|
27
|
+
def execute(self, notebook_name: FQN):
|
|
28
|
+
query = f"EXECUTE NOTEBOOK {notebook_name.sql_identifier}()"
|
|
29
29
|
return self._execute_query(query=query)
|
|
30
30
|
|
|
31
|
-
def get_url(self, notebook_name:
|
|
32
|
-
fqn =
|
|
31
|
+
def get_url(self, notebook_name: FQN):
|
|
32
|
+
fqn = notebook_name.using_connection(self._conn)
|
|
33
33
|
return make_snowsight_url(
|
|
34
34
|
self._conn,
|
|
35
35
|
f"/#/notebooks/{fqn.url_identifier}",
|
|
36
36
|
)
|
|
37
37
|
|
|
38
38
|
@staticmethod
|
|
39
|
-
def parse_stage_as_path(notebook_file:
|
|
39
|
+
def parse_stage_as_path(notebook_file: str) -> Path:
|
|
40
40
|
"""Parses notebook file path to pathlib.Path."""
|
|
41
41
|
if not notebook_file.endswith(".ipynb"):
|
|
42
42
|
raise NotebookStagePathError(notebook_file)
|
|
@@ -48,19 +48,19 @@ class NotebookManager(SqlExecutionMixin):
|
|
|
48
48
|
|
|
49
49
|
def create(
|
|
50
50
|
self,
|
|
51
|
-
notebook_name:
|
|
51
|
+
notebook_name: FQN,
|
|
52
52
|
notebook_file: NotebookStagePath,
|
|
53
53
|
) -> str:
|
|
54
|
-
notebook_fqn =
|
|
54
|
+
notebook_fqn = notebook_name.using_connection(self._conn)
|
|
55
55
|
stage_path = self.parse_stage_as_path(notebook_file)
|
|
56
56
|
|
|
57
57
|
queries = dedent(
|
|
58
58
|
f"""
|
|
59
|
-
CREATE OR REPLACE NOTEBOOK {notebook_fqn.
|
|
59
|
+
CREATE OR REPLACE NOTEBOOK {notebook_fqn.sql_identifier}
|
|
60
60
|
FROM '{stage_path.parent}'
|
|
61
|
-
QUERY_WAREHOUSE = '{
|
|
61
|
+
QUERY_WAREHOUSE = '{get_cli_context().connection.warehouse}'
|
|
62
62
|
MAIN_FILE = '{stage_path.name}';
|
|
63
|
-
|
|
63
|
+
// Cannot use IDENTIFIER(...)
|
|
64
64
|
ALTER NOTEBOOK {notebook_fqn.identifier} ADD LIVE VERSION FROM LAST;
|
|
65
65
|
"""
|
|
66
66
|
)
|
|
@@ -12,13 +12,13 @@
|
|
|
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.notebook import commands
|
|
15
16
|
from snowflake.cli.api.plugins.command import (
|
|
16
17
|
SNOWCLI_ROOT_COMMAND_PATH,
|
|
17
18
|
CommandSpec,
|
|
18
19
|
CommandType,
|
|
19
20
|
plugin_hook_impl,
|
|
20
21
|
)
|
|
21
|
-
from snowflake.cli.plugins.nativeapp import commands
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
@plugin_hook_impl
|
|
@@ -18,15 +18,16 @@ from typing import List, Optional, Tuple
|
|
|
18
18
|
|
|
19
19
|
import typer
|
|
20
20
|
from click import ClickException
|
|
21
|
-
from snowflake.cli.
|
|
22
|
-
from snowflake.cli.api.constants import ObjectType
|
|
23
|
-
from snowflake.cli.plugins.object.commands import (
|
|
21
|
+
from snowflake.cli._plugins.object.commands import (
|
|
24
22
|
ScopeOption,
|
|
25
23
|
describe,
|
|
26
24
|
drop,
|
|
27
25
|
list_,
|
|
28
26
|
scope_option, # noqa: F401
|
|
29
27
|
)
|
|
28
|
+
from snowflake.cli.api.commands.snow_typer import SnowTyperFactory
|
|
29
|
+
from snowflake.cli.api.constants import ObjectType
|
|
30
|
+
from snowflake.cli.api.identifiers import FQN
|
|
30
31
|
|
|
31
32
|
|
|
32
33
|
def add_object_command_aliases(
|
|
@@ -72,7 +73,7 @@ def add_object_command_aliases(
|
|
|
72
73
|
if "drop" not in ommit_commands:
|
|
73
74
|
|
|
74
75
|
@app.command("drop", requires_connection=True)
|
|
75
|
-
def drop_cmd(name:
|
|
76
|
+
def drop_cmd(name: FQN = name_argument, **options):
|
|
76
77
|
return drop(
|
|
77
78
|
object_type=object_type.value.cli_name,
|
|
78
79
|
object_name=name,
|
|
@@ -84,7 +85,7 @@ def add_object_command_aliases(
|
|
|
84
85
|
if "describe" not in ommit_commands:
|
|
85
86
|
|
|
86
87
|
@app.command("describe", requires_connection=True)
|
|
87
|
-
def describe_cmd(name:
|
|
88
|
+
def describe_cmd(name: FQN = name_argument, **options):
|
|
88
89
|
return describe(
|
|
89
90
|
object_type=object_type.value.cli_name,
|
|
90
91
|
object_name=name,
|
|
@@ -18,12 +18,18 @@ from typing import List, Optional, Tuple
|
|
|
18
18
|
|
|
19
19
|
import typer
|
|
20
20
|
from click import ClickException
|
|
21
|
-
from snowflake.cli.
|
|
21
|
+
from snowflake.cli._plugins.object.manager import ObjectManager
|
|
22
|
+
from snowflake.cli.api.commands.flags import (
|
|
23
|
+
IdentifierType,
|
|
24
|
+
like_option,
|
|
25
|
+
)
|
|
22
26
|
from snowflake.cli.api.commands.snow_typer import SnowTyperFactory
|
|
27
|
+
from snowflake.cli.api.commands.utils import parse_key_value_variables
|
|
23
28
|
from snowflake.cli.api.constants import SUPPORTED_OBJECTS, VALID_SCOPES
|
|
29
|
+
from snowflake.cli.api.exceptions import IncompatibleParametersError
|
|
30
|
+
from snowflake.cli.api.identifiers import FQN
|
|
24
31
|
from snowflake.cli.api.output.types import MessageResult, QueryResult
|
|
25
32
|
from snowflake.cli.api.project.util import is_valid_identifier
|
|
26
|
-
from snowflake.cli.plugins.object.manager import ObjectManager
|
|
27
33
|
|
|
28
34
|
app = SnowTyperFactory(
|
|
29
35
|
name="object",
|
|
@@ -31,7 +37,9 @@ app = SnowTyperFactory(
|
|
|
31
37
|
)
|
|
32
38
|
|
|
33
39
|
|
|
34
|
-
NameArgument = typer.Argument(
|
|
40
|
+
NameArgument = typer.Argument(
|
|
41
|
+
help="Name of the object.", show_default=False, click_type=IdentifierType()
|
|
42
|
+
)
|
|
35
43
|
ObjectArgument = typer.Argument(
|
|
36
44
|
help="Type of object. For example table, database, compute-pool.",
|
|
37
45
|
case_sensitive=False,
|
|
@@ -112,8 +120,8 @@ def list_(
|
|
|
112
120
|
help=f"Drops Snowflake object of given name and type. {SUPPORTED_TYPES_MSG}",
|
|
113
121
|
requires_connection=True,
|
|
114
122
|
)
|
|
115
|
-
def drop(object_type: str = ObjectArgument, object_name:
|
|
116
|
-
return QueryResult(ObjectManager().drop(object_type=object_type,
|
|
123
|
+
def drop(object_type: str = ObjectArgument, object_name: FQN = NameArgument, **options):
|
|
124
|
+
return QueryResult(ObjectManager().drop(object_type=object_type, fqn=object_name))
|
|
117
125
|
|
|
118
126
|
|
|
119
127
|
# Image repository is the only supported object that does not have a DESCRIBE command.
|
|
@@ -125,10 +133,10 @@ DESCRIBE_SUPPORTED_TYPES_MSG = f"\n\nSupported types: {', '.join(obj for obj in
|
|
|
125
133
|
requires_connection=True,
|
|
126
134
|
)
|
|
127
135
|
def describe(
|
|
128
|
-
object_type: str = ObjectArgument, object_name:
|
|
136
|
+
object_type: str = ObjectArgument, object_name: FQN = NameArgument, **options
|
|
129
137
|
):
|
|
130
138
|
return QueryResult(
|
|
131
|
-
ObjectManager().describe(object_type=object_type,
|
|
139
|
+
ObjectManager().describe(object_type=object_type, fqn=object_name)
|
|
132
140
|
)
|
|
133
141
|
|
|
134
142
|
|
|
@@ -146,9 +154,7 @@ def create(
|
|
|
146
154
|
import json
|
|
147
155
|
|
|
148
156
|
if object_attributes and object_json:
|
|
149
|
-
raise
|
|
150
|
-
"Conflict: both object attributes and JSON definition are provided"
|
|
151
|
-
)
|
|
157
|
+
raise IncompatibleParametersError(["object_attributes", "--json"])
|
|
152
158
|
|
|
153
159
|
if object_json:
|
|
154
160
|
object_data = json.loads(object_json)
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
|
-
from textwrap import dedent
|
|
18
17
|
from typing import Any, Dict, Optional, Tuple, Union
|
|
19
18
|
|
|
20
19
|
from click import ClickException
|
|
@@ -22,11 +21,13 @@ from snowflake.cli.api.constants import (
|
|
|
22
21
|
OBJECT_TO_NAMES,
|
|
23
22
|
ObjectNames,
|
|
24
23
|
)
|
|
24
|
+
from snowflake.cli.api.identifiers import FQN
|
|
25
25
|
from snowflake.cli.api.rest_api import RestApi
|
|
26
26
|
from snowflake.cli.api.sql_execution import SqlExecutionMixin
|
|
27
27
|
from snowflake.connector import ProgrammingError
|
|
28
28
|
from snowflake.connector.cursor import SnowflakeCursor
|
|
29
29
|
from snowflake.connector.errors import BadRequest
|
|
30
|
+
from snowflake.connector.vendored.requests.exceptions import HTTPError
|
|
30
31
|
|
|
31
32
|
|
|
32
33
|
def _get_object_names(object_type: str) -> ObjectNames:
|
|
@@ -53,22 +54,22 @@ class ObjectManager(SqlExecutionMixin):
|
|
|
53
54
|
query += f" in {scope[0].replace('-', ' ')} {scope[1]}"
|
|
54
55
|
return self._execute_query(query, **kwargs)
|
|
55
56
|
|
|
56
|
-
def drop(self, *, object_type: str,
|
|
57
|
+
def drop(self, *, object_type: str, fqn: FQN) -> SnowflakeCursor:
|
|
57
58
|
object_name = _get_object_names(object_type).sf_name
|
|
58
|
-
return self._execute_query(f"drop {object_name} {
|
|
59
|
+
return self._execute_query(f"drop {object_name} {fqn.sql_identifier}")
|
|
59
60
|
|
|
60
|
-
def describe(self, *, object_type: str,
|
|
61
|
+
def describe(self, *, object_type: str, fqn: FQN):
|
|
61
62
|
# Image repository is the only supported object that does not have a DESCRIBE command.
|
|
62
63
|
if object_type == "image-repository":
|
|
63
64
|
raise ClickException(
|
|
64
65
|
f"Describe is currently not supported for object of type image-repository"
|
|
65
66
|
)
|
|
66
67
|
object_name = _get_object_names(object_type).sf_name
|
|
67
|
-
return self._execute_query(f"describe {object_name} {
|
|
68
|
+
return self._execute_query(f"describe {object_name} {fqn.sql_identifier}")
|
|
68
69
|
|
|
69
|
-
def object_exists(self, *, object_type: str,
|
|
70
|
+
def object_exists(self, *, object_type: str, fqn: FQN):
|
|
70
71
|
try:
|
|
71
|
-
self.describe(object_type=object_type,
|
|
72
|
+
self.describe(object_type=object_type, fqn=fqn)
|
|
72
73
|
return True
|
|
73
74
|
except ProgrammingError:
|
|
74
75
|
return False
|
|
@@ -76,21 +77,42 @@ class ObjectManager(SqlExecutionMixin):
|
|
|
76
77
|
def create(self, object_type: str, object_data: Dict[str, Any]) -> str:
|
|
77
78
|
rest = RestApi(self._conn)
|
|
78
79
|
url = rest.determine_url_for_create_query(object_type=object_type)
|
|
79
|
-
|
|
80
80
|
try:
|
|
81
81
|
response = rest.send_rest_request(url=url, method="post", data=object_data)
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
except Exception as err:
|
|
83
|
+
_handle_create_error_codes(err)
|
|
84
|
+
return response["status"]
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def _handle_create_error_codes(err: Exception) -> None:
|
|
88
|
+
# according to https://docs.snowflake.com/developer-guide/snowflake-rest-api/reference/
|
|
89
|
+
if isinstance(err, BadRequest):
|
|
90
|
+
raise ClickException(
|
|
91
|
+
"400 bad request: Incorrect object definition (arguments misspelled or malformatted)."
|
|
92
|
+
)
|
|
93
|
+
if isinstance(err, HTTPError):
|
|
94
|
+
match err_code := err.response.status_code:
|
|
95
|
+
case 401:
|
|
84
96
|
raise ClickException(
|
|
85
|
-
|
|
86
|
-
""" An unexpected error occurred while creating the object. Try again with --debug for more info.
|
|
87
|
-
Most probable reasons:
|
|
88
|
-
* object you are trying to create already exists
|
|
89
|
-
* role you are using do not have permissions to create this object"""
|
|
90
|
-
)
|
|
97
|
+
"401 unauthorized: role you are using does not have permissions to create this object."
|
|
91
98
|
)
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
99
|
+
# error 403 should be handled by connector
|
|
100
|
+
# error 404 is handled by determine-url logic
|
|
101
|
+
# error 405 should not happen under assumption that "all listable objects can be created"
|
|
102
|
+
case 408:
|
|
103
|
+
raise ClickException(
|
|
104
|
+
"408 timeout: the request timed out and was not completed by the server."
|
|
105
|
+
)
|
|
106
|
+
case 409:
|
|
107
|
+
raise ClickException(
|
|
108
|
+
"409 conflict: object you're trying to create already exists."
|
|
109
|
+
)
|
|
110
|
+
# error 410 is a network maintenance debugging - should not happen to the user
|
|
111
|
+
case 429:
|
|
112
|
+
raise ClickException(
|
|
113
|
+
"429 too many requests. The number of requests hit the rate limit."
|
|
114
|
+
)
|
|
115
|
+
case 500 | 503 | 504:
|
|
116
|
+
raise ClickException(f"{err_code} internal server error.")
|
|
117
|
+
case _:
|
|
118
|
+
raise err
|
|
@@ -12,13 +12,13 @@
|
|
|
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.object import commands
|
|
15
16
|
from snowflake.cli.api.plugins.command import (
|
|
16
17
|
SNOWCLI_ROOT_COMMAND_PATH,
|
|
17
18
|
CommandSpec,
|
|
18
19
|
CommandType,
|
|
19
20
|
plugin_hook_impl,
|
|
20
21
|
)
|
|
21
|
-
from snowflake.cli.plugins.object import commands
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
@plugin_hook_impl
|