4.2.2.5. Location

class wsapiwrapper.consumer.location.LocationWrapper(baseurl: str, tokenstr: str)[source]

Wraps location endpoints of the Consumer API.

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

Constructor for ConsumerApiWrapper

Parameters
  • baseurl (str) – Websensor backend base URL.

  • tokenstr (str) – OAuth access token.

delete(location_id: int)int[source]

Delete one location by ID.

Makes a DELETE request to the Location endpoint. To delete locations the current user must have scanned the tag.

Parameters

location_id (int) – Location ID to delete.

Returns

HTTP status code.

Return type

int

get(location_id: int)dict[source]

Get one location by its ID.

Makes a GET request to the Location endpoint.

Parameters

location_id (int) – Location ID to retrieve.

Returns

Location dictionary returned by the API.

Return type

dict

get_list(tagserial: str, starttime: str = None, endtime: str = None)list[source]

Get a list of locations for a tag.

Optionally a time window can be specified, so that only location timestamps within that window will be returned.

Makes a GET request to the Locations endpoint.

Parameters
  • tagserial – Base64 serial identifying a tag.

  • starttime – Start datetime as an ISO-8601 string.

  • endtime – End datetime as an ISO-8601 string.

Returns

A list of Location dictionaries.

Return type

list

patch(location_id: int, description: str)dict[source]

Change description of an existing location.

The current user must have scanned the tag.

Parameters
  • location_id (int) – Location ID to modify.

  • description – New tag location (e.g. above the fireplace).

Returns

Location dictionary returned by the API.

Return type

dict

post(capturesample_id: int, description: str)dict[source]

Annotate a sample with location.

The timestamp of a location corresponds to that of its parent sample. All samples can be traced back to the tag that created them. This must have been scanned by the current user.

Parameters
  • capturesample_id (int) – Capturesample ID to annotate.

  • description (str) – The tag location e.g. under the stairs.

Returns

Location dictionary returned by the API and converted from JSON.

Return type

dict

static process_status(status_code: int, desc='')None[source]

Raise an exception in response to an HTTP error code.

Parameters

status_codeHTTP status code.

exception wsapiwrapper.consumer.location.NoScanOnTagException[source]

Location data cannot be modified on tags that have not been scanned.

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.