Skip to main content
Version: Release 25.1

Digital.ai Release API Client

The ReleaseAPIClient is a client class added to the digitalai-release-sdk in Release 25.1.0. It provides an interface to interact with the Digital.ai Release server using REST API calls. The class is a wrapper around the requests library, allowing users to customize configurations such as timeouts and retries in the same way as requests.

The BaseTask class provides the get_release_api_client() method, which returns a pre-configured ReleaseAPIClient instance with the Release server URL and authentication credentials set up automatically.

Usage Example with BaseTask

Below is an example of how to use ReleaseAPIClient within a BaseTask class.

This example demonstrates how to create, update, retrieve, and delete a global variable in Digital.ai Release using public API methods

For reference, see the Global variables section on the Digital.ai Release REST API documentation

from digitalai.release.integration import BaseTask

class ReleaseAPIExample(BaseTask):
"""
Example usage of ReleaseAPIClient.

Preconditions:
- The 'Run as user' property must be set on the release.
- The executing user must have valid credentials.
"""

def execute(self) -> None:

# Obtain an instance of the Release API client
release_api_client = self.get_release_api_client()

# Step 1: Create a new global variable
global_variable = {
"id": None,
"key": "global.newVar",
"type": "xlrelease.StringVariable",
"requiresValue": "false",
"showOnReleaseStart": "false",
"value": "new value"
}
response = release_api_client.post("/api/v1/config/Configuration/variables/global", json=global_variable)
global_variable_id = response.json()["id"]
print(f"Global variable created with ID: {global_variable_id}")

# Step 2: Update the global variable
update_global_variable = response.json()
update_global_variable["value"] = "updated value"
response = release_api_client.put(f"/api/v1/config/{global_variable_id}", json=update_global_variable)
print("Global variable updated:", response.json())

# Step 3: Retrieve the updated global variable
response = release_api_client.get(f"/api/v1/config/{global_variable_id}")
print("Retrieved global variable:", response.json())

# Step 4: Delete the global variable
response = release_api_client.delete(f"/api/v1/config/{global_variable_id}")
print(f"Global variable deleted successfully. Status code: {response.status_code}")

# Close the Release API client
release_api_client.close()