laceworksdk.api.crud_endpoint

Lacework API wrapper.

Module Contents

Classes

CrudEndpoint

A class used to implement CRUD create/read/update/delete functionality for Lacework API Endpoints.

class laceworksdk.api.crud_endpoint.CrudEndpoint(session, object_type, endpoint_root='/api/v2')[source]

Bases: laceworksdk.api.base_endpoint.BaseEndpoint

A class used to implement CRUD create/read/update/delete functionality for Lacework API Endpoints.

property session

Get the HttpSession instance the object is using.

create(params=None, **request_params)[source]

A method to create a new object.

Parameters:
  • params (any) – Parameters

  • request_params (any) – Request parameters.

Returns:

JSON containing the new object info

Return type:

dict

get(id=None, resource=None, **request_params)[source]

A method to get objects.

Parameters:
  • id (str) – A string representing the object ID.

  • resource (str) – The Lacework API resource type to get.

  • request_params (any) – A dictionary of parameters to add to the request.

Returns:

JSON containing the retrieved object(s)

Return type:

dict

search(json=None)[source]

A method to search objects.

See the API documentation for this API endpoint for valid fields to search against.

NOTE: While the “value” and “values” fields are marked as “optional” you must use one of them, depending on the operation you are using.

Parameters:

json (dict) –

The desired search parameters:

  • timeFilter (dict, optional): A dict containing the time frame for the search:

    • startTime (str): The start time for the search

    • endTime (str): The end time for the search

  • filters (list of dict, optional): Filters based on field contents:

    • field (str): The name of the data field to which the condition applies

    • expression (str): The comparison operator for the filter condition. Valid values are:

    ”eq”, “ne”, “in”, “not_in”, “like”, “ilike”, “not_like”, “not_ilike”, “not_rlike”, “rlike”, “gt”, “ge”, “lt”, “le”, “between”

    • value (str, optional): The value that the condition checks for in the specified field. Use this attribute when using an operator that requires a single value.

    • values (list of str, optional): The values that the condition checks for in the specified field. Use this attribute when using an operator that requires multiple values.

  • returns (list of str, optional): The fields to return

Returns:

returns a dict containing the search results

Return type:

dict

update(id=None, params=None, **request_params)[source]

A method to update an object.

Parameters:
  • id (str) – A string representing the object ID.

  • params (any) – parameters

  • request_params (dict) – Use to pass any additional parameters the API

Returns:

JSON containing the updated object info

Return type:

dict

delete(id, params=None)[source]

A method to delete an object.

Parameters:
  • id (str) – A string representing the object GUID.

  • params (any) – parameters

Returns:

a Requests response object containing the response code

Return type:

requests.models.Response