Assisted Service Client

2.52.0.post11 · active · verified Thu Apr 16

The `assisted-service-client` is the official Python client library for interacting with the OpenShift Assisted Installer service. It provides a programmatic interface to deploy and manage OpenShift clusters using the Assisted Service API. The library is actively maintained and frequently updated, with versions typically aligning with the development cycle of the Assisted Service itself, meaning it receives regular, often patch-like, releases to keep pace with API evolution. The current version is `2.52.0.post11`.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the `assisted-service-client`, configure it with a host URL and authentication token (retrieved from environment variables for safety), instantiate the `InstallerApi`, and make a simple call to list existing clusters. It also includes basic error handling for common API issues.

import assisted_service_client
import os

# Configure API client with host and authentication token
# In a production environment, these should come from secure sources (e.g., environment variables, secrets manager)
configuration = assisted_service_client.Configuration(
    host=os.environ.get("ASSISTED_SERVICE_URL", "http://localhost:8090/api/assisted-install/v2"),
    access_token=os.environ.get("ASSISTED_SERVICE_TOKEN", "") # Replace with your actual token
)

# Create an API client instance
api_client = assisted_service_client.ApiClient(configuration)

try:
    # Instantiate a specific API (e.g., InstallerApi for cluster management)
    installer_api = assisted_service_client.api.installer_api.InstallerApi(api_client)

    # Example: List all clusters
    clusters = installer_api.list_clusters()
    print(f"Successfully retrieved {len(clusters)} clusters.")
    for cluster in clusters:
        print(f"- Cluster ID: {cluster.id}, Name: {cluster.name}, Status: {cluster.status}")

except assisted_service_client.ApiException as e:
    print(f"API Error: {e.status} - {e.reason}\nBody: {e.body}")
    if e.status == 401:
        print("Authentication failed. Please check your ASSISTED_SERVICE_TOKEN.")
except Exception as e:
    print(f"An unexpected error occurred: {e}")
finally:
    # Close the API client when done to release resources
    api_client.close()

view raw JSON →