@azure/arm-managedapplications 1.1.2 → 2.0.0-alpha.20211011.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/{LICENSE.txt → LICENSE} +2 -2
- package/README.md +63 -80
- package/dist/index.js +2896 -0
- package/dist/index.js.map +1 -0
- package/dist/index.min.js +1 -0
- package/dist/index.min.js.map +1 -0
- package/esm/applicationClient.d.ts +50 -0
- package/esm/applicationClient.d.ts.map +1 -0
- package/esm/applicationClient.js +190 -0
- package/esm/applicationClient.js.map +1 -0
- package/esm/applicationClientContext.d.ts +16 -0
- package/esm/applicationClientContext.d.ts.map +1 -0
- package/esm/applicationClientContext.js +49 -0
- package/esm/applicationClientContext.js.map +1 -0
- package/esm/coreClientLro.d.ts +26 -0
- package/esm/coreClientLro.d.ts.map +1 -0
- package/esm/coreClientLro.js +186 -0
- package/esm/coreClientLro.js.map +1 -0
- package/esm/index.d.ts +770 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +13 -0
- package/esm/index.js.map +1 -0
- package/esm/lro/azureAsyncPolling.d.ts +3 -0
- package/esm/lro/azureAsyncPolling.d.ts.map +1 -0
- package/esm/lro/azureAsyncPolling.js +67 -0
- package/esm/lro/azureAsyncPolling.js.map +1 -0
- package/esm/lro/bodyPolling.d.ts +8 -0
- package/esm/lro/bodyPolling.d.ts.map +1 -0
- package/esm/lro/bodyPolling.js +37 -0
- package/esm/lro/bodyPolling.js.map +1 -0
- package/esm/lro/index.d.ts +4 -0
- package/esm/lro/index.d.ts.map +1 -0
- package/esm/lro/index.js +12 -0
- package/esm/lro/index.js.map +1 -0
- package/esm/lro/locationPolling.d.ts +3 -0
- package/esm/lro/locationPolling.d.ts.map +1 -0
- package/esm/lro/locationPolling.js +19 -0
- package/esm/lro/locationPolling.js.map +1 -0
- package/esm/lro/lroEngine.d.ts +14 -0
- package/esm/lro/lroEngine.d.ts.map +1 -0
- package/esm/lro/lroEngine.js +41 -0
- package/esm/lro/lroEngine.js.map +1 -0
- package/esm/lro/models.d.ts +138 -0
- package/esm/lro/models.d.ts.map +1 -0
- package/esm/lro/models.js +14 -0
- package/esm/lro/models.js.map +1 -0
- package/esm/lro/operation.d.ts +36 -0
- package/esm/lro/operation.d.ts.map +1 -0
- package/esm/lro/operation.js +82 -0
- package/esm/lro/operation.js.map +1 -0
- package/esm/lro/passthrough.d.ts +3 -0
- package/esm/lro/passthrough.d.ts.map +1 -0
- package/esm/lro/passthrough.js +15 -0
- package/esm/lro/passthrough.js.map +1 -0
- package/esm/lro/requestUtils.d.ts +16 -0
- package/esm/lro/requestUtils.d.ts.map +1 -0
- package/esm/lro/requestUtils.js +73 -0
- package/esm/lro/requestUtils.js.map +1 -0
- package/esm/lro/stateMachine.d.ts +18 -0
- package/esm/lro/stateMachine.d.ts.map +1 -0
- package/esm/lro/stateMachine.js +84 -0
- package/esm/lro/stateMachine.js.map +1 -0
- package/esm/models/index.d.ts +360 -762
- package/esm/models/index.d.ts.map +1 -1
- package/esm/models/index.js +17 -2
- package/esm/models/index.js.map +1 -1
- package/esm/models/mappers.d.ts +18 -20
- package/esm/models/mappers.d.ts.map +1 -1
- package/esm/models/mappers.js +296 -318
- package/esm/models/mappers.js.map +1 -1
- package/esm/models/parameters.d.ts +15 -10
- package/esm/models/parameters.d.ts.map +1 -1
- package/esm/models/parameters.js +77 -49
- package/esm/models/parameters.js.map +1 -1
- package/esm/operations/applicationDefinitions.d.ts +128 -0
- package/esm/operations/applicationDefinitions.d.ts.map +1 -0
- package/esm/operations/applicationDefinitions.js +574 -0
- package/esm/operations/applicationDefinitions.js.map +1 -0
- package/esm/operations/applications.d.ts +182 -0
- package/esm/operations/applications.d.ts.map +1 -0
- package/esm/operations/applications.js +802 -0
- package/esm/operations/applications.js.map +1 -0
- package/esm/operations/index.d.ts +2 -2
- package/esm/operations/index.d.ts.map +1 -1
- package/esm/operations/index.js +5 -7
- package/esm/operations/index.js.map +1 -1
- package/esm/operationsInterfaces/applicationDefinitions.d.ts +95 -0
- package/esm/operationsInterfaces/applicationDefinitions.d.ts.map +1 -0
- package/esm/operationsInterfaces/applicationDefinitions.js +9 -0
- package/esm/operationsInterfaces/applicationDefinitions.js.map +1 -0
- package/esm/operationsInterfaces/applications.d.ts +128 -0
- package/esm/operationsInterfaces/applications.d.ts.map +1 -0
- package/esm/operationsInterfaces/applications.js +9 -0
- package/esm/operationsInterfaces/applications.js.map +1 -0
- package/esm/operationsInterfaces/index.d.ts +3 -0
- package/esm/operationsInterfaces/index.d.ts.map +1 -0
- package/esm/operationsInterfaces/index.js +10 -0
- package/esm/operationsInterfaces/index.js.map +1 -0
- package/package.json +55 -16
- package/review/arm-managedapplications.api.md +443 -0
- package/rollup.config.js +181 -30
- package/src/applicationClient.ts +222 -0
- package/src/applicationClientContext.ts +70 -0
- package/src/coreClientLro.ts +323 -0
- package/src/index.ts +13 -0
- package/src/lro/azureAsyncPolling.ts +96 -0
- package/src/lro/bodyPolling.ts +54 -0
- package/src/lro/index.ts +26 -0
- package/src/lro/locationPolling.ts +30 -0
- package/src/lro/lroEngine.ts +61 -0
- package/src/lro/models.ts +173 -0
- package/src/lro/operation.ts +120 -0
- package/src/lro/passthrough.ts +23 -0
- package/src/lro/requestUtils.ts +105 -0
- package/src/lro/stateMachine.ts +138 -0
- package/src/models/index.ts +402 -794
- package/src/models/mappers.ts +290 -311
- package/src/models/parameters.ts +99 -50
- package/src/operations/applicationDefinitions.ts +810 -0
- package/src/operations/applications.ts +1069 -0
- package/src/operations/index.ts +5 -7
- package/src/operationsInterfaces/applicationDefinitions.ts +179 -0
- package/src/operationsInterfaces/applications.ts +225 -0
- package/src/operationsInterfaces/index.ts +10 -0
- package/tsconfig.json +3 -2
- package/dist/arm-managedapplications.js +0 -1865
- package/dist/arm-managedapplications.js.map +0 -1
- package/dist/arm-managedapplications.min.js +0 -1
- package/dist/arm-managedapplications.min.js.map +0 -1
- package/esm/managedApplicationClient.d.ts +0 -58
- package/esm/managedApplicationClient.d.ts.map +0 -1
- package/esm/managedApplicationClient.js +0 -92
- package/esm/managedApplicationClient.js.map +0 -1
- package/esm/managedApplicationClientContext.d.ts +0 -22
- package/esm/managedApplicationClientContext.d.ts.map +0 -1
- package/esm/managedApplicationClientContext.js +0 -61
- package/esm/managedApplicationClientContext.js.map +0 -1
- package/esm/models/applianceDefinitionsMappers.d.ts +0 -2
- package/esm/models/applianceDefinitionsMappers.d.ts.map +0 -1
- package/esm/models/applianceDefinitionsMappers.js +0 -9
- package/esm/models/applianceDefinitionsMappers.js.map +0 -1
- package/esm/models/appliancesMappers.d.ts +0 -2
- package/esm/models/appliancesMappers.d.ts.map +0 -1
- package/esm/models/appliancesMappers.js +0 -9
- package/esm/models/appliancesMappers.js.map +0 -1
- package/esm/operations/applianceDefinitions.d.ts +0 -167
- package/esm/operations/applianceDefinitions.d.ts.map +0 -1
- package/esm/operations/applianceDefinitions.js +0 -358
- package/esm/operations/applianceDefinitions.js.map +0 -1
- package/esm/operations/appliances.d.ts +0 -247
- package/esm/operations/appliances.d.ts.map +0 -1
- package/esm/operations/appliances.js +0 -482
- package/esm/operations/appliances.js.map +0 -1
- package/src/managedApplicationClient.ts +0 -144
- package/src/managedApplicationClientContext.ts +0 -68
- package/src/models/applianceDefinitionsMappers.ts +0 -24
- package/src/models/appliancesMappers.ts +0 -24
- package/src/operations/applianceDefinitions.ts +0 -492
- package/src/operations/appliances.ts +0 -716
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*
|
|
5
|
+
* Code generated by Microsoft (R) AutoRest Code Generator.
|
|
6
|
+
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import * as coreClient from "@azure/core-client";
|
|
10
|
+
import * as coreAuth from "@azure/core-auth";
|
|
11
|
+
import "@azure/core-paging";
|
|
12
|
+
import { PagedAsyncIterableIterator } from "@azure/core-paging";
|
|
13
|
+
import { ApplicationsImpl, ApplicationDefinitionsImpl } from "./operations";
|
|
14
|
+
import { Applications, ApplicationDefinitions } from "./operationsInterfaces";
|
|
15
|
+
import * as Parameters from "./models/parameters";
|
|
16
|
+
import * as Mappers from "./models/mappers";
|
|
17
|
+
import { ApplicationClientContext } from "./applicationClientContext";
|
|
18
|
+
import {
|
|
19
|
+
ApplicationClientOptionalParams,
|
|
20
|
+
Operation,
|
|
21
|
+
ApplicationClientListOperationsNextOptionalParams,
|
|
22
|
+
ApplicationClientListOperationsOptionalParams,
|
|
23
|
+
ApplicationClientListOperationsNextNextOptionalParams,
|
|
24
|
+
ApplicationClientListOperationsResponse,
|
|
25
|
+
ApplicationClientListOperationsNextResponse,
|
|
26
|
+
ApplicationClientListOperationsNextNextResponse
|
|
27
|
+
} from "./models";
|
|
28
|
+
|
|
29
|
+
/// <reference lib="esnext.asynciterable" />
|
|
30
|
+
export class ApplicationClient extends ApplicationClientContext {
|
|
31
|
+
/**
|
|
32
|
+
* Initializes a new instance of the ApplicationClient class.
|
|
33
|
+
* @param credentials Subscription credentials which uniquely identify client subscription.
|
|
34
|
+
* @param subscriptionId The ID of the target subscription.
|
|
35
|
+
* @param options The parameter options
|
|
36
|
+
*/
|
|
37
|
+
constructor(
|
|
38
|
+
credentials: coreAuth.TokenCredential,
|
|
39
|
+
subscriptionId: string,
|
|
40
|
+
options?: ApplicationClientOptionalParams
|
|
41
|
+
) {
|
|
42
|
+
super(credentials, subscriptionId, options);
|
|
43
|
+
this.applications = new ApplicationsImpl(this);
|
|
44
|
+
this.applicationDefinitions = new ApplicationDefinitionsImpl(this);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Lists all of the available Microsoft.Solutions REST API operations.
|
|
49
|
+
* @param options The options parameters.
|
|
50
|
+
*/
|
|
51
|
+
public listOperations(
|
|
52
|
+
options?: ApplicationClientListOperationsOptionalParams
|
|
53
|
+
): PagedAsyncIterableIterator<Operation> {
|
|
54
|
+
const iter = this.listOperationsPagingAll(options);
|
|
55
|
+
return {
|
|
56
|
+
next() {
|
|
57
|
+
return iter.next();
|
|
58
|
+
},
|
|
59
|
+
[Symbol.asyncIterator]() {
|
|
60
|
+
return this;
|
|
61
|
+
},
|
|
62
|
+
byPage: () => {
|
|
63
|
+
return this.listOperationsPagingPage(options);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
private async *listOperationsPagingPage(
|
|
69
|
+
options?: ApplicationClientListOperationsOptionalParams
|
|
70
|
+
): AsyncIterableIterator<Operation[]> {
|
|
71
|
+
let result = await this._listOperations(options);
|
|
72
|
+
yield result.value || [];
|
|
73
|
+
let continuationToken = result.nextLink;
|
|
74
|
+
while (continuationToken) {
|
|
75
|
+
result = await this._listOperationsNext(continuationToken, options);
|
|
76
|
+
continuationToken = result.nextLink;
|
|
77
|
+
yield result.value || [];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
private async *listOperationsPagingAll(
|
|
82
|
+
options?: ApplicationClientListOperationsOptionalParams
|
|
83
|
+
): AsyncIterableIterator<Operation> {
|
|
84
|
+
for await (const page of this.listOperationsPagingPage(options)) {
|
|
85
|
+
yield* page;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* ListOperationsNext
|
|
91
|
+
* @param nextLink The nextLink from the previous successful call to the ListOperations method.
|
|
92
|
+
* @param options The options parameters.
|
|
93
|
+
*/
|
|
94
|
+
public listOperationsNext(
|
|
95
|
+
nextLink: string,
|
|
96
|
+
options?: ApplicationClientListOperationsNextOptionalParams
|
|
97
|
+
): PagedAsyncIterableIterator<Operation> {
|
|
98
|
+
const iter = this.listOperationsNextPagingAll(nextLink, options);
|
|
99
|
+
return {
|
|
100
|
+
next() {
|
|
101
|
+
return iter.next();
|
|
102
|
+
},
|
|
103
|
+
[Symbol.asyncIterator]() {
|
|
104
|
+
return this;
|
|
105
|
+
},
|
|
106
|
+
byPage: () => {
|
|
107
|
+
return this.listOperationsNextPagingPage(nextLink, options);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
private async *listOperationsNextPagingPage(
|
|
113
|
+
nextLink: string,
|
|
114
|
+
options?: ApplicationClientListOperationsNextOptionalParams
|
|
115
|
+
): AsyncIterableIterator<Operation[]> {
|
|
116
|
+
let result = await this._listOperationsNext(nextLink, options);
|
|
117
|
+
yield result.value || [];
|
|
118
|
+
let continuationToken = result.nextLink;
|
|
119
|
+
while (continuationToken) {
|
|
120
|
+
result = await this._listOperationsNextNext(continuationToken, options);
|
|
121
|
+
continuationToken = result.nextLink;
|
|
122
|
+
yield result.value || [];
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
private async *listOperationsNextPagingAll(
|
|
127
|
+
nextLink: string,
|
|
128
|
+
options?: ApplicationClientListOperationsNextOptionalParams
|
|
129
|
+
): AsyncIterableIterator<Operation> {
|
|
130
|
+
for await (const page of this.listOperationsNextPagingPage(
|
|
131
|
+
nextLink,
|
|
132
|
+
options
|
|
133
|
+
)) {
|
|
134
|
+
yield* page;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Lists all of the available Microsoft.Solutions REST API operations.
|
|
140
|
+
* @param options The options parameters.
|
|
141
|
+
*/
|
|
142
|
+
private _listOperations(
|
|
143
|
+
options?: ApplicationClientListOperationsOptionalParams
|
|
144
|
+
): Promise<ApplicationClientListOperationsResponse> {
|
|
145
|
+
return this.sendOperationRequest({ options }, listOperationsOperationSpec);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* ListOperationsNext
|
|
150
|
+
* @param nextLink The nextLink from the previous successful call to the ListOperations method.
|
|
151
|
+
* @param options The options parameters.
|
|
152
|
+
*/
|
|
153
|
+
private _listOperationsNext(
|
|
154
|
+
nextLink: string,
|
|
155
|
+
options?: ApplicationClientListOperationsNextOptionalParams
|
|
156
|
+
): Promise<ApplicationClientListOperationsNextResponse> {
|
|
157
|
+
return this.sendOperationRequest(
|
|
158
|
+
{ nextLink, options },
|
|
159
|
+
listOperationsNextOperationSpec
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* ListOperationsNextNext
|
|
165
|
+
* @param nextLink The nextLink from the previous successful call to the ListOperationsNext method.
|
|
166
|
+
* @param options The options parameters.
|
|
167
|
+
*/
|
|
168
|
+
private _listOperationsNextNext(
|
|
169
|
+
nextLink: string,
|
|
170
|
+
options?: ApplicationClientListOperationsNextNextOptionalParams
|
|
171
|
+
): Promise<ApplicationClientListOperationsNextNextResponse> {
|
|
172
|
+
return this.sendOperationRequest(
|
|
173
|
+
{ nextLink, options },
|
|
174
|
+
listOperationsNextNextOperationSpec
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
applications: Applications;
|
|
179
|
+
applicationDefinitions: ApplicationDefinitions;
|
|
180
|
+
}
|
|
181
|
+
// Operation Specifications
|
|
182
|
+
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
|
|
183
|
+
|
|
184
|
+
const listOperationsOperationSpec: coreClient.OperationSpec = {
|
|
185
|
+
path: "/providers/Microsoft.Solutions/operations",
|
|
186
|
+
httpMethod: "GET",
|
|
187
|
+
responses: {
|
|
188
|
+
200: {
|
|
189
|
+
bodyMapper: Mappers.OperationListResult
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
queryParameters: [Parameters.apiVersion],
|
|
193
|
+
urlParameters: [Parameters.$host],
|
|
194
|
+
headerParameters: [Parameters.accept],
|
|
195
|
+
serializer
|
|
196
|
+
};
|
|
197
|
+
const listOperationsNextOperationSpec: coreClient.OperationSpec = {
|
|
198
|
+
path: "{nextLink}",
|
|
199
|
+
httpMethod: "GET",
|
|
200
|
+
responses: {
|
|
201
|
+
200: {
|
|
202
|
+
bodyMapper: Mappers.OperationListResult
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
queryParameters: [Parameters.apiVersion],
|
|
206
|
+
urlParameters: [Parameters.$host, Parameters.nextLink],
|
|
207
|
+
headerParameters: [Parameters.accept],
|
|
208
|
+
serializer
|
|
209
|
+
};
|
|
210
|
+
const listOperationsNextNextOperationSpec: coreClient.OperationSpec = {
|
|
211
|
+
path: "{nextLink}",
|
|
212
|
+
httpMethod: "GET",
|
|
213
|
+
responses: {
|
|
214
|
+
200: {
|
|
215
|
+
bodyMapper: Mappers.OperationListResult
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
queryParameters: [Parameters.apiVersion],
|
|
219
|
+
urlParameters: [Parameters.$host, Parameters.nextLink],
|
|
220
|
+
headerParameters: [Parameters.accept],
|
|
221
|
+
serializer
|
|
222
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*
|
|
5
|
+
* Code generated by Microsoft (R) AutoRest Code Generator.
|
|
6
|
+
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import * as coreClient from "@azure/core-client";
|
|
10
|
+
import * as coreAuth from "@azure/core-auth";
|
|
11
|
+
import { ApplicationClientOptionalParams } from "./models";
|
|
12
|
+
|
|
13
|
+
export class ApplicationClientContext extends coreClient.ServiceClient {
|
|
14
|
+
$host: string;
|
|
15
|
+
apiVersion: string;
|
|
16
|
+
subscriptionId: string;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Initializes a new instance of the ApplicationClientContext class.
|
|
20
|
+
* @param credentials Subscription credentials which uniquely identify client subscription.
|
|
21
|
+
* @param subscriptionId The ID of the target subscription.
|
|
22
|
+
* @param options The parameter options
|
|
23
|
+
*/
|
|
24
|
+
constructor(
|
|
25
|
+
credentials: coreAuth.TokenCredential,
|
|
26
|
+
subscriptionId: string,
|
|
27
|
+
options?: ApplicationClientOptionalParams
|
|
28
|
+
) {
|
|
29
|
+
if (credentials === undefined) {
|
|
30
|
+
throw new Error("'credentials' cannot be null");
|
|
31
|
+
}
|
|
32
|
+
if (subscriptionId === undefined) {
|
|
33
|
+
throw new Error("'subscriptionId' cannot be null");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Initializing default values for options
|
|
37
|
+
if (!options) {
|
|
38
|
+
options = {};
|
|
39
|
+
}
|
|
40
|
+
const defaults: ApplicationClientOptionalParams = {
|
|
41
|
+
requestContentType: "application/json; charset=utf-8",
|
|
42
|
+
credential: credentials
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const packageDetails = `azsdk-js-arm-managedapplications/2.0.0-beta.1`;
|
|
46
|
+
const userAgentPrefix =
|
|
47
|
+
options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
48
|
+
? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
|
|
49
|
+
: `${packageDetails}`;
|
|
50
|
+
|
|
51
|
+
if (!options.credentialScopes) {
|
|
52
|
+
options.credentialScopes = ["https://management.azure.com/.default"];
|
|
53
|
+
}
|
|
54
|
+
const optionsWithDefaults = {
|
|
55
|
+
...defaults,
|
|
56
|
+
...options,
|
|
57
|
+
userAgentOptions: {
|
|
58
|
+
userAgentPrefix
|
|
59
|
+
},
|
|
60
|
+
baseUri: options.endpoint || "https://management.azure.com"
|
|
61
|
+
};
|
|
62
|
+
super(optionsWithDefaults);
|
|
63
|
+
// Parameter assignments
|
|
64
|
+
this.subscriptionId = subscriptionId;
|
|
65
|
+
|
|
66
|
+
// Assigning values to Constant parameters
|
|
67
|
+
this.$host = options.$host || "https://management.azure.com";
|
|
68
|
+
this.apiVersion = options.apiVersion || "2018-06-01";
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*
|
|
5
|
+
* Code generated by Microsoft (R) AutoRest Code Generator.
|
|
6
|
+
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// Copyright (c) Microsoft Corporation.
|
|
10
|
+
// Licensed under the MIT License.
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
OperationArguments,
|
|
14
|
+
OperationSpec,
|
|
15
|
+
OperationResponseMap,
|
|
16
|
+
FullOperationResponse
|
|
17
|
+
} from "@azure/core-client";
|
|
18
|
+
import {
|
|
19
|
+
LroResourceLocationConfig,
|
|
20
|
+
GetLroStatusFromResponse,
|
|
21
|
+
LongRunningOperation,
|
|
22
|
+
LroConfig,
|
|
23
|
+
LroMode,
|
|
24
|
+
LroResponse,
|
|
25
|
+
LroStatus,
|
|
26
|
+
createGetLroStatusFromResponse,
|
|
27
|
+
RawResponse
|
|
28
|
+
} from "./lro";
|
|
29
|
+
|
|
30
|
+
export const successStates = ["succeeded"];
|
|
31
|
+
export const failureStates = ["failed", "canceled", "cancelled"];
|
|
32
|
+
export const terminalStates = successStates.concat(failureStates);
|
|
33
|
+
|
|
34
|
+
export type SendOperationFn<T> = (
|
|
35
|
+
args: OperationArguments,
|
|
36
|
+
spec: OperationSpec
|
|
37
|
+
) => Promise<LroResponse<T>>;
|
|
38
|
+
|
|
39
|
+
export function createPollingMethod<TResult>(
|
|
40
|
+
sendOperationFn: SendOperationFn<TResult>,
|
|
41
|
+
GetLroStatusFromResponse: GetLroStatusFromResponse<TResult>,
|
|
42
|
+
args: OperationArguments,
|
|
43
|
+
spec: OperationSpec,
|
|
44
|
+
mode?: LroMode
|
|
45
|
+
): (path?: string) => Promise<LroStatus<TResult>> {
|
|
46
|
+
/**
|
|
47
|
+
* Polling calls will always return a status object i.e. {"status": "success"}
|
|
48
|
+
* these intermediate responses are not described in the swagger so we need to
|
|
49
|
+
* pass custom mappers at runtime.
|
|
50
|
+
* This function replaces all the existing mappers to be able to deserialize a status object
|
|
51
|
+
* @param responses Original set of responses defined in the operation
|
|
52
|
+
*/
|
|
53
|
+
function getCompositeMappers(responses: {
|
|
54
|
+
[responseCode: string]: OperationResponseMap;
|
|
55
|
+
}): {
|
|
56
|
+
[responseCode: string]: OperationResponseMap;
|
|
57
|
+
} {
|
|
58
|
+
return Object.keys(responses).reduce((acc, statusCode) => {
|
|
59
|
+
return {
|
|
60
|
+
...acc,
|
|
61
|
+
[statusCode]: {
|
|
62
|
+
...responses[statusCode],
|
|
63
|
+
bodyMapper: {
|
|
64
|
+
type: {
|
|
65
|
+
name: "Composite",
|
|
66
|
+
modelProperties: {
|
|
67
|
+
status: {
|
|
68
|
+
serializedName: "status",
|
|
69
|
+
type: {
|
|
70
|
+
name: "String"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}, {} as { [responseCode: string]: OperationResponseMap });
|
|
79
|
+
}
|
|
80
|
+
let response: LroStatus<TResult> | undefined = undefined;
|
|
81
|
+
const customerCallback = args?.options?.onResponse;
|
|
82
|
+
const updatedArgs = {
|
|
83
|
+
...args,
|
|
84
|
+
options: {
|
|
85
|
+
...args.options,
|
|
86
|
+
onResponse: (
|
|
87
|
+
rawResponse: FullOperationResponse,
|
|
88
|
+
flatResponse: unknown
|
|
89
|
+
): void => {
|
|
90
|
+
response = GetLroStatusFromResponse(
|
|
91
|
+
{
|
|
92
|
+
statusCode: rawResponse.status,
|
|
93
|
+
body: rawResponse.parsedBody,
|
|
94
|
+
headers: rawResponse.headers.toJSON()
|
|
95
|
+
},
|
|
96
|
+
flatResponse as TResult
|
|
97
|
+
);
|
|
98
|
+
if (response.done) {
|
|
99
|
+
customerCallback?.(rawResponse, flatResponse);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
// Make sure we don't send any body to the get request
|
|
105
|
+
const { requestBody, responses, ...restSpec } = spec;
|
|
106
|
+
if (mode === "AzureAsync") {
|
|
107
|
+
return async (path?: string) => {
|
|
108
|
+
await sendOperationFn(updatedArgs, {
|
|
109
|
+
...restSpec,
|
|
110
|
+
responses: getCompositeMappers(responses),
|
|
111
|
+
httpMethod: "GET",
|
|
112
|
+
...(path && { path })
|
|
113
|
+
});
|
|
114
|
+
return response!;
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
return async (path?: string) => {
|
|
118
|
+
await sendOperationFn(updatedArgs, {
|
|
119
|
+
...restSpec,
|
|
120
|
+
responses: responses,
|
|
121
|
+
httpMethod: "GET",
|
|
122
|
+
...(path && { path })
|
|
123
|
+
});
|
|
124
|
+
return response!;
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* We need to selectively deserialize our responses, only deserializing if we
|
|
130
|
+
* are in a final Lro response, not deserializing any polling non-terminal responses
|
|
131
|
+
*/
|
|
132
|
+
export function shouldDeserializeLro(lroResourceLocationConfig?: string) {
|
|
133
|
+
let initialOperationInfo: LroResponseInfo | undefined;
|
|
134
|
+
let isInitialRequest = true;
|
|
135
|
+
|
|
136
|
+
return (response: FullOperationResponse) => {
|
|
137
|
+
if (response.status < 200 || response.status >= 300) {
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (!initialOperationInfo) {
|
|
142
|
+
initialOperationInfo = getLroData(response);
|
|
143
|
+
} else {
|
|
144
|
+
isInitialRequest = false;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (
|
|
148
|
+
initialOperationInfo.azureAsyncOperation ||
|
|
149
|
+
initialOperationInfo.operationLocation
|
|
150
|
+
) {
|
|
151
|
+
return (
|
|
152
|
+
!isInitialRequest &&
|
|
153
|
+
isAsyncOperationFinalResponse(
|
|
154
|
+
response,
|
|
155
|
+
initialOperationInfo,
|
|
156
|
+
lroResourceLocationConfig
|
|
157
|
+
)
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (initialOperationInfo.location) {
|
|
162
|
+
return isLocationFinalResponse(response);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (initialOperationInfo.requestMethod === "PUT") {
|
|
166
|
+
return isBodyPollingFinalResponse(response);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return true;
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function isAsyncOperationFinalResponse(
|
|
174
|
+
response: FullOperationResponse,
|
|
175
|
+
initialOperationInfo: LroResponseInfo,
|
|
176
|
+
lroResourceLocationConfig?: string
|
|
177
|
+
): boolean {
|
|
178
|
+
const status: string = response.parsedBody?.status || "Succeeded";
|
|
179
|
+
if (!terminalStates.includes(status.toLowerCase())) {
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (initialOperationInfo.requestMethod === "DELETE") {
|
|
184
|
+
return true;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (
|
|
188
|
+
initialOperationInfo.requestMethod === "PUT" &&
|
|
189
|
+
lroResourceLocationConfig &&
|
|
190
|
+
lroResourceLocationConfig.toLowerCase() === "azure-asyncoperation"
|
|
191
|
+
) {
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (
|
|
196
|
+
initialOperationInfo.requestMethod !== "PUT" &&
|
|
197
|
+
!initialOperationInfo.location
|
|
198
|
+
) {
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function isLocationFinalResponse(response: FullOperationResponse): boolean {
|
|
206
|
+
return response.status !== 202;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function isBodyPollingFinalResponse(response: FullOperationResponse): boolean {
|
|
210
|
+
const provisioningState: string =
|
|
211
|
+
response.parsedBody?.properties?.provisioningState || "Succeeded";
|
|
212
|
+
|
|
213
|
+
if (terminalStates.includes(provisioningState.toLowerCase())) {
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
interface LroResponseInfo {
|
|
221
|
+
requestMethod: string;
|
|
222
|
+
azureAsyncOperation?: string;
|
|
223
|
+
operationLocation?: string;
|
|
224
|
+
location?: string;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function getLroData(result: FullOperationResponse): LroResponseInfo {
|
|
228
|
+
return {
|
|
229
|
+
azureAsyncOperation: result.headers.get("azure-asyncoperation"),
|
|
230
|
+
operationLocation: result.headers.get("operation-location"),
|
|
231
|
+
location: result.headers.get("location"),
|
|
232
|
+
requestMethod: result.request.method
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export function getSpecPath(spec: OperationSpec): string {
|
|
237
|
+
if (spec.path) {
|
|
238
|
+
return spec.path;
|
|
239
|
+
} else {
|
|
240
|
+
throw Error("Bad spec: request path is not found!");
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export class CoreClientLro<T> implements LongRunningOperation<T> {
|
|
245
|
+
constructor(
|
|
246
|
+
private sendOperationFn: SendOperationFn<T>,
|
|
247
|
+
private args: OperationArguments,
|
|
248
|
+
private spec: OperationSpec,
|
|
249
|
+
private lroResourceLocationConfig?: LroResourceLocationConfig,
|
|
250
|
+
public requestPath: string = spec.path!,
|
|
251
|
+
public requestMethod: string = spec.httpMethod
|
|
252
|
+
) {}
|
|
253
|
+
public async sendInitialRequest(
|
|
254
|
+
initializeState: (
|
|
255
|
+
rawResponse: RawResponse,
|
|
256
|
+
flatResponse: unknown
|
|
257
|
+
) => boolean
|
|
258
|
+
): Promise<LroResponse<T>> {
|
|
259
|
+
const { onResponse, ...restOptions } = this.args.options || {};
|
|
260
|
+
return this.sendOperationFn(
|
|
261
|
+
{
|
|
262
|
+
...this.args,
|
|
263
|
+
options: {
|
|
264
|
+
...restOptions,
|
|
265
|
+
onResponse: (
|
|
266
|
+
rawResponse: FullOperationResponse,
|
|
267
|
+
flatResponse: unknown
|
|
268
|
+
) => {
|
|
269
|
+
const isCompleted = initializeState(
|
|
270
|
+
{
|
|
271
|
+
statusCode: rawResponse.status,
|
|
272
|
+
body: rawResponse.parsedBody,
|
|
273
|
+
headers: rawResponse.headers.toJSON()
|
|
274
|
+
},
|
|
275
|
+
flatResponse
|
|
276
|
+
);
|
|
277
|
+
if (isCompleted) {
|
|
278
|
+
onResponse?.(rawResponse, flatResponse);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
this.spec
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
public async sendPollRequest(
|
|
288
|
+
config: LroConfig,
|
|
289
|
+
path: string
|
|
290
|
+
): Promise<LroStatus<T>> {
|
|
291
|
+
const getLroStatusFromResponse = createGetLroStatusFromResponse(
|
|
292
|
+
this,
|
|
293
|
+
config,
|
|
294
|
+
this.lroResourceLocationConfig
|
|
295
|
+
);
|
|
296
|
+
return createPollingMethod(
|
|
297
|
+
this.sendOperationFn,
|
|
298
|
+
getLroStatusFromResponse,
|
|
299
|
+
this.args,
|
|
300
|
+
this.spec,
|
|
301
|
+
config.mode
|
|
302
|
+
)(path);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
public async retrieveAzureAsyncResource(
|
|
306
|
+
path?: string
|
|
307
|
+
): Promise<LroResponse<T>> {
|
|
308
|
+
const updatedArgs = { ...this.args };
|
|
309
|
+
if (updatedArgs.options) {
|
|
310
|
+
(updatedArgs.options as any).shouldDeserialize = true;
|
|
311
|
+
}
|
|
312
|
+
return createPollingMethod(
|
|
313
|
+
this.sendOperationFn,
|
|
314
|
+
(rawResponse, flatResponse) => ({
|
|
315
|
+
rawResponse,
|
|
316
|
+
flatResponse,
|
|
317
|
+
done: true
|
|
318
|
+
}),
|
|
319
|
+
updatedArgs,
|
|
320
|
+
this.spec
|
|
321
|
+
)(path);
|
|
322
|
+
}
|
|
323
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*
|
|
5
|
+
* Code generated by Microsoft (R) AutoRest Code Generator.
|
|
6
|
+
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/// <reference lib="esnext.asynciterable" />
|
|
10
|
+
export * from "./models";
|
|
11
|
+
export { ApplicationClient } from "./applicationClient";
|
|
12
|
+
export { ApplicationClientContext } from "./applicationClientContext";
|
|
13
|
+
export * from "./operationsInterfaces";
|