4.3.1. Adapters

API for working with adapters.

class axonius_api_client.api.adapters.adapters.Adapters(auth, log_level='debug', **kwargs)[source]

Bases: 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.model.AuthModel) –

  • log_level (typing.Union[int, str]) –

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, optional) – Include the connections and schemas in the response

Returns:

list of adapter metadata

Return type:

t.List[dict]

get_by_name_basic(value)[source]

Get an adapters basic metadata (including display title) by name.

Parameters:

value (str) – short name of adapter (i.e. aws)

Returns:

adapter basic metadata

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 (Optional[str], optional) – name of node to get adapter from

  • get_clients (bool, optional) – Include the connections and schemas in the response

Raises:

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

Returns:

adapter metadata

Return type:

dict

get_basic_cached()[source]

Get basic adapter data cached.

Return type:

axonius_api_client.api.json_api.adapters.adapters_list_response.AdaptersList

get_basic()[source]

Get basic adapter data.

Return type:

axonius_api_client.api.json_api.adapters.adapters_list_response.AdaptersList

get_fetch_history_filters()[source]

Get filter values for use in adapters history.

Return type:

axonius_api_client.api.json_api.adapters.fetch_history_filters_response.AdapterFetchHistoryFilters

get_fetch_history(generator=False, **kwargs)[source]

Get adapter fetch history.

Parameters:
Returns:

t.Generator or list of history event models

Return type:

t.Union[HIST_GEN, HIST_LIST]

get_fetch_history_generator(adapters=None, connection_labels=None, clients=None, instances=None, statuses=None, discoveries=None, exclude_realtime=False, relative_unit_type='day', relative_unit_count=None, absolute_date_start=None, absolute_date_end=None, sort_attribute=None, sort_descending=False, search=None, filter=None, page_sleep=0, page_size=2000, row_start=0, row_stop=None, log_level='debug', history_filters=None, request_obj=None)[source]

Get adapter fetch history.

Notes

Use ~ prefix for regex in adapters, connection_labels, clients, instances, statuses

Parameters:
  • adapters (t.Optional[PatternLikeListy], optional) – Filter for records with matching adapters

  • connection_labels (t.Optional[PatternLikeListy], optional) – Filter for records with connection labels

  • clients (t.Optional[PatternLikeListy], optional) – Filter for records with matching client ids

  • instances (t.Optional[PatternLikeListy], optional) – Filter for records with matching instances

  • statuses (t.Optional[PatternLikeListy], optional) – Filter for records with matching statuses

  • discoveries (t.Optional[PatternLikeListy], optional) – Filter for records with matching discovery IDs

  • exclude_realtime (bool, optional) – Exclude records for realtime adapters

  • relative_unit_type (UnitTypes, optional) – Type of unit to use when supplying relative_unit_count

  • relative_unit_count (Optional[int], optional) – Filter records for the past N units of relative_unit_type

  • absolute_date_start (Optional[datetime.datetime], optional) – Filter records that are after this date. (overrides relative values)

  • absolute_date_end (Optional[datetime.datetime], optional) – Filter records that are before this date. (defaults to now if start but no end)

  • sort_attribute (Optional[str], optional) – Sort records based on this attribute

  • sort_descending (bool, optional) – Sort sort_attribute descending or ascending

  • page_sleep (int, optional) – Sleep N seconds between pages

  • page_size (int, optional) – Get N records per page

  • row_start (int, optional) – Start at row N

  • row_stop (Optional[int], optional) – Stop at row N

  • log_level (t.Union[int, str], optional) – log level to use for paging

  • history_filters (Optional[AdapterFetchHistoryFilters], optional) – response from get_fetch_history_filters() (will be fetched if not supplied)

  • request_obj (Optional[AdapterFetchHistoryRequest], optional) – Request object to use for options

  • search (typing.Optional[str]) –

  • filter (typing.Optional[str]) –

Return type:

typing.Generator[axonius_api_client.api.json_api.adapters.fetch_history_response.AdapterFetchHistory, None, None]

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 (Optional[str], optional) – name of node to get adapter from [NO LONGER USED]

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

Returns:

configuration for config_type

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
... )
Parameters:
  • name (str) – name of adapter to update advanced settings of

  • node (Optional[str], optional) – name of node to get adapter from

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

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

Returns:

updated configuration for 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 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

Returns:

with keys ‘filename’ and ‘uuid’

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:
Returns:

with keys ‘filename’ and ‘uuid’

Return type:

dict

_init(**kwargs)[source]

Post init method for subclasses to use for extra setup.

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

Private API method to get all adapters.

Parameters:
  • get_clients (bool, optional) – Include the connections and schemas in the response

  • filter (Optional[str], optional) – unk

Returns:

t.List of Adapter dataclass models

Return type:

t.List[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

  • config (dict) – the advanced configuration key value pairs to set

Returns:

dataclass model containing response

Return type:

SystemSettings

_get_basic()[source]

Get the basic metadata for all adapters.

Returns:

dataclass model containing response

Return type:

AdaptersList

_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’

Returns:

dataclass model containing response

Return type:

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 (t.Union[bytes, str]) – content of file to upload

  • file_content_type (Optional[str], optional) – mime type of file to upload

  • file_headers (Optional[dict], optional) – headers to use for file

Returns:

containing filename and uuid keys

Return type:

dict

_get_labels()[source]

Get labels metadata for all connections.

Returns:

dataclass model containing response

Return type:

CnxLabels

_get_fetch_history_filters()[source]

Get filter values for use in adapters history.

Return type:

axonius_api_client.api.json_api.adapters.fetch_history_filters_response.AdapterFetchHistoryFilters

_get_fetch_history(request_obj=None)[source]

Get adapter fetch history.

Parameters:

request_obj (typing.Optional[axonius_api_client.api.json_api.adapters.fetch_history_request.AdapterFetchHistoryRequest]) –

Return type:

typing.List[axonius_api_client.api.json_api.adapters.fetch_history_response.AdapterFetchHistory]

LOG: logging.Logger = None

Logger for this object.

__init__(auth, log_level='debug', **kwargs)

Mixins for API Models.

Parameters:
  • auth (axonius_api_client.auth.model.AuthModel) – object to use for auth and sending API requests

  • log_level (typing.Union[int, str]) – logging level to use for this objects logger

  • **kwargs – passed to _init()

__repr__()

Show info for this model object.

Return type:

str

__str__()

Show info for this model object.

Return type:

str

_init_auth(**kwargs)

Post init method for subclasses to use for overriding auth setup.

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.