Cloud SDK Reference¶
The Cloud SDK is part of the formant Python package. Instantiate a single
client, then use admin, query, and ingest for API access.
from formant.sdk.cloud import Client
client = Client()
client.query.queries.query(...)
client.admin.devices.query(...)
client.ingest_datapoints({"items": [...]})
Authenticate by setting FORMANT_EMAIL and FORMANT_PASSWORD, or pass
email and password to Client.
Client¶
- class formant.sdk.cloud.v2.client.Client(email=None, password=None, base_url='https://api.formant.io/v1')¶
Creates a client to interact with the Formant cloud. Allows you to create, update, and delete entities in your Formant organization.
from formant.sdk.cloud import Client fclient = Client()
- Parameters:
email (
str) – Formant email address. This must be provided, or theFORMANT_EMAILenvironment variable must be set. Defaults to Nonepassword (
str) – Formant password. This must be provided, or theFORMANT_PASSWORDenvironment variable must be set. Defaults to Nonebase_url (
str) – API base URL, defaults to DEFAULT_BASE_URL
- Raises:
ValueError –
email argument missing and FORMANT_EMAIL environment variable not set!ValueError –
password argument missing and FORMANT_PASSWORD environment variable not set
- ingest_datapoints(payload)¶
Ingest telemetry using a v1-compatible
{"items": [...]}payload.- Parameters:
payload (dict)
Admin API¶
Access admin endpoints via client.admin.
- class formant.sdk.cloud.v2.src.admin_api.AdminAPI(email, password, base_url, timeout=30)¶
- Parameters:
email (str)
password (str)
base_url (str)
timeout (int)
Devices¶
- class formant.sdk.cloud.v2.src.resources.devices.devices.Devices(get_client)¶
- Parameters:
get_client (Callable[[None], Any | Client | AuthenticatedClient])
- create(device)¶
Create a new device.
- Parameters:
device (Device)
- async create_async(device)¶
Create a new device.
- Parameters:
device (Device)
- generate_provisioning_token(device_id)¶
Generate a device provisioning token.
- Parameters:
device_id (str)
- async generate_provisioning_token_async(device_id)¶
Generate a device provisioning token.
- Parameters:
device_id (str)
- get_device(device_id)¶
Get a device
- Parameters:
device_id (str)
- async get_device_async(device_id)¶
Get a device
- Parameters:
device_id (str)
- get_device_configuration(device_id, desired_configuration_version)¶
Get a device configuration
- Parameters:
device_id (str)
desired_configuration_version (int)
- async get_device_configuration_async(device_id, desired_configuration_version)¶
Get a device configuration
- Parameters:
device_id (str)
desired_configuration_version (int)
- patch(device_id, partial_device)¶
Update a device
- Parameters:
device_id (str)
partial_device (PartialDevice)
- async patch_async(device_id, partial_device)¶
Update a device
- Parameters:
device_id (str)
partial_device (PartialDevice)
- post_device_configuration(device_id, device_configuration)¶
Create a device configuration
- Parameters:
device_configuration (DeviceConfiguration)
- async post_device_configuration_async(device_id, device_configuration)¶
Create a device configuration
- Parameters:
device_configuration (DeviceConfiguration)
- provision(provisioning_request)¶
Provision a device with a provisioning token and public key.
- Parameters:
provisioning_request (DeviceProvisioningRequest)
- async provision_async(provisioning_request)¶
Provision a device with a provisioning token and public key.
- Parameters:
provisioning_request (DeviceProvisioningRequest)
- query(device_query)¶
Query devices by name and/or tags
- Parameters:
device_query (DeviceQuery)
- async query_async(device_query)¶
Query devices by name and/or tags
- Parameters:
device_query (DeviceQuery)
Commands¶
- class formant.sdk.cloud.v2.src.resources.commands.commands.Commands(get_client, get_organization_id=None)¶
- create(command)¶
Creates a command
- Parameters:
command (Command)
- async create_async(command)¶
Creates a command
- Parameters:
command (Command)
- demand_device_data(device_id, start, end, organization_id=None)¶
Request on-demand data upload for a device over a time range.
- Parameters:
device_id (str)
start (datetime)
end (datetime)
organization_id (str)
- async demand_device_data_async(device_id, start, end, organization_id=None)¶
Request on-demand data upload for a device over a time range.
- Parameters:
device_id (str)
start (datetime)
end (datetime)
organization_id (str)
- query(command_query)¶
Query undelivered commands by device ID
- Parameters:
command_query (CommandQuery)
- async query_async(command_query)¶
Query undelivered commands by device ID
- Parameters:
command_query (CommandQuery)
Files¶
- class formant.sdk.cloud.v2.src.resources.files.files.Files(get_client)¶
- Parameters:
get_client (Callable[[None], Any | Client | AuthenticatedClient])
- upload(path, timeout=60)¶
Uploads a file
- Parameters:
path (str)
timeout (int)
- async upload_async(path, timeout=60)¶
Uploads a file
- Parameters:
path (str)
timeout (int)
Adapters¶
- class formant.sdk.cloud.v2.src.resources.adapters.adapters.Adapters(get_client)¶
- Parameters:
get_client (Callable[[None], Any | Client | AuthenticatedClient])
- create(adapter)¶
Creates an Adapter
- Parameters:
adapter (Adapter)
- async create_async(adapter)¶
Creates an Adapter
- Parameters:
adapter (Adapter)
- delete(id)¶
Deletes and Adapter
- Parameters:
id (str)
- async delete_async(id)¶
Deletes and Adapter
- Parameters:
id (str)
Annotations¶
- class formant.sdk.cloud.v2.src.resources.annotations.annotations.Annotations(get_client)¶
- Parameters:
get_client (Callable[[None], Any | Client | AuthenticatedClient])
- get_template(id)¶
Get an annotation
- Parameters:
id (str)
- async get_template_async(id)¶
Get an annotation
- Parameters:
id (str)
- list_templates()¶
List all annotations
- async list_templates_async()¶
List all annotations
- post(annotation)¶
Creates an annotation
- Parameters:
annotation (Annotation)
- async post_async(annotation)¶
Creates an annotation
- Parameters:
annotation (Annotation)
Events¶
- class formant.sdk.cloud.v2.src.resources.events.events.Events(get_client)¶
- Parameters:
get_client (Callable[[None], Any | Client | AuthenticatedClient])
- query(event_query)¶
Get an event
- Parameters:
event_query (EventQuery)
- async query_async(event_query)¶
Get an event
- Parameters:
event_query (EventQuery)
Views¶
- class formant.sdk.cloud.v2.src.resources.views.views.Views(get_client)¶
- Parameters:
get_client (Callable[[None], Any | Client | AuthenticatedClient])
- get(device_id)¶
Get a device layout
- Parameters:
device_id (str)
- get_all()¶
List all device layouts
- async get_all_async()¶
List all device layouts
- async get_async(device_id)¶
Get a device layout
- Parameters:
device_id (str)
- patch(id, partial_view)¶
Update a device layout
- Parameters:
id (str)
partial_view (PartialView)
- async patch_async(id, partial_view)¶
Update a device layout
- Parameters:
id (str)
partial_view (PartialView)
Interventions¶
- class formant.sdk.cloud.v2.src.resources.interventions.interventions.Interventions(get_client)¶
- Parameters:
get_client (Callable[[None], Any | Client | AuthenticatedClient])
- create_request(intervention_request)¶
Create an intervention request.
- Parameters:
intervention_request (InterventionRequest)
- async create_request_async(intervention_request)¶
Create an intervention request.
- Parameters:
intervention_request (InterventionRequest)
- create_response(intervention_response)¶
Create an intervention response.
- Parameters:
intervention_response (CreateInterventionResponse)
- async create_response_async(intervention_response)¶
Create an intervention response.
- Parameters:
intervention_response (CreateInterventionResponse)
Organizations¶
- class formant.sdk.cloud.v2.src.resources.organizations.organizations.Organizations(get_client)¶
- Parameters:
get_client (Callable[[None], Any | Client | AuthenticatedClient])
- get(organization_id)¶
Get an organization by ID.
- Parameters:
organization_id (str)
- async get_async(organization_id)¶
Get an organization by ID.
- Parameters:
organization_id (str)
Query API¶
Access query endpoints via client.query.
- class formant.sdk.cloud.v2.src.query_api.QueryAPI(email, password, base_url, timeout=30)¶
- Parameters:
email (str)
password (str)
base_url (str)
timeout (int)
Queries¶
- class formant.sdk.cloud.v2.src.resources.queries.queries.Queries(get_client)¶
- Parameters:
get_client (Callable[[None], Any | Client | AuthenticatedClient])
- query(query, app_id='formant/sdk')¶
Queries objects based on data types
- Parameters:
query (Query)
- async query_async(query, app_id='formant/sdk')¶
Queries objects based on data types
- Parameters:
query (Query)
Stream current value¶
- class formant.sdk.cloud.v2.src.resources.stream_current.stream_current.StreamCurrent(get_client)¶
- Parameters:
get_client (Callable[[None], Any | Client | AuthenticatedClient])
- query(scope_filter)¶
Gets you the current value of a stream that has been configured to cache the current value
- Parameters:
scope_filter (ScopeFilter)
- async query_async(scope_filter)¶
Gets you the current value of a stream that has been configured to cache the current value
- Parameters:
scope_filter (ScopeFilter)
Metadata¶
- class formant.sdk.cloud.v2.src.resources.metadata.metadata.Metadata(get_client)¶
- Parameters:
get_client (Callable[[None], Any | Client | AuthenticatedClient])
- list_device_ids(scope_filer)¶
List device ids
- Parameters:
scope_filer (ScopeFilter)
- async list_device_ids_async(scope_filer)¶
List device ids
- Parameters:
scope_filer (ScopeFilter)
- list_metadata(scope_filer)¶
List stream metadata
- Parameters:
scope_filer (ScopeFilter)
- async list_metadata_async(scope_filer)¶
List stream metadata
- Parameters:
scope_filer (ScopeFilter)
- list_stream_names(scope_filer)¶
List stream names
- Parameters:
scope_filer (ScopeFilter)
- async list_stream_names_async(scope_filer)¶
List stream names
- Parameters:
scope_filer (ScopeFilter)
Online devices¶
Presence¶
- class formant.sdk.cloud.v2.src.resources.presence.presence.Presence(get_client)¶
- Parameters:
get_client (Callable[[None], Any | Client | AuthenticatedClient])
- count(interval_query)¶
Tells you if data has been ingested within a certain time period
- Parameters:
interval_query (IntervalQuery)
- async count_async(interval_query)¶
Tells you if data has been ingested within a certain time period
- Parameters:
interval_query (IntervalQuery)
Count¶
- class formant.sdk.cloud.v2.src.resources.count.count.Count(get_client)¶
- Parameters:
get_client (Callable[[None], Any | Client | AuthenticatedClient])
- active_devices(active_devices_query)¶
Gets all the active devices during the timestamp
- Parameters:
active_devices_query (ActiveDevicesQuery)
- async active_devices_async(active_devices_query)¶
Gets all the active devices during the timestamp
- Parameters:
active_devices_query (ActiveDevicesQuery)
Ingest API¶
Access ingest endpoints via client.ingest.
- class formant.sdk.cloud.v2.src.ingest_api.IngestAPI(email, password, base_url, timeout=30)¶
- Parameters:
email (str)
password (str)
base_url (str)
timeout (int)
Ingest¶
- class formant.sdk.cloud.v2.src.resources.ingest.ingest.Ingest(get_client)¶
- Parameters:
get_client (Callable[[None], Any | Client | AuthenticatedClient])