4.4.4. Tags¶
API for working with tags for assets.
- class axonius_api_client.api.assets.labels.Labels(parent)[source]¶
Bases:
ChildMixins
API for working with tags for the parent asset type.
Examples
Create a
client
usingaxonius_api_client.connect.Connect
and assumeapiobj
is eitherclient.devices
orclient.users
>>> apiobj = client.devices # or client.users
See also
Device assets
axonius_api_client.api.assets.devices.Devices
User assets
axonius_api_client.api.assets.users.Users
- Parameters
parent (
axonius_api_client.api.mixins.Model
) –
- get()[source]¶
Get all known tags. :rtype:
typing.List
[str
]Examples
Get all known tags for this asset type
>>> apiobj.labels.get() ['tag1', 'tag2']
- get_expirable_names()[source]¶
Get all known expirable tags. :rtype:
typing.List
[str
]Examples
Get all known expirable tags for this asset type
>>> apiobj.labels.get_expirable_names() ['tag1', 'tag2']
- add(rows, labels)[source]¶
Add tags to assets.
Examples
Get some assets to tag
>>> rows = apiobj.get(wiz_entries=[{'type': 'simple', 'value': 'name equals test'}]) >>> len(rows) 1
>>> apiobj.labels.add(rows=rows, labels=['api tag 1', 'api tag 2']) 1
- Parameters
rows (
typing.Union
[typing.List
[dict
],str
]) – list of internal_axon_id strs or list of assets returned from a get methodlabels (
typing.List
[str
]) – tags to add
- Return type
- remove(rows, labels)[source]¶
Remove tags from assets.
Examples
Get some assets to un-tag
>>> rows = apiobj.get(wiz_entries=[{'type': 'simple', 'value': 'name equals test'}]) >>> len(rows) 1
>>> apiobj.labels.remove(rows=rows, labels=['api tag 1', 'api tag 2']) 1
- Parameters
rows (
typing.List
[dict
]) – list of internal_axon_id strs or list of assets returned from a get methodlabels (
typing.List
[str
]) – tags to remove
- Return type
- _get_ids(rows)[source]¶
Get the internal_axon_id from a list of assets.
- Parameters
rows (
typing.Union
[typing.List
[dict
],str
]) – list of internal_axon_id strs or list of assets returned from a get method- Return type
- _add(labels, ids)[source]¶
Direct API method to add labels/tags to assets.
- Parameters
labels (
typing.List
[str
]) – tags to processids (
typing.List
[str
]) – internal_axon_id of assets to add tags to
- Return type
axonius_api_client.api.json_api.generic.IntValue
- _get()[source]¶
Direct API method to get all known labels/tags.
- Return type
typing.List
[axonius_api_client.api.json_api.generic.StrValue
]
- _get_expirable_names()[source]¶
Direct API method to get all known expirable labels/tags.
- Return type
typing.List
[axonius_api_client.api.json_api.generic.StrValue
]
- _remove(labels, ids)[source]¶
Direct API method to remove labels/tags from assets.
- Parameters
labels (
typing.List
[str
]) – tags to processids (
typing.List
[str
]) – internal_axon_id of assets to remove tags from
- Return type
axonius_api_client.api.json_api.generic.IntValue
- __init__(parent)¶
Mixins model for API child objects.
- Parameters
parent (
axonius_api_client.api.mixins.Model
) – parent API model of this child
- _init(parent)¶
Post init method for subclasses to use for extra setup.
- Parameters
parent (
axonius_api_client.api.mixins.Model
) – parent API model of this child