snowflake-cli-labs 3.0.0rc4__py3-none-any.whl → 3.0.1__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.
Files changed (244) hide show
  1. README.md +21 -0
  2. {snowflake_cli_labs-3.0.0rc4.dist-info → snowflake_cli_labs-3.0.1.dist-info}/METADATA +6 -96
  3. snowflake_cli_labs-3.0.1.dist-info/RECORD +5 -0
  4. snowflake/cli/__about__.py +0 -17
  5. snowflake/cli/__init__.py +0 -13
  6. snowflake/cli/_app/__init__.py +0 -22
  7. snowflake/cli/_app/__main__.py +0 -31
  8. snowflake/cli/_app/api_impl/__init__.py +0 -13
  9. snowflake/cli/_app/api_impl/plugin/__init__.py +0 -13
  10. snowflake/cli/_app/api_impl/plugin/plugin_config_provider_impl.py +0 -66
  11. snowflake/cli/_app/cli_app.py +0 -252
  12. snowflake/cli/_app/commands_registration/__init__.py +0 -33
  13. snowflake/cli/_app/commands_registration/builtin_plugins.py +0 -50
  14. snowflake/cli/_app/commands_registration/command_plugins_loader.py +0 -169
  15. snowflake/cli/_app/commands_registration/commands_registration_with_callbacks.py +0 -105
  16. snowflake/cli/_app/commands_registration/exception_logging.py +0 -26
  17. snowflake/cli/_app/commands_registration/threadsafe.py +0 -48
  18. snowflake/cli/_app/commands_registration/typer_registration.py +0 -153
  19. snowflake/cli/_app/constants.py +0 -19
  20. snowflake/cli/_app/dev/__init__.py +0 -13
  21. snowflake/cli/_app/dev/commands_structure.py +0 -48
  22. snowflake/cli/_app/dev/docs/__init__.py +0 -13
  23. snowflake/cli/_app/dev/docs/commands_docs_generator.py +0 -118
  24. snowflake/cli/_app/dev/docs/generator.py +0 -35
  25. snowflake/cli/_app/dev/docs/project_definition_docs_generator.py +0 -58
  26. snowflake/cli/_app/dev/docs/project_definition_generate_json_schema.py +0 -227
  27. snowflake/cli/_app/dev/docs/template_utils.py +0 -23
  28. snowflake/cli/_app/dev/docs/templates/definition_description.rst.jinja2 +0 -38
  29. snowflake/cli/_app/dev/docs/templates/overview.rst.jinja2 +0 -9
  30. snowflake/cli/_app/dev/docs/templates/usage.rst.jinja2 +0 -67
  31. snowflake/cli/_app/dev/pycharm_remote_debug.py +0 -46
  32. snowflake/cli/_app/loggers.py +0 -199
  33. snowflake/cli/_app/main_typer.py +0 -62
  34. snowflake/cli/_app/printing.py +0 -181
  35. snowflake/cli/_app/secret.py +0 -9
  36. snowflake/cli/_app/snow_connector.py +0 -309
  37. snowflake/cli/_app/telemetry.py +0 -220
  38. snowflake/cli/_app/version_check.py +0 -74
  39. snowflake/cli/_plugins/__init__.py +0 -13
  40. snowflake/cli/_plugins/connection/__init__.py +0 -13
  41. snowflake/cli/_plugins/connection/commands.py +0 -353
  42. snowflake/cli/_plugins/connection/plugin_spec.py +0 -30
  43. snowflake/cli/_plugins/connection/util.py +0 -195
  44. snowflake/cli/_plugins/cortex/__init__.py +0 -13
  45. snowflake/cli/_plugins/cortex/commands.py +0 -332
  46. snowflake/cli/_plugins/cortex/constants.py +0 -17
  47. snowflake/cli/_plugins/cortex/manager.py +0 -189
  48. snowflake/cli/_plugins/cortex/plugin_spec.py +0 -30
  49. snowflake/cli/_plugins/cortex/types.py +0 -22
  50. snowflake/cli/_plugins/git/__init__.py +0 -13
  51. snowflake/cli/_plugins/git/commands.py +0 -358
  52. snowflake/cli/_plugins/git/manager.py +0 -151
  53. snowflake/cli/_plugins/git/plugin_spec.py +0 -30
  54. snowflake/cli/_plugins/helpers/__init__.py +0 -13
  55. snowflake/cli/_plugins/helpers/commands.py +0 -61
  56. snowflake/cli/_plugins/helpers/plugin_spec.py +0 -30
  57. snowflake/cli/_plugins/init/__init__.py +0 -13
  58. snowflake/cli/_plugins/init/commands.py +0 -248
  59. snowflake/cli/_plugins/init/plugin_spec.py +0 -30
  60. snowflake/cli/_plugins/nativeapp/__init__.py +0 -13
  61. snowflake/cli/_plugins/nativeapp/artifacts.py +0 -757
  62. snowflake/cli/_plugins/nativeapp/bundle_context.py +0 -31
  63. snowflake/cli/_plugins/nativeapp/codegen/__init__.py +0 -13
  64. snowflake/cli/_plugins/nativeapp/codegen/artifact_processor.py +0 -91
  65. snowflake/cli/_plugins/nativeapp/codegen/compiler.py +0 -149
  66. snowflake/cli/_plugins/nativeapp/codegen/sandbox.py +0 -306
  67. snowflake/cli/_plugins/nativeapp/codegen/setup/native_app_setup_processor.py +0 -249
  68. snowflake/cli/_plugins/nativeapp/codegen/setup/setup_driver.py.source +0 -59
  69. snowflake/cli/_plugins/nativeapp/codegen/snowpark/callback_source.py.jinja +0 -181
  70. snowflake/cli/_plugins/nativeapp/codegen/snowpark/extension_function_utils.py +0 -217
  71. snowflake/cli/_plugins/nativeapp/codegen/snowpark/models.py +0 -61
  72. snowflake/cli/_plugins/nativeapp/codegen/snowpark/python_processor.py +0 -523
  73. snowflake/cli/_plugins/nativeapp/codegen/templates/templates_processor.py +0 -114
  74. snowflake/cli/_plugins/nativeapp/commands.py +0 -559
  75. snowflake/cli/_plugins/nativeapp/common_flags.py +0 -44
  76. snowflake/cli/_plugins/nativeapp/constants.py +0 -27
  77. snowflake/cli/_plugins/nativeapp/entities/__init__.py +0 -0
  78. snowflake/cli/_plugins/nativeapp/entities/application.py +0 -878
  79. snowflake/cli/_plugins/nativeapp/entities/application_package.py +0 -1392
  80. snowflake/cli/_plugins/nativeapp/exceptions.py +0 -113
  81. snowflake/cli/_plugins/nativeapp/feature_flags.py +0 -24
  82. snowflake/cli/_plugins/nativeapp/manager.py +0 -415
  83. snowflake/cli/_plugins/nativeapp/plugin_spec.py +0 -30
  84. snowflake/cli/_plugins/nativeapp/policy.py +0 -53
  85. snowflake/cli/_plugins/nativeapp/project_model.py +0 -211
  86. snowflake/cli/_plugins/nativeapp/run_processor.py +0 -184
  87. snowflake/cli/_plugins/nativeapp/same_account_install_method.py +0 -70
  88. snowflake/cli/_plugins/nativeapp/teardown_processor.py +0 -70
  89. snowflake/cli/_plugins/nativeapp/utils.py +0 -98
  90. snowflake/cli/_plugins/nativeapp/v2_conversions/v2_to_v1_decorator.py +0 -262
  91. snowflake/cli/_plugins/nativeapp/version/__init__.py +0 -13
  92. snowflake/cli/_plugins/nativeapp/version/commands.py +0 -141
  93. snowflake/cli/_plugins/nativeapp/version/version_processor.py +0 -98
  94. snowflake/cli/_plugins/notebook/__init__.py +0 -13
  95. snowflake/cli/_plugins/notebook/commands.py +0 -86
  96. snowflake/cli/_plugins/notebook/exceptions.py +0 -20
  97. snowflake/cli/_plugins/notebook/manager.py +0 -71
  98. snowflake/cli/_plugins/notebook/plugin_spec.py +0 -30
  99. snowflake/cli/_plugins/notebook/types.py +0 -15
  100. snowflake/cli/_plugins/object/__init__.py +0 -13
  101. snowflake/cli/_plugins/object/command_aliases.py +0 -95
  102. snowflake/cli/_plugins/object/commands.py +0 -180
  103. snowflake/cli/_plugins/object/common.py +0 -85
  104. snowflake/cli/_plugins/object/manager.py +0 -118
  105. snowflake/cli/_plugins/object/plugin_spec.py +0 -30
  106. snowflake/cli/_plugins/snowpark/__init__.py +0 -13
  107. snowflake/cli/_plugins/snowpark/commands.py +0 -450
  108. snowflake/cli/_plugins/snowpark/common.py +0 -268
  109. snowflake/cli/_plugins/snowpark/models.py +0 -150
  110. snowflake/cli/_plugins/snowpark/package/__init__.py +0 -13
  111. snowflake/cli/_plugins/snowpark/package/anaconda_packages.py +0 -199
  112. snowflake/cli/_plugins/snowpark/package/commands.py +0 -195
  113. snowflake/cli/_plugins/snowpark/package/manager.py +0 -44
  114. snowflake/cli/_plugins/snowpark/package/utils.py +0 -26
  115. snowflake/cli/_plugins/snowpark/package_utils.py +0 -354
  116. snowflake/cli/_plugins/snowpark/plugin_spec.py +0 -30
  117. snowflake/cli/_plugins/snowpark/snowpark_entity.py +0 -29
  118. snowflake/cli/_plugins/snowpark/snowpark_entity_model.py +0 -173
  119. snowflake/cli/_plugins/snowpark/snowpark_project_paths.py +0 -109
  120. snowflake/cli/_plugins/snowpark/snowpark_shared.py +0 -59
  121. snowflake/cli/_plugins/snowpark/zipper.py +0 -89
  122. snowflake/cli/_plugins/spcs/__init__.py +0 -33
  123. snowflake/cli/_plugins/spcs/common.py +0 -99
  124. snowflake/cli/_plugins/spcs/compute_pool/__init__.py +0 -13
  125. snowflake/cli/_plugins/spcs/compute_pool/commands.py +0 -241
  126. snowflake/cli/_plugins/spcs/compute_pool/manager.py +0 -121
  127. snowflake/cli/_plugins/spcs/image_registry/__init__.py +0 -13
  128. snowflake/cli/_plugins/spcs/image_registry/commands.py +0 -65
  129. snowflake/cli/_plugins/spcs/image_registry/manager.py +0 -105
  130. snowflake/cli/_plugins/spcs/image_repository/__init__.py +0 -13
  131. snowflake/cli/_plugins/spcs/image_repository/commands.py +0 -202
  132. snowflake/cli/_plugins/spcs/image_repository/manager.py +0 -84
  133. snowflake/cli/_plugins/spcs/plugin_spec.py +0 -30
  134. snowflake/cli/_plugins/spcs/services/__init__.py +0 -13
  135. snowflake/cli/_plugins/spcs/services/commands.py +0 -345
  136. snowflake/cli/_plugins/spcs/services/manager.py +0 -208
  137. snowflake/cli/_plugins/sql/__init__.py +0 -13
  138. snowflake/cli/_plugins/sql/commands.py +0 -86
  139. snowflake/cli/_plugins/sql/manager.py +0 -92
  140. snowflake/cli/_plugins/sql/plugin_spec.py +0 -30
  141. snowflake/cli/_plugins/sql/snowsql_templating.py +0 -28
  142. snowflake/cli/_plugins/stage/__init__.py +0 -13
  143. snowflake/cli/_plugins/stage/commands.py +0 -264
  144. snowflake/cli/_plugins/stage/diff.py +0 -280
  145. snowflake/cli/_plugins/stage/manager.py +0 -582
  146. snowflake/cli/_plugins/stage/md5.py +0 -160
  147. snowflake/cli/_plugins/stage/plugin_spec.py +0 -30
  148. snowflake/cli/_plugins/stage/utils.py +0 -54
  149. snowflake/cli/_plugins/streamlit/__init__.py +0 -13
  150. snowflake/cli/_plugins/streamlit/commands.py +0 -195
  151. snowflake/cli/_plugins/streamlit/manager.py +0 -220
  152. snowflake/cli/_plugins/streamlit/plugin_spec.py +0 -30
  153. snowflake/cli/_plugins/streamlit/streamlit_entity.py +0 -12
  154. snowflake/cli/_plugins/streamlit/streamlit_entity_model.py +0 -66
  155. snowflake/cli/_plugins/workspace/__init__.py +0 -13
  156. snowflake/cli/_plugins/workspace/action_context.py +0 -18
  157. snowflake/cli/_plugins/workspace/commands.py +0 -306
  158. snowflake/cli/_plugins/workspace/manager.py +0 -74
  159. snowflake/cli/_plugins/workspace/plugin_spec.py +0 -30
  160. snowflake/cli/api/__init__.py +0 -48
  161. snowflake/cli/api/cli_global_context.py +0 -247
  162. snowflake/cli/api/commands/__init__.py +0 -13
  163. snowflake/cli/api/commands/alias.py +0 -23
  164. snowflake/cli/api/commands/common.py +0 -25
  165. snowflake/cli/api/commands/decorators.py +0 -369
  166. snowflake/cli/api/commands/execution_metadata.py +0 -40
  167. snowflake/cli/api/commands/experimental_behaviour.py +0 -18
  168. snowflake/cli/api/commands/flags.py +0 -561
  169. snowflake/cli/api/commands/overrideable_parameter.py +0 -143
  170. snowflake/cli/api/commands/snow_typer.py +0 -247
  171. snowflake/cli/api/commands/utils.py +0 -18
  172. snowflake/cli/api/config.py +0 -380
  173. snowflake/cli/api/connections.py +0 -216
  174. snowflake/cli/api/console/__init__.py +0 -17
  175. snowflake/cli/api/console/abc.py +0 -94
  176. snowflake/cli/api/console/console.py +0 -134
  177. snowflake/cli/api/console/enum.py +0 -17
  178. snowflake/cli/api/constants.py +0 -90
  179. snowflake/cli/api/entities/common.py +0 -56
  180. snowflake/cli/api/entities/utils.py +0 -370
  181. snowflake/cli/api/errno.py +0 -28
  182. snowflake/cli/api/exceptions.py +0 -190
  183. snowflake/cli/api/feature_flags.py +0 -54
  184. snowflake/cli/api/identifiers.py +0 -190
  185. snowflake/cli/api/metrics.py +0 -92
  186. snowflake/cli/api/output/__init__.py +0 -13
  187. snowflake/cli/api/output/formats.py +0 -20
  188. snowflake/cli/api/output/types.py +0 -118
  189. snowflake/cli/api/plugins/__init__.py +0 -13
  190. snowflake/cli/api/plugins/command/__init__.py +0 -72
  191. snowflake/cli/api/plugins/command/plugin_hook_specs.py +0 -21
  192. snowflake/cli/api/plugins/plugin_config.py +0 -32
  193. snowflake/cli/api/project/__init__.py +0 -13
  194. snowflake/cli/api/project/definition.py +0 -126
  195. snowflake/cli/api/project/definition_conversion.py +0 -395
  196. snowflake/cli/api/project/definition_manager.py +0 -145
  197. snowflake/cli/api/project/errors.py +0 -56
  198. snowflake/cli/api/project/project_verification.py +0 -23
  199. snowflake/cli/api/project/schemas/__init__.py +0 -13
  200. snowflake/cli/api/project/schemas/entities/__init__.py +0 -13
  201. snowflake/cli/api/project/schemas/entities/common.py +0 -153
  202. snowflake/cli/api/project/schemas/entities/entities.py +0 -61
  203. snowflake/cli/api/project/schemas/project_definition.py +0 -330
  204. snowflake/cli/api/project/schemas/template.py +0 -77
  205. snowflake/cli/api/project/schemas/updatable_model.py +0 -202
  206. snowflake/cli/api/project/schemas/v1/__init__.py +0 -0
  207. snowflake/cli/api/project/schemas/v1/identifier_model.py +0 -51
  208. snowflake/cli/api/project/schemas/v1/native_app/__init__.py +0 -0
  209. snowflake/cli/api/project/schemas/v1/native_app/application.py +0 -61
  210. snowflake/cli/api/project/schemas/v1/native_app/native_app.py +0 -93
  211. snowflake/cli/api/project/schemas/v1/native_app/package.py +0 -84
  212. snowflake/cli/api/project/schemas/v1/native_app/path_mapping.py +0 -65
  213. snowflake/cli/api/project/schemas/v1/snowpark/__init__.py +0 -0
  214. snowflake/cli/api/project/schemas/v1/snowpark/argument.py +0 -28
  215. snowflake/cli/api/project/schemas/v1/snowpark/callable.py +0 -69
  216. snowflake/cli/api/project/schemas/v1/snowpark/snowpark.py +0 -36
  217. snowflake/cli/api/project/schemas/v1/streamlit/__init__.py +0 -0
  218. snowflake/cli/api/project/schemas/v1/streamlit/streamlit.py +0 -47
  219. snowflake/cli/api/project/util.py +0 -278
  220. snowflake/cli/api/rendering/__init__.py +0 -13
  221. snowflake/cli/api/rendering/jinja.py +0 -118
  222. snowflake/cli/api/rendering/project_definition_templates.py +0 -43
  223. snowflake/cli/api/rendering/project_templates.py +0 -98
  224. snowflake/cli/api/rendering/sql_templates.py +0 -105
  225. snowflake/cli/api/rest_api.py +0 -178
  226. snowflake/cli/api/sanitizers.py +0 -43
  227. snowflake/cli/api/secure_path.py +0 -360
  228. snowflake/cli/api/secure_utils.py +0 -118
  229. snowflake/cli/api/sql_execution.py +0 -280
  230. snowflake/cli/api/utils/__init__.py +0 -13
  231. snowflake/cli/api/utils/cursor.py +0 -34
  232. snowflake/cli/api/utils/definition_rendering.py +0 -415
  233. snowflake/cli/api/utils/dict_utils.py +0 -73
  234. snowflake/cli/api/utils/error_handling.py +0 -23
  235. snowflake/cli/api/utils/graph.py +0 -97
  236. snowflake/cli/api/utils/models.py +0 -63
  237. snowflake/cli/api/utils/naming_utils.py +0 -13
  238. snowflake/cli/api/utils/path_utils.py +0 -36
  239. snowflake/cli/api/utils/templating_functions.py +0 -144
  240. snowflake/cli/api/utils/types.py +0 -35
  241. snowflake_cli_labs-3.0.0rc4.dist-info/RECORD +0 -242
  242. snowflake_cli_labs-3.0.0rc4.dist-info/entry_points.txt +0 -2
  243. {snowflake_cli_labs-3.0.0rc4.dist-info → snowflake_cli_labs-3.0.1.dist-info}/WHEEL +0 -0
  244. {snowflake_cli_labs-3.0.0rc4.dist-info → snowflake_cli_labs-3.0.1.dist-info}/licenses/LICENSE +0 -0
@@ -1,559 +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
- import itertools
18
- import logging
19
- from enum import Enum
20
- from pathlib import Path
21
- from textwrap import dedent
22
- from typing import Generator, Iterable, List, Optional, cast
23
-
24
- import typer
25
- from click.exceptions import ClickException
26
- from snowflake.cli._plugins.nativeapp.common_flags import (
27
- ForceOption,
28
- InteractiveOption,
29
- ValidateOption,
30
- )
31
- from snowflake.cli._plugins.nativeapp.entities.application import ApplicationEntityModel
32
- from snowflake.cli._plugins.nativeapp.entities.application_package import (
33
- ApplicationPackageEntityModel,
34
- )
35
- from snowflake.cli._plugins.nativeapp.manager import NativeAppManager
36
- from snowflake.cli._plugins.nativeapp.policy import (
37
- AllowAlwaysPolicy,
38
- AskAlwaysPolicy,
39
- DenyAlwaysPolicy,
40
- )
41
- from snowflake.cli._plugins.nativeapp.run_processor import NativeAppRunProcessor
42
- from snowflake.cli._plugins.nativeapp.teardown_processor import (
43
- NativeAppTeardownProcessor,
44
- )
45
- from snowflake.cli._plugins.nativeapp.v2_conversions.v2_to_v1_decorator import (
46
- find_entity,
47
- nativeapp_definition_v2_to_v1,
48
- )
49
- from snowflake.cli._plugins.nativeapp.version.commands import app as versions_app
50
- from snowflake.cli._plugins.stage.diff import (
51
- DiffResult,
52
- compute_stage_diff,
53
- )
54
- from snowflake.cli._plugins.stage.utils import print_diff_to_console
55
- from snowflake.cli._plugins.workspace.manager import WorkspaceManager
56
- from snowflake.cli.api.cli_global_context import get_cli_context
57
- from snowflake.cli.api.commands.decorators import (
58
- with_project_definition,
59
- )
60
- from snowflake.cli.api.commands.snow_typer import SnowTyperFactory
61
- from snowflake.cli.api.entities.common import EntityActions
62
- from snowflake.cli.api.exceptions import IncompatibleParametersError
63
- from snowflake.cli.api.output.formats import OutputFormat
64
- from snowflake.cli.api.output.types import (
65
- CommandResult,
66
- MessageResult,
67
- ObjectResult,
68
- StreamResult,
69
- )
70
- from snowflake.cli.api.project.project_verification import assert_project_type
71
- from snowflake.cli.api.project.schemas.project_definition import ProjectDefinitionV1
72
- from typing_extensions import Annotated
73
-
74
- app = SnowTyperFactory(
75
- name="app",
76
- help="Manages a Snowflake Native App",
77
- )
78
- app.add_typer(versions_app)
79
-
80
- log = logging.getLogger(__name__)
81
-
82
-
83
- @app.command("init", hidden=True)
84
- def app_init(**options):
85
- """
86
- *** Deprecated. Use snow init instead ***
87
-
88
- Initializes a Snowflake Native App project.
89
- """
90
-
91
- raise ClickException("This command has been removed. Use `snow init` instead.")
92
-
93
-
94
- @app.command("bundle")
95
- @with_project_definition()
96
- @nativeapp_definition_v2_to_v1()
97
- def app_bundle(
98
- **options,
99
- ) -> CommandResult:
100
- """
101
- Prepares a local folder with configured app artifacts.
102
- """
103
-
104
- assert_project_type("native_app")
105
-
106
- cli_context = get_cli_context()
107
- manager = NativeAppManager(
108
- project_definition=cli_context.project_definition.native_app,
109
- project_root=cli_context.project_root,
110
- )
111
- manager.build_bundle()
112
- return MessageResult(f"Bundle generated at {manager.deploy_root}")
113
-
114
-
115
- @app.command("diff", requires_connection=True, hidden=True)
116
- @with_project_definition()
117
- @nativeapp_definition_v2_to_v1()
118
- def app_diff(
119
- **options,
120
- ) -> CommandResult:
121
- """
122
- Performs a diff between the app's source stage and the local deploy root.
123
- """
124
- assert_project_type("native_app")
125
-
126
- cli_context = get_cli_context()
127
- manager = NativeAppManager(
128
- project_definition=cli_context.project_definition.native_app,
129
- project_root=cli_context.project_root,
130
- )
131
- bundle_map = manager.build_bundle()
132
- diff: DiffResult = compute_stage_diff(
133
- local_root=Path(manager.deploy_root), stage_fqn=manager.stage_fqn
134
- )
135
- if cli_context.output_format == OutputFormat.JSON:
136
- return ObjectResult(diff.to_dict())
137
- else:
138
- print_diff_to_console(diff, bundle_map)
139
- return None # don't print any output
140
-
141
-
142
- @app.command("run", requires_connection=True)
143
- @with_project_definition()
144
- @nativeapp_definition_v2_to_v1(app_required=True)
145
- def app_run(
146
- version: Optional[str] = typer.Option(
147
- None,
148
- help=f"""The version defined in an existing application package from which you want to create an application object.
149
- The application object and application package names are determined from the project definition file.""",
150
- ),
151
- patch: Optional[int] = typer.Option(
152
- None,
153
- "--patch",
154
- help=f"""The patch number under the given `--version` defined in an existing application package that should be used to create an application object.
155
- The application object and application package names are determined from the project definition file.""",
156
- ),
157
- from_release_directive: Optional[bool] = typer.Option(
158
- False,
159
- "--from-release-directive",
160
- help=f"""Creates or upgrades an application object to the version and patch specified by the release directive applicable to your Snowflake account.
161
- The command fails if no release directive exists for your Snowflake account for a given application package, which is determined from the project definition file. Default: unset.""",
162
- is_flag=True,
163
- ),
164
- interactive: bool = InteractiveOption,
165
- force: Optional[bool] = ForceOption,
166
- validate: bool = ValidateOption,
167
- **options,
168
- ) -> CommandResult:
169
- """
170
- Creates an application package in your Snowflake account, uploads code files to its stage,
171
- then creates or upgrades an application object from the application package.
172
- """
173
-
174
- assert_project_type("native_app")
175
-
176
- is_interactive = False
177
- if force:
178
- policy = AllowAlwaysPolicy()
179
- elif interactive:
180
- is_interactive = True
181
- policy = AskAlwaysPolicy()
182
- else:
183
- policy = DenyAlwaysPolicy()
184
-
185
- cli_context = get_cli_context()
186
- processor = NativeAppRunProcessor(
187
- project_definition=cli_context.project_definition.native_app,
188
- project_root=cli_context.project_root,
189
- )
190
- bundle_map = processor.build_bundle()
191
- processor.process(
192
- bundle_map=bundle_map,
193
- policy=policy,
194
- version=version,
195
- patch=patch,
196
- from_release_directive=from_release_directive,
197
- is_interactive=is_interactive,
198
- validate=validate,
199
- )
200
- return MessageResult(
201
- f"Your application object ({processor.app_name}) is now available:\n"
202
- + processor.get_snowsight_url()
203
- )
204
-
205
-
206
- @app.command("open", requires_connection=True)
207
- @with_project_definition()
208
- @nativeapp_definition_v2_to_v1(app_required=True)
209
- def app_open(
210
- **options,
211
- ) -> CommandResult:
212
- """
213
- Opens the Snowflake Native App inside of your browser,
214
- once it has been installed in your account.
215
- """
216
-
217
- assert_project_type("native_app")
218
-
219
- cli_context = get_cli_context()
220
- manager = NativeAppManager(
221
- project_definition=cli_context.project_definition.native_app,
222
- project_root=cli_context.project_root,
223
- )
224
- if manager.get_existing_app_info():
225
- typer.launch(manager.get_snowsight_url())
226
- return MessageResult(f"Snowflake Native App opened in browser.")
227
- else:
228
- return MessageResult(
229
- 'Snowflake Native App not yet deployed! Please run "snow app run" first.'
230
- )
231
-
232
-
233
- @app.command("teardown", requires_connection=True)
234
- @with_project_definition()
235
- # This command doesn't use @nativeapp_definition_v2_to_v1 because it needs to
236
- # be aware of PDFv2 definitions that have multiple apps created from the same package,
237
- # which all need to be torn down.
238
- def app_teardown(
239
- force: Optional[bool] = ForceOption,
240
- cascade: Optional[bool] = typer.Option(
241
- None,
242
- help=f"""Whether to drop all application objects owned by the application within the account. Default: false.""",
243
- show_default=False,
244
- ),
245
- interactive: bool = InteractiveOption,
246
- # Same as the param auto-added by @nativeapp_definition_v2_to_v1
247
- package_entity_id: Optional[str] = typer.Option(
248
- default="",
249
- help="The ID of the package entity on which to operate when definition_version is 2 or higher.",
250
- ),
251
- **options,
252
- ) -> CommandResult:
253
- """
254
- Attempts to drop both the application object and application package as defined in the project definition file.
255
- """
256
- cli_context = get_cli_context()
257
- project = cli_context.project_definition
258
- if isinstance(project, ProjectDefinitionV1):
259
- # Old behaviour, not multi-app aware so we can use the old processor
260
- processor = NativeAppTeardownProcessor(
261
- project_definition=cli_context.project_definition.native_app,
262
- project_root=cli_context.project_root,
263
- )
264
- processor.process(interactive, force, cascade)
265
- else:
266
- # New behaviour, multi-app aware so teardown all the apps created from the package
267
-
268
- # Determine the package entity to drop, there must be one
269
- app_package_entity = find_entity(
270
- project,
271
- ApplicationPackageEntityModel,
272
- package_entity_id,
273
- disambiguation_option="--package-entity-id",
274
- required=True,
275
- )
276
- assert app_package_entity is not None # satisfy mypy
277
-
278
- # Same implementation as `snow ws drop`
279
- ws = WorkspaceManager(
280
- project_definition=cli_context.project_definition,
281
- project_root=cli_context.project_root,
282
- )
283
- for app_entity in project.get_entities_by_type(
284
- ApplicationEntityModel.get_type()
285
- ).values():
286
- # Drop each app
287
- if app_entity.from_.target == app_package_entity.entity_id:
288
- ws.perform_action(
289
- app_entity.entity_id,
290
- EntityActions.DROP,
291
- force_drop=force,
292
- interactive=interactive,
293
- cascade=cascade,
294
- )
295
- # Then drop the package
296
- ws.perform_action(
297
- app_package_entity.entity_id,
298
- EntityActions.DROP,
299
- force_drop=force,
300
- interactive=interactive,
301
- cascade=cascade,
302
- )
303
-
304
- return MessageResult(f"Teardown is now complete.")
305
-
306
-
307
- @app.command("deploy", requires_connection=True)
308
- @with_project_definition()
309
- @nativeapp_definition_v2_to_v1()
310
- def app_deploy(
311
- prune: Optional[bool] = typer.Option(
312
- default=None,
313
- help=f"""Whether to delete specified files from the stage if they don't exist locally. If set, the command deletes files that exist in the stage, but not in the local filesystem. This option cannot be used when paths are specified.""",
314
- ),
315
- recursive: Optional[bool] = typer.Option(
316
- None,
317
- "--recursive/--no-recursive",
318
- "-r",
319
- help=f"""Whether to traverse and deploy files from subdirectories. If set, the command deploys all files and subdirectories; otherwise, only files in the current directory are deployed.""",
320
- ),
321
- paths: Optional[List[Path]] = typer.Argument(
322
- default=None,
323
- show_default=False,
324
- help=dedent(
325
- f"""
326
- Paths, relative to the the project root, of files or directories you want to upload to a stage. If a file is
327
- specified, it must match one of the artifacts src pattern entries in snowflake.yml. If a directory is
328
- specified, it will be searched for subfolders or files to deploy based on artifacts src pattern entries. If
329
- unspecified, the command syncs all local changes to the stage."""
330
- ).strip(),
331
- ),
332
- interactive: bool = InteractiveOption,
333
- force: Optional[bool] = ForceOption,
334
- validate: bool = ValidateOption,
335
- **options,
336
- ) -> CommandResult:
337
- """
338
- Creates an application package in your Snowflake account and syncs the local changes to the stage without creating or updating the application.
339
- Running this command with no arguments at all, as in `snow app deploy`, is a shorthand for `snow app deploy --prune --recursive`.
340
- """
341
-
342
- assert_project_type("native_app")
343
-
344
- if force:
345
- policy = AllowAlwaysPolicy()
346
- elif interactive:
347
- policy = AskAlwaysPolicy()
348
- else:
349
- policy = DenyAlwaysPolicy()
350
-
351
- has_paths = paths is not None and len(paths) > 0
352
- if prune is None and recursive is None and not has_paths:
353
- prune = True
354
- recursive = True
355
- else:
356
- if prune is None:
357
- prune = False
358
- if recursive is None:
359
- recursive = False
360
-
361
- if has_paths and prune:
362
- raise IncompatibleParametersError(["paths", "--prune"])
363
-
364
- cli_context = get_cli_context()
365
- manager = NativeAppManager(
366
- project_definition=cli_context.project_definition.native_app,
367
- project_root=cli_context.project_root,
368
- )
369
-
370
- bundle_map = manager.build_bundle()
371
- manager.deploy(
372
- bundle_map=bundle_map,
373
- prune=prune,
374
- recursive=recursive,
375
- local_paths_to_sync=paths,
376
- validate=validate,
377
- policy=policy,
378
- )
379
-
380
- return MessageResult(
381
- f"Deployed successfully. Application package and stage are up-to-date."
382
- )
383
-
384
-
385
- @app.command("validate", requires_connection=True)
386
- @with_project_definition()
387
- @nativeapp_definition_v2_to_v1()
388
- def app_validate(
389
- **options,
390
- ):
391
- """
392
- Validates a deployed Snowflake Native App's setup script.
393
- """
394
-
395
- assert_project_type("native_app")
396
-
397
- cli_context = get_cli_context()
398
- manager = NativeAppManager(
399
- project_definition=cli_context.project_definition.native_app,
400
- project_root=cli_context.project_root,
401
- )
402
- if cli_context.output_format == OutputFormat.JSON:
403
- return ObjectResult(manager.get_validation_result(use_scratch_stage=True))
404
-
405
- manager.validate(use_scratch_stage=True)
406
- return MessageResult("Snowflake Native App validation succeeded.")
407
-
408
-
409
- class RecordType(Enum):
410
- LOG = "log"
411
- SPAN = "span"
412
- SPAN_EVENT = "span_event"
413
-
414
-
415
- # The default number of lines to print before streaming when running
416
- # snow app events --follow
417
- DEFAULT_EVENT_FOLLOW_LAST = 20
418
-
419
-
420
- @app.command("events", requires_connection=True)
421
- @with_project_definition()
422
- @nativeapp_definition_v2_to_v1(app_required=True)
423
- def app_events(
424
- since: str = typer.Option(
425
- default="",
426
- help="Fetch events that are newer than this time ago, in Snowflake interval syntax.",
427
- ),
428
- until: str = typer.Option(
429
- default="",
430
- help="Fetch events that are older than this time ago, in Snowflake interval syntax.",
431
- ),
432
- record_types: Annotated[
433
- list[RecordType], typer.Option(case_sensitive=False)
434
- ] = typer.Option(
435
- [],
436
- "--type",
437
- help="Restrict results to specific record type. Can be specified multiple times.",
438
- ),
439
- scopes: Annotated[list[str], typer.Option()] = typer.Option(
440
- [],
441
- "--scope",
442
- help="Restrict results to a specific scope name. Can be specified multiple times.",
443
- ),
444
- consumer_org: str = typer.Option(
445
- default="", help="The name of the consumer organization."
446
- ),
447
- consumer_account: str = typer.Option(
448
- default="",
449
- help="The name of the consumer account in the organization.",
450
- ),
451
- consumer_app_hash: str = typer.Option(
452
- default="",
453
- help="The SHA-1 hash of the consumer application name",
454
- ),
455
- first: int = typer.Option(
456
- default=-1,
457
- show_default=False,
458
- help="Fetch only the first N events. Cannot be used with --last.",
459
- ),
460
- last: int = typer.Option(
461
- default=-1,
462
- show_default=False,
463
- help="Fetch only the last N events. Cannot be used with --first.",
464
- ),
465
- follow: bool = typer.Option(
466
- False,
467
- "--follow",
468
- "-f",
469
- help=(
470
- f"Continue polling for events. Implies --last {DEFAULT_EVENT_FOLLOW_LAST} "
471
- f"unless overridden or the --since flag is used."
472
- ),
473
- ),
474
- follow_interval: int = typer.Option(
475
- 10,
476
- help=f"Polling interval in seconds when using the --follow flag.",
477
- ),
478
- **options,
479
- ):
480
- """Fetches events for this app from the event table configured in Snowflake.
481
-
482
- By default, this command will fetch events generated by an app installed in the
483
- current connection's account. To fetch events generated by an app installed
484
- in a consumer account, use the --consumer-org and --consumer-account options.
485
- This requires event sharing to be set up to route events to the provider account:
486
- https://docs.snowflake.com/en/developer-guide/native-apps/setting-up-logging-and-events
487
- """
488
- if first >= 0 and last >= 0:
489
- raise IncompatibleParametersError(["--first", "--last"])
490
-
491
- if (consumer_org and not consumer_account) or (
492
- consumer_account and not consumer_org
493
- ):
494
- raise IncompatibleParametersError(["--consumer-org", "--consumer-account"])
495
-
496
- if follow:
497
- if until:
498
- raise IncompatibleParametersError(["--follow", "--until"])
499
- if first >= 0:
500
- raise IncompatibleParametersError(["--follow", "--first"])
501
-
502
- assert_project_type("native_app")
503
-
504
- record_type_names = [r.name for r in record_types]
505
- manager = NativeAppManager(
506
- project_definition=get_cli_context().project_definition.native_app,
507
- project_root=get_cli_context().project_root,
508
- )
509
- if follow:
510
- if last == -1 and not since:
511
- # If we don't have a value for --last or --since, assume a value
512
- # for --last so we at least print something before starting the stream
513
- last = DEFAULT_EVENT_FOLLOW_LAST
514
- stream: Iterable[CommandResult] = (
515
- EventResult(event)
516
- for event in manager.stream_events(
517
- since=since,
518
- last=last,
519
- interval_seconds=follow_interval,
520
- record_types=record_type_names,
521
- scopes=scopes,
522
- consumer_org=consumer_org,
523
- consumer_account=consumer_account,
524
- consumer_app_hash=consumer_app_hash,
525
- )
526
- )
527
- # Append a newline at the end to make the CLI output clean when we hit Ctrl-C
528
- stream = itertools.chain(stream, [MessageResult("")])
529
- else:
530
- stream = (
531
- EventResult(event)
532
- for event in manager.get_events(
533
- since=since,
534
- until=until,
535
- record_types=record_type_names,
536
- scopes=scopes,
537
- first=first,
538
- last=last,
539
- consumer_org=consumer_org,
540
- consumer_account=consumer_account,
541
- consumer_app_hash=consumer_app_hash,
542
- )
543
- )
544
-
545
- # Cast the stream to a Generator since that's what StreamResult wants
546
- return StreamResult(cast(Generator[CommandResult, None, None], stream))
547
-
548
-
549
- class EventResult(ObjectResult, MessageResult):
550
- """ObjectResult that renders as a custom string when not printed as JSON."""
551
-
552
- @property
553
- def message(self):
554
- e = self._element
555
- return f"{e['TIMESTAMP']} {e['VALUE']}"
556
-
557
- @property
558
- def result(self):
559
- return self._element
@@ -1,44 +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
- import typer
16
- from snowflake.cli._plugins.nativeapp.utils import is_tty_interactive
17
-
18
-
19
- def interactive_callback(val):
20
- if val is None:
21
- return is_tty_interactive()
22
- return val
23
-
24
-
25
- InteractiveOption = typer.Option(
26
- None,
27
- help=f"""When enabled, this option displays prompts even if the standard input and output are not terminal devices. Defaults to True in an interactive shell environment, and False otherwise.""",
28
- callback=interactive_callback,
29
- show_default=False,
30
- )
31
-
32
- ForceOption = typer.Option(
33
- False,
34
- "--force",
35
- help=f"""When enabled, this option causes the command to implicitly approve any prompts that arise.
36
- You should enable this option if interactive mode is not specified and if you want perform potentially destructive actions. Defaults to unset.""",
37
- is_flag=True,
38
- )
39
- ValidateOption = typer.Option(
40
- True,
41
- "--validate/--no-validate",
42
- help="""When enabled, this option triggers validation of a deployed Snowflake Native App's setup script SQL""",
43
- is_flag=True,
44
- )
@@ -1,27 +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
- SPECIAL_COMMENT_OLD = "GENERATED_BY_SNOWCLI"
16
- SPECIAL_COMMENT = "GENERATED_BY_SNOWFLAKECLI"
17
- ALLOWED_SPECIAL_COMMENTS = {SPECIAL_COMMENT, SPECIAL_COMMENT_OLD}
18
- LOOSE_FILES_MAGIC_VERSION = "UNVERSIONED"
19
-
20
- NAME_COL = "name"
21
- COMMENT_COL = "comment"
22
- OWNER_COL = "owner"
23
- VERSION_COL = "version"
24
- PATCH_COL = "patch"
25
-
26
- INTERNAL_DISTRIBUTION = "internal"
27
- EXTERNAL_DISTRIBUTION = "external"
File without changes