Skip to content

The python library for interacting with the SensorBucket API

Notifications You must be signed in to change notification settings

sensorbucket/PythonClient

Repository files navigation

sensorbucket

SensorBucket processes data from different sources and devices into a single standardized format. An applications connected to SensorBucket, can use all devices SensorBucket supports.

Missing a device or source? SensorBucket is designed to be scalable and extendable. Create your own worker that receives data from an AMQP source, process said data and output in the expected worker output format.

Find out more at: https://developer.sensorbucket.nl/

Developed and designed by Provincie Zeeland and Pollex'

This Python package is automatically generated by the OpenAPI Generator project:

  • API version: 1.2.5
  • Package version: v1.2.5
  • Generator version: 7.9.0-SNAPSHOT
  • Build package: org.openapitools.codegen.languages.PythonClientCodegen For more information, please visit https://sensorbucket.nl

Requirements.

Python 3.7+

Installation & Usage

pip install

If the python package is hosted on a repository, you can install directly using:

pip install git+https://github.com/sensorbucket.nl/PythonClient.git

(you may need to run pip with root permission: sudo pip install git+https://github.com/sensorbucket.nl/PythonClient.git)

Then import the package:

import sensorbucket

Setuptools

Install via Setuptools.

python setup.py install --user

(or sudo python setup.py install to install the package for all users)

Then import the package:

import sensorbucket

Tests

Execute pytest to run the tests.

Getting Started

Please follow the installation procedure and then run the following:

import sensorbucket
from sensorbucket.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to https://sensorbucket.nl/api
# See configuration.py for a list of all supported configuration parameters.
configuration = sensorbucket.Configuration(
    host = "https://sensorbucket.nl/api"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure Bearer authorization: APIKey
configuration = sensorbucket.Configuration(
    access_token = os.environ["BEARER_TOKEN"]
)

# Configure API key authorization: CookieSession
configuration.api_key['CookieSession'] = os.environ["API_KEY"]

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['CookieSession'] = 'Bearer'


# Enter a context with an instance of the API client
with sensorbucket.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = sensorbucket.APIKeysApi(api_client)
    create_api_key_request = sensorbucket.CreateApiKeyRequest() # CreateApiKeyRequest |  (optional)

    try:
        # Creates a new API key for the given Tenant
        api_response = api_instance.create_api_key(create_api_key_request=create_api_key_request)
        print("The response of APIKeysApi->create_api_key:\n")
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling APIKeysApi->create_api_key: %s\n" % e)

This package has been extended with generator functions to iterate over SensorBucket pagination. If an endpoint returns a paginated response, a {method}_gen function should be available as shown below:

import sensorbucket as sb

cfg = sb.Configuration()

with sb.ApiClient(cfg) as api:
    devices = sb.DevicesApi(api)

    # This method will return a Generator which can be iterated over.
    # Every iteration returns a page of the results, the next iteration will return the next page
    # This can be used to lazily request all devices
    pages = devices.list_devices_gen()

    # A Generator can be used in a for loop
    for page in pages:
        print(page.data)

    # Or iterated over manually
    page1 = next(pages)
    page2 = next(pages)
    page3 = next(pages)

Documentation for API Endpoints

All URIs are relative to https://sensorbucket.nl/api

Class Method HTTP request Description
APIKeysApi create_api_key POST /api-keys Creates a new API key for the given Tenant
APIKeysApi get_api_key GET /api-keys/{api_key_id} Get an API Key by ID
APIKeysApi list_api_keys GET /api-keys List API Keys
APIKeysApi revoke_api_key DELETE /api-keys/{api_key_id} Revokes an API key
DevicesApi add_sensor_to_sensor_group POST /sensor-groups/{id}/sensors Add sensor to a sensor group
DevicesApi create_device POST /devices Create device
DevicesApi create_device_sensor POST /devices/{device_id}/sensors Create sensor for device
DevicesApi create_sensor_group POST /sensor-groups Create sensor group
DevicesApi delete_device DELETE /devices/{id} Delete device
DevicesApi delete_device_sensor DELETE /devices/{device_id}/sensors/{sensor_code} Delete sensor
DevicesApi delete_sensor_from_sensor_group DELETE /sensor-groups/{id}/sensors/{sensor_id} Delete sensor from sensor group
DevicesApi delete_sensor_group DELETE /sensor-groups/{id} Delete sensor group
DevicesApi get_device GET /devices/{id} Get device
DevicesApi get_sensor GET /devices/{device_id}/sensors/{sensor_code} Get sensor
DevicesApi get_sensor_group GET /sensor-groups/{id} Get sensor group
DevicesApi list_device_sensors GET /devices/{device_id}/sensors List sensors device
DevicesApi list_devices GET /devices List devices
DevicesApi list_sensor_groups GET /sensor-groups List sensor groups
DevicesApi list_sensors GET /sensors List sensors
DevicesApi update_device PATCH /devices/{id} Update device properties
DevicesApi update_sensor PATCH /devices/{device_id}/sensors/{sensor_code} Update sensor properties
DevicesApi update_sensor_group PATCH /sensor-groups/{id} Update sensor group
MeasurementsApi get_datastream GET /datastreams/{id} Get datastream
MeasurementsApi list_datastreams GET /datastreams List all datastreams
MeasurementsApi query_measurements GET /measurements Query measurements
PipelinesApi create_pipeline POST /pipelines Create pipeline
PipelinesApi disable_pipeline DELETE /pipelines/{id} Disable pipeline
PipelinesApi get_pipeline GET /pipelines/{id} Get pipeline
PipelinesApi list_pipelines GET /pipelines List pipelines
PipelinesApi update_pipeline PATCH /pipelines/{id} Update pipeline
TenantsApi add_tenant_member POST /tenants/{tenant_id}/members Add a User to a Tenant as member
TenantsApi list_tenants GET /tenants Retrieves tenants
TenantsApi remove_tenant_member DELETE /tenants/{tenant_id}/members/{user_id} Removes a member from a tenant
TenantsApi update_tenant_member PATCH /tenants/{tenant_id}/members/{user_id} Update a tenant member's permissions
TracingApi list_ingresses GET /ingresses List ingresses
TracingApi list_traces GET /tracing List traces
UplinkApi process_uplink_data POST /uplinks/{pipeline_id} Process uplink message
WorkersApi create_worker POST /workers Create Worker
WorkersApi get_worker GET /workers/{id} Get worker
WorkersApi get_worker_user_code GET /workers/{id}/usercode Get the User Code for a Worker
WorkersApi list_workers GET /workers List workers
WorkersApi update_worker PATCH /workers/{id} Update worker properties

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

CookieSession

  • Type: API key
  • API key parameter name: SID
  • Location:

APIKey

  • Type: Bearer authentication

Author

[email protected]

About

The python library for interacting with the SensorBucket API

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages