Skip to main content

services

Creates, updates, deletes, gets or lists a services resource.

Overview

Nameservices
TypeResource
Idsnowflake.service.services

Fields

The following fields are returned by SELECT queries:

A Snowflake service object.

NameDatatypeDescription
namestringA Snowflake object identifier. If the identifier contains spaces or special characters, the entire string must be enclosed in double quotes. Identifiers enclosed in double quotes are also case-sensitive. (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$, example: TEST_NAME)
database_namestringA Snowflake object identifier. If the identifier contains spaces or special characters, the entire string must be enclosed in double quotes. Identifiers enclosed in double quotes are also case-sensitive. (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$, example: TEST_NAME)
dns_namestringSnowflake-assiged DNS name of the service. The DNS name enables service-to-service communications.
managing_object_namestringThe name of the managing object (for example, the name of the notebook that manages the service). NULL if the service is not managed by a Snowflake entity.
schema_namestringA Snowflake object identifier. If the identifier contains spaces or special characters, the entire string must be enclosed in double quotes. Identifiers enclosed in double quotes are also case-sensitive. (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$, example: TEST_NAME)
auto_resumebooleanSpecifies whether to automatically resume a service when a service function or ingress is called.
auto_suspend_secsinteger (int64)Number of seconds of inactivity after which the service will be automatically suspended. The default value is 0 which represents the service will not be automatically suspended.
commentstringSpecifies a comment for the service.
compute_poolstringSpecifies the name of the compute pool in your account on which to run the service.
created_onstring (date-time)Timestamp when the service was created.
current_instancesintegerThe current number of instances for the service.
external_access_integrationsarraySpecifies the names of the external access integrations that allow your service to access external sites.
is_async_jobbooleanTrue if the service is an async job service; false otherwise.
is_jobbooleanTrue if the service is a job service; false otherwise.
is_upgradingbooleanTRUE, if Snowflake is in the process of upgrading the service.
managing_object_domainstringThe domain of the managing object (for example, the domain of the notebook that manages the service). NULL if the service is not managed by a Snowflake entity.
max_instancesintegerSpecifies the maximum number of service instances to run.
min_instancesintegerSpecifies the minimum number of service instances to run.
min_ready_instancesintegerThe minimum number of ready service instances to declare the service as READY.
ownerstringRole that owns the service.
owner_role_typestringThe role type of the service owner.
query_warehousestringA Snowflake object identifier. If the identifier contains spaces or special characters, the entire string must be enclosed in double quotes. Identifiers enclosed in double quotes are also case-sensitive. (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$, example: TEST_NAME)
resumed_onstring (date-time)Timestamp when the service was last resumed.
specobjectSpecifies service specification.
spec_digeststringThe unique and immutable identifier representing the service spec content.
statusstringThe current status of the service.
suspended_onstring (date-time)Timestamp when the service was last suspended.
target_instancesintegerThe target number of service instances that should be running as determined by Snowflake.
updated_onstring (date-time)Timestamp when the service was last updated.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
list_servicesselectdatabase_name, schema_name, endpointlike, startsWith, showLimit, fromNameLists the services under the database and schema.
fetch_serviceselectdatabase_name, schema_name, name, endpointFetch a service.
create_serviceinsertdatabase_name, schema_name, endpointcreateModeCreate a service, with standard create modifiers as query parameters. See the Service component definition for what is required to be provided in the request body.
create_or_alter_servicereplacedatabase_name, schema_name, name, endpointCreate a (or alter an existing) service. Even if the operation is just an alter, the full property set must be provided.
delete_servicedeletedatabase_name, schema_name, name, endpointifExistsDelete a service with the given name. If ifExists is used, the operation will succeed even if the object does not exist. Otherwise, there will be a failure if the drop is unsuccessful.
execute_job_serviceexecdatabase_name, schema_name, endpointCreate and execute a job service. See the JobService component definition for what is required to be provided in the request body.
resume_serviceexecdatabase_name, schema_name, name, endpointifExistsResume a service.
suspend_serviceexecdatabase_name, schema_name, name, endpointifExistsSuspend a service.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
database_namestringIdentifier (i.e. name) for the database to which the resource belongs. You can use the /api/v2/databases GET request to get a list of available databases.
endpointstringOrganization and Account Name (default: orgid-acctid)
namestringIdentifier (i.e. name) for the resource.
schema_namestringIdentifier (i.e. name) for the schema to which the resource belongs. You can use the /api/v2/databases/{database}/schemas GET request to get a list of available schemas for the specified database.
createModestringQuery parameter allowing support for different modes of resource creation. Possible values include: - errorIfExists: Throws an error if you try to create a resource that already exists. - ifNotExists: Creates a new resource when an alter is requested for a non-existent resource.
fromNamestringQuery parameter to enable fetching rows only following the first row whose object name matches the specified string. Case-sensitive and does not have to be the full name.
ifExistsbooleanQuery parameter that specifies how to handle the request for a resource that does not exist: - true: The endpoint does not throw an error if the resource does not exist. It returns a 200 success response, but does not take any action on the resource. - false: The endpoint throws an error if the resource doesn't exist.
likestringQuery parameter to filter the command output by resource name. Uses case-insensitive pattern matching, with support for SQL wildcard characters.
showLimitintegerQuery parameter to limit the maximum number of rows returned by a command.
startsWithstringQuery parameter to filter the command output based on the string of characters that appear at the beginning of the object name. Uses case-sensitive pattern matching.

SELECT examples

Lists the services under the database and schema.

SELECT
name,
database_name,
dns_name,
managing_object_name,
schema_name,
auto_resume,
auto_suspend_secs,
comment,
compute_pool,
created_on,
current_instances,
external_access_integrations,
is_async_job,
is_job,
is_upgrading,
managing_object_domain,
max_instances,
min_instances,
min_ready_instances,
owner,
owner_role_type,
query_warehouse,
resumed_on,
spec,
spec_digest,
status,
suspended_on,
target_instances,
updated_on
FROM snowflake.service.services
WHERE database_name = '{{ database_name }}' -- required
AND schema_name = '{{ schema_name }}' -- required
AND endpoint = '{{ endpoint }}' -- required
AND like = '{{ like }}'
AND startsWith = '{{ startsWith }}'
AND showLimit = '{{ showLimit }}'
AND fromName = '{{ fromName }}';

INSERT examples

Create a service, with standard create modifiers as query parameters. See the Service component definition for what is required to be provided in the request body.

INSERT INTO snowflake.service.services (
data__name,
data__status,
data__compute_pool,
data__spec,
data__external_access_integrations,
data__query_warehouse,
data__comment,
data__is_async_job,
data__auto_resume,
data__min_ready_instances,
data__min_instances,
data__max_instances,
data__database_name,
data__schema_name,
data__auto_suspend_secs,
database_name,
schema_name,
endpoint,
createMode
)
SELECT
'{{ name }}' --required,
'{{ status }}',
'{{ compute_pool }}' --required,
'{{ spec }}' --required,
'{{ external_access_integrations }}',
'{{ query_warehouse }}',
'{{ comment }}',
{{ is_async_job }},
{{ auto_resume }},
{{ min_ready_instances }},
{{ min_instances }},
{{ max_instances }},
'{{ database_name }}',
'{{ schema_name }}',
{{ auto_suspend_secs }},
'{{ database_name }}',
'{{ schema_name }}',
'{{ endpoint }}',
'{{ createMode }}'
;

REPLACE examples

Create a (or alter an existing) service. Even if the operation is just an alter, the full property set must be provided.

REPLACE snowflake.service.services
SET
data__name = '{{ name }}',
data__status = '{{ status }}',
data__compute_pool = '{{ compute_pool }}',
data__spec = '{{ spec }}',
data__external_access_integrations = '{{ external_access_integrations }}',
data__query_warehouse = '{{ query_warehouse }}',
data__comment = '{{ comment }}',
data__is_async_job = {{ is_async_job }},
data__auto_resume = {{ auto_resume }},
data__min_ready_instances = {{ min_ready_instances }},
data__min_instances = {{ min_instances }},
data__max_instances = {{ max_instances }},
data__database_name = '{{ database_name }}',
data__schema_name = '{{ schema_name }}',
data__auto_suspend_secs = {{ auto_suspend_secs }}
WHERE
database_name = '{{ database_name }}' --required
AND schema_name = '{{ schema_name }}' --required
AND name = '{{ name }}' --required
AND endpoint = '{{ endpoint }}' --required
AND data__name = '{{ name }}' --required
AND data__compute_pool = '{{ compute_pool }}' --required
AND data__spec = '{{ spec }}' --required
RETURNING
status;

DELETE examples

Delete a service with the given name. If ifExists is used, the operation will succeed even if the object does not exist. Otherwise, there will be a failure if the drop is unsuccessful.

DELETE FROM snowflake.service.services
WHERE database_name = '{{ database_name }}' --required
AND schema_name = '{{ schema_name }}' --required
AND name = '{{ name }}' --required
AND endpoint = '{{ endpoint }}' --required
AND ifExists = '{{ ifExists }}';

Lifecycle Methods

Create and execute a job service. See the JobService component definition for what is required to be provided in the request body.

EXEC snowflake.service.services.execute_job_service 
@database_name='{{ database_name }}' --required,
@schema_name='{{ schema_name }}' --required,
@endpoint='{{ endpoint }}' --required
@@json=
'{
"name": "{{ name }}",
"status": "{{ status }}",
"compute_pool": "{{ compute_pool }}",
"spec": "{{ spec }}",
"external_access_integrations": "{{ external_access_integrations }}",
"query_warehouse": "{{ query_warehouse }}",
"comment": "{{ comment }}",
"is_async_job": {{ is_async_job }}
}';