Tags

Tags organize the agent inventory and can be used in AgentFilter selections.

In the following examples, client is an AgentManagementClient created as described in The main AgentManagementClient class.

Assigning tags to an agent

agent = client.get_agent("production", "support-agent")
settings = agent.get_settings()
tags = settings.get_raw()["configuration"].setdefault("tags", [])
if "production" not in tags:
    tags.append("production")
settings.save()

Listing tags

tags = client.list_tags()
for tag in tags:
    print(tag.name, tag.color)

The collection is a snapshot. Call list_tags() again after changes when you need a refreshed listing.

Changing a tag’s color

tag = client.list_tags().tag("production")
tag.color = "#336699"
tag.save()

Renaming or deleting a tag

These operations change the tag everywhere it is used, subject to the server’s access checks.

tag = client.list_tags().tag("production")
tag.rename("production-agents")

# Remove a different, unused organizational label from all agents:
client.list_tags().tag("obsolete-tag").delete()

tag(name) raises KeyError if the name is absent from the snapshot. The name property is read-only; use rename() to change it.

Reference documentation

Classes

dataikuapi.agentmanagement_client.AgentManagementTags(...)

A snapshot of tags used by Agent Management agents, iterable as tag objects.

dataikuapi.agentmanagement_client.AgentManagementTag(...)

An Agent Management tag.

Functions

delete()

Deletes the tag everywhere it is used.

get_agent(platform_id, agent_id)

Returns a handle to an agent.

get_raw()

Returns the raw settings of this agent.

get_settings()

Returns the settings of this agent.

list_tags()

Lists tags used by Agent Management agents.

rename(new_name)

Renames the tag everywhere it is used and updates this object's definition.

save()

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

save()

Saves the tag color.

tag(name)

Returns a tag by its name.