iotcs.http module

class iotcs.http.HttpCredentials(tam: iotcs.trust.UnifiedTrustedAssetsManager)

Bases: object

EXP_CLAIM_DELTA = 900000
buildClientAssertion(useSharedSecret)
getAssertionCredentialsPostData()
tam
class iotcs.http.HttpResponse(responseCode=None, data=None, headers=None, response=None)

Bases: object

Parameters:
  • responseCode
  • data – b’‘, bytearray
  • headers
  • response – if not None must be instance of urllib3.response.HTTPResponse
getData()
getHeaders()
getStatus()
getVerboseStatus(method, path)
class iotcs.http.HttpSecureConnection(tam: iotcs.trust.UnifiedTrustedAssetsManager)

Bases: iotcs.transport.SecureConnection

  • messaging:long_polling_timeout_offset : Default: 100 milliseconds
    The time, in milliseconds, added to the receive timeout given by the application and then used for the client transport timeout.
  • messaging:send_receive_timeout : Default: 100 milliseconds
    Only used when long polling is disabled. The minimum time, in milliseconds, since the last send before polling the server for incoming messages if the receive buffer is empty. A larger value may cause a delay in the receipt of incoming messages, but will cause less network overhead. A value of zero will cause the library to skip the poll for incoming messages when calling receive if the receive buffer is empty.
  • messaging:http_response_timeout : Default: 15000 milliseconds
    Only used when long polling is disabled. The amount of time, in milliseconds, to wait for the server to respond to an HTTPS request.

When long polling the server closes the connection after 9 minutes.

ACCESS_TOKEN_MAX_RETRIES_PROPERTY = 'access_token_max_retries'
OAUTH_ENDPOINT = '/iot/api/v2/oauth2/token'
addAccessToken(headers)
close()

Close the connection.

delete(url, queryparams, data, headers=None, timeout=None)

Send a DELETE message.

Parameters:
  • url – the REST api resource URN
  • queryparams
  • data
  • headers
  • timeout
disconnect()

Disconnect the connection to the IoT server.

get(url, queryparams, headers=None, timeout=None)

Http GET :param url: REST resource :param queryparams: HTTP query parameters :param headers: these headers are merged with required headers and can

override a required header
Returns:response as iotcs.shared.http.HttpResponse
getAccessToken(force=False)
getLogger()
getResolvedUrl(endpoint, queryParams)
Parameters:
  • endpoint
  • queryParams
Returns:

head(url, queryparams, data, headers=None, timeout=None)
invalidateAccessToken()
patch(url, queryparams, data, headers=None, timeout=None)

Send a PATCH message.

Parameters:
  • url – the REST api resource URN
  • queryparams
  • data – the message payload in json format
  • headers
  • timeout
post(url, queryparams, data, headers=None, timeout=None)
Parameters:
  • url
  • queryparams
  • data
  • headers
  • timeout
Returns:

iotcs.shared.http.HttpResponse

postRenewAccessToken()
put(url, queryparams, data, headers=None, timeout=None)

Send a PUT message.

Parameters:
  • url – the REST api resource URN
  • queryparams
  • data – the message payload in json format
  • headers
  • timeout
renewAccessToken(retries=-1)
Returns:
Raisees:Exceptions raised by urllib3.PoolManager.request.
class iotcs.http.HttpSendReceiveImpl(secureConnection)

Bases: iotcs.transport.SendReceiveImpl

HttpSendReceiveImpl is an implementation of the DirectlyConnectedDevice.send(). The send is synchronous. Receive should be considered as a synchronous call. The implementation has a buffer for receiving request messages. If there are no messages in the buffer, the receive implementation will send a message to the server to receive any pending requests the server may have.

The size of the buffer can be configured see iotcs.device.impl.SendReceiveImpl

MIN_ACCEPT_BYTES_HEADER = 'X-min-acceptBytes'
getLogger()
longPollingOffset
post(payload, timeout=-1)

HTTP ‘POST’ payload to IOT Cloud Service :param payload: json object (pyhton object) could be list or dict :param timeout: :return:

secureConnection