queries
Creates, updates, deletes, gets or lists a queries
resource.
Overview
Name | queries |
Type | Resource |
Id | google.apigee.queries |
Fields
The following fields are returned by SELECT
queries:
- organizations_environments_queries_get
- organizations_environments_queries_list
Successful response
Name | Datatype | Description |
---|---|---|
name | string | Asynchronous Query Name. |
created | string | Creation time of the query. |
envgroupHostname | string | Hostname is available only when query is executed at host level. |
error | string | Error is set when query fails. |
executionTime | string | ExecutionTime is available only after the query is completed. |
queryParams | object | Contains information like metrics, dimenstions etc of the AsyncQuery. (id: GoogleCloudApigeeV1QueryMetadata) |
reportDefinitionId | string | Asynchronous Report ID. |
result | object | Result is available only after the query is completed. (id: GoogleCloudApigeeV1AsyncQueryResult) |
resultFileSize | string | ResultFileSize is available only after the query is completed. |
resultRows | string (int64) | ResultRows is available only after the query is completed. |
self | string | Self link of the query. Example: /organizations/myorg/environments/myenv/queries/9cfc0d85-0f30-46d6-ae6f-318d0cb961bd or following format if query is running at host level: /organizations/myorg/hostQueries/9cfc0d85-0f30-46d6-ae6f-318d0cb961bd |
state | string | Query state could be "enqueued", "running", "completed", "failed". |
updated | string | Last updated timestamp for the query. |
Successful response
Name | Datatype | Description |
---|---|---|
queries | array | The asynchronous queries belong to requested resource name. |
Methods
The following methods are available for this resource:
Name | Accessible by | Required Params | Optional Params | Description |
---|---|---|---|---|
organizations_environments_queries_get | select | organizationsId , environmentsId , queriesId | Get query status If the query is still in progress, the state is set to "running" After the query has completed successfully, state is set to "completed" | |
organizations_environments_queries_list | select | organizationsId , environmentsId | submittedBy , status , from , to , dataset , inclQueriesWithoutReport | Return a list of Asynchronous Queries |
organizations_environments_queries_create | insert | organizationsId , environmentsId | Submit a query to be processed in the background. If the submission of the query succeeds, the API returns a 201 status and an ID that refer to the query. In addition to the HTTP status 201, the state of "enqueued" means that the request succeeded. |
Parameters
Parameters can be passed in the WHERE
clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
Name | Datatype | Description |
---|---|---|
environmentsId | string | |
organizationsId | string | |
queriesId | string | |
dataset | string | |
from | string | |
inclQueriesWithoutReport | string | |
status | string | |
submittedBy | string | |
to | string |
SELECT
examples
- organizations_environments_queries_get
- organizations_environments_queries_list
Get query status If the query is still in progress, the state
is set to "running" After the query has completed successfully, state
is set to "completed"
SELECT
name,
created,
envgroupHostname,
error,
executionTime,
queryParams,
reportDefinitionId,
result,
resultFileSize,
resultRows,
self,
state,
updated
FROM google.apigee.queries
WHERE organizationsId = '{{ organizationsId }}' -- required
AND environmentsId = '{{ environmentsId }}' -- required
AND queriesId = '{{ queriesId }}' -- required;
Return a list of Asynchronous Queries
SELECT
queries
FROM google.apigee.queries
WHERE organizationsId = '{{ organizationsId }}' -- required
AND environmentsId = '{{ environmentsId }}' -- required
AND submittedBy = '{{ submittedBy }}'
AND status = '{{ status }}'
AND from = '{{ from }}'
AND to = '{{ to }}'
AND dataset = '{{ dataset }}'
AND inclQueriesWithoutReport = '{{ inclQueriesWithoutReport }}';
INSERT
examples
- organizations_environments_queries_create
- Manifest
Submit a query to be processed in the background. If the submission of the query succeeds, the API returns a 201 status and an ID that refer to the query. In addition to the HTTP status 201, the state
of "enqueued" means that the request succeeded.
INSERT INTO google.apigee.queries (
data__metrics,
data__dimensions,
data__timeRange,
data__filter,
data__groupByTimeUnit,
data__limit,
data__outputFormat,
data__csvDelimiter,
data__envgroupHostname,
data__reportDefinitionId,
data__name,
organizationsId,
environmentsId
)
SELECT
'{{ metrics }}',
'{{ dimensions }}',
'{{ timeRange }}',
'{{ filter }}',
'{{ groupByTimeUnit }}',
{{ limit }},
'{{ outputFormat }}',
'{{ csvDelimiter }}',
'{{ envgroupHostname }}',
'{{ reportDefinitionId }}',
'{{ name }}',
'{{ organizationsId }}',
'{{ environmentsId }}'
RETURNING
name,
created,
envgroupHostname,
error,
executionTime,
queryParams,
reportDefinitionId,
result,
resultFileSize,
resultRows,
self,
state,
updated
;
# Description fields are for documentation purposes
- name: queries
props:
- name: organizationsId
value: string
description: Required parameter for the queries resource.
- name: environmentsId
value: string
description: Required parameter for the queries resource.
- name: metrics
value: array
description: >
A list of Metrics.
- name: dimensions
value: array
description: >
A list of dimensions. https://docs.apigee.com/api-platform/analytics/analytics-reference#dimensions
- name: timeRange
value: any
description: >
Required. Time range for the query. Can use the following predefined strings to specify the time range: `last60minutes` `last24hours` `last7days` Or, specify the timeRange as a structure describing start and end timestamps in the ISO format: yyyy-mm-ddThh:mm:ssZ. Example: "timeRange": { "start": "2018-07-29T00:13:00Z", "end": "2018-08-01T00:18:00Z" }
- name: filter
value: string
description: >
Boolean expression that can be used to filter data. Filter expressions can be combined using AND/OR terms and should be fully parenthesized to avoid ambiguity. See Analytics metrics, dimensions, and filters reference https://docs.apigee.com/api-platform/analytics/analytics-reference for more information on the fields available to filter on. For more information on the tokens that you use to build filter expressions, see Filter expression syntax. https://docs.apigee.com/api-platform/analytics/asynch-reports-api#filter-expression-syntax
- name: groupByTimeUnit
value: string
description: >
Time unit used to group the result set. Valid values include: second, minute, hour, day, week, or month. If a query includes groupByTimeUnit, then the result is an aggregation based on the specified time unit and the resultant timestamp does not include milliseconds precision. If a query omits groupByTimeUnit, then the resultant timestamp includes milliseconds precision.
- name: limit
value: integer
description: >
Maximum number of rows that can be returned in the result.
- name: outputFormat
value: string
description: >
Valid values include: `csv` or `json`. Defaults to `json`. Note: Configure the delimiter for CSV output using the csvDelimiter property.
- name: csvDelimiter
value: string
description: >
Delimiter used in the CSV file, if `outputFormat` is set to `csv`. Defaults to the `,` (comma) character. Supported delimiter characters include comma (`,`), pipe (`|`), and tab (`\t`).
- name: envgroupHostname
value: string
description: >
Hostname needs to be specified if query intends to run at host level. This field is only allowed when query is submitted by CreateHostAsyncQuery where analytics data will be grouped by organization and hostname.
- name: reportDefinitionId
value: string
description: >
Asynchronous Report ID.
- name: name
value: string
description: >
Asynchronous Query Name.