Responses

The tempoiq.response module contains functionality for working with responses from the TempoIQ API. A Response object is ultimately returned by every method call to the tempoiq.client.Client class. Its “data” attribute will vary according to the type of response expected from the API.

class tempoiq.response.Response(resp, session)[source]

Represents responses from the TempoIQ API. The Response object has several useful attributes after it is created:

  • successful: whether the overall request was successful (see below)

  • status: the HTTP status code for the API call

  • reason: the explanation for the HTTP status code

  • data: an object or list of objects representing the data from the API

  • error: a string if the API returned any additional error information

    in the response body, None otherwise

Note: data will be None if the status code was anything other than 200.

Note: successful has 3 possible values defined as constants in this module, SUCCESS, FAILURE, and PARTIAL. A PARTIAL value can occur during a multi-write if some datapoints fail to write. The error attribute in that case will be a JSON encoded string of errors for each datapoint. The response object does not derserialize that error (there could be other circumstances where the error is not JSON encoded), so if that case, error handling code surrounding multi-writes should decode the error attribute with the json library if it wants to attempt error recovery.

Parameters:resp (obj) – a response object from the requests library
exception tempoiq.response.ResponseException(response)[source]

Exception class for HTTP responses