Authentication and API keys

In the following examples, client is an AgentManagementClient created as described in The main AgentManagementClient class. Authentication and key administration methods are available directly on this client.

Inspecting the current identity

auth_info = client.get_auth_info()
print(auth_info)

The permissions of an API call depend on the API key used. Personal keys use the user’s permissions. Global keys can use the permissions of their assigned groups.

Listing global keys

These administration examples require an API key with instance administration rights.

for item in client.list_global_api_keys():
    print(item.id, item.label)

Creating a key with group permissions

Use an existing group with the required platform and agent permissions.

key = client.create_global_api_key_with_groups(
    label="Agent inventory integration",
    description="Reads the production agent inventory",
    groups=["agent-readers"],
)

The returned key handle contains the new secret. Store it in your integration’s secret store. A global key does not inherit the creator’s personal favorites; use a personal key for user-specific favorites.

Using the new key

import dataikuapi

integration_client = dataikuapi.AgentManagementClient(
    host,
    api_key=key.key,
)
agents = integration_client.list_agents()

Here host is the base URL used to create the original client. For TLS settings, see The main AgentManagementClient class.

Reference documentation

Classes

dataikuapi.dss.admin.DSSGlobalApiKey(client, ...)

A global API key on the DSS instance

dataikuapi.dss.admin.DSSGlobalApiKeyListItem(...)

An item in a list of global API keys.

Functions

create_global_api_key_with_groups([label, ...])

Create a Global API key, and return a handle to interact with it.

get_auth_info()

Returns various information about the user currently authenticated using this instance of the API client.

list_agents([as_type, agent_filter])

Lists readable agents matching an optional filter.

list_global_api_keys([as_type])

List all global API keys set up on the Agent Management instance