Skip to content

Generated Python SDK plugin for the Waylay queries service.

License

Notifications You must be signed in to change notification settings

waylayio/waylay-sdk-queries-py

Repository files navigation

Waylay Queries Service

Execute and store queries on the Waylay timeseries.

Protocol version: v1.

This Python package is automatically generated based on the Waylay Queries OpenAPI specification (API version: 0.5.0) For more information, please visit the openapi specification.

It consists of two sub-packages that are both plugins for the waylay-sdk-core package.

  • The waylay-sdk-queries sub-package contains the Queries api methods.
  • The waylay-sdk-queries-types sub-package is an extension that contains the typed model classes for all path params, query params, body params and responses for each of the api methods in waylay-sdk-queries.

Requirements.

This package requires Python 3.9+.

Installation

Normally this package is installed together with support for other services using the waylay-sdk umbrella package:

  • pip install waylay-sdk will install waylay-sdk-queries together with the SDK api packages for other services.
  • pip install waylay-sdk[types-queries] will additionally install the types package waylay-sdk-queries-types.
  • pip install waylay-sdk[types] will install the types packages for this and all other services.

Alternatively, you can install support for this queries service only, installing or extending an existing waylay-sdk-core:

  • pip install waylay-sdk-queries to only install api support for queries.
  • pip install waylay-sdk-queries[types] to additionally install type support for queries.

Usage

from pprint import pprint

# Import the waylay-client from the waylay-sdk-core package
from waylay.sdk.client import WaylayClient
from waylay.sdk.api.api_exceptions import ApiError

# Intialize a waylay client instance
waylay_client = WaylayClient.from_profile()

# Note that the typed model classes for responses/parameters/... are only available when `waylay-sdk-queries-types` is installed
from waylay.services.queries.models.query_input import QueryInput
from waylay.services.queries.models.query_result import QueryResult
try:
    # Execute Query
    # calls `POST /queries/v1/data`
    api_response = await waylay_client.queries.execute.execute(
        # query parameters:
        query = {
            'resource': '13efb488-75ac-4dac-828a-d49c5c2ebbfc'
            'metric': 'temperature'
        },
        # json data: use a generated model or a json-serializable python data structure (dict, list)
        json = waylay.services.queries.QueryInput() # QueryInput | 
        headers = {
            'accept': 'accept_example',
        },
    )
    print("The response of queries.execute.execute:\n")
    pprint(api_response)
except ApiError as e:
    print("Exception when calling queries.execute.execute: %s\n" % e)

For more information, please visit the Waylay API documentation.

Documentation for API Endpoints

All URIs are relative to https://api.waylay.io

Class Method HTTP request Description
ExecuteApi execute_by_name GET /queries/v1/data/{query_name} Execute Named Query
ExecuteApi execute POST /queries/v1/data Execute Query
ManageApi create POST /queries/v1/query Post Query
ManageApi get GET /queries/v1/query/{query_name} Get Query
ManageApi list GET /queries/v1/query List Queries
ManageApi remove DELETE /queries/v1/query/{query_name} Remove Query
ManageApi update PUT /queries/v1/query/{query_name} Update Query
StatusApi get GET /queries/v1 Get Version And Health

Documentation For Models