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.
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
>>> import axonius_api_client as axonapi >>> connect_args: dict = axonapi.get_env_connect() >>> client: axonapi.Connect = axonapi.Connect(**connect_args) >>> apiobj: axonapi.api.assets.AssetMixin = client.devices >>> # or client.users or client.vulnerabilities >>> 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
>>> import axonius_api_client as axonapi >>> connect_args: dict = axonapi.get_env_connect() >>> client: axonapi.Connect = axonapi.Connect(**connect_args) >>> apiobj: axonapi.api.assets.AssetMixin = client.devices >>> # or client.users or client.vulnerabilities >>> apiobj.labels.get_expirable_names() ['tag1', 'tag2']
- add(rows, labels, invert_selection=False)[source]¶
Add tags to assets.
Examples
Get some assets to tag
>>> import axonius_api_client as axonapi >>> connect_args: dict = axonapi.get_env_connect() >>> client: axonapi.Connect = axonapi.Connect(**connect_args) >>> apiobj: axonapi.api.assets.AssetMixin = client.devices >>> # or client.users or client.vulnerabilities >>> data = apiobj.get(wiz_entries=[{'type': 'simple', 'value': 'name equals test'}]) >>> len(data) 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 addinvert_selection (
bool
) – True=add tags to assets that ARE NOT supplied in rows; False=add tags to assets that ARE supplied in rows
- Return type
- _add(labels, ids, include=True)[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 toinclude (
bool
) – True=add tags to assets that ARE supplied in rows; False=add tags to assets that ARE NOT supplied in rows
- Return type
axonius_api_client.api.json_api.generic.IntValue
- remove(rows, labels, invert_selection=False)[source]¶
Remove tags from assets.
Examples
Get some assets to un-tag >>> import axonius_api_client as axonapi >>> connect_args: dict = axonapi.get_env_connect() >>> client: axonapi.Connect = axonapi.Connect(**connect_args) >>> apiobj: axonapi.api.assets.AssetMixin = client.devices >>> # or client.users or client.vulnerabilities >>> data = apiobj.get(wiz_entries=[{‘type’: ‘simple’, ‘value’: ‘name equals test’}]) >>> len(data) 1 >>> apiobj.labels.remove(rows=data, 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 removeinvert_selection (
bool
) – True=remove tags from assets that ARE NOT supplied in rows; False=remove tags from assets that ARE supplied in rows
- Return type
- _remove(labels, ids, include=True)[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 frominclude (
bool
) – True=remove tags from assets that ARE supplied in rows; False=remove tags from assets that ARE NOT supplied in rows
- Return type
axonius_api_client.api.json_api.generic.IntValue
- static _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
- _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
]
-
LOG:
logging.Logger
= None¶ Logger for this object.
- __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
-
auth:
axonius_api_client.auth.model.AuthModel
= None¶ Authentication model with bound Http object to use for requests.
-
http:
axonius_api_client.http.Http
= None¶ Http object to use for requests.
-
parent:
axonius_api_client.api.mixins.Model
= None¶ Parent API model of this child.