Exemplo n.º 1
0
from formant.sdk.cloud.v1 import Client as FormantClient

if __name__ == "__main__":
    # to authenticate set FORMANT_EMAIL and FORMANT_PASSWORD
    # environment variables for an existing service account
    # NOTE: the account must have administrator access to ingest data
    fclient = FormantClient()

    device_id = "572f5ff3-63e9-4687-b242-c0d8a4891d80"
    timestamp = 1609804800000
    tags = {"location": "sf"}

    # Ingests one of each datapoint type:
    # - numeric
    # - text
    # - json
    # - numeric set
    # - bitset
    # - battery
    # - health
    # - location
    # - point cloud
    # - file
    # - image
    # - video
    ingest_result = fclient.ingest(
        {
            "items": [
                {
                    "deviceId": device_id,
                    "name": "engine_temp",
Exemplo n.º 2
0
from formant.sdk.cloud.v1 import Client as FormantClient

if __name__ == "__main__":
    # to authenticate set FORMANT_EMAIL and FORMANT_PASSWORD
    # environment variables for an existing service account
    fclient = FormantClient()

    result = fclient.query_devices({"tags": {"location": "sf"}})
    print(result)
Exemplo n.º 3
0
import datetime

from formant.sdk.cloud.v1 import Client as FormantClient

if __name__ == "__main__":
    # to authenticate set FORMANT_EMAIL and FORMANT_PASSWORD
    # environment variables for an existing service account
    fclient = FormantClient(admin_api="http://localhost:8080", )

    print("Uploading file ...")
    result = fclient.upload_file({
        "path": "/tmp/test.log",
    })
    print(result)
Exemplo n.º 4
0
from formant.sdk.cloud.v1 import Client as FormantClient

if __name__ == "__main__":
    # to authenticate set FORMANT_EMAIL and FORMANT_PASSWORD
    # environment variables for an existing service account
    fclient = FormantClient()

    device_id = "572f5ff3-63e9-4687-b242-c0d8a4891d80"

    # query by tags
    query_result = fclient.query({
        "start": "2021-01-01T00:00:00.000Z",
        "end": "2021-01-10T00:00:00.000Z",
        "tags": {
            "location": ["sf"]
        },
    })

    # query by device
    query_result = fclient.query({
        "start": "2021-01-01T00:00:00.000Z",
        "end": "2021-01-10T00:00:00.000Z",
        "deviceIds": [device_id],
    })
    print(query_result)
Exemplo n.º 5
0
from formant.sdk.cloud.v1 import Client as FormantClient

if __name__ == "__main__":
    # to authenticate set FORMANT_EMAIL and FORMANT_PASSWORD
    # environment variables for an existing service account
    fclient = FormantClient()

    device_id = "572f5ff3-63e9-4687-b242-c0d8a4891d80"

    # query last known value of all streams from a device
    # within a given period
    query_result = fclient.query_stream_current_value({
        "start": "2021-01-01T00:00:00.000Z",
        "end": "2021-01-10T00:00:00.000Z",
        "deviceIds": [device_id],
    })
    print(query_result)

    # query last known value of all streams matching a name
    query_result = fclient.query_stream_current_value({
        "names": ["engine_temp"],
    })

    # query last known value of all streams matching a tag
    query_result = fclient.query_stream_current_value({
        "tags": {
            "location": ["sf"]
        },
    })
Exemplo n.º 6
0
if __name__ == "__main__":
    # to authenticate set FORMANT_EMAIL and FORMANT_PASSWORD
    # environment variables for an existing service account
    """Example query params (only start and end time are required):
        {
            start: "2021-01-01T01:00:00.000Z",
            end: "2021-01-01T02:00:00.000Z",
            deviceIds: ["99e8ee37-0a27-4a11-bba2-521facabefa3"],
            names: ["engine_temp"],
            types: ["numeric"],
            tags: {"location":["sf","la"]},
            notNames: ["speed"],
        }
    """

    fclient = FormantClient()

    device_id = "572f5ff3-63e9-4687-b242-c0d8a4891d80"

    # query by tags
    tag_query_result = fclient.query({
        "start": "2021-01-01T00:00:00.000Z",
        "end": "2021-01-10T00:00:00.000Z",
        "tags": {
            "location": ["sf"]
        },
    })
    print(tag_query_result)

    # query by device
    device_query_result = fclient.query({
Exemplo n.º 7
0
import datetime

from formant.sdk.cloud.v1 import Client as FormantClient


def get_current_isodate():
    return datetime.datetime.now(tz=datetime.timezone.utc).isoformat()


if __name__ == "__main__":
    # to authenticate set FORMANT_EMAIL and FORMANT_PASSWORD
    # environment variables for an existing service account
    fclient = FormantClient()

    device_id = "43be1d4b-2178-46b8-81b5-61cf865e264b"

    print("Sending command ...")
    command_result = fclient.create_command({
        "deviceId": device_id,
        "command": "start_recording",
        "parameter": {
            "scrubberTime": get_current_isodate()
        },
    })
    print(command_result)
    print("\n")

    # file id obtained by uploading to formant file storage
    # see files.py for an example
    file_id = "ffcd8958-6f94-4b0d-b9a9-3cbf105c3df5"