App services API

On This Page

This is a wrapper class for performing various operations on igz_mgmt.AppServicesManifest without using the igz_mgmt.AppServicesManifest instance. igz_mgmt.AppServices is a syntactic sugar to igz_mgmt.AppServicesManifest.

Before you start, make sure that the igz_mgmt package is installed and that you are logged in to the system with the igz_mgmt.Client API. If not, see Control plane API.

import igz_mgmt

client = igz_mgmt.Client(access_key="some-access-id")

Many of the AppServices functions create jobs. See more details in Jobs API.

Create an app service

Example of creating a Jupyter app service:

jupyter_app_service = igz_mgmt.AppServiceSpec(
    name="jupyter-sdk-test",
    owner="admin",
    description="my-description",
    jupyter=igz_mgmt.JupyterSpec(),
)
igz_mgmt.AppServices.create_or_update(client, jupyter_app_service)

Get an app service

Find a specific app service from the app services list by app service name. The response includes the service’s spec, status and metadata.

jupyter_service = igz_mgmt.AppServices.get(client, "jupyter-sdk-test")

# service description
print(f"Jupyter description: {jupyter_service.spec.description}")

Update an app service

Example of updating an app service spec description:

jupyter_service.description = "new-description"
igz_mgmt.AppServices.create_or_update(client, jupyter_service)

Restart the app service

igz_mgmt.AppServices.restart(client, jupyter_service.name)

Scale to/from Zero

Jupyter supports scaling to/from zero based on its usage. To enable scaling to/from zero, see the following snippet. First, update the service that enables scaling to zero, then, once scaled to zero, scale it up again.

import time
from igz_mgmt import AppServiceScaleToZeroSpecPresets

# scales to zero after 1 minute of being idle
jupyter_service.spec.scale_to_zero = AppServiceScaleToZeroSpecPresets.one_minute
igz_mgmt.AppServices.create_or_update(client, jupyter_service.spec)

# give it some time to scale down...
time.sleep(2 * 60)

# wake up the service
igz_mgmt.AppServices.scale_from_zero(client, jupyter_service.spec.name)

Tip:

You can choose the window size (time to wait before scaling the service to zero) from the presets given by AppServiceScaleToZeroSpecPresets, and pass it to the scale_to_zero parameter of AppServiceSpec, as in the example above.

Disable an app service

igz_mgmt.AppServices.disable(client, jupyter_service.name)

Enable an app service

igz_mgmt.AppServices.enable(client, jupyter_service.name)

Delete an app service

igz_mgmt.AppServices.remove(client, jupyter_service.name)