Service Instances#

A service instance is a provisioned instance of a Cloud Pak for Data service, which allows you to execute and manage workloads (such as jobs and flows) through its dedicated compute resources.

The SDK provides functionality to interact with service instances on the watsonx.data integration platform.

This includes operations such as:
  • Creating Service Instances

  • Retrieving Service Instances

  • Deleting Service Instances

Note

Working with service instances is only supported on Cloud Pak for Data SaaS.

Retrieving Service Instances#

To retrieve existing service instances, use the service_instances property of the Platform class. This will return a Services object.

>>> # Returns a list of all service instances
>>> service_instances = platform.service_instances

>>> # Returns a list of the first five service instances
>>> service_instances = platform.service_instances.get_all(limit=5)

Creating Service Instances#

To create a new Service object within the watsonx.data integration platform, you can use the Platform.create_service_instance() method to instantiate the service instance.

You must specify instance_type and name. Optionally, you can also specify target and tags.

>>> service_instance = platform.create_service_instance(
...     instance_type='datastage',
...     name='My Datastage Service Instance',
...     target='us-south',
...     tags=['DatastageInstance']
... )

Retrieving Service Instances#

To retrieve existing service instances, use the ibm_watsonx_data_integration.platform.Platform.service_instances property of the ibm_watsonx_data_integration.platform.Platform class. This will return a ibm_watsonx_data_integration.cpd_models.service_model.Services object.

>>> # Returns a CollectionModel of all service instances
>>> service_instances = platform.service_instances

>>> # Returns a CollectionModel of the first five service instances
>>> service_instances = platform.service_instances.get_all(limit=5)

Deleting Service Instances#

To delete a service instance, pass the Service object you want to delete into the Platform.delete_service_instance() method to delete it.

This method returns an HTTP response indicating the status of the delete operation.

>>> service_instance = platform.service_instances.get(name='My Datastage Service Instance')
>>> platform.delete_service_instance(service_instance)