cozify.cloud_api
¶
Module for handling Cozify Cloud API 1:1 functions
- cozify.cloud_api.cloudBase¶
API endpoint including version
- Type
str
Module Contents¶
Functions¶
|
GET method for calling hub API. |
|
PUT method for calling hub API. For rest of kwargs parameters see get() |
|
PUT method for calling hub API. For rest of kwargs parameters see get() |
|
Raw Cloud API call, request OTP to be sent to account email address. |
|
Raw Cloud API call, request cloud token with email address & OTP. |
|
1:1 implementation of hub/lan_ip |
|
1:1 implementation of user/hubkeys |
|
1:1 implementation of user/refreshsession |
|
1:1 implementation of 'hub/remote' |
|
Backend for get & post |
Attributes¶
- cozify.cloud_api.cloudBase = https://cloud2.cozify.fi/ui/0.2¶
- cozify.cloud_api.get(call, headers=None, base=cloudBase, no_headers=False, json_output=True, raw=False, **kwargs)[source]¶
GET method for calling hub API.
- Parameters
call (str) – API path to call after the base, needs to include leading /.
headers (dict) – Header dictionary to pass along to the request.
base (str) – Base path to call from API instead of global base. Defaults to cloudBase.
no_headers (bool) – Allow calling without headers or data.
json_output (bool) – Assume API will return json and decode it.
- cozify.cloud_api.post(call, headers=None, data=None, params=None, base=cloudBase, no_headers=False, raw=False, **kwargs)[source]¶
PUT method for calling hub API. For rest of kwargs parameters see get()
- Parameters
call (str) – API path to call after apiPath, needs to include leading /.
headers (dict) – Header dictionary to pass along to the request.
data (dict) – Payload dictionary to POST.
params (dict) – Payload dictionary to include as GET parameters.
base (str) – Base path to call from API instead of global base. Defaults to cloudBase.
no_headers (bool) – Allow calling without headers or data.
- cozify.cloud_api.put(call, headers=None, data=None, base=cloudBase, no_headers=False, raw=False, **kwargs)[source]¶
PUT method for calling hub API. For rest of kwargs parameters see get()
- Parameters
call (str) – API path to call after apiPath, needs to include leading /.
headers (dict) – Header dictionary to pass along to the request.
data (dict) – Payload dictionary to PUT.
base (str) – Base path to call from API instead of global base. Defaults to cloudBase.
no_headers (bool) – Allow calling without headers or data.
- cozify.cloud_api.requestlogin(email, **kwargs)[source]¶
Raw Cloud API call, request OTP to be sent to account email address.
- Parameters
email (str) – Email address connected to Cozify account.
- cozify.cloud_api.emaillogin(email, otp, **kwargs)[source]¶
Raw Cloud API call, request cloud token with email address & OTP.
- Parameters
email (str) – Email address connected to Cozify account.
otp (int) – One time passcode.
- Returns
cloud token
- Return type
str
- cozify.cloud_api.lan_ip(**kwargs)[source]¶
1:1 implementation of hub/lan_ip
This call will fail with an APIError if the requesting source address is not the same as that of the hub, i.e. if they’re not in the same NAT network. The above is based on observation and may only be partially true.
- Returns
List of Hub ip addresses.
- Return type
list
- cozify.cloud_api.hubkeys(cloud_token, **kwargs)[source]¶
1:1 implementation of user/hubkeys
- Parameters
cloud_token (str) –
- Returns
Map of hub_id: hub_token pairs.
- Return type
dict
- cozify.cloud_api.refreshsession(cloud_token, **kwargs)[source]¶
1:1 implementation of user/refreshsession
- Parameters
cloud_token (str) –
- Returns
New cloud remote authentication token. Not automatically stored into state.
- Return type
str
- cozify.cloud_api.remote(apicall, headers, data=None)[source]¶
1:1 implementation of ‘hub/remote’
- Parameters
apicall (str) – Full API call that would normally go directly to hub, e.g. ‘/cc/1.6/hub/colors’
headers (dict) – Headers to send with request. Must contain Authorization & X-Hub-Key data.
data (str) – json string to use as payload, changes method to PUT.
- Returns
Requests response object.
- Return type
requests.response
- cozify.cloud_api._call(call, method, headers, params=None, data=None, no_headers=False, json_output=True, raw=False, **kwargs)[source]¶
Backend for get & post
- Parameters
call (str) – Full API path to call.
method (function) – requests.get|put function to use for call.
headers (dict) – Header dictionary to pass along to the request.
params (dict) – Params dictionary to POST.
data (dict) – Payload dictionary to PUT.
no_headers (bool) – Allow calling without headers, data or args.
json_output (bool) – Assume API will return json and decode it.
raw (bool) – Do no decoding, return requests.response object.