4.2.1.2. Capture

class wsapiwrapper.admin.capture.CaptureWrapper(baseurl: str, adminapi_token: str)[source]

Wraps calls to capture endpoints on the Admin API.

__init__(baseurl: str, adminapi_token: str)[source]

Constructor for CaptureWrapper

Parameters
  • baseurl (str) – Websensor backend URL.

  • adminapi_token (str) – Token for accessing the admin API.

  • endpoint_one (str) – Endpoint for returning one resource instance.

  • endpoint_many (str) – Endpoint for returning a list of resource instances.

get_many(offset: int = 0, limit: int = None, tag_id: int = None)list[source]

Makes a GET request to endpoint_many.

Parameters
  • offset (int) – Return captures with an ID greater than this number.

  • limit (int) – Number of captures to return.

  • tag_id (int) – Filter by tag_id (optional)

Returns

A list of capture dictionaries

Return type

list

post(capturepayload: dict)[source]

Create a capture in the database directly.

The is made from a dictionary including a list of samples, a tag_id and a user_id. The endpoint is used for testing. It removes the need to encode test vectors with wscodec (introduces a second point of failure in an external library).

Captures can be created with a known list of samples. Then samples are collected from the tag using the consumer API. These are compared with a vector of expected samples. If captures overlap slightly in time it is expected that duplicate samples are removed.

Parameters

capturepayload (dict) – Dictionary following the capture schema.

Returns: HTTP response from wsbackend.