{"id":7945,"library":"assisted-service-client","title":"Assisted Service Client","description":"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`.","status":"active","version":"2.52.0.post11","language":"en","source_language":"en","source_url":"https://github.com/openshift/assisted-service","tags":["openshift","kubernetes","installation","api-client","automation"],"install":[{"cmd":"pip install assisted-service-client","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"symbol":"ApiClient","correct":"from assisted_service_client import ApiClient"},{"symbol":"Configuration","correct":"from assisted_service_client import Configuration"},{"note":"Specific API classes are found under the `assisted_service_client.api` submodule.","symbol":"InstallerApi","correct":"from assisted_service_client.api.installer_api import InstallerApi"},{"note":"Common exception for API errors.","symbol":"ApiException","correct":"from assisted_service_client import ApiException"}],"quickstart":{"code":"import assisted_service_client\nimport os\n\n# Configure API client with host and authentication token\n# In a production environment, these should come from secure sources (e.g., environment variables, secrets manager)\nconfiguration = assisted_service_client.Configuration(\n    host=os.environ.get(\"ASSISTED_SERVICE_URL\", \"http://localhost:8090/api/assisted-install/v2\"),\n    access_token=os.environ.get(\"ASSISTED_SERVICE_TOKEN\", \"\") # Replace with your actual token\n)\n\n# Create an API client instance\napi_client = assisted_service_client.ApiClient(configuration)\n\ntry:\n    # Instantiate a specific API (e.g., InstallerApi for cluster management)\n    installer_api = assisted_service_client.api.installer_api.InstallerApi(api_client)\n\n    # Example: List all clusters\n    clusters = installer_api.list_clusters()\n    print(f\"Successfully retrieved {len(clusters)} clusters.\")\n    for cluster in clusters:\n        print(f\"- Cluster ID: {cluster.id}, Name: {cluster.name}, Status: {cluster.status}\")\n\nexcept assisted_service_client.ApiException as e:\n    print(f\"API Error: {e.status} - {e.reason}\\nBody: {e.body}\")\n    if e.status == 401:\n        print(\"Authentication failed. Please check your ASSISTED_SERVICE_TOKEN.\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")\nfinally:\n    # Close the API client when done to release resources\n    api_client.close()\n","lang":"python","description":"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."},"warnings":[{"fix":"Always ensure your `assisted-service-client` version is compatible with the Assisted Service instance you are targeting. It is best practice to upgrade the client to the latest version alongside major/minor updates of the Assisted Service.","message":"As a generated client, API method signatures and data models can change significantly between `assisted-service-client` versions, especially following updates to the underlying Assisted Service API. Mismatches between client and service versions can lead to `AttributeError` for missing fields/methods or `ApiException` due to invalid requests/responses.","severity":"breaking","affected_versions":"All versions, whenever the Assisted Service API changes."},{"fix":"Ensure `assisted_service_client.Configuration(access_token='YOUR_TOKEN')` is correctly set with a valid token. Refer to the Assisted Service documentation for how to obtain and manage API tokens.","message":"The client requires proper authentication, typically via an `access_token`. Incorrect, expired, or missing tokens will result in `ApiException` with a 401 Unauthorized status.","severity":"gotcha","affected_versions":"All versions."},{"fix":"Verify that `assisted_service_client.Configuration(host='YOUR_SERVICE_URL')` points to the correct and accessible Assisted Service API endpoint (e.g., typically ends with `/api/assisted-install/v2`). Check network connectivity and firewall rules.","message":"Providing an incorrect `host` URL in the `Configuration` can lead to connection errors (`requests.exceptions.ConnectionError`) if the service is unreachable, or `ApiException` (e.g., 404 Not Found) if the base path is wrong or the endpoint does not exist.","severity":"gotcha","affected_versions":"All versions."}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure the `Configuration` object's `access_token` parameter is set with a valid, active authentication token (e.g., an OpenShift pull secret or a generated API key). Example: `Configuration(access_token='your_actual_token')`.","cause":"The API request was made without a valid or unexpired authentication token, or the provided token does not have sufficient permissions.","error":"assisted_service_client.ApiException: (401) Reason: Unauthorized"},{"fix":"Verify that the `host` parameter in `assisted_service_client.Configuration` points to the correct and reachable URL of the Assisted Service. Check network connectivity from your client to the service endpoint and ensure no firewalls are blocking access.","cause":"The Python client could not establish a connection to the specified `host` URL, often due to an incorrect URL, network issues, DNS problems, or the Assisted Service being down/inaccessible.","error":"requests.exceptions.ConnectionError: HTTPSConnectionPool(...) Max retries exceeded with url: ..."},{"fix":"Upgrade your `assisted-service-client` package to the latest available version using `pip install --upgrade assisted-service-client`. This ensures your client models and API definitions are synchronized with the most recent service API.","cause":"Your `assisted-service-client` library version is older than the Assisted Service instance it's interacting with. The service API has introduced new fields or methods that your client's data models or API classes do not yet recognize.","error":"AttributeError: 'Cluster' object has no attribute 'new_field'"}]}