snowflake.core.service.ServiceResource¶
- class snowflake.core.service.ServiceResource(name: str, collection: ServiceCollection)¶
- Bases: - SchemaObjectReferenceMixin[- ServiceCollection]- Represents a reference to a Snowflake Snowpark Container Service. - With this service reference, you can create, alter, and fetch information about services, as well as perform certain actions on them. - Attributes - database¶
- The DatabaseResource this reference belongs to. 
 - fully_qualified_name¶
- Return the fully qualified name of the object this reference points to. 
 - root¶
- The Root object this reference belongs to. 
 - Methods - create_or_alter(service: Service) None¶
- Create a service in Snowflake or alter one if it already exists. - Parameters:
- service (Service) – The - Serviceobject, together with the- Service’s properties: name, compute_pool, spec; auto_resume, min_instances, max_instances, status, external_access_integrations, query_warehouse, comment are optional.
 - Examples - Creating or updating a service in Snowflake: - >>> service_parameters = Service( ... name="your-service-name", ... compute_pool="my_cp" ... spec=ServiceSpecStageFile(stage="stage_name", spec_file=spec_file), ...) >>> services = root.databases["my_db"].schemas["my_schema"].services >>> services["your-service-name"].create_or_alter(service_parameters) 
 - create_or_alter_async(service: Service) PollingOperation[None]¶
- An asynchronous version of - create_or_alter().- Refer to - PollingOperationfor more information on asynchronous execution and the return type.
 - drop(if_exists: bool | None = None) None¶
- Drop the service. - Parameters:
- if_exists (bool, optional) – Check the existence of this service before dropping it. Default is - None, which is equivalent to- False.
 - Examples - Deleting a service using its reference: - >>> service_reference.drop() 
 - drop_async(if_exists: bool | None = None) PollingOperation[None]¶
- An asynchronous version of - drop().- Refer to - PollingOperationfor more information on asynchronous execution and the return type.
 - fetch() Service¶
- Fetch the details of a service. - Examples - Fetching a service using its reference: - >>> service_reference.fetch() 
 - fetch_async() PollingOperation[Service]¶
- An asynchronous version of - fetch().- Refer to - PollingOperationfor more information on asynchronous execution and the return type.
 - get_containers() Iterator[ServiceContainer]¶
- Show the containers corresponding to this service. - Examples - Showing the containers of a service using its reference: - >>> service_reference.get_containers() 
 - get_containers_async() PollingOperation[Iterator[ServiceContainer]]¶
- An asynchronous version of - get_containers().- Refer to - PollingOperationfor more information on asynchronous execution and the return type.
 - get_endpoints() Iterator[ServiceEndpoint]¶
- Show the endpoints corresponding to this service. - Examples - Showing the endpoints of a service using its reference: - >>> service_reference.get_endpoints() 
 - get_endpoints_async() PollingOperation[Iterator[ServiceEndpoint]]¶
- An asynchronous version of - get_endpoints().- Refer to - PollingOperationfor more information on asynchronous execution and the return type.
 - get_instances() Iterator[ServiceInstance]¶
- Show the instances corresponding to this service. - Examples - Showing the instances of a service using its reference: - >>> service_reference.get_instances() 
 - get_instances_async() PollingOperation[Iterator[ServiceInstance]]¶
- An asynchronous version of - get_instances().- Refer to - PollingOperationfor more information on asynchronous execution and the return type.
 - get_roles() Iterator[ServiceRole]¶
- Show the roles corresponding to this service. - Examples - Showing the roles of a service using its reference: - >>> service_reference.get_roles() 
 - get_roles_async() PollingOperation[Iterator[ServiceRole]]¶
- An asynchronous version of - get_roles().- Refer to - PollingOperationfor more information on asynchronous execution and the return type.
 - get_service_logs(instance_id: str, container_name: str, num_lines: int | None = None) str¶
- Get the service logs of the service. - Parameters:
- instance_id (str) – Instance ID of the service. 
- container_name (str) – Container name of the service. 
- num_lines (int, optional) – Number of the most recent log lines to retrieve. 
 
 - get_service_status()returns the- instance_idand- container_nameas a part of its results.- Examples - Getting the logs of a service using its reference: - >>> service_reference.get_service_logs(instance_id="instance_id", container_name="container_name") 
 - get_service_logs_async(instance_id: str, container_name: str, num_lines: int | None = None) PollingOperation[str]¶
- An asynchronous version of - get_service_logs().- Refer to - PollingOperationfor more information on asynchronous execution and the return type.
 - get_service_status(timeout: int = 0) list[dict[str, Any]]¶
- The - get_service_status()method is deprecated; use- get_containers()instead.- Get the status of the service. - timeout: int
- Number of seconds to wait for the service to reach a steady state (for example, READY) before returning the status. If the service does not reach steady state within the specified time, Snowflake returns the current state. - If not specified or - 0, Snowflake returns the current state immediately.- Default: - 0seconds.
 - Getting the status of a service using its reference: - >>> service_reference.get_service_status() - Getting the status of a service using its reference with a timeout: - >>> service_reference.get_service_status(timeout=10) 
 - get_service_status_async(timeout: int = 0) PollingOperation[list[dict[str, Any]]]¶
- The - get_service_status_async()method is deprecated; use- get_containers_async()instead.- An asynchronous version of - get_service_status().- Refer to - PollingOperationfor more information on asynchronous execution and the return type.
 - iter_grants_of_service_role(role_name: str) Iterator[GrantOf]¶
- Show the grants of the service role associated with this service. - Parameters:
- role_name (str) – Name of the service role. 
 - Examples - Showing the grants of the service role associated with a service using the service reference: - >>> service_reference.iter_grants_of_service_role("all_endpoints_usage") 
 - iter_grants_of_service_role_async(role_name: str) PollingOperation[Iterator[GrantOf]]¶
- An asynchronous version of - iter_grants_of_service_role().- Refer to - PollingOperationfor more information on asynchronous execution and the return type.
 - iter_grants_to_service_role(role_name: str) Iterator[ServiceRoleGrantTo]¶
- Show the grants given to the service role associated with this service. - Parameters:
- role_name (str) – Name of the service role. 
 - Examples - Showing the grants given to the service role associated with a service using the service reference: - >>> service_reference.iter_grants_to_service_role("all_endpoints_usage") 
 - iter_grants_to_service_role_async(role_name: str) PollingOperation[Iterator[ServiceRoleGrantTo]]¶
- An asynchronous version of - iter_grants_to_service_role().- Refer to - PollingOperationfor more information on asynchronous execution and the return type.
 - resume(if_exists: bool | None = None) None¶
- Resumes the service. - Parameters:
- if_exists (bool, optional) – Check the existence of this service before resuming it. Default is - None, which is equivalent to- False.
 - Examples - Resuming a service using its reference: - >>> service_reference.resume() 
 - resume_async(if_exists: bool | None = None) PollingOperation[None]¶
- An asynchronous version of - resume().- Refer to - PollingOperationfor more information on asynchronous execution and the return type.
 - suspend(if_exists: bool | None = None) None¶
- Suspend the service. - Parameters:
- if_exists (bool, optional) – Check the existence of this service before suspending it. Default is - None, which is equivalent to- False.
 - Examples - Suspending a service using its reference: - >>> service_reference.suspend() 
 - suspend_async(if_exists: bool | None = None) PollingOperation[None]¶
- An asynchronous version of - suspend().- Refer to - PollingOperationfor more information on asynchronous execution and the return type.