laceworksdk.http_session

HttpSession class for package HTTP functions.

Module Contents

Classes

HttpSession

Package HttpSession class.

class laceworksdk.http_session.HttpSession(account, subaccount, api_key, api_secret, base_domain)[source]

Package HttpSession class.

property account

Returns the current account for the session.

property subaccount

Returns the current subaccount for the session.

get(uri, params=None, **kwargs)[source]

A method to build a GET request to interact with Lacework.

Parameters:
  • uri (str) – uri to send the HTTP GET request to

  • params (dict) – parameters for the HTTP request

  • kwargs (Any) – passed on to the requests package

Returns:

a Requests response object

Return type:

requests.models.Response

Raises:

ApiError if anything but expected response code is returned

get_pages(uri, params=None, **kwargs)[source]

A method to build a GET request that yields pages of data returned by Lacework.

Parameters:
  • uri (str) – uri to send the HTTP GET request to

  • params (dict) – parameters for the HTTP request

  • kwargs (Any) – passed on to the requests package

Yields:

Generator – a generator that yields pages of data

Raises:

ApiError if anything but expected response code is returned

get_data_items(uri, params=None, **kwargs)[source]

A method to build a GET request that yields individual objects as returned by Lacework.

Parameters:
  • uri (str) – uri to send the HTTP GET request to

  • params (dict) – parameters for the HTTP request

  • kwargs (Any) – passed on to the requests package

Yields:

Generator – a generator that yields pages of data

Raises:
  • ApiError if anything but expected response code is returned

  • MalformedResponse if the returned response does not contain a top-level dictionary with an "data" key.

patch(uri, data=None, json=None, **kwargs)[source]

A method to build a PATCH request to interact with Lacework.

Parameters:
  • uri (str) – uri to send the HTTP POST request to

  • data (Any) – data to be sent in the body of the request

  • json (dict) – data to be sent in JSON format in the body of the request

  • kwargs (Any) – passed on to the requests package

Returns:

a Requests response object

Return type:

requests.models.Response

Raises:

ApiError if anything but expected response code is returned

post(uri, data=None, json=None, **kwargs)[source]

A method to build a POST request to interact with Lacework.

Parameters:
  • uri (str) – uri to send the HTTP POST request to

  • data (Any) – data to be sent in the body of the request

  • json (dict) – data to be sent in JSON format in the body of the request

  • kwargs (Any) – passed on to the requests package

Returns:

a Requests response object

Return type:

requests.models.Response

Raises:

ApiError if anything but expected response code is returned

put(uri, data=None, json=None, **kwargs)[source]

A method to build a PUT request to interact with Lacework.

Parameters:
  • uri (str) – uri to send the HTTP POST request to

  • data (Any) – data to be sent in the body of the request

  • json (dict) – data to be sent in JSON format in the body of the request

  • kwargs (Any) – passed on to the requests package

Returns:

a Requests response object

Return type:

requests.models.Response

Raises:

ApiError if anything but expected response code is returned

delete(uri, data=None, json=None, **kwargs)[source]

A method to build a DELETE request to interact with Lacework.

Parameters:
  • uri (str) – uri to send the HTTP POST request to

  • data (Any) – data to be sent in the body of the request

  • json (dict) – data to be sent in JSON format in the body of the request

  • kwargs (Any) – passed on to the requests package

Returns:

a Requests response object

Return type:

requests.models.Response

Raises:

ApiError if anything but expected response code is returned