4.5.2. Actions

API for running actions.

class axonius_api_client.api.enforcements.actions.RunAction(auth, **kwargs)[source]

Bases: axonius_api_client.api.mixins.ModelMixins

API for running actions.

Notes

Future versions of API client 4.x branch will be expanded quite a bit to make it user friendly. The current incarnation should be considered BETA until such time.

Parameters

auth (axonius_api_client.auth.models.Model) –

property router

Router for this API model.

Return type

axonius_api_client.api.routers.Router

_get()[source]

Direct API method to get all actions.

Return type

typing.List[str]

_deploy(action_name, ids, file_uuid, file_name, params=None)[source]

Deploy an action.

Parameters
  • name – name of action to deploy

  • ids (typing.List[str]) – internal_axon_ids of devices to process

  • uuid – UUID of binary to use in deployment

  • filename – filename of binary to use in deployment

  • params (typing.Optional[str]) – parameters to pass to action

  • action_name (str) –

  • file_uuid (str) –

  • file_name (str) –

Return type

dict

_shell(action_name, ids, command)[source]

Run an action.

Parameters
  • action_name (str) – name of action to run

  • ids (typing.List[str]) – internal_axon_ids of devices to process

  • command (str) – command to run

Return type

dict

_upload_file(name, content, content_type=None, headers=None)[source]

Upload a file to the system for use in deployment and get the UUID of new file.

Parameters
Return type

str

__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

_build_err_msg(response, error=None, exc=None)

Build an error message from a response.

Parameters
Return type

str

_check_response_code(response, error_status=True)

Check the status code of a response.

Parameters
  • responserequests.Response object to check

  • error_status (bool) – throw exc if response status code is bad

Raises

ResponseNotOk – if response has a status code that is an error and error_status is True

_check_response_json(response, error_json_bad_status=True, error_json_invalid=True, uses_api_response=False)

Check the text body of a response is JSON.

Parameters
Raises
  • JsonInvalid – if error_json_invalid is True and response has invalid json

  • JsonError – if error_json_bad_status is True and response is a json dict that has a non-empty error key or a status key that == error

Return type

typing.Any

_init(**kwargs)

Post init method for subclasses to use for extra setup.

request(path, method='get', raw=False, is_json=True, empty_ok=False, error_status=True, error_json_bad_status=True, error_json_invalid=True, **kwargs)

Send a REST API request.

Parameters
  • path (str) – path to use in request

  • method (str) – method to use in request

  • raw (bool) – return the raw response object

  • is_json (bool) – return the response as deserialized json or just return the text body

  • error_status (bool) – throw error if response has a bad status code

  • error_json_bad_status (bool) – throw error if json response has non-empty error key

  • error_json_invalid (bool) – throw error if response can not be deserialized into json

  • **kwargs – Passed to axonius_api_client.http.Http.__call__()

  • empty_ok (bool) –

Return type

typing.Any

Returns

requests.Response or str or dict or int or list