Owners and permissions

Platform and agent permissions are assigned to users or groups. An agent owner can read the agent even without an explicit read permission. Write, administration, and risk-management rights must be granted through permission entries.

In the following examples, client is an AgentManagementClient created as described in The main AgentManagementClient class. The users and groups in permission entries must already exist.

Granting access to a platform

A platform administrator can update its permission entries. This example adds read access for an existing group while retaining the other entries.

platform = client.get_platform("production")
settings = platform.get_settings()
settings.raw["permissions"].append({
    "group": "agent-readers",
    "read": True,
    "write": False,
    "admin": False,
})
settings.save()

Use either user or group in an entry. Keep at least one explicit platform administrator.

Granting agent permissions

Agent permissions include read, write, admin, and manageRisk. This example gives a group access to read the agent and manage its risk assessment.

agent = client.get_agent("production", "support-agent")
settings = agent.get_settings()
settings.get_raw()["permissions"].append({
    "group": "risk-reviewers",
    "read": True,
    "write": False,
    "admin": False,
    "manageRisk": True,
})
settings.save()

Changing the permission list requires agent administration rights. Replace an existing entry when updating its permissions instead of appending a second entry for the same user or group.

Assigning an owner

An owner is a user or a group. An agent editor can transfer ownership.

settings = agent.get_settings()
settings.get_raw()["configuration"]["agentOwner"] = {
    "group": "agent-operators"
}
settings.save()

Use {"user": "login"} for a user owner, or None to remove the owner. The new owner can read the agent. The server preserves the previous owner’s read access with an explicit permission entry; other explicit rights remain unchanged.

Setting platform defaults

settings = platform.get_settings()
settings.raw["defaultAgentOwner"] = {"group": "agent-operators"}
settings.raw["defaultAgentPermissions"] = [{
    "group": "agent-readers",
    "read": True,
    "write": False,
    "admin": False,
    "manageRisk": False,
}]
settings.save()

defaultAgentOwner sets the owner for new agents. It does not change the owner of existing agents. defaultAgentPermissions is combined with each agent’s explicit permission entries, so changing it also affects access to existing agents on the platform.

For user and group administration, see Users and groups.

Reference documentation

Classes

dataikuapi.agentmanagement.platform.PlatformSettings(...)

The settings of an Agent Management platform.

dataikuapi.agentmanagement.agent.AgentSettings(...)

The settings of a monitored agent.

Functions

get_agent(platform_id, agent_id)

Returns a handle to an agent.

get_platform(platform_id)

Returns a handle to an Agent Management platform.

get_raw()

Returns the raw settings of this agent.

get_settings()

Returns the settings of this agent.

get_settings()

Returns the settings of this platform.

save()

Saves the settings of this agent, checking fetchedRevision read by get_settings.

save()

Saves the settings of this platform, using fetchedRevision to detect concurrent changes.