10.4.3.1. Rest API Client

class pytan3.api_clients.Rest(http_client, auth_method, ver_check=True, lvl='info')[source]

Bases: pytan3.api_clients.ApiClient

Client for making REST API requests to Tanium for versions 7.3 and above.

__init__(http_client, auth_method, ver_check=True, lvl='info')[source]

Constructor.

Parameters:
log = None

logging.Logger – Log for this object.

__str__()[source]

Show object info.

Returns:str
__repr__()[source]

Show object info.

Returns:str
__call__(endpoint, method='get', data=None, timeout=30, **kwargs)[source]

Get response of request of method to /api/v$version/$endpoint?$params.

Parameters:
  • endpoint (str) – Endpoint of rest api
  • method (str, optional) –

    Method to use in request.

    Defaults to: “get”.

  • data (str, optional) –

    Body to send in request.

    Defaults to: None

  • timeout (int, optional) –

    Response timeout.

    Defaults to: 30.

  • **kwargs
    cause (str):
    String to explain purpose of request.

    Defaults to: “”.

    headers (dict):
    Headers to send in request.

    Defaults to: {}.

    version (int):
    Version of REST API.

    Defaults to: 2.

    params (dict):
    Params to send encoded in URL.

    Defaults to: {}.

Returns:

requests.Response

classmethod get_name()[source]

Get the ref name of this object for use by load().

Returns:str
classmethod get_type()[source]

Get the ref type of this object for use by load_type().

Returns:str
classmethod get_version_req()[source]

Get the min, max, and eq version requirements of this class.

Notes

Dict can specify keys: “vmin”, “vmax”, “veq”.

This class method gets called by pytan3.utils.versions.version_check_obj_req() to perform version checks.

Returns:dict
rest_version

Get the API version to use when communicating with the REST API.

Returns:int
auth_method

Get the AuthMethod for this object.

Returns:pytan3.auth_methods.AuthMethod
http_client

Get the HTTP Client for this object.

Returns:pytan3.http_client.HttpClient
url

Get the URL from ApiClient.http_client.

Returns:str
version

Get the platform version from ApiClient.config.

Returns:str
config

Get the deserialized config.json from ApiClient.url.

Returns:dict
info

Get the deserialized info.json from ApiClient.url.

Returns:dict
_abc_impl = <_abc_data object>