Resource

class fabman.resource.Resource(requester: Requester, attributes: dict)

Resource object returned by the API. Provides access to all API calls that operate on a single Resource.

Initialize the Object. Stores the requester method to interact with the API for further calls

Parameters:
  • requester (Requester) – The Requester object to make requests with

  • attributes (dict) – The attributes to initialize this object with

delete(**kwargs) Response

Deletes the resource. WARNING: THIS CANNOT BE UNDONE. All future API calls from this resource will fail.

Calls:

“DELETE /resources/{id}” <https://fabman.io/api/v1/documentation#/resources/deleteResourcesId>

Returns:

response information of call

Return type:

requests.Response

delete_bridge(**kwargs) Response

Delete the bridge that is currently connected to this resource. If no bridge is currently connected, this will do nothing.

Calls:

“DELETE /resources/{id}/bridge” <https://fabman.io/api/v1/documentation#/resources/deleteResourcesIdBridge>

Returns:

response information of call

Return type:

requests.Response

get_bridge(**kwargs) ResourceBridge

Get the bridge that is currently connected to this resource. If no bridge is connected, this will return an empty list.

Calls:

“GET /resources/{id}/bridge” <https://fabman.io/api/v1/documentation#/resources/getResourcesIdBridge>

Returns:

ResourceBridge object with information on the bridge

Return type:

fabman.resource.ResourceBridge

get_bridge_api_key(**kwargs) ResourceBridgeApiKey

Get the API key for the bridge that is currently connected to this resource. For most users, this will return a 204 code with an empty body. Only superusers or users who have created a custom bridge should be able to access this endpoint.

Calls:

“GET /resources/{id}/bridge/api-key” <https://fabman.io/api/v1/documentation#/resources/getResourcesIdBridgeApikey>

Returns:

response information of call

Return type:

ResourceBridgeApiKey

switch_on(**kwargs) Response

Switch on the resource. Requires “code” field to be in the data packet. Does not seem to work without the proper code, which is undocumented.

Calls:

“POST /resources/{id}/switch-on” <https://fabman.io/api/v1/documentation#/resources/postResourcesIdBridgeSwitchon>

Returns:

response information of call

Return type:

requests.Response

update(**kwargs) None

Update the resource.

Calls:

“PUT /resources/{id}” <https://fabman.io/api/v1/documentation#/resources/putResourcesId>

Returns:

None – attributes are updated in place

Return type:

None

ResourceBridge

class fabman.resource.ResourceBridge(requester: Requester, attributes: dict)

Simple class to hold Bridge information for a Bridge connected to a resource. Further used to issue commands to the bridge

Initialize the Object. Stores the requester method to interact with the API for further calls

Parameters:
  • requester (Requester) – The Requester object to make requests with

  • attributes (dict) – The attributes to initialize this object with

update(**kwargs) None

Update the bridge object on the server. Returns the updated bridge object. Updates all information in place.

Calls:

“PUT /resources/{resource_id}/bridge” <https://fabman.io/api/v1/documentation#/resources/putResourcesIdBridge>

Returns:

None – attributes are updated in place

Return type:

None