4.2.1. Admin API Wrapper

class wsapiwrapper.admin.AdminApiWrapper(baseurl: str, tokenstr: str, endpoint_one: str, endpoint_many: str)[source]

Wraps calls to the wsbackend Admin API

The Admin API is intended for administrators.

__init__(baseurl: str, tokenstr: str, endpoint_one: str, endpoint_many: str)[source]

Constructor for AdminApiWrapper

Parameters
  • baseurl (str) – Websensor backend URL.

  • adminapi_client_id (str) – Client ID API access credential. A long base64 string e.g. SVpP…kO8

  • adminapi_client_secret (str) – Client Secret API access credential. A long base64 string e.g. CM300…1aVB

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

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

delete(id: int)[source]

Make a DELETE request to the Tag endpoint.

Parameters

id (int) – ID of the resource to delete

get(id: int)dict[source]

Make a GET request to endpoint_single.

Returns

A dictionary representing a tag object.

Return type

dict

get_many(offset: int = 0, limit: int = None, **kwargs)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.

Returns

A list of resource dictionaries

Return type

list

wsapiwrapper.admin.api_url(baseurl: str)str[source]
wsapiwrapper.admin.request_admin_token(baseurl: str, adminapi_client_id: str, adminapi_client_secret: str)str[source]

Request a token from the token endpoint.

A client_id and client_secret are exchanged for a token. This uses the OAuth Client Credentials flow:

  1. A POST request is made to the token endpoint of wsbackend.

  2. Client ID and Client Secret are validated.

  3. Access token is returned.

Returns

token received from wsbackend.

Return type

str