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 using axonius_api_client.connect.Connect and assume apiobj is either client.devices or client.users

>>> apiobj = client.devices  # or client.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
Return type

int

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 method

  • labels (typing.List[str]) – tags to remove

Return type

int

_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

typing.List[str]

_add(labels, ids)[source]

Direct API method to add labels/tags to assets.

Parameters
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
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

__repr__()

Show info for this model object.

Return type

str

__str__()

Show info for this model object.

Return type

str

_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