-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
query.ts
85 lines (79 loc) · 2.44 KB
/
query.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
import * as coreHttp from "@azure/core-http";
import * as Mappers from "../models/mappers";
import * as Parameters from "../models/parameters";
import { AzureDigitalTwinsAPI } from "../azureDigitalTwinsAPI";
import {
QuerySpecification,
QueryQueryTwinsOptionalParams,
QueryQueryTwinsResponse
} from "../models";
/**
* Class representing a Query.
*/
export class Query {
private readonly client: AzureDigitalTwinsAPI;
/**
* Initialize a new instance of the class Query class.
* @param client Reference to the service client
*/
constructor(client: AzureDigitalTwinsAPI) {
this.client = client;
}
/**
* Executes a query that allows traversing relationships and filtering by property values.
* Status codes:
* * 200 OK
* * 400 Bad Request
* * BadRequest - The continuation token is invalid.
* * SqlQueryError - The query contains some errors.
* * 429 Too Many Requests
* * QuotaReachedError - The maximum query rate limit has been reached.
* @param querySpecification The query specification to execute.
* @param options The options parameters.
*/
queryTwins(
querySpecification: QuerySpecification,
options?: QueryQueryTwinsOptionalParams
): Promise<QueryQueryTwinsResponse> {
const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase(
options || {}
);
return this.client.sendOperationRequest(
{ querySpecification, options: operationOptions },
queryTwinsOperationSpec
) as Promise<QueryQueryTwinsResponse>;
}
}
// Operation Specifications
const serializer = new coreHttp.Serializer(Mappers, /* isXml */ false);
const queryTwinsOperationSpec: coreHttp.OperationSpec = {
path: "/query",
httpMethod: "POST",
responses: {
200: {
bodyMapper: Mappers.QueryResult,
headersMapper: Mappers.QueryQueryTwinsHeaders
},
default: {
bodyMapper: Mappers.ErrorResponse
}
},
requestBody: Parameters.querySpecification,
queryParameters: [Parameters.apiVersion],
urlParameters: [Parameters.$host],
headerParameters: [
Parameters.contentType,
Parameters.traceparent,
Parameters.tracestate,
Parameters.maxItemsPerPage
],
mediaType: "json",
serializer
};