Skip to content

Commit 52b513c

Browse files
Adds events feature flag. (#2070)
1 parent ab36d24 commit 52b513c

File tree

4 files changed

+34
-109
lines changed

4 files changed

+34
-109
lines changed

src/snowflake/cli/_plugins/spcs/services/commands.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
from snowflake.cli.api.exceptions import (
4141
IncompatibleParametersError,
4242
)
43+
from snowflake.cli.api.feature_flags import FeatureFlag
4344
from snowflake.cli.api.identifiers import FQN
4445
from snowflake.cli.api.output.types import (
4546
CollectionResult,
@@ -320,6 +321,7 @@ def logs(
320321

321322
@app.command(
322323
requires_connection=True,
324+
is_enabled=FeatureFlag.ENABLE_SPCS_SERVICE_EVENTS.is_enabled,
323325
)
324326
def events(
325327
name: FQN = ServiceNameArgument,

src/snowflake/cli/api/feature_flags.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,4 @@ class FeatureFlag(FeatureFlagMixin):
6767
"ENABLE_SEPARATE_AUTHENTICATION_POLICY_ID", False
6868
)
6969
ENABLE_SNOWPARK_GLOB_SUPPORT = BooleanFlag("ENABLE_SNOWPARK_GLOB_SUPPORT", False)
70+
ENABLE_SPCS_SERVICE_EVENTS = BooleanFlag("ENABLE_SPCS_SERVICE_EVENTS", False)

tests/__snapshots__/test_help_messages.ambr

Lines changed: 0 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -8251,111 +8251,6 @@
82518251
+------------------------------------------------------------------------------+
82528252

82538253

8254-
'''
8255-
# ---
8256-
# name: test_help_messages[spcs.service.events]
8257-
'''
8258-
8259-
Usage: root spcs service events [OPTIONS] NAME
8260-
8261-
Retrieve platform events for a service container.
8262-
8263-
+- Arguments ------------------------------------------------------------------+
8264-
| * name TEXT Identifier of the service; for example: my_service |
8265-
| [required] |
8266-
+------------------------------------------------------------------------------+
8267-
+- Options --------------------------------------------------------------------+
8268-
| * --container-name TEXT Name of the container. |
8269-
| [required] |
8270-
| * --instance-id TEXT ID of the service instance, starting |
8271-
| with 0. |
8272-
| [required] |
8273-
| --since TEXT Fetch events that are newer than this |
8274-
| time ago, in Snowflake interval |
8275-
| syntax. |
8276-
| --until TEXT Fetch events that are older than this |
8277-
| time ago, in Snowflake interval |
8278-
| syntax. |
8279-
| --first INTEGER Fetch only the first N events. Cannot |
8280-
| be used with --last. |
8281-
| --last INTEGER Fetch only the last N events. Cannot |
8282-
| be used with --first. |
8283-
| --all Fetch all columns. |
8284-
| --help -h Show this message and exit. |
8285-
+------------------------------------------------------------------------------+
8286-
+- Connection configuration ---------------------------------------------------+
8287-
| --connection,--environment -c TEXT Name of the connection, as |
8288-
| defined in your config.toml |
8289-
| file. Default: default. |
8290-
| --host TEXT Host address for the |
8291-
| connection. Overrides the |
8292-
| value specified for the |
8293-
| connection. |
8294-
| --port INTEGER Port for the connection. |
8295-
| Overrides the value |
8296-
| specified for the |
8297-
| connection. |
8298-
| --account,--accountname TEXT Name assigned to your |
8299-
| Snowflake account. Overrides |
8300-
| the value specified for the |
8301-
| connection. |
8302-
| --user,--username TEXT Username to connect to |
8303-
| Snowflake. Overrides the |
8304-
| value specified for the |
8305-
| connection. |
8306-
| --password TEXT Snowflake password. |
8307-
| Overrides the value |
8308-
| specified for the |
8309-
| connection. |
8310-
| --authenticator TEXT Snowflake authenticator. |
8311-
| Overrides the value |
8312-
| specified for the |
8313-
| connection. |
8314-
| --private-key-file,--private… TEXT Snowflake private key file |
8315-
| path. Overrides the value |
8316-
| specified for the |
8317-
| connection. |
8318-
| --token-file-path TEXT Path to file with an OAuth |
8319-
| token that should be used |
8320-
| when connecting to Snowflake |
8321-
| --database,--dbname TEXT Database to use. Overrides |
8322-
| the value specified for the |
8323-
| connection. |
8324-
| --schema,--schemaname TEXT Database schema to use. |
8325-
| Overrides the value |
8326-
| specified for the |
8327-
| connection. |
8328-
| --role,--rolename TEXT Role to use. Overrides the |
8329-
| value specified for the |
8330-
| connection. |
8331-
| --warehouse TEXT Warehouse to use. Overrides |
8332-
| the value specified for the |
8333-
| connection. |
8334-
| --temporary-connection -x Uses a connection defined |
8335-
| with command line |
8336-
| parameters, instead of one |
8337-
| defined in config |
8338-
| --mfa-passcode TEXT Token to use for |
8339-
| multi-factor authentication |
8340-
| (MFA) |
8341-
| --enable-diag Run Python connector |
8342-
| diagnostic test |
8343-
| --diag-log-path TEXT Diagnostic report path |
8344-
| --diag-allowlist-path TEXT Diagnostic report path to |
8345-
| optional allowlist |
8346-
+------------------------------------------------------------------------------+
8347-
+- Global configuration -------------------------------------------------------+
8348-
| --format [TABLE|JSON] Specifies the output format. |
8349-
| [default: TABLE] |
8350-
| --verbose -v Displays log entries for log levels info |
8351-
| and higher. |
8352-
| --debug Displays log entries for log levels debug |
8353-
| and higher; debug logs contain additional |
8354-
| information. |
8355-
| --silent Turns off intermediate output to console. |
8356-
+------------------------------------------------------------------------------+
8357-
8358-
83598254
'''
83608255
# ---
83618256
# name: test_help_messages[spcs.service.execute-job]
@@ -9723,8 +9618,6 @@
97239618
| schema. |
97249619
| describe Provides description of service. |
97259620
| drop Drops service with given name. |
9726-
| events Retrieve platform events for a service |
9727-
| container. |
97289621
| execute-job Creates and executes a job service in the |
97299622
| current schema. |
97309623
| list Lists all available services. |
@@ -11837,8 +11730,6 @@
1183711730
| schema. |
1183811731
| describe Provides description of service. |
1183911732
| drop Drops service with given name. |
11840-
| events Retrieve platform events for a service |
11841-
| container. |
1184211733
| execute-job Creates and executes a job service in the |
1184311734
| current schema. |
1184411735
| list Lists all available services. |

tests/spcs/test_services.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,37 @@ def test_latest_metrics(
909909
)
910910

911911

912+
def test_service_events_disabled(runner, empty_snowcli_config):
913+
result = runner.invoke_with_config_file(
914+
empty_snowcli_config,
915+
[
916+
"spcs",
917+
"service",
918+
"events",
919+
"LOG_EVENT",
920+
"--container-name",
921+
"log-printer",
922+
"--instance-id",
923+
"0",
924+
"--since",
925+
"1 minute",
926+
],
927+
)
928+
assert (
929+
result.exit_code != 0
930+
), "Expected a non-zero exit code due to feature flag being disabled"
931+
expected_output = (
932+
"Usage: root spcs service [OPTIONS] COMMAND [ARGS]...\n"
933+
"Try 'root spcs service --help' for help.\n"
934+
"+- Error ----------------------------------------------------------------------+\n"
935+
"| No such command 'events'. |\n"
936+
"+------------------------------------------------------------------------------+\n"
937+
)
938+
assert (
939+
result.output == expected_output
940+
), f"Expected formatted output not found: {result.output}"
941+
942+
912943
@patch("snowflake.cli._plugins.spcs.services.manager.ServiceManager.execute_query")
913944
def test_metrics_all_filters(
914945
mock_execute_query, runner, enable_events_and_metrics_config

0 commit comments

Comments
 (0)