4.5.1. Enforcements

API for working with enforcements.

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

Bases: axonius_api_client.api.mixins.ModelMixins, axonius_api_client.api.mixins.PagingMixinsObject

API working with enforcements.

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) –

delete(rows)[source]

Delete an enforcement by name.

Parameters

rows (typing.List[dict]) –

Return type

str

property router

Router for this API model.

Return type

axonius_api_client.api.routers.Router

_delete(ids)[source]

Delete objects by internal axonius IDs.

Parameters

ids (typing.List[str]) –

Return type

str

_create(name, main, success=None, failure=None, post=None, triggers=None)[source]

Create an enforcement set.

Parameters
Return type

str

_get(query=None, row_start=0, page_size=0)[source]

Get a page of enforcements.

Parameters
Return type

dict

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

get(generator=False, **kwargs)

Get objects for a given query using paging.

Parameters
  • generator (bool) – return an iterator for objects that will yield rows as they are fetched

  • **kwargs – passed to get_generator()

Return type

typing.Union[typing.Generator[dict, None, None], typing.List[dict]]

get_by_name(value, **kwargs)

Get an object by name.

Parameters
  • value (str) – name of object ot get

  • **kwargs – passed to get()

Return type

dict

get_by_uuid(value, **kwargs)

Get an object by UUID.

Parameters
  • value (str) – uuid of object to get

  • **kwargs – passed to get()

Return type

dict

get_generator(query=None, max_rows=None, max_pages=None, page_size=2000, page_start=0, page_sleep=0, **kwargs)

Get saved queries using paging.

Parameters
  • query (typing.Optional[str]) – mongo query to filter objects to return

  • max_rows (typing.Optional[int]) – only return N objects

  • max_pages (typing.Optional[int]) – only return N pages

  • page_size (int) – fetch N objects per page

  • page_start (int) – start at page N

  • page_sleep (int) – sleep for N seconds between each page fetch

Return type

typing.Generator[dict, None, None]

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