Skip to content

Latest commit

 

History

History
203 lines (142 loc) · 8.53 KB

QueriesApi.md

File metadata and controls

203 lines (142 loc) · 8.53 KB

cm_python_openapi_sdk.QueriesApi

All URIs are relative to https://staging.dev.clevermaps.io/rest

Method HTTP request Description
accept_queries POST /projects/{projectId}/dwh/{dwhClusterId}/queries Accept queries
get_queries GET /projects/{projectId}/dwh/{dwhClusterId}/queries/{dwhCacheId} Get queries

accept_queries

QueriesResponse accept_queries(project_id, dwh_cluster_id, dwh_query_request1, size=size, page=page)

Accept queries

Accepts a query to be computed on a data warehouse. This is the main endpoint for computing data messages on a multidimensional data model.

The POST of an query request starts an asynchronous task and returns the location URI of the result in location response header. To get the status of asynchronous report result computation, client must make another GET request on the URI from location header (see getQueries).

More information about functions and building CleverMaps metrics is described in the developer documentation:

Example

  • Bearer Authentication (bearerAuth):
import cm_python_openapi_sdk
from cm_python_openapi_sdk.models.dwh_query_request1 import DwhQueryRequest1
from cm_python_openapi_sdk.models.queries_response import QueriesResponse
from cm_python_openapi_sdk.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to https://staging.dev.clevermaps.io/rest
# See configuration.py for a list of all supported configuration parameters.
configuration = cm_python_openapi_sdk.Configuration(
    host = "https://staging.dev.clevermaps.io/rest"
)

# 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: bearerAuth
configuration = cm_python_openapi_sdk.Configuration(
    access_token = os.environ["BEARER_TOKEN"]
)

# Enter a context with an instance of the API client
with cm_python_openapi_sdk.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = cm_python_openapi_sdk.QueriesApi(api_client)
    project_id = 'srb6iq85a8h0ors3' # str | Id of the project
    dwh_cluster_id = 'cmstd1' # str | Id of the dwh cluster
    dwh_query_request1 = {"properties":[{"id":"_split_property","type":"property","value":"baskets.value_name"},{"id":"turnover_metric","type":"function_sum","content":[{"type":"property","value":"baskets.amount"}]}],"filterBy":[{"property":"dim_dates.date_iso","operator":"gte","value":"2017-09-24"},{"property":"dim_dates.date_iso","operator":"lte","value":"2017-09-30"},{"property":"baskets.amount","operator":"gte","value":5},{"property":"baskets.amount","operator":"lte","value":898.17}],"having":[],"orderBy":[{"propertyId":"_split_property","sort":"asc","nulls":"last"}]} # DwhQueryRequest1 | 
    size = 200 # int | The count of records to return for one page (optional) (default to 200)
    page = 0 # int | Number of the page (optional) (default to 0)

    try:
        # Accept queries
        api_response = api_instance.accept_queries(project_id, dwh_cluster_id, dwh_query_request1, size=size, page=page)
        print("The response of QueriesApi->accept_queries:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling QueriesApi->accept_queries: %s\n" % e)

Parameters

Name Type Description Notes
project_id str Id of the project
dwh_cluster_id str Id of the dwh cluster
dwh_query_request1 DwhQueryRequest1
size int The count of records to return for one page [optional] [default to 200]
page int Number of the page [optional] [default to 0]

Return type

QueriesResponse

Authorization

bearerAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status code Description Response headers
202 Accepted - query was successfully accepted for processing * location - URI of overlaps result

[Back to top] [Back to API list] [Back to Model list] [Back to README]

get_queries

QueryResponse get_queries(project_id, dwh_cluster_id, dwh_cache_id, page=page, size=size)

Get queries

Get the result of the asynchronous query request submitted in acceptQueries.

This endpoint implements long polling - the client polls the Location URI and the server holds the request open until the query result is available. Then returns either successful or failed response.

It is also possible that the request will time out and respond with 404 after 30s. This can mean two things:

  • The result is still being computed
  • The result was not found

In that case, the client can make another request and wait if the result will be computed in another 30s interval. The number of repeated GET requests is up to the client.

Example

  • Bearer Authentication (bearerAuth):
import cm_python_openapi_sdk
from cm_python_openapi_sdk.models.query_response import QueryResponse
from cm_python_openapi_sdk.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to https://staging.dev.clevermaps.io/rest
# See configuration.py for a list of all supported configuration parameters.
configuration = cm_python_openapi_sdk.Configuration(
    host = "https://staging.dev.clevermaps.io/rest"
)

# 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: bearerAuth
configuration = cm_python_openapi_sdk.Configuration(
    access_token = os.environ["BEARER_TOKEN"]
)

# Enter a context with an instance of the API client
with cm_python_openapi_sdk.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = cm_python_openapi_sdk.QueriesApi(api_client)
    project_id = 'srb6iq85a8h0ors3' # str | Id of the project
    dwh_cluster_id = 'cmstd1' # str | Id of the dwh cluster
    dwh_cache_id = 'q:f76on62tb6bpitbb:DqBZN5IjSwfufj-7rDMAOQ' # str | Id of the dwh cache
    page = 0 # int | Number of the page (optional) (default to 0)
    size = 100 # int | The count of records to return for one page (optional) (default to 100)

    try:
        # Get queries
        api_response = api_instance.get_queries(project_id, dwh_cluster_id, dwh_cache_id, page=page, size=size)
        print("The response of QueriesApi->get_queries:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling QueriesApi->get_queries: %s\n" % e)

Parameters

Name Type Description Notes
project_id str Id of the project
dwh_cluster_id str Id of the dwh cluster
dwh_cache_id str Id of the dwh cache
page int Number of the page [optional] [default to 0]
size int The count of records to return for one page [optional] [default to 100]

Return type

QueryResponse

Authorization

bearerAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 OK - query was successfully executed -
404 Not Found - the cache was not found -

[Back to top] [Back to API list] [Back to Model list] [Back to README]