@azure-rest/arm-appservice 1.0.0-beta.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/LICENSE +21 -0
- package/README.md +95 -0
- package/dist/index.js +144 -0
- package/dist/index.js.map +1 -0
- package/dist-esm/src/clientDefinitions.js +4 -0
- package/dist-esm/src/clientDefinitions.js.map +1 -0
- package/dist-esm/src/index.js +13 -0
- package/dist-esm/src/index.js.map +1 -0
- package/dist-esm/src/models.js +4 -0
- package/dist-esm/src/models.js.map +1 -0
- package/dist-esm/src/outputModels.js +4 -0
- package/dist-esm/src/outputModels.js.map +1 -0
- package/dist-esm/src/paginateHelper.js +70 -0
- package/dist-esm/src/paginateHelper.js.map +1 -0
- package/dist-esm/src/parameters.js +4 -0
- package/dist-esm/src/parameters.js.map +1 -0
- package/dist-esm/src/pollingHelper.js +46 -0
- package/dist-esm/src/pollingHelper.js.map +1 -0
- package/dist-esm/src/responses.js +4 -0
- package/dist-esm/src/responses.js.map +1 -0
- package/dist-esm/src/webSiteManagementClient.js +21 -0
- package/dist-esm/src/webSiteManagementClient.js.map +1 -0
- package/package.json +129 -0
- package/review/arm-appservice.api.md +27581 -0
- package/types/arm-appservice.d.ts +27921 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Microsoft
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Azure WebSitemManagement REST client library for JavaScript
|
|
2
|
+
|
|
3
|
+
App Service Client
|
|
4
|
+
|
|
5
|
+
**If you are not familiar with our REST client, please spend 5 minutes to take a look at our [REST client docs](https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/rest-clients.md) to use this library, the REST client provides a light-weighted & developer friendly way to call azure rest api**
|
|
6
|
+
|
|
7
|
+
Key links:
|
|
8
|
+
|
|
9
|
+
- [Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/appservice/arm-appservice-rest)
|
|
10
|
+
- [Package (NPM)](https://www.npmjs.com/package/@azure-rest/arm-appservice)
|
|
11
|
+
- [API reference documentation](https://docs.microsoft.com/javascript/api/@azure-rest/arm-appservice)
|
|
12
|
+
|
|
13
|
+
## Getting started
|
|
14
|
+
|
|
15
|
+
### Currently supported environments
|
|
16
|
+
|
|
17
|
+
- Node.js version 14.x.x or higher
|
|
18
|
+
|
|
19
|
+
### Prerequisites
|
|
20
|
+
|
|
21
|
+
- You must have an [Azure subscription](https://azure.microsoft.com/free/) to use this package.
|
|
22
|
+
|
|
23
|
+
### Install the `@azure-rest/arm-appservice` package
|
|
24
|
+
|
|
25
|
+
Install the Azure WebSiteManagement client REST client library for JavaScript with `npm`:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install @azure-rest/arm-appservice
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Create and authenticate a `WebSiteManagementClient`
|
|
32
|
+
|
|
33
|
+
To use an [Azure Active Directory (AAD) token credential](https://docs.microsoft.com/azure/databricks/dev-tools/api/latest/aad/app-aad-token),
|
|
34
|
+
provide an instance of the desired credential type obtained from the
|
|
35
|
+
[@azure/identity](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#credentials) library.
|
|
36
|
+
|
|
37
|
+
To authenticate with AAD, you must first `npm` install [`@azure/identity`](https://www.npmjs.com/package/@azure/identity)
|
|
38
|
+
|
|
39
|
+
After setup, you can choose which type of [credential](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#credentials) from `@azure/identity` to use.
|
|
40
|
+
As an example, [DefaultAzureCredential](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential)
|
|
41
|
+
can be used to authenticate the client:
|
|
42
|
+
|
|
43
|
+
Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables:
|
|
44
|
+
AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET
|
|
45
|
+
|
|
46
|
+
Use the returned token credential to authenticate the client:
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
import WebSiteManagementClient from "@azure-rest/arm-appservice";
|
|
50
|
+
import { DefaultAzureCredential } from "@azure/identity";
|
|
51
|
+
const credential = new DefaultAzureCredential();
|
|
52
|
+
const client = WebSiteManagementClient(credential);
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Examples
|
|
56
|
+
|
|
57
|
+
The following section shows you how to initialize and authenticate your client, then list all of your App Service Plans.
|
|
58
|
+
|
|
59
|
+
### List All App Service Plans
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
import WebSiteManagementClient, { paginate } from "@azure-rest/arm-appservice";
|
|
63
|
+
import { DefaultAzureCredential } from "@azure/identity";
|
|
64
|
+
|
|
65
|
+
async function listAppServicePlans() {
|
|
66
|
+
const subscriptionId = process.env.SUBSCRIPTION_ID as string;
|
|
67
|
+
const credential = new DefaultAzureCredential();
|
|
68
|
+
const client = WebSiteManagementClient(credential);
|
|
69
|
+
const result = [];
|
|
70
|
+
const initialResposne = await client
|
|
71
|
+
.path("/subscriptions/{subscriptionId}/providers/Microsoft.Web/serverfarms", subscriptionId)
|
|
72
|
+
.get();
|
|
73
|
+
const res = paginate(client, initialResposne);
|
|
74
|
+
for await (let item of res) {
|
|
75
|
+
result.push(item);
|
|
76
|
+
}
|
|
77
|
+
console.log(result);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
listAppServicePlans().catch(console.error);
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Troubleshooting
|
|
84
|
+
|
|
85
|
+
### Logging
|
|
86
|
+
|
|
87
|
+
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`:
|
|
88
|
+
|
|
89
|
+
```javascript
|
|
90
|
+
import { setLogLevel } from "@azure/logger";
|
|
91
|
+
|
|
92
|
+
setLogLevel("info");
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
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).
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var coreClient = require('@azure-rest/core-client');
|
|
6
|
+
var corePaging = require('@azure/core-paging');
|
|
7
|
+
var coreLro = require('@azure/core-lro');
|
|
8
|
+
|
|
9
|
+
// Copyright (c) Microsoft Corporation.
|
|
10
|
+
function createClient(credentials, options = {}) {
|
|
11
|
+
var _a, _b;
|
|
12
|
+
const baseUrl = (_a = options.baseUrl) !== null && _a !== void 0 ? _a : "https://management.azure.com";
|
|
13
|
+
options.apiVersion = (_b = options.apiVersion) !== null && _b !== void 0 ? _b : "2021-03-01";
|
|
14
|
+
options = Object.assign(Object.assign({}, options), { credentials: {
|
|
15
|
+
scopes: ["https://management.azure.com/.default"],
|
|
16
|
+
} });
|
|
17
|
+
const userAgentInfo = `azsdk-js-arm-appservice-rest/1.0.0-beta.1`;
|
|
18
|
+
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
19
|
+
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
|
|
20
|
+
: `${userAgentInfo}`;
|
|
21
|
+
options = Object.assign(Object.assign({}, options), { userAgentOptions: {
|
|
22
|
+
userAgentPrefix,
|
|
23
|
+
} });
|
|
24
|
+
const client = coreClient.getClient(baseUrl, credentials, options);
|
|
25
|
+
return client;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Copyright (c) Microsoft Corporation.
|
|
29
|
+
/**
|
|
30
|
+
* Helper to paginate results from an initial response that follows the specification of Autorest `x-ms-pageable` extension
|
|
31
|
+
* @param client - Client to use for sending the next page requests
|
|
32
|
+
* @param initialResponse - Initial response containing the nextLink and current page of elements
|
|
33
|
+
* @param customGetPage - Optional - Function to define how to extract the page and next link to be used to paginate the results
|
|
34
|
+
* @returns - PagedAsyncIterableIterator to iterate the elements
|
|
35
|
+
*/
|
|
36
|
+
function paginate(client, initialResponse, options = {}) {
|
|
37
|
+
let firstRun = true;
|
|
38
|
+
const itemName = "value";
|
|
39
|
+
const nextLinkName = "nextLink";
|
|
40
|
+
const { customGetPage } = options;
|
|
41
|
+
const pagedResult = {
|
|
42
|
+
firstPageLink: "",
|
|
43
|
+
getPage: typeof customGetPage === "function"
|
|
44
|
+
? customGetPage
|
|
45
|
+
: async (pageLink) => {
|
|
46
|
+
const result = firstRun ? initialResponse : await client.pathUnchecked(pageLink).get();
|
|
47
|
+
firstRun = false;
|
|
48
|
+
checkPagingRequest(result);
|
|
49
|
+
const nextLink = getNextLink(result.body, nextLinkName);
|
|
50
|
+
const values = getElements(result.body, itemName);
|
|
51
|
+
return {
|
|
52
|
+
page: values,
|
|
53
|
+
nextPageLink: nextLink,
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
return corePaging.getPagedAsyncIterator(pagedResult);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Gets for the value of nextLink in the body
|
|
61
|
+
*/
|
|
62
|
+
function getNextLink(body, nextLinkName) {
|
|
63
|
+
if (!nextLinkName) {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
const nextLink = body[nextLinkName];
|
|
67
|
+
if (typeof nextLink !== "string" && typeof nextLink !== "undefined") {
|
|
68
|
+
throw new Error(`Body Property ${nextLinkName} should be a string or undefined`);
|
|
69
|
+
}
|
|
70
|
+
return nextLink;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Gets the elements of the current request in the body.
|
|
74
|
+
*/
|
|
75
|
+
function getElements(body, itemName) {
|
|
76
|
+
const value = body[itemName];
|
|
77
|
+
// value has to be an array according to the x-ms-pageable extension.
|
|
78
|
+
// The fact that this must be an array is used above to calculate the
|
|
79
|
+
// type of elements in the page in PaginateReturn
|
|
80
|
+
if (!Array.isArray(value)) {
|
|
81
|
+
throw new Error(`Couldn't paginate response\n Body doesn't contain an array property with name: ${itemName}`);
|
|
82
|
+
}
|
|
83
|
+
return value !== null && value !== void 0 ? value : [];
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Checks if a request failed
|
|
87
|
+
*/
|
|
88
|
+
function checkPagingRequest(response) {
|
|
89
|
+
const Http2xxStatusCodes = ["200", "201", "202", "203", "204", "205", "206", "207", "208", "226"];
|
|
90
|
+
if (!Http2xxStatusCodes.includes(response.status)) {
|
|
91
|
+
throw coreClient.createRestError(`Pagination failed with unexpected statusCode ${response.status}`, response);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Copyright (c) Microsoft Corporation.
|
|
96
|
+
/**
|
|
97
|
+
* Helper function that builds a Poller object to help polling a long running operation.
|
|
98
|
+
* @param client - Client to use for sending the request to get additional pages.
|
|
99
|
+
* @param initialResponse - The initial response.
|
|
100
|
+
* @param options - Options to set a resume state or custom polling interval.
|
|
101
|
+
* @returns - A poller object to poll for operation state updates and eventually get the final response.
|
|
102
|
+
*/
|
|
103
|
+
function getLongRunningPoller(client, initialResponse, options = {}) {
|
|
104
|
+
const poller = {
|
|
105
|
+
requestMethod: initialResponse.request.method,
|
|
106
|
+
requestPath: initialResponse.request.url,
|
|
107
|
+
sendInitialRequest: async () => {
|
|
108
|
+
// In the case of Rest Clients we are building the LRO poller object from a response that's the reason
|
|
109
|
+
// we are not triggering the initial request here, just extracting the information from the
|
|
110
|
+
// response we were provided.
|
|
111
|
+
return getLroResponse(initialResponse);
|
|
112
|
+
},
|
|
113
|
+
sendPollRequest: async (path) => {
|
|
114
|
+
// This is the callback that is going to be called to poll the service
|
|
115
|
+
// to get the latest status. We use the client provided and the polling path
|
|
116
|
+
// which is an opaque URL provided by caller, the service sends this in one of the following headers: operation-location, azure-asyncoperation or location
|
|
117
|
+
// depending on the lro pattern that the service implements. If non is provided we default to the initial path.
|
|
118
|
+
const response = await client.pathUnchecked(path !== null && path !== void 0 ? path : initialResponse.request.url).get();
|
|
119
|
+
return getLroResponse(response);
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
return new coreLro.LroEngine(poller, options);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Converts a Rest Client response to a response that the LRO engine knows about
|
|
126
|
+
* @param response - a rest client http response
|
|
127
|
+
* @returns - An LRO response that the LRO engine can work with
|
|
128
|
+
*/
|
|
129
|
+
function getLroResponse(response) {
|
|
130
|
+
if (Number.isNaN(response.status)) {
|
|
131
|
+
throw new TypeError(`Status code of the response is not a number. Value: ${response.status}`);
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
flatResponse: response,
|
|
135
|
+
rawResponse: Object.assign(Object.assign({}, response), { statusCode: Number.parseInt(response.status), body: response.body }),
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Copyright (c) Microsoft Corporation.
|
|
140
|
+
|
|
141
|
+
exports["default"] = createClient;
|
|
142
|
+
exports.getLongRunningPoller = getLongRunningPoller;
|
|
143
|
+
exports.paginate = paginate;
|
|
144
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/webSiteManagementClient.ts","../src/paginateHelper.ts","../src/pollingHelper.ts","../src/index.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { getClient, ClientOptions } from \"@azure-rest/core-client\";\nimport { TokenCredential } from \"@azure/core-auth\";\nimport { WebSiteManagementClient } from \"./clientDefinitions\";\n\nexport default function createClient(\n credentials: TokenCredential,\n options: ClientOptions = {}\n): WebSiteManagementClient {\n const baseUrl = options.baseUrl ?? \"https://management.azure.com\";\n options.apiVersion = options.apiVersion ?? \"2021-03-01\";\n options = {\n ...options,\n credentials: {\n scopes: [\"https://management.azure.com/.default\"],\n },\n };\n\n const userAgentInfo = `azsdk-js-arm-appservice-rest/1.0.0-beta.1`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`\n : `${userAgentInfo}`;\n options = {\n ...options,\n userAgentOptions: {\n userAgentPrefix,\n },\n };\n\n const client = getClient(baseUrl, credentials, options) as WebSiteManagementClient;\n\n return client;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { getPagedAsyncIterator, PagedAsyncIterableIterator, PagedResult } from \"@azure/core-paging\";\nimport { Client, createRestError, PathUncheckedResponse } from \"@azure-rest/core-client\";\n\n/**\n * Helper type to extract the type of an array\n */\nexport type GetArrayType<T> = T extends Array<infer TData> ? TData : never;\n\n/**\n * The type of a custom function that defines how to get a page and a link to the next one if any.\n */\nexport type GetPage<TPage> = (\n pageLink: string,\n maxPageSize?: number\n) => Promise<{\n page: TPage;\n nextPageLink?: string;\n}>;\n\n/**\n * Options for the paging helper\n */\nexport interface PagingOptions<TResponse> {\n /**\n * Custom function to extract pagination details for crating the PagedAsyncIterableIterator\n */\n customGetPage?: GetPage<PaginateReturn<TResponse>[]>;\n}\n\n/**\n * Helper type to infer the Type of the paged elements from the response type\n * This type is generated based on the swagger information for x-ms-pageable\n * specifically on the itemName property which indicates the property of the response\n * where the page items are found. The default value is `value`.\n * This type will allow us to provide strongly typed Iterator based on the response we get as second parameter\n */\nexport type PaginateReturn<TResult> = TResult extends {\n body: { value?: infer TPage };\n}\n ? GetArrayType<TPage>\n : Array<unknown>;\n\n/**\n * Helper to paginate results from an initial response that follows the specification of Autorest `x-ms-pageable` extension\n * @param client - Client to use for sending the next page requests\n * @param initialResponse - Initial response containing the nextLink and current page of elements\n * @param customGetPage - Optional - Function to define how to extract the page and next link to be used to paginate the results\n * @returns - PagedAsyncIterableIterator to iterate the elements\n */\nexport function paginate<TResponse extends PathUncheckedResponse>(\n client: Client,\n initialResponse: TResponse,\n options: PagingOptions<TResponse> = {}\n): PagedAsyncIterableIterator<PaginateReturn<TResponse>> {\n // Extract element type from initial response\n type TElement = PaginateReturn<TResponse>;\n let firstRun = true;\n const itemName = \"value\";\n const nextLinkName = \"nextLink\";\n const { customGetPage } = options;\n const pagedResult: PagedResult<TElement[]> = {\n firstPageLink: \"\",\n getPage:\n typeof customGetPage === \"function\"\n ? customGetPage\n : async (pageLink: string) => {\n const result = firstRun ? initialResponse : await client.pathUnchecked(pageLink).get();\n firstRun = false;\n checkPagingRequest(result);\n const nextLink = getNextLink(result.body, nextLinkName);\n const values = getElements<TElement>(result.body, itemName);\n return {\n page: values,\n nextPageLink: nextLink,\n };\n },\n };\n\n return getPagedAsyncIterator(pagedResult);\n}\n\n/**\n * Gets for the value of nextLink in the body\n */\nfunction getNextLink(body: unknown, nextLinkName?: string): string | undefined {\n if (!nextLinkName) {\n return undefined;\n }\n\n const nextLink = (body as Record<string, unknown>)[nextLinkName];\n\n if (typeof nextLink !== \"string\" && typeof nextLink !== \"undefined\") {\n throw new Error(`Body Property ${nextLinkName} should be a string or undefined`);\n }\n\n return nextLink;\n}\n\n/**\n * Gets the elements of the current request in the body.\n */\nfunction getElements<T = unknown>(body: unknown, itemName: string): T[] {\n const value = (body as Record<string, unknown>)[itemName] as T[];\n\n // value has to be an array according to the x-ms-pageable extension.\n // The fact that this must be an array is used above to calculate the\n // type of elements in the page in PaginateReturn\n if (!Array.isArray(value)) {\n throw new Error(\n `Couldn't paginate response\\n Body doesn't contain an array property with name: ${itemName}`\n );\n }\n\n return value ?? [];\n}\n\n/**\n * Checks if a request failed\n */\nfunction checkPagingRequest(response: PathUncheckedResponse): void {\n const Http2xxStatusCodes = [\"200\", \"201\", \"202\", \"203\", \"204\", \"205\", \"206\", \"207\", \"208\", \"226\"];\n if (!Http2xxStatusCodes.includes(response.status)) {\n throw createRestError(\n `Pagination failed with unexpected statusCode ${response.status}`,\n response\n );\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Client, HttpResponse } from \"@azure-rest/core-client\";\nimport {\n LongRunningOperation,\n LroEngine,\n LroEngineOptions,\n LroResponse,\n PollerLike,\n PollOperationState,\n} from \"@azure/core-lro\";\n\n/**\n * Helper function that builds a Poller object to help polling a long running operation.\n * @param client - Client to use for sending the request to get additional pages.\n * @param initialResponse - The initial response.\n * @param options - Options to set a resume state or custom polling interval.\n * @returns - A poller object to poll for operation state updates and eventually get the final response.\n */\nexport function getLongRunningPoller<TResult extends HttpResponse>(\n client: Client,\n initialResponse: TResult,\n options: LroEngineOptions<TResult, PollOperationState<TResult>> = {}\n): PollerLike<PollOperationState<TResult>, TResult> {\n const poller: LongRunningOperation<TResult> = {\n requestMethod: initialResponse.request.method,\n requestPath: initialResponse.request.url,\n sendInitialRequest: async () => {\n // In the case of Rest Clients we are building the LRO poller object from a response that's the reason\n // we are not triggering the initial request here, just extracting the information from the\n // response we were provided.\n return getLroResponse(initialResponse);\n },\n sendPollRequest: async (path) => {\n // This is the callback that is going to be called to poll the service\n // to get the latest status. We use the client provided and the polling path\n // which is an opaque URL provided by caller, the service sends this in one of the following headers: operation-location, azure-asyncoperation or location\n // depending on the lro pattern that the service implements. If non is provided we default to the initial path.\n const response = await client.pathUnchecked(path ?? initialResponse.request.url).get();\n return getLroResponse(response as TResult);\n },\n };\n\n return new LroEngine(poller, options);\n}\n\n/**\n * Converts a Rest Client response to a response that the LRO engine knows about\n * @param response - a rest client http response\n * @returns - An LRO response that the LRO engine can work with\n */\nfunction getLroResponse<TResult extends HttpResponse>(response: TResult): LroResponse<TResult> {\n if (Number.isNaN(response.status)) {\n throw new TypeError(`Status code of the response is not a number. Value: ${response.status}`);\n }\n\n return {\n flatResponse: response,\n rawResponse: {\n ...response,\n statusCode: Number.parseInt(response.status),\n body: response.body,\n },\n };\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport WebSiteManagementClient from \"./webSiteManagementClient\";\n\nexport * from \"./webSiteManagementClient\";\nexport * from \"./parameters\";\nexport * from \"./responses\";\nexport * from \"./clientDefinitions\";\nexport * from \"./models\";\nexport * from \"./outputModels\";\nexport * from \"./paginateHelper\";\nexport * from \"./pollingHelper\";\n\nexport default WebSiteManagementClient;\n"],"names":["getClient","getPagedAsyncIterator","createRestError","LroEngine"],"mappings":";;;;;;;;AAAA;AAOwB,SAAA,YAAY,CAClC,WAA4B,EAC5B,UAAyB,EAAE,EAAA;;IAE3B,MAAM,OAAO,GAAG,CAAA,EAAA,GAAA,OAAO,CAAC,OAAO,MAAA,IAAA,IAAA,EAAA,KAA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