4.6.2. Instances

API for working with instances.

class axonius_api_client.api.system.instances.Instances(auth, log_level='debug', **kwargs)[source]

Bases: ModelMixins

API for working with instances.

Examples

Notes

Certain functionality is not yet exposed, please submit a feature request via support@axonius.com if you would like to:

  • Deactivate an instance

  • Connect an instance

  • Tag an instance

Parameters:
  • auth (axonius_api_client.auth.model.AuthModel) –

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

get()[source]

Get metadata about all instances. :rtype: dict

Examples

Create a client using axonius_api_client.connect.Connect

>>> data = client.instances.get()
>>> len(data)
1
get_core(key=None)[source]

Get the core instance.

Examples

Create a client using axonius_api_client.connect.Connect

>>> instance = client.instances.get_core()
>>> instance['node_name']
'Master'
>>> instance['cpu_usage']
39
>>> instance['data_disk_free_space']
74431500
>>> instance['hostname']
'builds-vm-jim-pre-3-10-1601596999-000'
>>> instance['ips']
['10.20.0.61']
>>> instance['data_disk_free_space_percent']
36.62
>>> instance['memory_free_space_percent']
1.46
>>> instance['swap_free_space_percent']
0.0
Parameters:

key (typing.Optional[str]) – key to return or just return whole object

Return type:

typing.Union[dict, str, bool, int, float]

get_collectors()[source]

Get the collector instances. :rtype: typing.List[dict]

Examples

Create a client using axonius_api_client.connect.Connect

>>> collectors = client.instances.get_collectors()
>>> len(collectors)
0
get_by_name(name, key=None)[source]

Get an instance by name.

Examples

Create a client using axonius_api_client.connect.Connect

>>> instance = client.instances.get_by_name("Master")
>>> instance['cpu_usage']
39
>>> instance['data_disk_free_space']
74431500
>>> instance['hostname']
'builds-vm-jim-pre-3-10-1601596999-000'
>>> instance['ips']
['10.20.0.61']
>>> instance['data_disk_free_space_percent']
36.62
>>> instance['memory_free_space_percent']
1.46
>>> instance['swap_free_space_percent']
0.0
Parameters:
  • name (str) – name of instance

  • key (typing.Optional[str]) – key to return or just return whole object

Return type:

typing.Union[dict, str, bool, int, float]

get_by_name_id_core(value=None, serial=True)[source]

Pass.

Parameters:
Return type:

dict

check_tunnel_feature(feature_error=True)[source]

Pass.

Parameters:

feature_error (bool) –

Return type:

bool

get_tunnels(feature_error=True)[source]

Pass.

Parameters:

feature_error (bool) –

Return type:

typing.List[axonius_api_client.api.json_api.instances.Tunnel]

get_tunnel(value=None, return_id=False, feature_error=True)[source]

Pass.

Parameters:
Return type:

typing.Union[axonius_api_client.api.json_api.instances.Tunnel, str, None]

get_tunnel_default(return_id=False, feature_error=True)[source]

Pass.

Parameters:
  • return_id (bool) –

  • feature_error (bool) –

Return type:

typing.Union[axonius_api_client.api.json_api.instances.Tunnel, str, None]

set_name(name, new_name)[source]

Set the name of an instance.

Examples

Create a client using axonius_api_client.connect.Connect

Get the current name

>>> orig_value = client.instances.get_core(key='name')
>>> orig_value
'Master'

Set a new name

>>> new_value = client.instances.set_name(name=orig_value, new_name='Temp')
>>> new_value
'Temp'

Revert back to the original name

>>> reset_value = client.instances.set_name(name=new_value, new_name=orig_value)
>>> reset_value
'Master'
Parameters:
  • name (str) – name of instance

  • new_name (str) – new name to set on instance

Return type:

str

get_hostname(name)[source]

Get the host name of an instance.

Examples

Create a client using axonius_api_client.connect.Connect

Get the hostname

>>> hostname = client.instances.get_hostname(name='Master')
>>> hostname
'builds-vm-jim-pre-3-10-1601596999-000'
Parameters:
  • name (str) – name of instance

  • value – new hostname to set on instance

Return type:

str

set_hostname(name, value)[source]

Set the hostname of an instance.

Examples

Create a client using axonius_api_client.connect.Connect

Get the current hostname

>>> orig_value = client.instances.get_hostname(name='Master')
>>> orig_value
'builds-vm-jim-pre-3-10-1601596999-000'

Set a new hostname

>>> new_value = client.instances.set_hostname(name='Master', value="hostname")
>>> new_value
"hostname"

Revert to the old hostname

>>> reset_value = client.instances.set_hostname(name='Master', value=orig_value)
>>> reset_value
'builds-vm-jim-pre-3-10-1601596999-000'
Parameters:
  • name (str) – name of instance

  • value (str) – new hostname to set on instance

Return type:

str

get_is_env_name(name)[source]

See if an instance name is being used for the environment name.

Examples

Create a client using axonius_api_client.connect.Connect

>>> client.instances.get_is_env_name(name='Master')
False

Notes

Environment name is the name shown in the banner at the bottom of the GUI.

Parameters:

name (str) – name of instance

Return type:

bool

set_is_env_name(name, enabled)[source]

Set if an instance name is being used for the environment name.

Examples

Create a client using axonius_api_client.connect.Connect

Enable an instance name as the environment name

>>> client.instances.set_is_env_name(name='Master', enabled=True)
True

Disable an instance name as the environment name

>>> client.instances.set_is_env_name(name='Master', enabled=False)
False

Notes

Environment name is the name shown in the banner at the bottom of the GUI.

Parameters:
  • name (str) – name of instance

  • enabled (bool) – enable/disable instance name as the environment name

Return type:

bool

get_central_core_mode()[source]

Get a bool that shows if a core is in central core mode. :rtype: bool

Examples

Create a client using axonius_api_client.connect.Connect

>>> client.instances.get_central_core_mode()
False
set_central_core_mode(enabled)[source]

Convert a normal core into a central core.

Examples

Create a client using axonius_api_client.connect.Connect

Enable central core mode on a core

>>> client.instances.set_central_core_mode(enabled=True)
True

Disable central core mode on a core

>>> client.instances.set_central_core_mode(enabled=False)
False
Parameters:

enabled (bool) – enable/disable central core mode

Return type:

bool

get_core_delete_mode()[source]

Get a bool that shows if a core is in central core mode. :rtype: bool

Examples

Create a client using axonius_api_client.connect.Connect

>>> client.instances.get_core_delete_mode()
True
set_core_delete_mode(enabled)[source]

Configure a normal core to delete backups after they have been restored.

Examples

Create a client using axonius_api_client.connect.Connect

Set backups to delete after restore

>>> client.instances.set_core_delete_mode(enabled=True)
True

Set backups to NOT delete after restore

>>> client.instances.set_core_delete_mode(enabled=False)
False
Parameters:

enabled (bool) – enable/disable deletion of backups after they have been restored by a core

Return type:

bool

factory_reset(reset=False)[source]

Perform a factory reset on an instance.

Notes

Can not run in test suite!

Parameters:

reset (bool) – actually do it… be careful!

Return type:

axonius_api_client.api.json_api.instances.FactoryReset

get_central_core_config()[source]

Get the current central core configuration. :rtype: dict

Examples

Create a client using axonius_api_client.connect.Connect

>>> client.instances.get_central_core_config()
{'core_delete_backups': False, 'central_core_enabled': False}
restore_from_aws_s3(key_name, bucket_name=None, access_key_id=None, secret_access_key=None, preshared_key=None, allow_re_restore=None, delete_backups=None)[source]

Perform a restore on a core from a file in an AWS S3 Bucket.

Notes

Can not run in test suite!

Parameters:
  • key_name (str) – Name of backup file from central core in [bucket_name] to restore to this core

  • bucket_name (typing.Optional[str]) – Name of bucket in S3 to get [key_name] from (Overrides Global Settings > Amazon S3 Settings > Amazon S3 bucket name)

  • access_key_id (typing.Optional[str]) – AWS Access Key ID to use to access [bucket_name] (Overrides Global Settings > Amazon S3 Settings > AWS Access Key ID)

  • secret_access_key (typing.Optional[str]) – AWS Secret Access Key to use to access [bucket_name] (Overrides Global Settings > Amazon S3 Settings > AWS Secret Access Key)

  • preshared_key (typing.Optional[str]) – Password to use to decrypt [key_name] (Overrides: Global Settings > Amazon S3 Settings > Backup encryption passphrase)

  • allow_re_restore (typing.Optional[bool]) – Restore [key_name] even if it has already been restored

  • delete_backups (typing.Optional[bool]) – Delete [key_name] from [bucket_name] after restore has finished (Overrides the current value of get_core_delete_mode())

Return type:

dict

property api_version: str

Pass.

property api_versions: List[str]

Pass.

property feature_flags: FeatureFlags

Get the feature flags for the core.

property has_saas_enabled: bool

Get the status of SAAS & tunnel support being enabled.

property has_cloud_compliance: bool

Get the status of cloud compliance module being enabled.

property trial_expiry: Optional[datetime]

Get the trial expiration date.

property trial_days_left: Optional[int]

Get the number of days left for the trial.

property license_expiry: Optional[datetime]

Get the license expiration date.

property license_days_left: Optional[int]

Get the number of days left for the license.

admin_script_upload(file_name, file_content)[source]

Upload an admin script and execute it.

Parameters:
  • file_name (str) – name to give uploaded script file

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

Return type:

dict

admin_script_upload_path(path, path_verify=True, **kwargs)[source]

Upload an admin script from a file or URL and execute it.

Parameters:
  • path (typing.Union[str, pathlib.Path]) – URL or path to file of script to upload and execute

  • **kwargs – passed to upload_script()

  • path_verify (bool) –

Return type:

dict

_get()[source]

Direct API method to get instances.

Return type:

typing.List[axonius_api_client.api.json_api.instances.Instance]

_factory_reset(approve_not_recoverable_action=False)[source]

Direct API method to do a factory reset on an instance.

Notes

Can not run in test suite!

Parameters:

approve_not_recoverable_action (bool) – actually do it… be careful!

Return type:

axonius_api_client.api.json_api.instances.FactoryReset

_delete(node_id)[source]

Direct API method to delete an instance.

Notes

Can not run in test suite!

Parameters:

node_id (str) – node id of instance

Return type:

str

_update_attrs(node_id, node_name, hostname, use_as_environment_name)[source]

Direct API method to update an instance.

Parameters:
  • node_id (str) – node id of instance

  • node_name (str) – node name of instance

  • hostname (str) – hostname of instance

  • use_as_environment_name (bool) – instance name is being used for the environment name

Return type:

str

_update_active(node_id, status)[source]

Direct API method to update an instance.

Notes

Can not run in test suite!

Parameters:
  • node_id (str) – node id of instance

  • status (bool) – enabled or disabled an instance

Return type:

str

_get_central_core_config()[source]

Direct API method to get the current central core configuration.

Return type:

axonius_api_client.api.json_api.system_settings.SystemSettings

_update_central_core_config(enabled, delete_backups)[source]

Direct API method to set the current central core configuration.

Parameters:
  • enabled (bool) – enable/disable central core mode (ignored if not True/False)

  • delete_backups (bool) – enable/disable deletion of backups on a core after resture (ignored if not True/False)

Return type:

axonius_api_client.api.json_api.system_settings.SystemSettings

_restore_aws(key_name, bucket_name=None, preshared_key=None, access_key_id=None, secret_access_key=None, delete_backups=None, allow_re_restore=None)[source]

Direct API method to perform a central core restore operation.

Notes

Can not run in test suite!

Parameters:
Return type:

axonius_api_client.api.json_api.central_core.CentralCoreRestore

_feature_flags()[source]

Direct API method to get the feature flags for the core.

Return type:

axonius_api_client.api.json_api.system_settings.FeatureFlags

_admin_script_upload(file_name, file_content, chunk_size=104857600)[source]

Upload an admin script.

Parameters:
Return type:

dict

_admin_script_execute(uuid)[source]

Upload a script file.

Parameters:

uuid (str) –

Return type:

str

_get_api_version()[source]

Pass.

Return type:

axonius_api_client.api.json_api.generic.StrValueSchema

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(**kwargs)

Post init method for subclasses to use for extra setup.

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