4.3.1. Adapters

API for working with adapters.

class axonius_api_client.api.adapters.adapters.Adapters(auth, **kwargs)[source]

Bases: axonius_api_client.api.mixins.ModelMixins

API model for working with adapters.

Examples

Create a client using axonius_api_client.connect.Connect

Notes

All methods use the Core instance by default, but you can work with another instance by passing the name of the instance to node.

Supplying unknown keys/values for configurations will throw an error showing the valid keys/values.

Parameters

auth (axonius_api_client.auth.models.Model) –

get(get_clients=False)[source]

Get all adapters on all nodes.

Examples

Create a client using axonius_api_client.connect.Connect.

Get all adapters

>>> adapters = client.adapters.get()

Get details of each adapter

>>> for adapter in adapters:
...     print(adapter["name"])  # name of adapter
...     print(adapter["node_name"])  # name of node adapter is running on
Parameters

get_clients (bool) –

Return type

typing.List[dict]

get_by_name_basic(value)[source]

Get an adapter by name.

Parameters

value (str) –

Return type

dict

get_by_name(name, node=None, get_clients=False)[source]

Get an adapter by name on a single node.

Examples

Create a client using axonius_api_client.connect.Connect.

Get an adapter by name

>>> adapter = client.adapters.get_by_name(name="aws")

Get details of adapter

>>> adapter['status']               # overall adapter status
'success'
>>> adapter['cnx_count_total']      # total connection count
1
>>> adapter['cnx_count_broken']     # broken connection count
0
>>> adapter['cnx_count_working']    # working connection count
1

Get details of each connection of the adapter

>>> for cnx in adapter["cnx"]:
...     print(cnx["working"])  # bool if connection is working or not
...     print(cnx["error"])  # error from last fetch attempt
...     print(cnx["config"])  # configuration of connection
...     print(cnx["id"])  # ID of connection
...     print(cnx["uuid"])  # UUID of connection
Parameters
  • name (str) – name of adapter to get

  • node (typing.Optional[str]) – name of node to get adapter from

  • get_clients (bool) –

Raises

NotFoundError – when no node found or when no adapter found on node

Return type

dict

config_get(name, node=None, config_type='generic')[source]

Get the advanced settings for an adapter.

Examples

Create a client using axonius_api_client.connect.Connect.

Get the generic advanced settings for an adapter

>>> config = client.adapters.config_get(name="aws")

Get the adapter specific advanced settings for an adapter

>>> config = client.adapters.config_get(name="aws", config_type="specific")

Get the discovery advanced settings for an adapter

>>> config = client.adapters.config_get(name="aws", config_type="discovery")

See the current values of a configuration

>>> import pprint
>>> pprint.pprint(config['config'])
{'connect_client_timeout': 300,
 'fetching_timeout': 43200,
 'last_fetched_threshold_hours': 48,
 'last_seen_prioritized': False,
 'last_seen_threshold_hours': 24,
 'minimum_time_until_next_fetch': None,
 'realtime_adapter': False,
 'user_last_fetched_threshold_hours': 48,
 'user_last_seen_threshold_hours': None}

Investigate the schema and current values of a configuration

>>> for setting, info in config['schema'].items():
...    current_value = config['config'][setting]
...    title = info['title']
...    description = info.get('description')
...    print(f"name of setting: {setting}")
...    print(f"  title of setting in GUI: {title}")
...    print(f"  description of setting: {description}")
...    print(f"  current value of setting: {current_value}")
Parameters
  • name (str) – name of adapter to get advanced settings of

  • node (typing.Optional[str]) – name of node to get adapter from [NO LONGER USED]

  • config_type (str) – One of generic, specific, or discovery

Return type

dict

config_update(name, node=None, config_type='generic', **kwargs)[source]

Update the advanced settings for an adapter.

Examples

Create a client using axonius_api_client.connect.Connect.

Update the generic advanced settings for the adapter

>>> updated_config = client.adapters.config_update(
...     name="aws", last_seen_threshold_hours=24
... )

Update the adapter specific advanced settings

>>> updated_config = client.adapters.config_update(
...     name="aws", config_type="specific", fetch_s3=True
... )

Update the discovery advanced settings >>> # XXX currently broken!

Parameters
  • name (str) – name of adapter to update advanced settings of

  • node (typing.Optional[str]) – name of node to get adapter from

  • config_type (str) – One of generic, specific, or discovery

  • **kwargs – configuration to update advanced settings of config_type

Return type

dict

file_upload(name, field_name, file_name, file_content, file_content_type=None, node=None)[source]

Upload a file to a specific adapter on a specific node.

Examples

Create a client using axonius_api_client.connect.Connect.

Upload content as a file for use in a connection later

>>> content = "content of file to upload"
>>> file_uuid = client.adapters.file_upload(
...     name="aws",
...     file_name="name_of_file",
...     file_content=content,
...     field_name="name_of_field",
... )
>>> file_uuid
{'uuid': '5f78b7dee33f0a113700a6fc', 'filename': 'name_of_file'}
Parameters
  • name (str) – name of adapter to upload file to

  • node (typing.Optional[str]) – name of node to to upload file to

  • field_name (str) – name of field (should match configuration schema key name)

  • file_name (str) – name of file to upload

  • file_content (typing.Union[str, bytes]) – content of file to upload

  • file_content_type (typing.Optional[str]) – mime type of file to upload

Return type

dict

file_upload_path(path, **kwargs)[source]

Upload the contents of a file to a specific adapter on a specific node.

Examples

Create a client using axonius_api_client.connect.Connect.

Upload a file for use in a connection later

>>> file_uuid = client.adapters.file_upload_path(name="aws", path="test.csv")
>>> file_uuid
{'uuid': '5f78b674e33f0a113700a6fa', 'filename': 'test.csv'}
Parameters
_init(**kwargs)[source]

Post init method for subclasses to use for extra setup.

_get(get_clients=True, filter=None)[source]

Private API method to get all adapters.

Parameters
Return type

typing.List[axonius_api_client.api.json_api.adapters.Adapter]

_config_update(adapter_name, config_name, config)[source]

Private API method to set advanced settings for an adapter.

Parameters
  • adapter_name (str) – raw name of the adapter i.e. aws_adapter

  • config_name (str) –

    name of advanced settings to set

    • AdapterBase for generic advanced settings

    • AwsSettings for adapter specific advanced settings (name changes per adapter)

    • DiscoverySchema for discovery advanced settings

  • new_config – the advanced configuration key value pairs to set

  • config (dict) –

Return type

str

_get_basic()[source]

Pass.

Return type

axonius_api_client.api.json_api.generic.Metadata

_config_get(adapter_name)[source]

Private API method to set advanced settings for an adapter.

Parameters

adapter_name (str) – raw name of the adapter, i.e. ‘aws_adapter’

Return type

axonius_api_client.api.json_api.adapters.AdapterSettings

_file_upload(adapter_name, node_id, field_name, file_name, file_content, file_content_type=None, file_headers=None)[source]

Private API method to upload a file to a specific adapter on a specifc node.

Parameters
  • adapter_name (str) – raw name of the adapter i.e. aws_adapter

  • node_id (str) – ID of node running adapter

  • field_name (str) – name of field (should match configuration schema key name)

  • file_name (str) – name of file to upload

  • file_content (typing.Union[bytes, str]) – content of file to upload

  • file_content_type (typing.Optional[str]) – mime type of file to upload

  • file_headers (typing.Optional[dict]) – headers to use for file

Return type

dict

_get_labels()[source]

Pass.

Return type

axonius_api_client.api.json_api.adapters.CnxLabels

__init__(auth, **kwargs)

Mixins for API Models.

Parameters
__repr__()

Show info for this model object.

Return type

str

__str__()

Show info for this model object.

Return type

str

LOG: logging.Logger

Logger for this object.

auth

axonius_api_client.auth.models.Mixins authentication object.

http

axonius_api_client.http.Http client to use to send requests,