snowflake-cli-labs 3.0.0rc5__py3-none-any.whl → 3.0.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.
- README.md +21 -0
- {snowflake_cli_labs-3.0.0rc5.dist-info → snowflake_cli_labs-3.0.2.dist-info}/METADATA +6 -96
- snowflake_cli_labs-3.0.2.dist-info/RECORD +5 -0
- snowflake/cli/__about__.py +0 -17
- snowflake/cli/__init__.py +0 -13
- snowflake/cli/_app/__init__.py +0 -22
- snowflake/cli/_app/__main__.py +0 -31
- snowflake/cli/_app/api_impl/__init__.py +0 -13
- snowflake/cli/_app/api_impl/plugin/__init__.py +0 -13
- snowflake/cli/_app/api_impl/plugin/plugin_config_provider_impl.py +0 -66
- snowflake/cli/_app/cli_app.py +0 -252
- snowflake/cli/_app/commands_registration/__init__.py +0 -33
- snowflake/cli/_app/commands_registration/builtin_plugins.py +0 -50
- snowflake/cli/_app/commands_registration/command_plugins_loader.py +0 -169
- snowflake/cli/_app/commands_registration/commands_registration_with_callbacks.py +0 -105
- snowflake/cli/_app/commands_registration/exception_logging.py +0 -26
- snowflake/cli/_app/commands_registration/threadsafe.py +0 -48
- snowflake/cli/_app/commands_registration/typer_registration.py +0 -153
- snowflake/cli/_app/constants.py +0 -19
- snowflake/cli/_app/dev/__init__.py +0 -13
- snowflake/cli/_app/dev/commands_structure.py +0 -48
- snowflake/cli/_app/dev/docs/__init__.py +0 -13
- snowflake/cli/_app/dev/docs/commands_docs_generator.py +0 -118
- snowflake/cli/_app/dev/docs/generator.py +0 -35
- snowflake/cli/_app/dev/docs/project_definition_docs_generator.py +0 -58
- snowflake/cli/_app/dev/docs/project_definition_generate_json_schema.py +0 -227
- snowflake/cli/_app/dev/docs/template_utils.py +0 -23
- snowflake/cli/_app/dev/docs/templates/definition_description.rst.jinja2 +0 -38
- snowflake/cli/_app/dev/docs/templates/overview.rst.jinja2 +0 -9
- snowflake/cli/_app/dev/docs/templates/usage.rst.jinja2 +0 -67
- snowflake/cli/_app/dev/pycharm_remote_debug.py +0 -46
- snowflake/cli/_app/loggers.py +0 -199
- snowflake/cli/_app/main_typer.py +0 -62
- snowflake/cli/_app/printing.py +0 -181
- snowflake/cli/_app/secret.py +0 -9
- snowflake/cli/_app/snow_connector.py +0 -309
- snowflake/cli/_app/telemetry.py +0 -220
- snowflake/cli/_app/version_check.py +0 -74
- snowflake/cli/_plugins/__init__.py +0 -13
- snowflake/cli/_plugins/connection/__init__.py +0 -13
- snowflake/cli/_plugins/connection/commands.py +0 -353
- snowflake/cli/_plugins/connection/plugin_spec.py +0 -30
- snowflake/cli/_plugins/connection/util.py +0 -195
- snowflake/cli/_plugins/cortex/__init__.py +0 -13
- snowflake/cli/_plugins/cortex/commands.py +0 -332
- snowflake/cli/_plugins/cortex/constants.py +0 -17
- snowflake/cli/_plugins/cortex/manager.py +0 -189
- snowflake/cli/_plugins/cortex/plugin_spec.py +0 -30
- snowflake/cli/_plugins/cortex/types.py +0 -22
- snowflake/cli/_plugins/git/__init__.py +0 -13
- snowflake/cli/_plugins/git/commands.py +0 -358
- snowflake/cli/_plugins/git/manager.py +0 -151
- snowflake/cli/_plugins/git/plugin_spec.py +0 -30
- snowflake/cli/_plugins/helpers/__init__.py +0 -13
- snowflake/cli/_plugins/helpers/commands.py +0 -90
- snowflake/cli/_plugins/helpers/plugin_spec.py +0 -30
- snowflake/cli/_plugins/init/__init__.py +0 -13
- snowflake/cli/_plugins/init/commands.py +0 -248
- snowflake/cli/_plugins/init/plugin_spec.py +0 -30
- snowflake/cli/_plugins/nativeapp/__init__.py +0 -13
- snowflake/cli/_plugins/nativeapp/artifacts.py +0 -757
- snowflake/cli/_plugins/nativeapp/bundle_context.py +0 -31
- snowflake/cli/_plugins/nativeapp/codegen/__init__.py +0 -13
- snowflake/cli/_plugins/nativeapp/codegen/artifact_processor.py +0 -91
- snowflake/cli/_plugins/nativeapp/codegen/compiler.py +0 -149
- snowflake/cli/_plugins/nativeapp/codegen/sandbox.py +0 -306
- snowflake/cli/_plugins/nativeapp/codegen/setup/native_app_setup_processor.py +0 -249
- snowflake/cli/_plugins/nativeapp/codegen/setup/setup_driver.py.source +0 -59
- snowflake/cli/_plugins/nativeapp/codegen/snowpark/callback_source.py.jinja +0 -181
- snowflake/cli/_plugins/nativeapp/codegen/snowpark/extension_function_utils.py +0 -217
- snowflake/cli/_plugins/nativeapp/codegen/snowpark/models.py +0 -61
- snowflake/cli/_plugins/nativeapp/codegen/snowpark/python_processor.py +0 -523
- snowflake/cli/_plugins/nativeapp/codegen/templates/templates_processor.py +0 -114
- snowflake/cli/_plugins/nativeapp/commands.py +0 -559
- snowflake/cli/_plugins/nativeapp/common_flags.py +0 -44
- snowflake/cli/_plugins/nativeapp/constants.py +0 -27
- snowflake/cli/_plugins/nativeapp/entities/__init__.py +0 -0
- snowflake/cli/_plugins/nativeapp/entities/application.py +0 -878
- snowflake/cli/_plugins/nativeapp/entities/application_package.py +0 -1392
- snowflake/cli/_plugins/nativeapp/exceptions.py +0 -113
- snowflake/cli/_plugins/nativeapp/feature_flags.py +0 -24
- snowflake/cli/_plugins/nativeapp/manager.py +0 -415
- snowflake/cli/_plugins/nativeapp/plugin_spec.py +0 -30
- snowflake/cli/_plugins/nativeapp/policy.py +0 -53
- snowflake/cli/_plugins/nativeapp/project_model.py +0 -211
- snowflake/cli/_plugins/nativeapp/run_processor.py +0 -184
- snowflake/cli/_plugins/nativeapp/same_account_install_method.py +0 -70
- snowflake/cli/_plugins/nativeapp/teardown_processor.py +0 -70
- snowflake/cli/_plugins/nativeapp/utils.py +0 -98
- snowflake/cli/_plugins/nativeapp/v2_conversions/v2_to_v1_decorator.py +0 -262
- snowflake/cli/_plugins/nativeapp/version/__init__.py +0 -13
- snowflake/cli/_plugins/nativeapp/version/commands.py +0 -141
- snowflake/cli/_plugins/nativeapp/version/version_processor.py +0 -98
- snowflake/cli/_plugins/notebook/__init__.py +0 -13
- snowflake/cli/_plugins/notebook/commands.py +0 -86
- snowflake/cli/_plugins/notebook/exceptions.py +0 -20
- snowflake/cli/_plugins/notebook/manager.py +0 -71
- snowflake/cli/_plugins/notebook/plugin_spec.py +0 -30
- snowflake/cli/_plugins/notebook/types.py +0 -15
- snowflake/cli/_plugins/object/__init__.py +0 -13
- snowflake/cli/_plugins/object/command_aliases.py +0 -95
- snowflake/cli/_plugins/object/commands.py +0 -180
- snowflake/cli/_plugins/object/common.py +0 -85
- snowflake/cli/_plugins/object/manager.py +0 -118
- snowflake/cli/_plugins/object/plugin_spec.py +0 -30
- snowflake/cli/_plugins/snowpark/__init__.py +0 -13
- snowflake/cli/_plugins/snowpark/commands.py +0 -450
- snowflake/cli/_plugins/snowpark/common.py +0 -268
- snowflake/cli/_plugins/snowpark/models.py +0 -150
- snowflake/cli/_plugins/snowpark/package/__init__.py +0 -13
- snowflake/cli/_plugins/snowpark/package/anaconda_packages.py +0 -199
- snowflake/cli/_plugins/snowpark/package/commands.py +0 -195
- snowflake/cli/_plugins/snowpark/package/manager.py +0 -44
- snowflake/cli/_plugins/snowpark/package/utils.py +0 -26
- snowflake/cli/_plugins/snowpark/package_utils.py +0 -354
- snowflake/cli/_plugins/snowpark/plugin_spec.py +0 -30
- snowflake/cli/_plugins/snowpark/snowpark_entity.py +0 -29
- snowflake/cli/_plugins/snowpark/snowpark_entity_model.py +0 -173
- snowflake/cli/_plugins/snowpark/snowpark_project_paths.py +0 -109
- snowflake/cli/_plugins/snowpark/snowpark_shared.py +0 -59
- snowflake/cli/_plugins/snowpark/zipper.py +0 -89
- snowflake/cli/_plugins/spcs/__init__.py +0 -33
- snowflake/cli/_plugins/spcs/common.py +0 -99
- snowflake/cli/_plugins/spcs/compute_pool/__init__.py +0 -13
- snowflake/cli/_plugins/spcs/compute_pool/commands.py +0 -241
- snowflake/cli/_plugins/spcs/compute_pool/manager.py +0 -121
- snowflake/cli/_plugins/spcs/image_registry/__init__.py +0 -13
- snowflake/cli/_plugins/spcs/image_registry/commands.py +0 -65
- snowflake/cli/_plugins/spcs/image_registry/manager.py +0 -105
- snowflake/cli/_plugins/spcs/image_repository/__init__.py +0 -13
- snowflake/cli/_plugins/spcs/image_repository/commands.py +0 -202
- snowflake/cli/_plugins/spcs/image_repository/manager.py +0 -84
- snowflake/cli/_plugins/spcs/plugin_spec.py +0 -30
- snowflake/cli/_plugins/spcs/services/__init__.py +0 -13
- snowflake/cli/_plugins/spcs/services/commands.py +0 -345
- snowflake/cli/_plugins/spcs/services/manager.py +0 -208
- snowflake/cli/_plugins/sql/__init__.py +0 -13
- snowflake/cli/_plugins/sql/commands.py +0 -86
- snowflake/cli/_plugins/sql/manager.py +0 -92
- snowflake/cli/_plugins/sql/plugin_spec.py +0 -30
- snowflake/cli/_plugins/sql/snowsql_templating.py +0 -28
- snowflake/cli/_plugins/stage/__init__.py +0 -13
- snowflake/cli/_plugins/stage/commands.py +0 -264
- snowflake/cli/_plugins/stage/diff.py +0 -280
- snowflake/cli/_plugins/stage/manager.py +0 -582
- snowflake/cli/_plugins/stage/md5.py +0 -160
- snowflake/cli/_plugins/stage/plugin_spec.py +0 -30
- snowflake/cli/_plugins/stage/utils.py +0 -54
- snowflake/cli/_plugins/streamlit/__init__.py +0 -13
- snowflake/cli/_plugins/streamlit/commands.py +0 -195
- snowflake/cli/_plugins/streamlit/manager.py +0 -220
- snowflake/cli/_plugins/streamlit/plugin_spec.py +0 -30
- snowflake/cli/_plugins/streamlit/streamlit_entity.py +0 -12
- snowflake/cli/_plugins/streamlit/streamlit_entity_model.py +0 -66
- snowflake/cli/_plugins/workspace/__init__.py +0 -13
- snowflake/cli/_plugins/workspace/action_context.py +0 -18
- snowflake/cli/_plugins/workspace/commands.py +0 -306
- snowflake/cli/_plugins/workspace/manager.py +0 -74
- snowflake/cli/_plugins/workspace/plugin_spec.py +0 -30
- snowflake/cli/api/__init__.py +0 -48
- snowflake/cli/api/cli_global_context.py +0 -247
- snowflake/cli/api/commands/__init__.py +0 -13
- snowflake/cli/api/commands/alias.py +0 -23
- snowflake/cli/api/commands/common.py +0 -25
- snowflake/cli/api/commands/decorators.py +0 -369
- snowflake/cli/api/commands/execution_metadata.py +0 -40
- snowflake/cli/api/commands/experimental_behaviour.py +0 -18
- snowflake/cli/api/commands/flags.py +0 -561
- snowflake/cli/api/commands/overrideable_parameter.py +0 -143
- snowflake/cli/api/commands/snow_typer.py +0 -247
- snowflake/cli/api/commands/utils.py +0 -18
- snowflake/cli/api/config.py +0 -380
- snowflake/cli/api/connections.py +0 -216
- snowflake/cli/api/console/__init__.py +0 -17
- snowflake/cli/api/console/abc.py +0 -94
- snowflake/cli/api/console/console.py +0 -134
- snowflake/cli/api/console/enum.py +0 -17
- snowflake/cli/api/constants.py +0 -90
- snowflake/cli/api/entities/common.py +0 -56
- snowflake/cli/api/entities/utils.py +0 -370
- snowflake/cli/api/errno.py +0 -28
- snowflake/cli/api/exceptions.py +0 -190
- snowflake/cli/api/feature_flags.py +0 -54
- snowflake/cli/api/identifiers.py +0 -190
- snowflake/cli/api/metrics.py +0 -92
- snowflake/cli/api/output/__init__.py +0 -13
- snowflake/cli/api/output/formats.py +0 -20
- snowflake/cli/api/output/types.py +0 -118
- snowflake/cli/api/plugins/__init__.py +0 -13
- snowflake/cli/api/plugins/command/__init__.py +0 -72
- snowflake/cli/api/plugins/command/plugin_hook_specs.py +0 -21
- snowflake/cli/api/plugins/plugin_config.py +0 -32
- snowflake/cli/api/project/__init__.py +0 -13
- snowflake/cli/api/project/definition.py +0 -126
- snowflake/cli/api/project/definition_conversion.py +0 -400
- snowflake/cli/api/project/definition_manager.py +0 -145
- snowflake/cli/api/project/errors.py +0 -56
- snowflake/cli/api/project/project_verification.py +0 -23
- snowflake/cli/api/project/schemas/__init__.py +0 -13
- snowflake/cli/api/project/schemas/entities/__init__.py +0 -13
- snowflake/cli/api/project/schemas/entities/common.py +0 -153
- snowflake/cli/api/project/schemas/entities/entities.py +0 -61
- snowflake/cli/api/project/schemas/project_definition.py +0 -330
- snowflake/cli/api/project/schemas/template.py +0 -77
- snowflake/cli/api/project/schemas/updatable_model.py +0 -202
- snowflake/cli/api/project/schemas/v1/__init__.py +0 -0
- snowflake/cli/api/project/schemas/v1/identifier_model.py +0 -51
- snowflake/cli/api/project/schemas/v1/native_app/__init__.py +0 -0
- snowflake/cli/api/project/schemas/v1/native_app/application.py +0 -61
- snowflake/cli/api/project/schemas/v1/native_app/native_app.py +0 -93
- snowflake/cli/api/project/schemas/v1/native_app/package.py +0 -84
- snowflake/cli/api/project/schemas/v1/native_app/path_mapping.py +0 -65
- snowflake/cli/api/project/schemas/v1/snowpark/__init__.py +0 -0
- snowflake/cli/api/project/schemas/v1/snowpark/argument.py +0 -28
- snowflake/cli/api/project/schemas/v1/snowpark/callable.py +0 -69
- snowflake/cli/api/project/schemas/v1/snowpark/snowpark.py +0 -36
- snowflake/cli/api/project/schemas/v1/streamlit/__init__.py +0 -0
- snowflake/cli/api/project/schemas/v1/streamlit/streamlit.py +0 -47
- snowflake/cli/api/project/util.py +0 -278
- snowflake/cli/api/rendering/__init__.py +0 -13
- snowflake/cli/api/rendering/jinja.py +0 -118
- snowflake/cli/api/rendering/project_definition_templates.py +0 -43
- snowflake/cli/api/rendering/project_templates.py +0 -98
- snowflake/cli/api/rendering/sql_templates.py +0 -105
- snowflake/cli/api/rest_api.py +0 -178
- snowflake/cli/api/sanitizers.py +0 -43
- snowflake/cli/api/secure_path.py +0 -360
- snowflake/cli/api/secure_utils.py +0 -118
- snowflake/cli/api/sql_execution.py +0 -280
- snowflake/cli/api/utils/__init__.py +0 -13
- snowflake/cli/api/utils/cursor.py +0 -34
- snowflake/cli/api/utils/definition_rendering.py +0 -415
- snowflake/cli/api/utils/dict_utils.py +0 -73
- snowflake/cli/api/utils/error_handling.py +0 -23
- snowflake/cli/api/utils/graph.py +0 -97
- snowflake/cli/api/utils/models.py +0 -63
- snowflake/cli/api/utils/naming_utils.py +0 -13
- snowflake/cli/api/utils/path_utils.py +0 -36
- snowflake/cli/api/utils/templating_functions.py +0 -144
- snowflake/cli/api/utils/types.py +0 -35
- snowflake_cli_labs-3.0.0rc5.dist-info/RECORD +0 -242
- snowflake_cli_labs-3.0.0rc5.dist-info/entry_points.txt +0 -2
- {snowflake_cli_labs-3.0.0rc5.dist-info → snowflake_cli_labs-3.0.2.dist-info}/WHEEL +0 -0
- {snowflake_cli_labs-3.0.0rc5.dist-info → snowflake_cli_labs-3.0.2.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,113 +0,0 @@
|
|
|
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 textwrap import dedent
|
|
18
|
-
from typing import Optional
|
|
19
|
-
|
|
20
|
-
import jinja2
|
|
21
|
-
from click.exceptions import ClickException
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
class ApplicationPackageAlreadyExistsError(ClickException):
|
|
25
|
-
"""An application package not created by Snowflake CLI exists with the same name."""
|
|
26
|
-
|
|
27
|
-
def __init__(self, name: str):
|
|
28
|
-
super().__init__(
|
|
29
|
-
f"An Application Package {name} already exists in account that may have been created without Snowflake CLI."
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
class ApplicationPackageDoesNotExistError(ClickException):
|
|
34
|
-
"""An application package of the specified name does not exist in the Snowflake account or the current role isn't authorized."""
|
|
35
|
-
|
|
36
|
-
def __init__(self, name: str):
|
|
37
|
-
super().__init__(
|
|
38
|
-
f"Application Package {name} does not exist in the Snowflake account or not authorized."
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
class ApplicationCreatedExternallyError(ClickException):
|
|
43
|
-
"""An application object not created by Snowflake CLI exists with the same name."""
|
|
44
|
-
|
|
45
|
-
def __init__(self, name: str):
|
|
46
|
-
super().__init__(
|
|
47
|
-
f'An application object "{name}" not created by Snowflake CLI already exists in the account.'
|
|
48
|
-
)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
class MissingScriptError(ClickException):
|
|
52
|
-
"""A referenced script was not found."""
|
|
53
|
-
|
|
54
|
-
def __init__(self, relpath: str):
|
|
55
|
-
super().__init__(f'Script "{relpath}" does not exist')
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
class InvalidTemplateInFileError(ClickException):
|
|
59
|
-
"""A referenced templated file had syntax error(s)."""
|
|
60
|
-
|
|
61
|
-
def __init__(
|
|
62
|
-
self, relpath: str, err: jinja2.TemplateError, lineno: Optional[int] = None
|
|
63
|
-
):
|
|
64
|
-
lineno_str = f":{lineno}" if lineno is not None else ""
|
|
65
|
-
super().__init__(
|
|
66
|
-
f'File "{relpath}{lineno_str}" does not contain a valid template: {err.message}'
|
|
67
|
-
)
|
|
68
|
-
self.err = err
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
class MissingSchemaError(ClickException):
|
|
72
|
-
"""An identifier is missing a schema qualifier."""
|
|
73
|
-
|
|
74
|
-
def __init__(self, identifier: str):
|
|
75
|
-
super().__init__(f'Identifier missing a schema qualifier: "{identifier}"')
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
class CouldNotDropApplicationPackageWithVersions(ClickException):
|
|
79
|
-
"""Application package could not be dropped as it has versions associated with it."""
|
|
80
|
-
|
|
81
|
-
def __init__(self, additional_msg: str = ""):
|
|
82
|
-
super().__init__(
|
|
83
|
-
dedent(
|
|
84
|
-
f"""
|
|
85
|
-
{self.__doc__}
|
|
86
|
-
{additional_msg}
|
|
87
|
-
"""
|
|
88
|
-
).strip()
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
class SetupScriptFailedValidation(ClickException):
|
|
93
|
-
"""Snowflake Native App setup script failed validation."""
|
|
94
|
-
|
|
95
|
-
def __init__(self):
|
|
96
|
-
super().__init__(self.__doc__)
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
class NoEventTableForAccount(ClickException):
|
|
100
|
-
"""No event table was found for this Snowflake account."""
|
|
101
|
-
|
|
102
|
-
INSTRUCTIONS = dedent(
|
|
103
|
-
"""\
|
|
104
|
-
Ask your Snowflake administrator to set up an event table for your account by following the docs at
|
|
105
|
-
https://docs.snowflake.com/en/developer-guide/logging-tracing/event-table-setting-up.
|
|
106
|
-
|
|
107
|
-
If your account is configured to send events to an organization event account, create a new
|
|
108
|
-
connection to this account using `snow connection add` and re-run this command using the new connection.
|
|
109
|
-
More information on event accounts is available at https://docs.snowflake.com/en/developer-guide/native-apps/setting-up-logging-and-events#configure-an-account-to-store-shared-events."""
|
|
110
|
-
)
|
|
111
|
-
|
|
112
|
-
def __init__(self):
|
|
113
|
-
super().__init__(f"{self.__doc__}\n\n{self.INSTRUCTIONS}")
|
|
@@ -1,24 +0,0 @@
|
|
|
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 enum import unique
|
|
16
|
-
|
|
17
|
-
from snowflake.cli.api.feature_flags import BooleanFlag, FeatureFlagMixin
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
@unique
|
|
21
|
-
class FeatureFlag(FeatureFlagMixin):
|
|
22
|
-
ENABLE_NATIVE_APP_PYTHON_SETUP = BooleanFlag(
|
|
23
|
-
"ENABLE_NATIVE_APP_PYTHON_SETUP", False
|
|
24
|
-
)
|
|
@@ -1,415 +0,0 @@
|
|
|
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 abc import ABC, abstractmethod
|
|
18
|
-
from datetime import datetime
|
|
19
|
-
from functools import cached_property
|
|
20
|
-
from pathlib import Path
|
|
21
|
-
from typing import Generator, List, Optional
|
|
22
|
-
|
|
23
|
-
from snowflake.cli._plugins.nativeapp.artifacts import (
|
|
24
|
-
BundleMap,
|
|
25
|
-
)
|
|
26
|
-
from snowflake.cli._plugins.nativeapp.entities.application import (
|
|
27
|
-
ApplicationEntity,
|
|
28
|
-
ApplicationOwnedObject,
|
|
29
|
-
)
|
|
30
|
-
from snowflake.cli._plugins.nativeapp.entities.application_package import (
|
|
31
|
-
ApplicationPackageEntity,
|
|
32
|
-
)
|
|
33
|
-
from snowflake.cli._plugins.nativeapp.policy import AllowAlwaysPolicy, PolicyBase
|
|
34
|
-
from snowflake.cli._plugins.nativeapp.project_model import (
|
|
35
|
-
NativeAppProjectModel,
|
|
36
|
-
)
|
|
37
|
-
from snowflake.cli._plugins.stage.diff import (
|
|
38
|
-
DiffResult,
|
|
39
|
-
)
|
|
40
|
-
from snowflake.cli.api.console import cli_console as cc
|
|
41
|
-
from snowflake.cli.api.entities.utils import (
|
|
42
|
-
execute_post_deploy_hooks,
|
|
43
|
-
sync_deploy_root_with_stage,
|
|
44
|
-
)
|
|
45
|
-
from snowflake.cli.api.project.schemas.entities.common import PostDeployHook
|
|
46
|
-
from snowflake.cli.api.project.schemas.v1.native_app.native_app import NativeApp
|
|
47
|
-
from snowflake.cli.api.project.schemas.v1.native_app.path_mapping import PathMapping
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
class NativeAppCommandProcessor(ABC):
|
|
51
|
-
@abstractmethod
|
|
52
|
-
def process(self, *args, **kwargs):
|
|
53
|
-
pass
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
class NativeAppManager:
|
|
57
|
-
"""
|
|
58
|
-
Base class with frequently used functionality already implemented and ready to be used by related subclasses.
|
|
59
|
-
"""
|
|
60
|
-
|
|
61
|
-
def __init__(self, project_definition: NativeApp, project_root: Path):
|
|
62
|
-
super().__init__()
|
|
63
|
-
self._na_project = NativeAppProjectModel(
|
|
64
|
-
project_definition=project_definition,
|
|
65
|
-
project_root=project_root,
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
@property
|
|
69
|
-
def na_project(self) -> NativeAppProjectModel:
|
|
70
|
-
return self._na_project
|
|
71
|
-
|
|
72
|
-
@property
|
|
73
|
-
def project_root(self) -> Path:
|
|
74
|
-
return self.na_project.project_root
|
|
75
|
-
|
|
76
|
-
@property
|
|
77
|
-
def definition(self) -> NativeApp:
|
|
78
|
-
return self.na_project.definition
|
|
79
|
-
|
|
80
|
-
@property
|
|
81
|
-
def artifacts(self) -> List[PathMapping]:
|
|
82
|
-
return self.na_project.artifacts
|
|
83
|
-
|
|
84
|
-
@property
|
|
85
|
-
def bundle_root(self) -> Path:
|
|
86
|
-
return self.na_project.bundle_root
|
|
87
|
-
|
|
88
|
-
@property
|
|
89
|
-
def deploy_root(self) -> Path:
|
|
90
|
-
return self.na_project.deploy_root
|
|
91
|
-
|
|
92
|
-
@property
|
|
93
|
-
def generated_root(self) -> Path:
|
|
94
|
-
return self.na_project.generated_root
|
|
95
|
-
|
|
96
|
-
@property
|
|
97
|
-
def package_scripts(self) -> List[str]:
|
|
98
|
-
return self.na_project.package_scripts
|
|
99
|
-
|
|
100
|
-
@property
|
|
101
|
-
def stage_fqn(self) -> str:
|
|
102
|
-
return self.na_project.stage_fqn
|
|
103
|
-
|
|
104
|
-
@property
|
|
105
|
-
def scratch_stage_fqn(self) -> str:
|
|
106
|
-
return self.na_project.scratch_stage_fqn
|
|
107
|
-
|
|
108
|
-
@property
|
|
109
|
-
def stage_schema(self) -> Optional[str]:
|
|
110
|
-
return self.na_project.stage_schema
|
|
111
|
-
|
|
112
|
-
@property
|
|
113
|
-
def package_warehouse(self) -> Optional[str]:
|
|
114
|
-
return self.na_project.package_warehouse
|
|
115
|
-
|
|
116
|
-
def use_package_warehouse(self):
|
|
117
|
-
return ApplicationPackageEntity.use_package_warehouse(
|
|
118
|
-
self.package_warehouse,
|
|
119
|
-
)
|
|
120
|
-
|
|
121
|
-
@property
|
|
122
|
-
def application_warehouse(self) -> Optional[str]:
|
|
123
|
-
return self.na_project.application_warehouse
|
|
124
|
-
|
|
125
|
-
@property
|
|
126
|
-
def project_identifier(self) -> str:
|
|
127
|
-
return self.na_project.project_identifier
|
|
128
|
-
|
|
129
|
-
@property
|
|
130
|
-
def package_name(self) -> str:
|
|
131
|
-
return self.na_project.package_name
|
|
132
|
-
|
|
133
|
-
@property
|
|
134
|
-
def package_role(self) -> str:
|
|
135
|
-
return self.na_project.package_role
|
|
136
|
-
|
|
137
|
-
@property
|
|
138
|
-
def package_distribution(self) -> str:
|
|
139
|
-
return self.na_project.package_distribution
|
|
140
|
-
|
|
141
|
-
@property
|
|
142
|
-
def app_name(self) -> str:
|
|
143
|
-
return self.na_project.app_name
|
|
144
|
-
|
|
145
|
-
@property
|
|
146
|
-
def app_role(self) -> str:
|
|
147
|
-
return self.na_project.app_role
|
|
148
|
-
|
|
149
|
-
@property
|
|
150
|
-
def app_post_deploy_hooks(self) -> Optional[List[PostDeployHook]]:
|
|
151
|
-
return self.na_project.app_post_deploy_hooks
|
|
152
|
-
|
|
153
|
-
@property
|
|
154
|
-
def package_post_deploy_hooks(self) -> Optional[List[PostDeployHook]]:
|
|
155
|
-
return self.na_project.package_post_deploy_hooks
|
|
156
|
-
|
|
157
|
-
@property
|
|
158
|
-
def debug_mode(self) -> bool:
|
|
159
|
-
return self.na_project.debug_mode
|
|
160
|
-
|
|
161
|
-
@cached_property
|
|
162
|
-
def get_app_pkg_distribution_in_snowflake(self) -> str:
|
|
163
|
-
return ApplicationPackageEntity.get_app_pkg_distribution_in_snowflake(
|
|
164
|
-
self.package_name, self.package_role
|
|
165
|
-
)
|
|
166
|
-
|
|
167
|
-
@cached_property
|
|
168
|
-
def account_event_table(self) -> str:
|
|
169
|
-
return ApplicationEntity.get_account_event_table()
|
|
170
|
-
|
|
171
|
-
def verify_project_distribution(
|
|
172
|
-
self, expected_distribution: Optional[str] = None
|
|
173
|
-
) -> bool:
|
|
174
|
-
return ApplicationPackageEntity.verify_project_distribution(
|
|
175
|
-
console=cc,
|
|
176
|
-
package_name=self.package_name,
|
|
177
|
-
package_role=self.package_role,
|
|
178
|
-
package_distribution=self.package_distribution,
|
|
179
|
-
expected_distribution=expected_distribution,
|
|
180
|
-
)
|
|
181
|
-
|
|
182
|
-
def build_bundle(self) -> BundleMap:
|
|
183
|
-
"""
|
|
184
|
-
Populates the local deploy root from artifact sources.
|
|
185
|
-
"""
|
|
186
|
-
return ApplicationPackageEntity.bundle(
|
|
187
|
-
project_root=self.project_root,
|
|
188
|
-
deploy_root=self.deploy_root,
|
|
189
|
-
bundle_root=self.bundle_root,
|
|
190
|
-
generated_root=self.generated_root,
|
|
191
|
-
package_name=self.package_name,
|
|
192
|
-
artifacts=self.artifacts,
|
|
193
|
-
)
|
|
194
|
-
|
|
195
|
-
def sync_deploy_root_with_stage(
|
|
196
|
-
self,
|
|
197
|
-
bundle_map: BundleMap,
|
|
198
|
-
role: str,
|
|
199
|
-
prune: bool,
|
|
200
|
-
recursive: bool,
|
|
201
|
-
stage_fqn: str,
|
|
202
|
-
local_paths_to_sync: List[Path] | None = None,
|
|
203
|
-
print_diff: bool = True,
|
|
204
|
-
) -> DiffResult:
|
|
205
|
-
return sync_deploy_root_with_stage(
|
|
206
|
-
console=cc,
|
|
207
|
-
deploy_root=self.deploy_root,
|
|
208
|
-
package_name=self.package_name,
|
|
209
|
-
stage_schema=self.stage_schema,
|
|
210
|
-
bundle_map=bundle_map,
|
|
211
|
-
role=role,
|
|
212
|
-
prune=prune,
|
|
213
|
-
recursive=recursive,
|
|
214
|
-
stage_fqn=stage_fqn,
|
|
215
|
-
local_paths_to_sync=local_paths_to_sync,
|
|
216
|
-
print_diff=print_diff,
|
|
217
|
-
)
|
|
218
|
-
|
|
219
|
-
def get_existing_app_info(self) -> Optional[dict]:
|
|
220
|
-
return ApplicationEntity.get_existing_app_info(
|
|
221
|
-
app_name=self.app_name,
|
|
222
|
-
app_role=self.app_role,
|
|
223
|
-
)
|
|
224
|
-
|
|
225
|
-
def get_existing_app_pkg_info(self) -> Optional[dict]:
|
|
226
|
-
return ApplicationPackageEntity.get_existing_app_pkg_info(
|
|
227
|
-
package_name=self.package_name,
|
|
228
|
-
package_role=self.package_role,
|
|
229
|
-
)
|
|
230
|
-
|
|
231
|
-
def get_objects_owned_by_application(self):
|
|
232
|
-
return ApplicationEntity.get_objects_owned_by_application(
|
|
233
|
-
app_name=self.app_name,
|
|
234
|
-
app_role=self.app_role,
|
|
235
|
-
)
|
|
236
|
-
|
|
237
|
-
def _application_objects_to_str(
|
|
238
|
-
self, application_objects: list[ApplicationOwnedObject]
|
|
239
|
-
) -> str:
|
|
240
|
-
return ApplicationEntity.application_objects_to_str(application_objects)
|
|
241
|
-
|
|
242
|
-
def _application_object_to_str(self, obj: ApplicationOwnedObject):
|
|
243
|
-
return ApplicationEntity.application_object_to_str(obj)
|
|
244
|
-
|
|
245
|
-
def get_snowsight_url(self) -> str:
|
|
246
|
-
"""Returns the URL that can be used to visit this app via Snowsight."""
|
|
247
|
-
return ApplicationEntity.get_snowsight_url(
|
|
248
|
-
self.app_name, self.application_warehouse
|
|
249
|
-
)
|
|
250
|
-
|
|
251
|
-
def create_app_package(self) -> None:
|
|
252
|
-
return ApplicationPackageEntity.create_app_package(
|
|
253
|
-
console=cc,
|
|
254
|
-
package_name=self.package_name,
|
|
255
|
-
package_role=self.package_role,
|
|
256
|
-
package_distribution=self.package_distribution,
|
|
257
|
-
)
|
|
258
|
-
|
|
259
|
-
def _apply_package_scripts(self) -> None:
|
|
260
|
-
return ApplicationPackageEntity.apply_package_scripts(
|
|
261
|
-
console=cc,
|
|
262
|
-
package_scripts=self.package_scripts,
|
|
263
|
-
package_warehouse=self.package_warehouse,
|
|
264
|
-
project_root=self.project_root,
|
|
265
|
-
package_role=self.package_role,
|
|
266
|
-
package_name=self.package_name,
|
|
267
|
-
)
|
|
268
|
-
|
|
269
|
-
def execute_package_post_deploy_hooks(self) -> None:
|
|
270
|
-
execute_post_deploy_hooks(
|
|
271
|
-
console=cc,
|
|
272
|
-
project_root=self.project_root,
|
|
273
|
-
post_deploy_hooks=self.package_post_deploy_hooks,
|
|
274
|
-
deployed_object_type="application package",
|
|
275
|
-
database_name=self.package_name,
|
|
276
|
-
)
|
|
277
|
-
|
|
278
|
-
def execute_app_post_deploy_hooks(self) -> None:
|
|
279
|
-
execute_post_deploy_hooks(
|
|
280
|
-
console=cc,
|
|
281
|
-
project_root=self.project_root,
|
|
282
|
-
post_deploy_hooks=self.app_post_deploy_hooks,
|
|
283
|
-
deployed_object_type="application",
|
|
284
|
-
database_name=self.app_name,
|
|
285
|
-
)
|
|
286
|
-
|
|
287
|
-
def deploy(
|
|
288
|
-
self,
|
|
289
|
-
bundle_map: BundleMap,
|
|
290
|
-
prune: bool,
|
|
291
|
-
recursive: bool,
|
|
292
|
-
policy: PolicyBase,
|
|
293
|
-
stage_fqn: Optional[str] = None,
|
|
294
|
-
local_paths_to_sync: List[Path] | None = None,
|
|
295
|
-
validate: bool = True,
|
|
296
|
-
print_diff: bool = True,
|
|
297
|
-
) -> DiffResult:
|
|
298
|
-
return ApplicationPackageEntity.deploy(
|
|
299
|
-
console=cc,
|
|
300
|
-
project_root=self.project_root,
|
|
301
|
-
deploy_root=self.deploy_root,
|
|
302
|
-
bundle_root=self.bundle_root,
|
|
303
|
-
generated_root=self.generated_root,
|
|
304
|
-
artifacts=self.artifacts,
|
|
305
|
-
bundle_map=bundle_map,
|
|
306
|
-
package_name=self.package_name,
|
|
307
|
-
package_role=self.package_role,
|
|
308
|
-
package_distribution=self.package_distribution,
|
|
309
|
-
prune=prune,
|
|
310
|
-
recursive=recursive,
|
|
311
|
-
paths=local_paths_to_sync,
|
|
312
|
-
print_diff=print_diff,
|
|
313
|
-
validate=validate,
|
|
314
|
-
stage_fqn=stage_fqn or self.stage_fqn,
|
|
315
|
-
package_warehouse=self.package_warehouse,
|
|
316
|
-
post_deploy_hooks=self.package_post_deploy_hooks,
|
|
317
|
-
package_scripts=self.package_scripts,
|
|
318
|
-
policy=policy,
|
|
319
|
-
)
|
|
320
|
-
|
|
321
|
-
def validate(self, use_scratch_stage: bool = False):
|
|
322
|
-
return ApplicationPackageEntity.validate_setup_script(
|
|
323
|
-
console=cc,
|
|
324
|
-
project_root=self.project_root,
|
|
325
|
-
deploy_root=self.deploy_root,
|
|
326
|
-
bundle_root=self.bundle_root,
|
|
327
|
-
generated_root=self.generated_root,
|
|
328
|
-
artifacts=self.artifacts,
|
|
329
|
-
package_name=self.package_name,
|
|
330
|
-
package_role=self.package_role,
|
|
331
|
-
package_distribution=self.package_distribution,
|
|
332
|
-
prune=True,
|
|
333
|
-
recursive=True,
|
|
334
|
-
paths=[],
|
|
335
|
-
stage_fqn=self.stage_fqn,
|
|
336
|
-
package_warehouse=self.package_warehouse,
|
|
337
|
-
post_deploy_hooks=self.package_post_deploy_hooks,
|
|
338
|
-
package_scripts=self.package_scripts,
|
|
339
|
-
policy=AllowAlwaysPolicy(),
|
|
340
|
-
use_scratch_stage=use_scratch_stage,
|
|
341
|
-
scratch_stage_fqn=self.scratch_stage_fqn,
|
|
342
|
-
)
|
|
343
|
-
|
|
344
|
-
def get_validation_result(self, use_scratch_stage: bool = False):
|
|
345
|
-
return ApplicationPackageEntity.get_validation_result(
|
|
346
|
-
console=cc,
|
|
347
|
-
project_root=self.project_root,
|
|
348
|
-
deploy_root=self.deploy_root,
|
|
349
|
-
bundle_root=self.bundle_root,
|
|
350
|
-
generated_root=self.generated_root,
|
|
351
|
-
artifacts=self.artifacts,
|
|
352
|
-
package_name=self.package_name,
|
|
353
|
-
package_role=self.package_role,
|
|
354
|
-
package_distribution=self.package_distribution,
|
|
355
|
-
prune=True,
|
|
356
|
-
recursive=True,
|
|
357
|
-
paths=[],
|
|
358
|
-
stage_fqn=self.stage_fqn,
|
|
359
|
-
package_warehouse=self.package_warehouse,
|
|
360
|
-
post_deploy_hooks=self.package_post_deploy_hooks,
|
|
361
|
-
package_scripts=self.package_scripts,
|
|
362
|
-
policy=AllowAlwaysPolicy(),
|
|
363
|
-
use_scratch_stage=use_scratch_stage,
|
|
364
|
-
scratch_stage_fqn=self.scratch_stage_fqn,
|
|
365
|
-
)
|
|
366
|
-
|
|
367
|
-
def get_events( # type: ignore
|
|
368
|
-
self,
|
|
369
|
-
since: str | datetime | None = None,
|
|
370
|
-
until: str | datetime | None = None,
|
|
371
|
-
record_types: list[str] | None = None,
|
|
372
|
-
scopes: list[str] | None = None,
|
|
373
|
-
consumer_org: str = "",
|
|
374
|
-
consumer_account: str = "",
|
|
375
|
-
consumer_app_hash: str = "",
|
|
376
|
-
first: int = -1,
|
|
377
|
-
last: int = -1,
|
|
378
|
-
) -> list[dict]:
|
|
379
|
-
return ApplicationEntity.get_events(
|
|
380
|
-
app_name=self.app_name,
|
|
381
|
-
package_name=self.package_name,
|
|
382
|
-
since=since,
|
|
383
|
-
until=until,
|
|
384
|
-
record_types=record_types,
|
|
385
|
-
scopes=scopes,
|
|
386
|
-
consumer_org=consumer_org,
|
|
387
|
-
consumer_account=consumer_account,
|
|
388
|
-
consumer_app_hash=consumer_app_hash,
|
|
389
|
-
first=first,
|
|
390
|
-
last=last,
|
|
391
|
-
)
|
|
392
|
-
|
|
393
|
-
def stream_events(
|
|
394
|
-
self,
|
|
395
|
-
interval_seconds: int,
|
|
396
|
-
since: str | datetime | None = None,
|
|
397
|
-
record_types: list[str] | None = None,
|
|
398
|
-
scopes: list[str] | None = None,
|
|
399
|
-
consumer_org: str = "",
|
|
400
|
-
consumer_account: str = "",
|
|
401
|
-
consumer_app_hash: str = "",
|
|
402
|
-
last: int = -1,
|
|
403
|
-
) -> Generator[dict, None, None]:
|
|
404
|
-
return ApplicationEntity.stream_events(
|
|
405
|
-
app_name=self.app_name,
|
|
406
|
-
package_name=self.package_name,
|
|
407
|
-
interval_seconds=interval_seconds,
|
|
408
|
-
since=since,
|
|
409
|
-
record_types=record_types,
|
|
410
|
-
scopes=scopes,
|
|
411
|
-
consumer_org=consumer_org,
|
|
412
|
-
consumer_account=consumer_account,
|
|
413
|
-
consumer_app_hash=consumer_app_hash,
|
|
414
|
-
last=last,
|
|
415
|
-
)
|
|
@@ -1,30 +0,0 @@
|
|
|
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 snowflake.cli._plugins.nativeapp import commands
|
|
16
|
-
from snowflake.cli.api.plugins.command import (
|
|
17
|
-
SNOWCLI_ROOT_COMMAND_PATH,
|
|
18
|
-
CommandSpec,
|
|
19
|
-
CommandType,
|
|
20
|
-
plugin_hook_impl,
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
@plugin_hook_impl
|
|
25
|
-
def command_spec():
|
|
26
|
-
return CommandSpec(
|
|
27
|
-
parent_command_path=SNOWCLI_ROOT_COMMAND_PATH,
|
|
28
|
-
command_type=CommandType.COMMAND_GROUP,
|
|
29
|
-
typer_instance=commands.app.create_instance(),
|
|
30
|
-
)
|
|
@@ -1,53 +0,0 @@
|
|
|
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 abc import ABC, abstractmethod
|
|
18
|
-
from typing import Optional
|
|
19
|
-
|
|
20
|
-
import typer
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
class PolicyBase(ABC):
|
|
24
|
-
"""Abstract Class for various policies that govern if a Snowflake CLI command can continue execution when it asks for a decision."""
|
|
25
|
-
|
|
26
|
-
@abstractmethod
|
|
27
|
-
def should_proceed(self, user_prompt: Optional[str]) -> bool:
|
|
28
|
-
pass
|
|
29
|
-
|
|
30
|
-
def __eq__(self, value: object) -> bool:
|
|
31
|
-
return self.__class__ == value.__class__
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
class AllowAlwaysPolicy(PolicyBase):
|
|
35
|
-
"""Always allow a Snowflake CLI command to continue execution."""
|
|
36
|
-
|
|
37
|
-
def should_proceed(self, user_prompt: Optional[str] = None):
|
|
38
|
-
return True
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
class DenyAlwaysPolicy(PolicyBase):
|
|
42
|
-
"""Never allow a Snowflake CLI command to continue execution."""
|
|
43
|
-
|
|
44
|
-
def should_proceed(self, user_prompt: Optional[str] = None):
|
|
45
|
-
return False
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
class AskAlwaysPolicy(PolicyBase):
|
|
49
|
-
"""Ask the user whether to continue execution of a Snowflake CLI command."""
|
|
50
|
-
|
|
51
|
-
def should_proceed(self, user_prompt: Optional[str]):
|
|
52
|
-
should_continue = typer.confirm(user_prompt)
|
|
53
|
-
return should_continue
|