@azure-rest/developer-devcenter 1.0.0-beta.1 → 1.0.0-beta.3
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/README.md +11 -10
- package/dist/index.js +98 -179
- package/dist/index.js.map +1 -1
- package/dist-esm/src/azureDeveloperDevCenter.js +29 -0
- package/dist-esm/src/azureDeveloperDevCenter.js.map +1 -0
- package/dist-esm/src/clientDefinitions.js.map +1 -0
- package/dist-esm/src/index.js +11 -11
- package/dist-esm/src/index.js.map +1 -1
- package/dist-esm/src/isUnexpected.js +111 -0
- package/dist-esm/src/isUnexpected.js.map +1 -0
- package/dist-esm/src/logger.js +5 -0
- package/dist-esm/src/logger.js.map +1 -0
- package/dist-esm/src/models.js.map +1 -0
- package/dist-esm/src/outputModels.js.map +1 -0
- package/dist-esm/src/{generated/paginateHelper.js → paginateHelper.js} +4 -17
- package/dist-esm/src/paginateHelper.js.map +1 -0
- package/dist-esm/src/parameters.js.map +1 -0
- package/dist-esm/src/{generated/pollingHelper.js → pollingHelper.js} +11 -19
- package/dist-esm/src/pollingHelper.js.map +1 -0
- package/dist-esm/src/responses.js.map +1 -0
- package/package.json +37 -35
- package/review/developer-devcenter.api.md +929 -927
- package/types/developer-devcenter.d.ts +1140 -1180
- package/dist-esm/src/azureDevCenter.js +0 -20
- package/dist-esm/src/azureDevCenter.js.map +0 -1
- package/dist-esm/src/generated/azureDevCenter.js +0 -28
- package/dist-esm/src/generated/azureDevCenter.js.map +0 -1
- package/dist-esm/src/generated/clientDefinitions.js.map +0 -1
- package/dist-esm/src/generated/index.js +0 -14
- package/dist-esm/src/generated/index.js.map +0 -1
- package/dist-esm/src/generated/isUnexpected.js +0 -162
- package/dist-esm/src/generated/isUnexpected.js.map +0 -1
- package/dist-esm/src/generated/models.js.map +0 -1
- package/dist-esm/src/generated/outputModels.js.map +0 -1
- package/dist-esm/src/generated/paginateHelper.js.map +0 -1
- package/dist-esm/src/generated/parameters.js.map +0 -1
- package/dist-esm/src/generated/pollingHelper.js.map +0 -1
- package/dist-esm/src/generated/responses.js.map +0 -1
- /package/dist-esm/src/{generated/clientDefinitions.js → clientDefinitions.js} +0 -0
- /package/dist-esm/src/{generated/models.js → models.js} +0 -0
- /package/dist-esm/src/{generated/outputModels.js → outputModels.js} +0 -0
- /package/dist-esm/src/{generated/parameters.js → parameters.js} +0 -0
- /package/dist-esm/src/{generated/responses.js → responses.js} +0 -0
package/README.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Azure DevCenter REST client library for JavaScript
|
|
2
|
+
|
|
2
3
|
|
|
3
4
|
The Azure DevCenter library provides access to manage resources for Microsoft Dev Box and Azure Deployment Environments. This package enables managing developer machines and environments in Azure.
|
|
4
5
|
|
|
@@ -6,6 +7,7 @@ Use the package for Azure DevCenter to:
|
|
|
6
7
|
> Create, access, manage, and delete Dev Box resources
|
|
7
8
|
> Create, deploy, manage, and delete Environment resources
|
|
8
9
|
|
|
10
|
+
DevCenter service
|
|
9
11
|
|
|
10
12
|
**Please rely heavily on our [REST client docs](https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/rest-clients.md) to use this library**
|
|
11
13
|
|
|
@@ -13,30 +15,30 @@ Key links:
|
|
|
13
15
|
|
|
14
16
|
- [Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/devcenter/developer-devcenter-rest)
|
|
15
17
|
- [Package (NPM)](https://www.npmjs.com/package/@azure-rest/developer-devcenter)
|
|
16
|
-
- [API reference documentation](https://
|
|
18
|
+
- [API reference documentation](https://docs.microsoft.com/javascript/api/@azure-rest/developer-devcenter?view=azure-node-preview)
|
|
17
19
|
- [Samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/devcenter/developer-devcenter-rest/samples)
|
|
18
20
|
|
|
19
21
|
## Getting started
|
|
20
22
|
|
|
21
23
|
### Currently supported environments
|
|
22
24
|
|
|
23
|
-
- Node.js
|
|
25
|
+
- LTS versions of Node.js
|
|
24
26
|
|
|
25
27
|
### Prerequisites
|
|
26
28
|
|
|
27
29
|
- You must have an [Azure subscription](https://azure.microsoft.com/free/) to use this package.
|
|
28
30
|
- You must have [configured](https://learn.microsoft.com/azure/dev-box/quickstart-configure-dev-box-service) a DevCenter, Project, Network Connection, Dev Box Definition, and Pool before you can create Dev Boxes
|
|
29
31
|
- You must have [configured](https://learn.microsoft.com/azure/deployment-environments/) a DevCenter, Project, Catalog, and Environment Type before you can create Environments
|
|
30
|
-
|
|
32
|
+
|
|
31
33
|
### Install the `@azure-rest/developer-devcenter` package
|
|
32
34
|
|
|
33
|
-
Install the
|
|
35
|
+
Install the Azure DevCenter REST client REST client library for JavaScript with `npm`:
|
|
34
36
|
|
|
35
37
|
```bash
|
|
36
38
|
npm install @azure-rest/developer-devcenter
|
|
37
39
|
```
|
|
38
40
|
|
|
39
|
-
### Create and authenticate
|
|
41
|
+
### Create and authenticate a `AzureDeveloperDevCenterClient`
|
|
40
42
|
|
|
41
43
|
To use an [Azure Active Directory (AAD) token credential](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-a-pre-fetched-access-token),
|
|
42
44
|
provide an instance of the desired credential type obtained from the
|
|
@@ -48,8 +50,8 @@ After setup, you can choose which type of [credential](https://github.com/Azure/
|
|
|
48
50
|
As an example, [DefaultAzureCredential](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential)
|
|
49
51
|
can be used to authenticate the client.
|
|
50
52
|
|
|
51
|
-
Set the
|
|
52
|
-
|
|
53
|
+
Set the value of dev center endpoint as environment variable:
|
|
54
|
+
DEVCENTER_ENDPOINT
|
|
53
55
|
|
|
54
56
|
## Key Concepts
|
|
55
57
|
|
|
@@ -69,10 +71,9 @@ Environments refer to templated developer environments, which combine a template
|
|
|
69
71
|
Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`:
|
|
70
72
|
|
|
71
73
|
```javascript
|
|
72
|
-
|
|
74
|
+
const { setLogLevel } = require("@azure/logger");
|
|
73
75
|
|
|
74
76
|
setLogLevel("info");
|
|
75
77
|
```
|
|
76
78
|
|
|
77
79
|
For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger).
|
|
78
|
-
|
package/dist/index.js
CHANGED
|
@@ -3,150 +3,86 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var coreClient = require('@azure-rest/core-client');
|
|
6
|
+
var logger$1 = require('@azure/logger');
|
|
6
7
|
var corePaging = require('@azure/core-paging');
|
|
7
8
|
var coreLro = require('@azure/core-lro');
|
|
8
9
|
|
|
9
10
|
// Copyright (c) Microsoft Corporation.
|
|
11
|
+
// Licensed under the MIT license.
|
|
12
|
+
const logger = logger$1.createClientLogger("developer-devcenter");
|
|
13
|
+
|
|
14
|
+
// Copyright (c) Microsoft Corporation.
|
|
15
|
+
// Licensed under the MIT license.
|
|
10
16
|
/**
|
|
11
|
-
* Initialize a new instance of
|
|
12
|
-
* @param
|
|
13
|
-
* @param
|
|
14
|
-
* @param
|
|
15
|
-
* @param credentials type: TokenCredential
|
|
17
|
+
* Initialize a new instance of `AzureDeveloperDevCenterClient`
|
|
18
|
+
* @param endpoint - The DevCenter-specific URI to operate on.
|
|
19
|
+
* @param credentials - uniquely identify client credential
|
|
20
|
+
* @param options - the parameter for all optional parameters
|
|
16
21
|
*/
|
|
17
|
-
function createClient
|
|
18
|
-
var _a, _b;
|
|
19
|
-
const baseUrl = (_a = options.baseUrl) !== null && _a !== void 0 ? _a :
|
|
20
|
-
options.apiVersion = (_b = options.apiVersion) !== null && _b !== void 0 ? _b : "
|
|
21
|
-
|
|
22
|
-
scopes: ["https://devcenter.azure.com/.default"]
|
|
23
|
-
} });
|
|
24
|
-
const userAgentInfo = `azsdk-js-developer-devcenter-rest/1.0.0-beta.1`;
|
|
22
|
+
function createClient(endpoint, credentials, options = {}) {
|
|
23
|
+
var _a, _b, _c, _d, _e, _f;
|
|
24
|
+
const baseUrl = (_a = options.baseUrl) !== null && _a !== void 0 ? _a : `${endpoint}`;
|
|
25
|
+
options.apiVersion = (_b = options.apiVersion) !== null && _b !== void 0 ? _b : "2023-04-01";
|
|
26
|
+
const userAgentInfo = `azsdk-js-developer-devcenter-rest/1.0.0-beta.3`;
|
|
25
27
|
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
26
28
|
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
|
|
27
29
|
: `${userAgentInfo}`;
|
|
28
30
|
options = Object.assign(Object.assign({}, options), { userAgentOptions: {
|
|
29
|
-
userAgentPrefix
|
|
31
|
+
userAgentPrefix,
|
|
32
|
+
}, loggingOptions: {
|
|
33
|
+
logger: (_d = (_c = options.loggingOptions) === null || _c === void 0 ? void 0 : _c.logger) !== null && _d !== void 0 ? _d : logger.info,
|
|
34
|
+
}, credentials: {
|
|
35
|
+
scopes: (_f = (_e = options.credentials) === null || _e === void 0 ? void 0 : _e.scopes) !== null && _f !== void 0 ? _f : ["https://devcenter.azure.com/.default"],
|
|
30
36
|
} });
|
|
31
37
|
const client = coreClient.getClient(baseUrl, credentials, options);
|
|
32
38
|
return client;
|
|
33
39
|
}
|
|
34
40
|
|
|
35
|
-
// Copyright (c) Microsoft Corporation.
|
|
36
|
-
const defaultDevCenterDnsSuffix = "devcenter.azure.com";
|
|
37
|
-
/**
|
|
38
|
-
* Initialize a new instance of the class AzureDevCenterClient class.
|
|
39
|
-
* @param tenantId type: string The tenant to operate on.
|
|
40
|
-
* @param devCenter type: string The DevCenter to operate on.
|
|
41
|
-
* @param credentials type: TokenCredential
|
|
42
|
-
* @param devCenterDnsSuffixOrOptions type: string | ClientOptions Either the DNS suffix used as the base for all devcenter requests or client options.
|
|
43
|
-
* @param options type: ClientOptions
|
|
44
|
-
*/
|
|
45
|
-
function createClient(tenantId, devCenter, credentials, devCenterDnsSuffixOrOptions = defaultDevCenterDnsSuffix, options) {
|
|
46
|
-
const devCenterDnsSuffix = typeof devCenterDnsSuffixOrOptions === "string"
|
|
47
|
-
? devCenterDnsSuffixOrOptions
|
|
48
|
-
: defaultDevCenterDnsSuffix;
|
|
49
|
-
const internalOptions = typeof devCenterDnsSuffixOrOptions === "string" ? options : devCenterDnsSuffixOrOptions;
|
|
50
|
-
return createClient$1(tenantId, devCenter, devCenterDnsSuffix, credentials, internalOptions);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
41
|
// Copyright (c) Microsoft Corporation.
|
|
54
42
|
// Licensed under the MIT license.
|
|
55
43
|
const responseMap = {
|
|
56
44
|
"GET /projects": ["200"],
|
|
57
45
|
"GET /projects/{projectName}": ["200"],
|
|
58
|
-
"GET /
|
|
59
|
-
"GET /users/{userId}/devboxes": ["200"],
|
|
46
|
+
"GET /projects/{projectName}/operationstatuses/{operationId}": ["200"],
|
|
60
47
|
"GET /projects/{projectName}/pools": ["200"],
|
|
61
48
|
"GET /projects/{projectName}/pools/{poolName}": ["200"],
|
|
62
49
|
"GET /projects/{projectName}/pools/{poolName}/schedules": ["200"],
|
|
63
|
-
"GET /projects/{projectName}/pools/{poolName}/schedules/{scheduleName}": [
|
|
64
|
-
"200"
|
|
65
|
-
],
|
|
50
|
+
"GET /projects/{projectName}/pools/{poolName}/schedules/{scheduleName}": ["200"],
|
|
66
51
|
"GET /projects/{projectName}/users/{userId}/devboxes": ["200"],
|
|
67
52
|
"GET /projects/{projectName}/users/{userId}/devboxes/{devBoxName}": ["200"],
|
|
68
|
-
"PUT /projects/{projectName}/users/{userId}/devboxes/{devBoxName}": [
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
],
|
|
72
|
-
"
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
],
|
|
77
|
-
"
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
"GET /projects/{projectName}/users/{userId}/devboxes/{devBoxName}:start": [
|
|
82
|
-
"200",
|
|
83
|
-
"202"
|
|
84
|
-
],
|
|
85
|
-
"POST /projects/{projectName}/users/{userId}/devboxes/{devBoxName}:stop": [
|
|
86
|
-
"200",
|
|
87
|
-
"202"
|
|
53
|
+
"PUT /projects/{projectName}/users/{userId}/devboxes/{devBoxName}": ["200", "201"],
|
|
54
|
+
"DELETE /projects/{projectName}/users/{userId}/devboxes/{devBoxName}": ["202", "204"],
|
|
55
|
+
"POST /projects/{projectName}/users/{userId}/devboxes/{devBoxName}:start": ["202"],
|
|
56
|
+
"GET /projects/{projectName}/users/{userId}/devboxes/{devBoxName}:start": ["200", "202"],
|
|
57
|
+
"POST /projects/{projectName}/users/{userId}/devboxes/{devBoxName}:stop": ["202"],
|
|
58
|
+
"GET /projects/{projectName}/users/{userId}/devboxes/{devBoxName}:stop": ["200", "202"],
|
|
59
|
+
"POST /projects/{projectName}/users/{userId}/devboxes/{devBoxName}:restart": ["202"],
|
|
60
|
+
"GET /projects/{projectName}/users/{userId}/devboxes/{devBoxName}:restart": ["200", "202"],
|
|
61
|
+
"GET /projects/{projectName}/users/{userId}/devboxes/{devBoxName}/remoteConnection": ["200"],
|
|
62
|
+
"GET /projects/{projectName}/users/{userId}/devboxes/{devBoxName}/actions": ["200"],
|
|
63
|
+
"GET /projects/{projectName}/users/{userId}/devboxes/{devBoxName}/actions/{actionName}": ["200"],
|
|
64
|
+
"POST /projects/{projectName}/users/{userId}/devboxes/{devBoxName}/actions/{actionName}:skip": [
|
|
65
|
+
"204",
|
|
88
66
|
],
|
|
89
|
-
"
|
|
67
|
+
"POST /projects/{projectName}/users/{userId}/devboxes/{devBoxName}/actions/{actionName}:delay": [
|
|
90
68
|
"200",
|
|
91
|
-
"202"
|
|
92
|
-
],
|
|
93
|
-
"GET /projects/{projectName}/users/{userId}/devboxes/{devBoxName}/remoteConnection": [
|
|
94
|
-
"200"
|
|
95
69
|
],
|
|
70
|
+
"POST /projects/{projectName}/users/{userId}/devboxes/{devBoxName}/actions:delay": ["200"],
|
|
71
|
+
"GET /devboxes": ["200"],
|
|
72
|
+
"GET /users/{userId}/devboxes": ["200"],
|
|
96
73
|
"GET /projects/{projectName}/environments": ["200"],
|
|
97
74
|
"GET /projects/{projectName}/users/{userId}/environments": ["200"],
|
|
98
|
-
"GET /projects/{projectName}/users/{userId}/environments/{environmentName}": [
|
|
99
|
-
|
|
100
|
-
],
|
|
101
|
-
"
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
],
|
|
105
|
-
"
|
|
106
|
-
"200"
|
|
107
|
-
],
|
|
108
|
-
"DELETE /projects/{projectName}/users/{userId}/environments/{environmentName}": [
|
|
109
|
-
"200",
|
|
110
|
-
"202",
|
|
111
|
-
"204"
|
|
112
|
-
],
|
|
113
|
-
"POST /projects/{projectName}/users/{userId}/environments/{environmentName}:deploy": [
|
|
114
|
-
"200",
|
|
115
|
-
"202"
|
|
116
|
-
],
|
|
117
|
-
"GET /projects/{projectName}/users/{userId}/environments/{environmentName}:deploy": [
|
|
118
|
-
"200",
|
|
119
|
-
"202"
|
|
120
|
-
],
|
|
121
|
-
"POST /projects/{projectName}/users/{userId}/environments/{environmentName}:delete": [
|
|
75
|
+
"GET /projects/{projectName}/users/{userId}/environments/{environmentName}": ["200"],
|
|
76
|
+
"PUT /projects/{projectName}/users/{userId}/environments/{environmentName}": ["201"],
|
|
77
|
+
"DELETE /projects/{projectName}/users/{userId}/environments/{environmentName}": ["202", "204"],
|
|
78
|
+
"GET /projects/{projectName}/catalogs": ["200"],
|
|
79
|
+
"GET /projects/{projectName}/catalogs/{catalogName}": ["200"],
|
|
80
|
+
"GET /projects/{projectName}/environmentDefinitions": ["200"],
|
|
81
|
+
"GET /projects/{projectName}/catalogs/{catalogName}/environmentDefinitions": ["200"],
|
|
82
|
+
"GET /projects/{projectName}/catalogs/{catalogName}/environmentDefinitions/{definitionName}": [
|
|
122
83
|
"200",
|
|
123
|
-
"202"
|
|
124
|
-
],
|
|
125
|
-
"GET /projects/{projectName}/users/{userId}/environments/{environmentName}:delete": [
|
|
126
|
-
"200",
|
|
127
|
-
"202"
|
|
128
|
-
],
|
|
129
|
-
"POST /projects/{projectName}/users/{userId}/environments/{environmentName}:custom": [
|
|
130
|
-
"200",
|
|
131
|
-
"202"
|
|
132
|
-
],
|
|
133
|
-
"GET /projects/{projectName}/users/{userId}/environments/{environmentName}:custom": [
|
|
134
|
-
"200",
|
|
135
|
-
"202"
|
|
136
|
-
],
|
|
137
|
-
"GET /projects/{projectName}/users/{userId}/environments/{environmentName}/artifacts": [
|
|
138
|
-
"200"
|
|
139
|
-
],
|
|
140
|
-
"GET /projects/{projectName}/users/{userId}/environments/{environmentName}/artifacts/{artifactPath}": [
|
|
141
|
-
"200"
|
|
142
84
|
],
|
|
143
|
-
"GET /projects/{projectName}/
|
|
144
|
-
"GET /projects/{projectName}/catalogItems/{catalogItemId}": ["200"],
|
|
145
|
-
"GET /projects/{projectName}/catalogItems/{catalogItemId}/versions": ["200"],
|
|
146
|
-
"GET /projects/{projectName}/catalogItems/{catalogItemId}/versions/{version}": [
|
|
147
|
-
"200"
|
|
148
|
-
],
|
|
149
|
-
"GET /projects/{projectName}/environmentTypes": ["200"]
|
|
85
|
+
"GET /projects/{projectName}/environmentTypes": ["200"],
|
|
150
86
|
};
|
|
151
87
|
function isUnexpected(response) {
|
|
152
88
|
const lroOriginal = response.headers["x-ms-original-url"];
|
|
@@ -154,13 +90,17 @@ function isUnexpected(response) {
|
|
|
154
90
|
const method = response.request.method;
|
|
155
91
|
let pathDetails = responseMap[`${method} ${url.pathname}`];
|
|
156
92
|
if (!pathDetails) {
|
|
157
|
-
pathDetails =
|
|
93
|
+
pathDetails = getParametrizedPathSuccess(method, url.pathname);
|
|
158
94
|
}
|
|
159
95
|
return !pathDetails.includes(response.status);
|
|
160
96
|
}
|
|
161
|
-
function
|
|
162
|
-
var _a, _b;
|
|
97
|
+
function getParametrizedPathSuccess(method, path) {
|
|
98
|
+
var _a, _b, _c, _d;
|
|
163
99
|
const pathParts = path.split("/");
|
|
100
|
+
// Traverse list to match the longest candidate
|
|
101
|
+
// matchedLen: the length of candidate path
|
|
102
|
+
// matchedValue: the matched status code array
|
|
103
|
+
let matchedLen = -1, matchedValue = [];
|
|
164
104
|
// Iterate the responseMap to find a match
|
|
165
105
|
for (const [key, value] of Object.entries(responseMap)) {
|
|
166
106
|
// Extracting the path from the map key which is in format
|
|
@@ -171,41 +111,38 @@ function geParametrizedPathSuccess(method, path) {
|
|
|
171
111
|
const candidatePath = getPathFromMapKey(key);
|
|
172
112
|
// Get each part of the url path
|
|
173
113
|
const candidateParts = candidatePath.split("/");
|
|
174
|
-
//
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
// skip as the parameterized part can match anything
|
|
186
|
-
continue;
|
|
187
|
-
}
|
|
188
|
-
// If the candidate part is not a template and
|
|
189
|
-
// the parts don't match mark the candidate as not found
|
|
190
|
-
// to move on with the next candidate path.
|
|
191
|
-
if (candidateParts[i] !== pathParts[i]) {
|
|
114
|
+
// track if we have found a match to return the values found.
|
|
115
|
+
let found = true;
|
|
116
|
+
for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {
|
|
117
|
+
if (((_a = candidateParts[i]) === null || _a === void 0 ? void 0 : _a.startsWith("{")) && ((_b = candidateParts[i]) === null || _b === void 0 ? void 0 : _b.indexOf("}")) !== -1) {
|
|
118
|
+
const start = candidateParts[i].indexOf("}") + 1, end = (_c = candidateParts[i]) === null || _c === void 0 ? void 0 : _c.length;
|
|
119
|
+
// If the current part of the candidate is a "template" part
|
|
120
|
+
// Try to use the suffix of pattern to match the path
|
|
121
|
+
// {guid} ==> $
|
|
122
|
+
// {guid}:export ==> :export$
|
|
123
|
+
const isMatched = new RegExp(`${(_d = candidateParts[i]) === null || _d === void 0 ? void 0 : _d.slice(start, end)}`).test(pathParts[j] || "");
|
|
124
|
+
if (!isMatched) {
|
|
192
125
|
found = false;
|
|
193
126
|
break;
|
|
194
127
|
}
|
|
128
|
+
continue;
|
|
195
129
|
}
|
|
196
|
-
//
|
|
197
|
-
//
|
|
198
|
-
// the path
|
|
199
|
-
if (
|
|
200
|
-
|
|
130
|
+
// If the candidate part is not a template and
|
|
131
|
+
// the parts don't match mark the candidate as not found
|
|
132
|
+
// to move on with the next candidate path.
|
|
133
|
+
if (candidateParts[i] !== pathParts[j]) {
|
|
134
|
+
found = false;
|
|
135
|
+
break;
|
|
201
136
|
}
|
|
202
137
|
}
|
|
138
|
+
// We finished evaluating the current candidate parts
|
|
139
|
+
// Update the matched value if and only if we found the longer pattern
|
|
140
|
+
if (found && candidatePath.length > matchedLen) {
|
|
141
|
+
matchedLen = candidatePath.length;
|
|
142
|
+
matchedValue = value;
|
|
143
|
+
}
|
|
203
144
|
}
|
|
204
|
-
|
|
205
|
-
return [];
|
|
206
|
-
}
|
|
207
|
-
function hasParametrizedPath(path) {
|
|
208
|
-
return path.includes("/{");
|
|
145
|
+
return matchedValue;
|
|
209
146
|
}
|
|
210
147
|
function getPathFromMapKey(mapKey) {
|
|
211
148
|
const pathStart = mapKey.indexOf("/");
|
|
@@ -213,6 +150,7 @@ function getPathFromMapKey(mapKey) {
|
|
|
213
150
|
}
|
|
214
151
|
|
|
215
152
|
// Copyright (c) Microsoft Corporation.
|
|
153
|
+
// Licensed under the MIT license.
|
|
216
154
|
/**
|
|
217
155
|
* Helper to paginate results from an initial response that follows the specification of Autorest `x-ms-pageable` extension
|
|
218
156
|
* @param client - Client to use for sending the next page requests
|
|
@@ -230,18 +168,16 @@ function paginate(client, initialResponse, options = {}) {
|
|
|
230
168
|
getPage: typeof customGetPage === "function"
|
|
231
169
|
? customGetPage
|
|
232
170
|
: async (pageLink) => {
|
|
233
|
-
const result = firstRun
|
|
234
|
-
? initialResponse
|
|
235
|
-
: await client.pathUnchecked(pageLink).get();
|
|
171
|
+
const result = firstRun ? initialResponse : await client.pathUnchecked(pageLink).get();
|
|
236
172
|
firstRun = false;
|
|
237
173
|
checkPagingRequest(result);
|
|
238
174
|
const nextLink = getNextLink(result.body, nextLinkName);
|
|
239
175
|
const values = getElements(result.body, itemName);
|
|
240
176
|
return {
|
|
241
177
|
page: values,
|
|
242
|
-
nextPageLink: nextLink
|
|
178
|
+
nextPageLink: nextLink,
|
|
243
179
|
};
|
|
244
|
-
}
|
|
180
|
+
},
|
|
245
181
|
};
|
|
246
182
|
return corePaging.getPagedAsyncIterator(pagedResult);
|
|
247
183
|
}
|
|
@@ -275,32 +211,16 @@ function getElements(body, itemName) {
|
|
|
275
211
|
* Checks if a request failed
|
|
276
212
|
*/
|
|
277
213
|
function checkPagingRequest(response) {
|
|
278
|
-
const Http2xxStatusCodes = [
|
|
279
|
-
"200",
|
|
280
|
-
"201",
|
|
281
|
-
"202",
|
|
282
|
-
"203",
|
|
283
|
-
"204",
|
|
284
|
-
"205",
|
|
285
|
-
"206",
|
|
286
|
-
"207",
|
|
287
|
-
"208",
|
|
288
|
-
"226"
|
|
289
|
-
];
|
|
214
|
+
const Http2xxStatusCodes = ["200", "201", "202", "203", "204", "205", "206", "207", "208", "226"];
|
|
290
215
|
if (!Http2xxStatusCodes.includes(response.status)) {
|
|
291
216
|
throw coreClient.createRestError(`Pagination failed with unexpected statusCode ${response.status}`, response);
|
|
292
217
|
}
|
|
293
218
|
}
|
|
294
219
|
|
|
295
220
|
// Copyright (c) Microsoft Corporation.
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
* @param initialResponse - The initial response.
|
|
300
|
-
* @param options - Options to set a resume state or custom polling interval.
|
|
301
|
-
* @returns - A poller object to poll for operation state updates and eventually get the final response.
|
|
302
|
-
*/
|
|
303
|
-
function getLongRunningPoller(client, initialResponse, options = {}) {
|
|
221
|
+
// Licensed under the MIT license.
|
|
222
|
+
async function getLongRunningPoller(client, initialResponse, options = {}) {
|
|
223
|
+
var _a;
|
|
304
224
|
const poller = {
|
|
305
225
|
requestMethod: initialResponse.request.method,
|
|
306
226
|
requestPath: initialResponse.request.url,
|
|
@@ -315,21 +235,19 @@ function getLongRunningPoller(client, initialResponse, options = {}) {
|
|
|
315
235
|
// to get the latest status. We use the client provided and the polling path
|
|
316
236
|
// which is an opaque URL provided by caller, the service sends this in one of the following headers: operation-location, azure-asyncoperation or location
|
|
317
237
|
// depending on the lro pattern that the service implements. If non is provided we default to the initial path.
|
|
318
|
-
const response = await client
|
|
319
|
-
.pathUnchecked(path !== null && path !== void 0 ? path : initialResponse.request.url)
|
|
320
|
-
.get();
|
|
238
|
+
const response = await client.pathUnchecked(path !== null && path !== void 0 ? path : initialResponse.request.url).get();
|
|
321
239
|
const lroResponse = getLroResponse(response);
|
|
322
|
-
lroResponse.rawResponse.headers["x-ms-original-url"] =
|
|
323
|
-
initialResponse.request.url;
|
|
240
|
+
lroResponse.rawResponse.headers["x-ms-original-url"] = initialResponse.request.url;
|
|
324
241
|
return lroResponse;
|
|
325
|
-
}
|
|
242
|
+
},
|
|
326
243
|
};
|
|
327
|
-
|
|
244
|
+
options.resolveOnUnsuccessful = (_a = options.resolveOnUnsuccessful) !== null && _a !== void 0 ? _a : true;
|
|
245
|
+
return coreLro.createHttpPoller(poller, options);
|
|
328
246
|
}
|
|
329
247
|
/**
|
|
330
|
-
* Converts a Rest Client response to a response that the LRO
|
|
248
|
+
* Converts a Rest Client response to a response that the LRO implementation understands
|
|
331
249
|
* @param response - a rest client http response
|
|
332
|
-
* @returns - An LRO response that the LRO
|
|
250
|
+
* @returns - An LRO response that the LRO implementation understands
|
|
333
251
|
*/
|
|
334
252
|
function getLroResponse(response) {
|
|
335
253
|
if (Number.isNaN(response.status)) {
|
|
@@ -337,13 +255,14 @@ function getLroResponse(response) {
|
|
|
337
255
|
}
|
|
338
256
|
return {
|
|
339
257
|
flatResponse: response,
|
|
340
|
-
rawResponse: Object.assign(Object.assign({}, response), { statusCode: Number.parseInt(response.status), body: response.body })
|
|
258
|
+
rawResponse: Object.assign(Object.assign({}, response), { statusCode: Number.parseInt(response.status), body: response.body }),
|
|
341
259
|
};
|
|
342
260
|
}
|
|
343
261
|
|
|
344
262
|
// Copyright (c) Microsoft Corporation.
|
|
263
|
+
// Licensed under the MIT license.
|
|
345
264
|
|
|
346
|
-
exports
|
|
265
|
+
exports.default = createClient;
|
|
347
266
|
exports.getLongRunningPoller = getLongRunningPoller;
|
|
348
267
|
exports.isUnexpected = isUnexpected;
|
|
349
268
|
exports.paginate = paginate;
|