[mgmt] edgezones with modular (#30341)
https://github.com/Azure/sdk-release-request/issues/5072 --------- Co-authored-by: Mary Gao <yanmeigao1210@gmail.com>
This commit is contained in:
Родитель
424bfd1b50
Коммит
27067aa8f8
|
@ -511,6 +511,9 @@ sdk/ai/ai-inference-rest @glharper @dargilco
|
|||
# PRLabel: %Mgmt
|
||||
/sdk/domainservices/arm-domainservices/ @qiaozha @MaryGao
|
||||
|
||||
# PRLabel: %Mgmt
|
||||
/sdk/edgezones/arm-edgezones/ @qiaozha @MaryGao
|
||||
|
||||
# PRLabel: %Mgmt
|
||||
/sdk/elasticsans/arm-elasticsan/ @qiaozha @MaryGao
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -27,3 +27,4 @@ https://docs.microsoft.com/javascript/api/@azure/arm-devopsinfrastructure?view=a
|
|||
https://docs.microsoft.com/javascript/api/@azure/arm-informaticadatamanagement?view=azure-node-preview
|
||||
https://docs.microsoft.com/javascript/api/@azure/arm-oracledatabase?view=azure-node-preview
|
||||
https://docs.microsoft.com/javascript/api/@azure/arm-mongocluster?view=azure-node-preview
|
||||
https://docs.microsoft.com/javascript/api/@azure/arm-edgezones?view=azure-node-preview
|
||||
|
|
|
@ -2231,6 +2231,11 @@
|
|||
"packageName": "@azure-rest/ai-inference",
|
||||
"projectFolder": "sdk/ai/ai-inference-rest",
|
||||
"versionPolicyName": "client"
|
||||
},
|
||||
{
|
||||
"packageName": "@azure/arm-edgezones",
|
||||
"projectFolder": "sdk/edgezones/arm-edgezones",
|
||||
"versionPolicyName": "management"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"plugins": ["@azure/azure-sdk"],
|
||||
"extends": ["plugin:@azure/azure-sdk/azure-sdk-base"],
|
||||
"rules": {
|
||||
"@azure/azure-sdk/ts-modules-only-named": "warn",
|
||||
"@azure/azure-sdk/ts-apiextractor-json-types": "warn",
|
||||
"@azure/azure-sdk/ts-package-json-types": "warn",
|
||||
"@azure/azure-sdk/ts-package-json-engine-is-present": "warn",
|
||||
"tsdoc/syntax": "warn",
|
||||
"@azure/azure-sdk/ts-package-json-module": "off",
|
||||
"@azure/azure-sdk/ts-package-json-files-required": "off",
|
||||
"@azure/azure-sdk/ts-package-json-main-is-cjs": "off"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
# Release History
|
||||
|
||||
## 1.0.0-beta.1 (2024-07-09)
|
||||
|
||||
### Features Added
|
||||
|
||||
Initial release of the Azure Edgezones package
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2024 Microsoft
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
|
@ -0,0 +1,105 @@
|
|||
# Azure EdgeZones client library for JavaScript
|
||||
|
||||
This package contains an isomorphic SDK (runs both in Node.js and in browsers) for Azure EdgeZones client.
|
||||
|
||||
Microsoft Edgezones Service
|
||||
|
||||
|
||||
[Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/edgezones/arm-edgezones) |
|
||||
[Package (NPM)](https://www.npmjs.com/package/@azure/arm-edgezones) |
|
||||
[API reference documentation](https://docs.microsoft.com/javascript/api/@azure/arm-edgezones?view=azure-node-preview) |
|
||||
|
||||
## Getting started
|
||||
|
||||
### Currently supported environments
|
||||
|
||||
- [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule)
|
||||
- Latest versions of Safari, Chrome, Edge and Firefox.
|
||||
|
||||
See our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details.
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- An [Azure subscription][azure_sub].
|
||||
|
||||
### Install the `@azure/arm-edgezones` package
|
||||
|
||||
Install the Azure EdgeZones client library for JavaScript with `npm`:
|
||||
|
||||
```bash
|
||||
npm install @azure/arm-edgezones
|
||||
```
|
||||
|
||||
### Create and authenticate a `EdgeZonesClient`
|
||||
|
||||
To create a client object to access the Azure EdgeZones API, you will need the `endpoint` of your Azure EdgeZones resource and a `credential`. The Azure EdgeZones client can use Azure Active Directory credentials to authenticate.
|
||||
You can find the endpoint for your Azure EdgeZones resource in the [Azure Portal][azure_portal].
|
||||
|
||||
You can authenticate with Azure Active Directory using a credential from the [@azure/identity][azure_identity] library or [an existing AAD Token](https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-a-pre-fetched-access-token).
|
||||
|
||||
To use the [DefaultAzureCredential][defaultazurecredential] provider shown below, or other credential providers provided with the Azure SDK, please install the `@azure/identity` package:
|
||||
|
||||
```bash
|
||||
npm install @azure/identity
|
||||
```
|
||||
|
||||
You will also need to **register a new AAD application and grant access to Azure EdgeZones** by assigning the suitable role to your service principal (note: roles such as `"Owner"` will not grant the necessary permissions).
|
||||
Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables: `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`.
|
||||
|
||||
For more information about how to create an Azure AD Application check out [this guide](https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal).
|
||||
|
||||
```javascript
|
||||
const { EdgeZonesClient } = require("@azure/arm-edgezones");
|
||||
const { DefaultAzureCredential } = require("@azure/identity");
|
||||
// For client-side applications running in the browser, use InteractiveBrowserCredential instead of DefaultAzureCredential. See https://aka.ms/azsdk/js/identity/examples for more details.
|
||||
|
||||
const subscriptionId = "00000000-0000-0000-0000-000000000000";
|
||||
const client = new EdgeZonesClient(new DefaultAzureCredential(), subscriptionId);
|
||||
|
||||
// For client-side applications running in the browser, use this code instead:
|
||||
// const credential = new InteractiveBrowserCredential({
|
||||
// tenantId: "<YOUR_TENANT_ID>",
|
||||
// clientId: "<YOUR_CLIENT_ID>"
|
||||
// });
|
||||
// const client = new EdgeZonesClient(credential, subscriptionId);
|
||||
```
|
||||
|
||||
|
||||
### JavaScript Bundle
|
||||
To use this client library in the browser, first you need to use a bundler. For details on how to do this, please refer to our [bundling documentation](https://aka.ms/AzureSDKBundling).
|
||||
|
||||
## Key concepts
|
||||
|
||||
### EdgeZonesClient
|
||||
|
||||
`EdgeZonesClient` is the primary interface for developers using the Azure EdgeZones client library. Explore the methods on this client object to understand the different features of the Azure EdgeZones service that you can access.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Logging
|
||||
|
||||
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`:
|
||||
|
||||
```javascript
|
||||
const { setLogLevel } = require("@azure/logger");
|
||||
setLogLevel("info");
|
||||
```
|
||||
|
||||
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).
|
||||
|
||||
## Next steps
|
||||
|
||||
Please take a look at the [samples](https://github.com/Azure-Samples/azure-samples-js-management) directory for detailed examples on how to use this library.
|
||||
|
||||
## Contributing
|
||||
|
||||
If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code.
|
||||
|
||||
## Related projects
|
||||
|
||||
- [Microsoft Azure SDK for JavaScript](https://github.com/Azure/azure-sdk-for-js)
|
||||
|
||||
[azure_sub]: https://azure.microsoft.com/free/
|
||||
[azure_portal]: https://portal.azure.com
|
||||
[azure_identity]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity
|
||||
[defaultazurecredential]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
||||
"mainEntryPointFilePath": "./dist/esm/index.d.ts",
|
||||
"docModel": { "enabled": true },
|
||||
"apiReport": { "enabled": true, "reportFolder": "./review" },
|
||||
"dtsRollup": {
|
||||
"enabled": true,
|
||||
"untrimmedFilePath": "",
|
||||
"publicTrimmedFilePath": "./types/arm-edgezones.d.ts"
|
||||
},
|
||||
"messages": {
|
||||
"tsdocMessageReporting": { "default": { "logLevel": "none" } },
|
||||
"extractorMessageReporting": {
|
||||
"ae-missing-release-tag": { "logLevel": "none" },
|
||||
"ae-unresolved-link": { "logLevel": "none" }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"AssetsRepo": "Azure/azure-sdk-assets",
|
||||
"AssetsRepoPrefixPath": "js",
|
||||
"TagPrefix": "js/edgezones/arm-edgezones",
|
||||
"Tag": "js/edgezones/arm-edgezones_dbaf4ac435"
|
||||
}
|
|
@ -0,0 +1,230 @@
|
|||
{
|
||||
"name": "@azure/arm-edgezones",
|
||||
"version": "1.0.0-beta.1",
|
||||
"description": "Azure Edgezones Service",
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"autoPublish": false,
|
||||
"tshy": {
|
||||
"exports": {
|
||||
"./package.json": "./package.json",
|
||||
".": "./src/index.ts",
|
||||
"./api": "./src/api/index.ts",
|
||||
"./models": "./src/models/index.ts",
|
||||
"./api/operations": "./src/api/operations/index.ts",
|
||||
"./api/extendedZones": "./src/api/extendedZones/index.ts"
|
||||
},
|
||||
"dialects": [
|
||||
"esm",
|
||||
"commonjs"
|
||||
],
|
||||
"esmDialects": [
|
||||
"browser",
|
||||
"react-native"
|
||||
],
|
||||
"selfLink": false
|
||||
},
|
||||
"type": "module",
|
||||
"keywords": [
|
||||
"node",
|
||||
"azure",
|
||||
"cloud",
|
||||
"typescript",
|
||||
"browser",
|
||||
"isomorphic"
|
||||
],
|
||||
"author": "Microsoft Corporation",
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"dist",
|
||||
"README.md",
|
||||
"LICENSE",
|
||||
"review/*"
|
||||
],
|
||||
"sdk-type": "mgmt",
|
||||
"repository": "github:Azure/azure-sdk-for-js",
|
||||
"bugs": {
|
||||
"url": "https://github.com/Azure/azure-sdk-for-js/issues"
|
||||
},
|
||||
"prettier": "@azure/eslint-plugin-azure-sdk/prettier.json",
|
||||
"//metadata": {
|
||||
"constantPaths": [
|
||||
{
|
||||
"path": "src/rest/edgeZonesClient.ts",
|
||||
"prefix": "package-version"
|
||||
}
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"@azure-rest/core-client": "^2.1.0",
|
||||
"@azure/core-auth": "^1.6.0",
|
||||
"@azure/core-rest-pipeline": "^1.5.0",
|
||||
"@azure/logger": "^1.0.0",
|
||||
"tslib": "^2.6.2",
|
||||
"@azure/core-paging": "^1.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"dotenv": "^16.0.0",
|
||||
"@microsoft/api-extractor": "^7.40.3",
|
||||
"@types/node": "^18.0.0",
|
||||
"eslint": "^8.55.0",
|
||||
"prettier": "^3.2.5",
|
||||
"rimraf": "^5.0.5",
|
||||
"mkdirp": "^3.0.1",
|
||||
"typescript": "~5.5.3",
|
||||
"tshy": "^1.11.1",
|
||||
"@azure/core-util": "^1.0.0",
|
||||
"@azure/identity": "^4.2.1",
|
||||
"@vitest/browser": "^1.3.1",
|
||||
"@vitest/coverage-istanbul": "^1.3.1",
|
||||
"playwright": "^1.41.2",
|
||||
"vitest": "^1.3.1",
|
||||
"@azure-tools/test-credential": "^2.0.0",
|
||||
"@azure-tools/test-recorder": "^4.0.0",
|
||||
"@azure/dev-tool": "^1.0.0",
|
||||
"@azure/eslint-plugin-azure-sdk": "^3.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"clean": "rimraf --glob dist dist-browser dist-esm test-dist temp types *.tgz *.log",
|
||||
"extract-api": "rimraf review && mkdirp ./review && dev-tool run extract-api",
|
||||
"pack": "npm pack 2>&1",
|
||||
"lint": "echo skipped",
|
||||
"lint:fix": "echo skipped",
|
||||
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
|
||||
"unit-test:browser": "npm run build:test && dev-tool run test:vitest --browser",
|
||||
"unit-test:node": "dev-tool run test:vitest",
|
||||
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
|
||||
"integration-test:browser": "echo skipped",
|
||||
"integration-test:node": "echo skipped",
|
||||
"audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit",
|
||||
"build:samples": "echo skipped",
|
||||
"check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\"",
|
||||
"execute:samples": "echo skipped",
|
||||
"format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\"",
|
||||
"generate:client": "echo skipped",
|
||||
"test:browser": "npm run clean && npm run build:test && npm run unit-test:browser && npm run integration-test:browser",
|
||||
"minify": "uglifyjs -c -m --comments --source-map \"content='./dist/index.js.map'\" -o ./dist/index.min.js ./dist/index.js",
|
||||
"build:test": "npm run clean && tshy && dev-tool run build-test",
|
||||
"build": "npm run clean && tshy && mkdirp ./review && dev-tool run extract-api",
|
||||
"test:node": "npm run clean && tshy && npm run unit-test:node && npm run integration-test:node",
|
||||
"test": "npm run clean && tshy && npm run unit-test:node && dev-tool run bundle && npm run unit-test:browser && npm run integration-test"
|
||||
},
|
||||
"exports": {
|
||||
"./package.json": "./package.json",
|
||||
".": {
|
||||
"browser": {
|
||||
"source": "./src/index.ts",
|
||||
"types": "./dist/browser/index.d.ts",
|
||||
"default": "./dist/browser/index.js"
|
||||
},
|
||||
"react-native": {
|
||||
"source": "./src/index.ts",
|
||||
"types": "./dist/react-native/index.d.ts",
|
||||
"default": "./dist/react-native/index.js"
|
||||
},
|
||||
"import": {
|
||||
"source": "./src/index.ts",
|
||||
"types": "./dist/esm/index.d.ts",
|
||||
"default": "./dist/esm/index.js"
|
||||
},
|
||||
"require": {
|
||||
"source": "./src/index.ts",
|
||||
"types": "./dist/commonjs/index.d.ts",
|
||||
"default": "./dist/commonjs/index.js"
|
||||
}
|
||||
},
|
||||
"./api": {
|
||||
"browser": {
|
||||
"source": "./src/api/index.ts",
|
||||
"types": "./dist/browser/api/index.d.ts",
|
||||
"default": "./dist/browser/api/index.js"
|
||||
},
|
||||
"react-native": {
|
||||
"source": "./src/api/index.ts",
|
||||
"types": "./dist/react-native/api/index.d.ts",
|
||||
"default": "./dist/react-native/api/index.js"
|
||||
},
|
||||
"import": {
|
||||
"source": "./src/api/index.ts",
|
||||
"types": "./dist/esm/api/index.d.ts",
|
||||
"default": "./dist/esm/api/index.js"
|
||||
},
|
||||
"require": {
|
||||
"source": "./src/api/index.ts",
|
||||
"types": "./dist/commonjs/api/index.d.ts",
|
||||
"default": "./dist/commonjs/api/index.js"
|
||||
}
|
||||
},
|
||||
"./models": {
|
||||
"browser": {
|
||||
"source": "./src/models/index.ts",
|
||||
"types": "./dist/browser/models/index.d.ts",
|
||||
"default": "./dist/browser/models/index.js"
|
||||
},
|
||||
"react-native": {
|
||||
"source": "./src/models/index.ts",
|
||||
"types": "./dist/react-native/models/index.d.ts",
|
||||
"default": "./dist/react-native/models/index.js"
|
||||
},
|
||||
"import": {
|
||||
"source": "./src/models/index.ts",
|
||||
"types": "./dist/esm/models/index.d.ts",
|
||||
"default": "./dist/esm/models/index.js"
|
||||
},
|
||||
"require": {
|
||||
"source": "./src/models/index.ts",
|
||||
"types": "./dist/commonjs/models/index.d.ts",
|
||||
"default": "./dist/commonjs/models/index.js"
|
||||
}
|
||||
},
|
||||
"./api/operations": {
|
||||
"browser": {
|
||||
"source": "./src/api/operations/index.ts",
|
||||
"types": "./dist/browser/api/operations/index.d.ts",
|
||||
"default": "./dist/browser/api/operations/index.js"
|
||||
},
|
||||
"react-native": {
|
||||
"source": "./src/api/operations/index.ts",
|
||||
"types": "./dist/react-native/api/operations/index.d.ts",
|
||||
"default": "./dist/react-native/api/operations/index.js"
|
||||
},
|
||||
"import": {
|
||||
"source": "./src/api/operations/index.ts",
|
||||
"types": "./dist/esm/api/operations/index.d.ts",
|
||||
"default": "./dist/esm/api/operations/index.js"
|
||||
},
|
||||
"require": {
|
||||
"source": "./src/api/operations/index.ts",
|
||||
"types": "./dist/commonjs/api/operations/index.d.ts",
|
||||
"default": "./dist/commonjs/api/operations/index.js"
|
||||
}
|
||||
},
|
||||
"./api/extendedZones": {
|
||||
"browser": {
|
||||
"source": "./src/api/extendedZones/index.ts",
|
||||
"types": "./dist/browser/api/extendedZones/index.d.ts",
|
||||
"default": "./dist/browser/api/extendedZones/index.js"
|
||||
},
|
||||
"react-native": {
|
||||
"source": "./src/api/extendedZones/index.ts",
|
||||
"types": "./dist/react-native/api/extendedZones/index.d.ts",
|
||||
"default": "./dist/react-native/api/extendedZones/index.js"
|
||||
},
|
||||
"import": {
|
||||
"source": "./src/api/extendedZones/index.ts",
|
||||
"types": "./dist/esm/api/extendedZones/index.d.ts",
|
||||
"default": "./dist/esm/api/extendedZones/index.js"
|
||||
},
|
||||
"require": {
|
||||
"source": "./src/api/extendedZones/index.ts",
|
||||
"types": "./dist/commonjs/api/extendedZones/index.d.ts",
|
||||
"default": "./dist/commonjs/api/extendedZones/index.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"main": "./dist/commonjs/index.js",
|
||||
"types": "./dist/commonjs/index.d.ts",
|
||||
"module": "./dist/esm/index.js"
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
## API Report File for "@azure/arm-edgezones"
|
||||
|
||||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
||||
|
||||
```ts
|
||||
|
||||
import { Client } from '@azure-rest/core-client';
|
||||
import { HttpResponse } from '@azure-rest/core-client';
|
||||
import { OperationOptions } from '@azure-rest/core-client';
|
||||
import { Paged } from '@azure/core-paging';
|
||||
import { RequestParameters } from '@azure-rest/core-client';
|
||||
import { StreamableMethod } from '@azure-rest/core-client';
|
||||
|
||||
// @public
|
||||
export function get(context: EdgeZonesContext, subscriptionId: string, extendedZoneName: string, options?: ExtendedZonesGetOptionalParams): Promise<ExtendedZone>;
|
||||
|
||||
// @public (undocumented)
|
||||
export function _getDeserialize(result: Get200Response | GetDefaultResponse): Promise<ExtendedZone>;
|
||||
|
||||
// @public (undocumented)
|
||||
export function _getSend(context: EdgeZonesContext, subscriptionId: string, extendedZoneName: string, options?: ExtendedZonesGetOptionalParams): StreamableMethod<Get200Response | GetDefaultResponse>;
|
||||
|
||||
// @public
|
||||
export function listBySubscription(context: EdgeZonesContext, subscriptionId: string, options?: ExtendedZonesListBySubscriptionOptionalParams): PagedAsyncIterableIterator<ExtendedZone>;
|
||||
|
||||
// @public (undocumented)
|
||||
export function _listBySubscriptionDeserialize(result: ListBySubscription200Response | ListBySubscriptionDefaultResponse): Promise<_ExtendedZoneListResult>;
|
||||
|
||||
// @public (undocumented)
|
||||
export function _listBySubscriptionSend(context: EdgeZonesContext, subscriptionId: string, options?: ExtendedZonesListBySubscriptionOptionalParams): StreamableMethod<ListBySubscription200Response | ListBySubscriptionDefaultResponse>;
|
||||
|
||||
// @public
|
||||
export function register(context: EdgeZonesContext, subscriptionId: string, extendedZoneName: string, options?: ExtendedZonesRegisterOptionalParams): Promise<ExtendedZone>;
|
||||
|
||||
// @public (undocumented)
|
||||
export function _registerDeserialize(result: Register200Response | RegisterDefaultResponse): Promise<ExtendedZone>;
|
||||
|
||||
// @public (undocumented)
|
||||
export function _registerSend(context: EdgeZonesContext, subscriptionId: string, extendedZoneName: string, options?: ExtendedZonesRegisterOptionalParams): StreamableMethod<Register200Response | RegisterDefaultResponse>;
|
||||
|
||||
// @public
|
||||
export function unregister(context: EdgeZonesContext, subscriptionId: string, extendedZoneName: string, options?: ExtendedZonesUnregisterOptionalParams): Promise<ExtendedZone>;
|
||||
|
||||
// @public (undocumented)
|
||||
export function _unregisterDeserialize(result: Unregister200Response | UnregisterDefaultResponse): Promise<ExtendedZone>;
|
||||
|
||||
// @public (undocumented)
|
||||
export function _unregisterSend(context: EdgeZonesContext, subscriptionId: string, extendedZoneName: string, options?: ExtendedZonesUnregisterOptionalParams): StreamableMethod<Unregister200Response | UnregisterDefaultResponse>;
|
||||
|
||||
// (No @packageDocumentation comment for this package)
|
||||
|
||||
```
|
|
@ -0,0 +1,25 @@
|
|||
## API Report File for "@azure/arm-edgezones"
|
||||
|
||||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
||||
|
||||
```ts
|
||||
|
||||
import { Client } from '@azure-rest/core-client';
|
||||
import { HttpResponse } from '@azure-rest/core-client';
|
||||
import { OperationOptions } from '@azure-rest/core-client';
|
||||
import { Paged } from '@azure/core-paging';
|
||||
import { RequestParameters } from '@azure-rest/core-client';
|
||||
import { StreamableMethod } from '@azure-rest/core-client';
|
||||
|
||||
// @public
|
||||
export function list(context: EdgeZonesContext, options?: OperationsListOptionalParams): PagedAsyncIterableIterator<Operation>;
|
||||
|
||||
// @public (undocumented)
|
||||
export function _listDeserialize(result: List200Response | ListDefaultResponse): Promise<_OperationListResult>;
|
||||
|
||||
// @public (undocumented)
|
||||
export function _listSend(context: EdgeZonesContext, options?: OperationsListOptionalParams): StreamableMethod<List200Response | ListDefaultResponse>;
|
||||
|
||||
// (No @packageDocumentation comment for this package)
|
||||
|
||||
```
|
|
@ -0,0 +1,30 @@
|
|||
## API Report File for "@azure/arm-edgezones"
|
||||
|
||||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
||||
|
||||
```ts
|
||||
|
||||
import { Client } from '@azure-rest/core-client';
|
||||
import { ClientOptions } from '@azure-rest/core-client';
|
||||
import { HttpResponse } from '@azure-rest/core-client';
|
||||
import { Paged } from '@azure/core-paging';
|
||||
import { RequestParameters } from '@azure-rest/core-client';
|
||||
import { StreamableMethod } from '@azure-rest/core-client';
|
||||
import { TokenCredential } from '@azure/core-auth';
|
||||
|
||||
// @public (undocumented)
|
||||
export function createEdgeZones(credential: TokenCredential, options?: EdgeZonesClientOptionalParams): EdgeZonesContext;
|
||||
|
||||
// @public
|
||||
export interface EdgeZonesClientOptionalParams extends ClientOptions {
|
||||
apiVersion?: string;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export type EdgeZonesContext = Client & {
|
||||
path: Routes;
|
||||
};
|
||||
|
||||
// (No @packageDocumentation comment for this package)
|
||||
|
||||
```
|
|
@ -0,0 +1,180 @@
|
|||
## API Report File for "@azure/arm-edgezones"
|
||||
|
||||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
||||
|
||||
```ts
|
||||
|
||||
import { OperationOptions } from '@azure-rest/core-client';
|
||||
|
||||
// @public
|
||||
export type ActionType = string;
|
||||
|
||||
// @public
|
||||
export type ContinuablePage<TElement, TPage = TElement[]> = TPage & {
|
||||
continuationToken?: string;
|
||||
};
|
||||
|
||||
// @public
|
||||
export type CreatedByType = string;
|
||||
|
||||
// @public
|
||||
export interface ErrorAdditionalInfo {
|
||||
readonly info?: Record<string, any>;
|
||||
readonly type?: string;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface ErrorDetail {
|
||||
readonly additionalInfo?: ErrorAdditionalInfo[];
|
||||
readonly code?: string;
|
||||
readonly details?: ErrorDetail[];
|
||||
readonly message?: string;
|
||||
readonly target?: string;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface ErrorResponse {
|
||||
error?: ErrorDetail;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface ExtendedZone extends ProxyResource {
|
||||
properties?: ExtendedZoneProperties;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface ExtendedZoneProperties {
|
||||
readonly displayName: string;
|
||||
readonly geography: string;
|
||||
readonly geographyGroup: string;
|
||||
readonly homeLocation: string;
|
||||
readonly latitude: string;
|
||||
readonly longitude: string;
|
||||
readonly provisioningState?: ProvisioningState;
|
||||
readonly regionalDisplayName: string;
|
||||
readonly regionCategory: string;
|
||||
readonly regionType: string;
|
||||
readonly registrationState?: RegistrationState;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface ExtendedZonesGetOptionalParams extends OperationOptions {
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface ExtendedZonesListBySubscriptionOptionalParams extends OperationOptions {
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface ExtendedZonesRegisterOptionalParams extends OperationOptions {
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface ExtendedZonesUnregisterOptionalParams extends OperationOptions {
|
||||
}
|
||||
|
||||
// @public
|
||||
export enum KnownActionType {
|
||||
Internal = "Internal"
|
||||
}
|
||||
|
||||
// @public
|
||||
export enum KnownCreatedByType {
|
||||
Application = "Application",
|
||||
Key = "Key",
|
||||
ManagedIdentity = "ManagedIdentity",
|
||||
User = "User"
|
||||
}
|
||||
|
||||
// @public
|
||||
export enum KnownOrigin {
|
||||
"user,system" = "user,system",
|
||||
system = "system",
|
||||
user = "user"
|
||||
}
|
||||
|
||||
// @public
|
||||
export enum KnownRegistrationState {
|
||||
NotRegistered = "NotRegistered",
|
||||
PendingRegister = "PendingRegister",
|
||||
PendingUnregister = "PendingUnregister",
|
||||
Registered = "Registered"
|
||||
}
|
||||
|
||||
// @public
|
||||
export enum KnownResourceProvisioningState {
|
||||
Canceled = "Canceled",
|
||||
Failed = "Failed",
|
||||
Succeeded = "Succeeded"
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface Operation {
|
||||
actionType?: ActionType;
|
||||
display?: OperationDisplay;
|
||||
readonly isDataAction?: boolean;
|
||||
readonly name?: string;
|
||||
readonly origin?: Origin;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface OperationDisplay {
|
||||
description?: string;
|
||||
operation?: string;
|
||||
provider?: string;
|
||||
resource?: string;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface OperationsListOptionalParams extends OperationOptions {
|
||||
}
|
||||
|
||||
// @public
|
||||
export type Origin = string;
|
||||
|
||||
// @public
|
||||
export interface PagedAsyncIterableIterator<TElement, TPage = TElement[], TPageSettings extends PageSettings = PageSettings> {
|
||||
[Symbol.asyncIterator](): PagedAsyncIterableIterator<TElement, TPage, TPageSettings>;
|
||||
byPage: (settings?: TPageSettings) => AsyncIterableIterator<ContinuablePage<TElement, TPage>>;
|
||||
next(): Promise<IteratorResult<TElement>>;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface PageSettings {
|
||||
continuationToken?: string;
|
||||
}
|
||||
|
||||
// @public
|
||||
export type ProvisioningState = string | ResourceProvisioningState | "Provisioning" | "Updating" | "Deleting" | "Accepted";
|
||||
|
||||
// @public
|
||||
export interface ProxyResource extends Resource {
|
||||
}
|
||||
|
||||
// @public
|
||||
export type RegistrationState = string;
|
||||
|
||||
// @public
|
||||
export interface Resource {
|
||||
readonly id?: string;
|
||||
readonly name?: string;
|
||||
readonly systemData?: SystemData;
|
||||
readonly type?: string;
|
||||
}
|
||||
|
||||
// @public
|
||||
export type ResourceProvisioningState = string;
|
||||
|
||||
// @public
|
||||
export interface SystemData {
|
||||
createdAt?: Date;
|
||||
createdBy?: string;
|
||||
createdByType?: CreatedByType;
|
||||
lastModifiedAt?: Date;
|
||||
lastModifiedBy?: string;
|
||||
lastModifiedByType?: CreatedByType;
|
||||
}
|
||||
|
||||
// (No @packageDocumentation comment for this package)
|
||||
|
||||
```
|
|
@ -0,0 +1,209 @@
|
|||
## API Report File for "@azure/arm-edgezones"
|
||||
|
||||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
||||
|
||||
```ts
|
||||
|
||||
import { ClientOptions } from '@azure-rest/core-client';
|
||||
import { OperationOptions } from '@azure-rest/core-client';
|
||||
import { Pipeline } from '@azure/core-rest-pipeline';
|
||||
import { TokenCredential } from '@azure/core-auth';
|
||||
|
||||
// @public
|
||||
export type ActionType = string;
|
||||
|
||||
// @public
|
||||
export type ContinuablePage<TElement, TPage = TElement[]> = TPage & {
|
||||
continuationToken?: string;
|
||||
};
|
||||
|
||||
// @public
|
||||
export type CreatedByType = string;
|
||||
|
||||
// @public (undocumented)
|
||||
export class EdgeZonesClient {
|
||||
constructor(credential: TokenCredential, subscriptionId: string, options?: EdgeZonesClientOptionalParams);
|
||||
readonly extendedZones: ExtendedZonesOperations;
|
||||
readonly operations: OperationsOperations;
|
||||
readonly pipeline: Pipeline;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface EdgeZonesClientOptionalParams extends ClientOptions {
|
||||
apiVersion?: string;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface ErrorAdditionalInfo {
|
||||
readonly info?: Record<string, any>;
|
||||
readonly type?: string;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface ErrorDetail {
|
||||
readonly additionalInfo?: ErrorAdditionalInfo[];
|
||||
readonly code?: string;
|
||||
readonly details?: ErrorDetail[];
|
||||
readonly message?: string;
|
||||
readonly target?: string;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface ErrorResponse {
|
||||
error?: ErrorDetail;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface ExtendedZone extends ProxyResource {
|
||||
properties?: ExtendedZoneProperties;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface ExtendedZoneProperties {
|
||||
readonly displayName: string;
|
||||
readonly geography: string;
|
||||
readonly geographyGroup: string;
|
||||
readonly homeLocation: string;
|
||||
readonly latitude: string;
|
||||
readonly longitude: string;
|
||||
readonly provisioningState?: ProvisioningState;
|
||||
readonly regionalDisplayName: string;
|
||||
readonly regionCategory: string;
|
||||
readonly regionType: string;
|
||||
readonly registrationState?: RegistrationState;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface ExtendedZonesGetOptionalParams extends OperationOptions {
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface ExtendedZonesListBySubscriptionOptionalParams extends OperationOptions {
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface ExtendedZonesOperations {
|
||||
get: (extendedZoneName: string, options?: ExtendedZonesGetOptionalParams) => Promise<ExtendedZone>;
|
||||
listBySubscription: (options?: ExtendedZonesListBySubscriptionOptionalParams) => PagedAsyncIterableIterator<ExtendedZone>;
|
||||
register: (extendedZoneName: string, options?: ExtendedZonesRegisterOptionalParams) => Promise<ExtendedZone>;
|
||||
unregister: (extendedZoneName: string, options?: ExtendedZonesUnregisterOptionalParams) => Promise<ExtendedZone>;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface ExtendedZonesRegisterOptionalParams extends OperationOptions {
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface ExtendedZonesUnregisterOptionalParams extends OperationOptions {
|
||||
}
|
||||
|
||||
// @public
|
||||
export enum KnownActionType {
|
||||
Internal = "Internal"
|
||||
}
|
||||
|
||||
// @public
|
||||
export enum KnownCreatedByType {
|
||||
Application = "Application",
|
||||
Key = "Key",
|
||||
ManagedIdentity = "ManagedIdentity",
|
||||
User = "User"
|
||||
}
|
||||
|
||||
// @public
|
||||
export enum KnownOrigin {
|
||||
"user,system" = "user,system",
|
||||
system = "system",
|
||||
user = "user"
|
||||
}
|
||||
|
||||
// @public
|
||||
export enum KnownRegistrationState {
|
||||
NotRegistered = "NotRegistered",
|
||||
PendingRegister = "PendingRegister",
|
||||
PendingUnregister = "PendingUnregister",
|
||||
Registered = "Registered"
|
||||
}
|
||||
|
||||
// @public
|
||||
export enum KnownResourceProvisioningState {
|
||||
Canceled = "Canceled",
|
||||
Failed = "Failed",
|
||||
Succeeded = "Succeeded"
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface Operation {
|
||||
actionType?: ActionType;
|
||||
display?: OperationDisplay;
|
||||
readonly isDataAction?: boolean;
|
||||
readonly name?: string;
|
||||
readonly origin?: Origin;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface OperationDisplay {
|
||||
description?: string;
|
||||
operation?: string;
|
||||
provider?: string;
|
||||
resource?: string;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface OperationsListOptionalParams extends OperationOptions {
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface OperationsOperations {
|
||||
list: (options?: OperationsListOptionalParams) => PagedAsyncIterableIterator<Operation>;
|
||||
}
|
||||
|
||||
// @public
|
||||
export type Origin = string;
|
||||
|
||||
// @public
|
||||
export interface PagedAsyncIterableIterator<TElement, TPage = TElement[], TPageSettings extends PageSettings = PageSettings> {
|
||||
[Symbol.asyncIterator](): PagedAsyncIterableIterator<TElement, TPage, TPageSettings>;
|
||||
byPage: (settings?: TPageSettings) => AsyncIterableIterator<ContinuablePage<TElement, TPage>>;
|
||||
next(): Promise<IteratorResult<TElement>>;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface PageSettings {
|
||||
continuationToken?: string;
|
||||
}
|
||||
|
||||
// @public
|
||||
export type ProvisioningState = string | ResourceProvisioningState | "Provisioning" | "Updating" | "Deleting" | "Accepted";
|
||||
|
||||
// @public
|
||||
export interface ProxyResource extends Resource {
|
||||
}
|
||||
|
||||
// @public
|
||||
export type RegistrationState = string;
|
||||
|
||||
// @public
|
||||
export interface Resource {
|
||||
readonly id?: string;
|
||||
readonly name?: string;
|
||||
readonly systemData?: SystemData;
|
||||
readonly type?: string;
|
||||
}
|
||||
|
||||
// @public
|
||||
export type ResourceProvisioningState = string;
|
||||
|
||||
// @public
|
||||
export interface SystemData {
|
||||
createdAt?: Date;
|
||||
createdBy?: string;
|
||||
createdByType?: CreatedByType;
|
||||
lastModifiedAt?: Date;
|
||||
lastModifiedBy?: string;
|
||||
lastModifiedByType?: CreatedByType;
|
||||
}
|
||||
|
||||
// (No @packageDocumentation comment for this package)
|
||||
|
||||
```
|
|
@ -0,0 +1,29 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { TokenCredential } from "@azure/core-auth";
|
||||
import { ClientOptions } from "@azure-rest/core-client";
|
||||
import { EdgeZonesContext } from "../rest/index.js";
|
||||
import getClient from "../rest/index.js";
|
||||
|
||||
/** Optional parameters for the client. */
|
||||
export interface EdgeZonesClientOptionalParams extends ClientOptions {
|
||||
/** The API version to use for this operation. */
|
||||
apiVersion?: string;
|
||||
}
|
||||
|
||||
export { EdgeZonesContext } from "../rest/index.js";
|
||||
|
||||
export function createEdgeZones(
|
||||
credential: TokenCredential,
|
||||
options: EdgeZonesClientOptionalParams = {},
|
||||
): EdgeZonesContext {
|
||||
const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix;
|
||||
const userAgentPrefix = prefixFromOptions ? `${prefixFromOptions} azsdk-js-api` : "azsdk-js-api";
|
||||
|
||||
const clientContext = getClient(credential, {
|
||||
...options,
|
||||
userAgentOptions: { userAgentPrefix },
|
||||
});
|
||||
return clientContext;
|
||||
}
|
|
@ -0,0 +1,323 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { ExtendedZone, _ExtendedZoneListResult } from "../../models/models.js";
|
||||
import { PagedAsyncIterableIterator } from "../../models/pagingTypes.js";
|
||||
import { buildPagedAsyncIterator } from "../pagingHelpers.js";
|
||||
import {
|
||||
isUnexpected,
|
||||
EdgeZonesContext as Client,
|
||||
Get200Response,
|
||||
GetDefaultResponse,
|
||||
ListBySubscription200Response,
|
||||
ListBySubscriptionDefaultResponse,
|
||||
Register200Response,
|
||||
RegisterDefaultResponse,
|
||||
Unregister200Response,
|
||||
UnregisterDefaultResponse,
|
||||
} from "../../rest/index.js";
|
||||
import {
|
||||
StreamableMethod,
|
||||
operationOptionsToRequestParameters,
|
||||
createRestError,
|
||||
} from "@azure-rest/core-client";
|
||||
import {
|
||||
ExtendedZonesGetOptionalParams,
|
||||
ExtendedZonesListBySubscriptionOptionalParams,
|
||||
ExtendedZonesRegisterOptionalParams,
|
||||
ExtendedZonesUnregisterOptionalParams,
|
||||
} from "../../models/options.js";
|
||||
|
||||
export function _getSend(
|
||||
context: Client,
|
||||
subscriptionId: string,
|
||||
extendedZoneName: string,
|
||||
options: ExtendedZonesGetOptionalParams = { requestOptions: {} },
|
||||
): StreamableMethod<Get200Response | GetDefaultResponse> {
|
||||
return context
|
||||
.path(
|
||||
"/subscriptions/{subscriptionId}/providers/Microsoft.EdgeZones/extendedZones/{extendedZoneName}",
|
||||
subscriptionId,
|
||||
extendedZoneName,
|
||||
)
|
||||
.get({ ...operationOptionsToRequestParameters(options) });
|
||||
}
|
||||
|
||||
export async function _getDeserialize(
|
||||
result: Get200Response | GetDefaultResponse,
|
||||
): Promise<ExtendedZone> {
|
||||
if (isUnexpected(result)) {
|
||||
throw createRestError(result);
|
||||
}
|
||||
|
||||
return {
|
||||
id: result.body["id"],
|
||||
name: result.body["name"],
|
||||
type: result.body["type"],
|
||||
systemData: !result.body.systemData
|
||||
? undefined
|
||||
: {
|
||||
createdBy: result.body.systemData?.["createdBy"],
|
||||
createdByType: result.body.systemData?.["createdByType"],
|
||||
createdAt:
|
||||
result.body.systemData?.["createdAt"] !== undefined
|
||||
? new Date(result.body.systemData?.["createdAt"])
|
||||
: undefined,
|
||||
lastModifiedBy: result.body.systemData?.["lastModifiedBy"],
|
||||
lastModifiedByType: result.body.systemData?.["lastModifiedByType"],
|
||||
lastModifiedAt:
|
||||
result.body.systemData?.["lastModifiedAt"] !== undefined
|
||||
? new Date(result.body.systemData?.["lastModifiedAt"])
|
||||
: undefined,
|
||||
},
|
||||
properties: !result.body.properties
|
||||
? undefined
|
||||
: {
|
||||
provisioningState: result.body.properties?.["provisioningState"],
|
||||
registrationState: result.body.properties?.["registrationState"],
|
||||
displayName: result.body.properties?.["displayName"],
|
||||
regionalDisplayName: result.body.properties?.["regionalDisplayName"],
|
||||
regionType: result.body.properties?.["regionType"],
|
||||
regionCategory: result.body.properties?.["regionCategory"],
|
||||
geography: result.body.properties?.["geography"],
|
||||
geographyGroup: result.body.properties?.["geographyGroup"],
|
||||
longitude: result.body.properties?.["longitude"],
|
||||
latitude: result.body.properties?.["latitude"],
|
||||
homeLocation: result.body.properties?.["homeLocation"],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/** Gets an Azure Extended Zone for a subscription */
|
||||
export async function get(
|
||||
context: Client,
|
||||
subscriptionId: string,
|
||||
extendedZoneName: string,
|
||||
options: ExtendedZonesGetOptionalParams = { requestOptions: {} },
|
||||
): Promise<ExtendedZone> {
|
||||
const result = await _getSend(context, subscriptionId, extendedZoneName, options);
|
||||
return _getDeserialize(result);
|
||||
}
|
||||
|
||||
export function _listBySubscriptionSend(
|
||||
context: Client,
|
||||
subscriptionId: string,
|
||||
options: ExtendedZonesListBySubscriptionOptionalParams = {
|
||||
requestOptions: {},
|
||||
},
|
||||
): StreamableMethod<ListBySubscription200Response | ListBySubscriptionDefaultResponse> {
|
||||
return context
|
||||
.path(
|
||||
"/subscriptions/{subscriptionId}/providers/Microsoft.EdgeZones/extendedZones",
|
||||
subscriptionId,
|
||||
)
|
||||
.get({ ...operationOptionsToRequestParameters(options) });
|
||||
}
|
||||
|
||||
export async function _listBySubscriptionDeserialize(
|
||||
result: ListBySubscription200Response | ListBySubscriptionDefaultResponse,
|
||||
): Promise<_ExtendedZoneListResult> {
|
||||
if (isUnexpected(result)) {
|
||||
throw createRestError(result);
|
||||
}
|
||||
|
||||
return {
|
||||
value: result.body["value"].map((p) => {
|
||||
return {
|
||||
id: p["id"],
|
||||
name: p["name"],
|
||||
type: p["type"],
|
||||
systemData: !p.systemData
|
||||
? undefined
|
||||
: {
|
||||
createdBy: p.systemData?.["createdBy"],
|
||||
createdByType: p.systemData?.["createdByType"],
|
||||
createdAt:
|
||||
p.systemData?.["createdAt"] !== undefined
|
||||
? new Date(p.systemData?.["createdAt"])
|
||||
: undefined,
|
||||
lastModifiedBy: p.systemData?.["lastModifiedBy"],
|
||||
lastModifiedByType: p.systemData?.["lastModifiedByType"],
|
||||
lastModifiedAt:
|
||||
p.systemData?.["lastModifiedAt"] !== undefined
|
||||
? new Date(p.systemData?.["lastModifiedAt"])
|
||||
: undefined,
|
||||
},
|
||||
properties: !p.properties
|
||||
? undefined
|
||||
: {
|
||||
provisioningState: p.properties?.["provisioningState"],
|
||||
registrationState: p.properties?.["registrationState"],
|
||||
displayName: p.properties?.["displayName"],
|
||||
regionalDisplayName: p.properties?.["regionalDisplayName"],
|
||||
regionType: p.properties?.["regionType"],
|
||||
regionCategory: p.properties?.["regionCategory"],
|
||||
geography: p.properties?.["geography"],
|
||||
geographyGroup: p.properties?.["geographyGroup"],
|
||||
longitude: p.properties?.["longitude"],
|
||||
latitude: p.properties?.["latitude"],
|
||||
homeLocation: p.properties?.["homeLocation"],
|
||||
},
|
||||
};
|
||||
}),
|
||||
nextLink: result.body["nextLink"],
|
||||
};
|
||||
}
|
||||
|
||||
/** Lists the Azure Extended Zones available to a subscription */
|
||||
export function listBySubscription(
|
||||
context: Client,
|
||||
subscriptionId: string,
|
||||
options: ExtendedZonesListBySubscriptionOptionalParams = {
|
||||
requestOptions: {},
|
||||
},
|
||||
): PagedAsyncIterableIterator<ExtendedZone> {
|
||||
return buildPagedAsyncIterator(
|
||||
context,
|
||||
() => _listBySubscriptionSend(context, subscriptionId, options),
|
||||
_listBySubscriptionDeserialize,
|
||||
{ itemName: "value", nextLinkName: "nextLink" },
|
||||
);
|
||||
}
|
||||
|
||||
export function _registerSend(
|
||||
context: Client,
|
||||
subscriptionId: string,
|
||||
extendedZoneName: string,
|
||||
options: ExtendedZonesRegisterOptionalParams = { requestOptions: {} },
|
||||
): StreamableMethod<Register200Response | RegisterDefaultResponse> {
|
||||
return context
|
||||
.path(
|
||||
"/subscriptions/{subscriptionId}/providers/Microsoft.EdgeZones/extendedZones/{extendedZoneName}/register",
|
||||
subscriptionId,
|
||||
extendedZoneName,
|
||||
)
|
||||
.post({ ...operationOptionsToRequestParameters(options) });
|
||||
}
|
||||
|
||||
export async function _registerDeserialize(
|
||||
result: Register200Response | RegisterDefaultResponse,
|
||||
): Promise<ExtendedZone> {
|
||||
if (isUnexpected(result)) {
|
||||
throw createRestError(result);
|
||||
}
|
||||
|
||||
return {
|
||||
id: result.body["id"],
|
||||
name: result.body["name"],
|
||||
type: result.body["type"],
|
||||
systemData: !result.body.systemData
|
||||
? undefined
|
||||
: {
|
||||
createdBy: result.body.systemData?.["createdBy"],
|
||||
createdByType: result.body.systemData?.["createdByType"],
|
||||
createdAt:
|
||||
result.body.systemData?.["createdAt"] !== undefined
|
||||
? new Date(result.body.systemData?.["createdAt"])
|
||||
: undefined,
|
||||
lastModifiedBy: result.body.systemData?.["lastModifiedBy"],
|
||||
lastModifiedByType: result.body.systemData?.["lastModifiedByType"],
|
||||
lastModifiedAt:
|
||||
result.body.systemData?.["lastModifiedAt"] !== undefined
|
||||
? new Date(result.body.systemData?.["lastModifiedAt"])
|
||||
: undefined,
|
||||
},
|
||||
properties: !result.body.properties
|
||||
? undefined
|
||||
: {
|
||||
provisioningState: result.body.properties?.["provisioningState"],
|
||||
registrationState: result.body.properties?.["registrationState"],
|
||||
displayName: result.body.properties?.["displayName"],
|
||||
regionalDisplayName: result.body.properties?.["regionalDisplayName"],
|
||||
regionType: result.body.properties?.["regionType"],
|
||||
regionCategory: result.body.properties?.["regionCategory"],
|
||||
geography: result.body.properties?.["geography"],
|
||||
geographyGroup: result.body.properties?.["geographyGroup"],
|
||||
longitude: result.body.properties?.["longitude"],
|
||||
latitude: result.body.properties?.["latitude"],
|
||||
homeLocation: result.body.properties?.["homeLocation"],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/** Registers a subscription for an Extended Zone */
|
||||
export async function register(
|
||||
context: Client,
|
||||
subscriptionId: string,
|
||||
extendedZoneName: string,
|
||||
options: ExtendedZonesRegisterOptionalParams = { requestOptions: {} },
|
||||
): Promise<ExtendedZone> {
|
||||
const result = await _registerSend(context, subscriptionId, extendedZoneName, options);
|
||||
return _registerDeserialize(result);
|
||||
}
|
||||
|
||||
export function _unregisterSend(
|
||||
context: Client,
|
||||
subscriptionId: string,
|
||||
extendedZoneName: string,
|
||||
options: ExtendedZonesUnregisterOptionalParams = { requestOptions: {} },
|
||||
): StreamableMethod<Unregister200Response | UnregisterDefaultResponse> {
|
||||
return context
|
||||
.path(
|
||||
"/subscriptions/{subscriptionId}/providers/Microsoft.EdgeZones/extendedZones/{extendedZoneName}/unregister",
|
||||
subscriptionId,
|
||||
extendedZoneName,
|
||||
)
|
||||
.post({ ...operationOptionsToRequestParameters(options) });
|
||||
}
|
||||
|
||||
export async function _unregisterDeserialize(
|
||||
result: Unregister200Response | UnregisterDefaultResponse,
|
||||
): Promise<ExtendedZone> {
|
||||
if (isUnexpected(result)) {
|
||||
throw createRestError(result);
|
||||
}
|
||||
|
||||
return {
|
||||
id: result.body["id"],
|
||||
name: result.body["name"],
|
||||
type: result.body["type"],
|
||||
systemData: !result.body.systemData
|
||||
? undefined
|
||||
: {
|
||||
createdBy: result.body.systemData?.["createdBy"],
|
||||
createdByType: result.body.systemData?.["createdByType"],
|
||||
createdAt:
|
||||
result.body.systemData?.["createdAt"] !== undefined
|
||||
? new Date(result.body.systemData?.["createdAt"])
|
||||
: undefined,
|
||||
lastModifiedBy: result.body.systemData?.["lastModifiedBy"],
|
||||
lastModifiedByType: result.body.systemData?.["lastModifiedByType"],
|
||||
lastModifiedAt:
|
||||
result.body.systemData?.["lastModifiedAt"] !== undefined
|
||||
? new Date(result.body.systemData?.["lastModifiedAt"])
|
||||
: undefined,
|
||||
},
|
||||
properties: !result.body.properties
|
||||
? undefined
|
||||
: {
|
||||
provisioningState: result.body.properties?.["provisioningState"],
|
||||
registrationState: result.body.properties?.["registrationState"],
|
||||
displayName: result.body.properties?.["displayName"],
|
||||
regionalDisplayName: result.body.properties?.["regionalDisplayName"],
|
||||
regionType: result.body.properties?.["regionType"],
|
||||
regionCategory: result.body.properties?.["regionCategory"],
|
||||
geography: result.body.properties?.["geography"],
|
||||
geographyGroup: result.body.properties?.["geographyGroup"],
|
||||
longitude: result.body.properties?.["longitude"],
|
||||
latitude: result.body.properties?.["latitude"],
|
||||
homeLocation: result.body.properties?.["homeLocation"],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/** Unregisters a subscription for an Extended Zone */
|
||||
export async function unregister(
|
||||
context: Client,
|
||||
subscriptionId: string,
|
||||
extendedZoneName: string,
|
||||
options: ExtendedZonesUnregisterOptionalParams = { requestOptions: {} },
|
||||
): Promise<ExtendedZone> {
|
||||
const result = await _unregisterSend(context, subscriptionId, extendedZoneName, options);
|
||||
return _unregisterDeserialize(result);
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
export {
|
||||
createEdgeZones,
|
||||
EdgeZonesClientOptionalParams,
|
||||
EdgeZonesContext,
|
||||
} from "./edgeZonesContext.js";
|
|
@ -0,0 +1,66 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { Operation, _OperationListResult } from "../../models/models.js";
|
||||
import { PagedAsyncIterableIterator } from "../../models/pagingTypes.js";
|
||||
import { buildPagedAsyncIterator } from "../pagingHelpers.js";
|
||||
import {
|
||||
isUnexpected,
|
||||
EdgeZonesContext as Client,
|
||||
List200Response,
|
||||
ListDefaultResponse,
|
||||
} from "../../rest/index.js";
|
||||
import {
|
||||
StreamableMethod,
|
||||
operationOptionsToRequestParameters,
|
||||
createRestError,
|
||||
} from "@azure-rest/core-client";
|
||||
import { OperationsListOptionalParams } from "../../models/options.js";
|
||||
|
||||
export function _listSend(
|
||||
context: Client,
|
||||
options: OperationsListOptionalParams = { requestOptions: {} },
|
||||
): StreamableMethod<List200Response | ListDefaultResponse> {
|
||||
return context
|
||||
.path("/providers/Microsoft.EdgeZones/operations")
|
||||
.get({ ...operationOptionsToRequestParameters(options) });
|
||||
}
|
||||
|
||||
export async function _listDeserialize(
|
||||
result: List200Response | ListDefaultResponse,
|
||||
): Promise<_OperationListResult> {
|
||||
if (isUnexpected(result)) {
|
||||
throw createRestError(result);
|
||||
}
|
||||
|
||||
return {
|
||||
value: result.body["value"].map((p) => {
|
||||
return {
|
||||
name: p["name"],
|
||||
isDataAction: p["isDataAction"],
|
||||
display: !p.display
|
||||
? undefined
|
||||
: {
|
||||
provider: p.display?.["provider"],
|
||||
resource: p.display?.["resource"],
|
||||
operation: p.display?.["operation"],
|
||||
description: p.display?.["description"],
|
||||
},
|
||||
origin: p["origin"],
|
||||
actionType: p["actionType"],
|
||||
};
|
||||
}),
|
||||
nextLink: result.body["nextLink"],
|
||||
};
|
||||
}
|
||||
|
||||
/** List the operations for the provider */
|
||||
export function list(
|
||||
context: Client,
|
||||
options: OperationsListOptionalParams = { requestOptions: {} },
|
||||
): PagedAsyncIterableIterator<Operation> {
|
||||
return buildPagedAsyncIterator(context, () => _listSend(context, options), _listDeserialize, {
|
||||
itemName: "value",
|
||||
nextLinkName: "nextLink",
|
||||
});
|
||||
}
|
|
@ -0,0 +1,171 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { Client, createRestError, PathUncheckedResponse } from "@azure-rest/core-client";
|
||||
import { RestError } from "@azure/core-rest-pipeline";
|
||||
import {
|
||||
BuildPagedAsyncIteratorOptions,
|
||||
ContinuablePage,
|
||||
PageSettings,
|
||||
PagedAsyncIterableIterator,
|
||||
PagedResult,
|
||||
} from "../models/pagingTypes.js";
|
||||
import { isUnexpected } from "../rest/index.js";
|
||||
|
||||
/**
|
||||
* Helper to paginate results in a generic way and return a PagedAsyncIterableIterator
|
||||
*/
|
||||
export function buildPagedAsyncIterator<
|
||||
TElement,
|
||||
TPage = TElement[],
|
||||
TPageSettings extends PageSettings = PageSettings,
|
||||
TResponse extends PathUncheckedResponse = PathUncheckedResponse,
|
||||
>(
|
||||
client: Client,
|
||||
getInitialResponse: () => PromiseLike<TResponse>,
|
||||
processResponseBody: (result: TResponse) => PromiseLike<unknown>,
|
||||
options: BuildPagedAsyncIteratorOptions = {},
|
||||
): PagedAsyncIterableIterator<TElement, TPage, TPageSettings> {
|
||||
const itemName = options.itemName ?? "value";
|
||||
const nextLinkName = options.nextLinkName ?? "nextLink";
|
||||
const pagedResult: PagedResult<TElement, TPage, TPageSettings> = {
|
||||
getPage: async (pageLink?: string) => {
|
||||
const result =
|
||||
pageLink === undefined
|
||||
? await getInitialResponse()
|
||||
: await client.pathUnchecked(pageLink).get();
|
||||
checkPagingRequest(result);
|
||||
const results = await processResponseBody(result as TResponse);
|
||||
const nextLink = getNextLink(results, nextLinkName);
|
||||
const values = getElements<TElement>(results, itemName) as TPage;
|
||||
return {
|
||||
page: values,
|
||||
nextPageLink: nextLink,
|
||||
};
|
||||
},
|
||||
byPage: (settings?: TPageSettings) => {
|
||||
const { continuationToken } = settings ?? {};
|
||||
return getPageAsyncIterator(pagedResult, {
|
||||
pageLink: continuationToken,
|
||||
});
|
||||
},
|
||||
};
|
||||
return getPagedAsyncIterator(pagedResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns an async iterator that iterates over results. It also has a `byPage`
|
||||
* method that returns pages of items at once.
|
||||
*
|
||||
* @param pagedResult - an object that specifies how to get pages.
|
||||
* @returns a paged async iterator that iterates over results.
|
||||
*/
|
||||
|
||||
function getPagedAsyncIterator<
|
||||
TElement,
|
||||
TPage = TElement[],
|
||||
TPageSettings extends PageSettings = PageSettings,
|
||||
>(
|
||||
pagedResult: PagedResult<TElement, TPage, TPageSettings>,
|
||||
): PagedAsyncIterableIterator<TElement, TPage, TPageSettings> {
|
||||
const iter = getItemAsyncIterator<TElement, TPage, TPageSettings>(pagedResult);
|
||||
return {
|
||||
next() {
|
||||
return iter.next();
|
||||
},
|
||||
[Symbol.asyncIterator]() {
|
||||
return this;
|
||||
},
|
||||
byPage:
|
||||
pagedResult?.byPage ??
|
||||
((settings?: TPageSettings) => {
|
||||
const { continuationToken } = settings ?? {};
|
||||
return getPageAsyncIterator(pagedResult, {
|
||||
pageLink: continuationToken,
|
||||
});
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
async function* getItemAsyncIterator<TElement, TPage, TPageSettings extends PageSettings>(
|
||||
pagedResult: PagedResult<TElement, TPage, TPageSettings>,
|
||||
): AsyncIterableIterator<TElement> {
|
||||
const pages = getPageAsyncIterator(pagedResult);
|
||||
for await (const page of pages) {
|
||||
yield* page as unknown as TElement[];
|
||||
}
|
||||
}
|
||||
|
||||
async function* getPageAsyncIterator<TElement, TPage, TPageSettings extends PageSettings>(
|
||||
pagedResult: PagedResult<TElement, TPage, TPageSettings>,
|
||||
options: {
|
||||
pageLink?: string;
|
||||
} = {},
|
||||
): AsyncIterableIterator<ContinuablePage<TElement, TPage>> {
|
||||
const { pageLink } = options;
|
||||
let response = await pagedResult.getPage(pageLink ?? pagedResult.firstPageLink);
|
||||
if (!response) {
|
||||
return;
|
||||
}
|
||||
let result = response.page as ContinuablePage<TElement, TPage>;
|
||||
result.continuationToken = response.nextPageLink;
|
||||
yield result;
|
||||
while (response.nextPageLink) {
|
||||
response = await pagedResult.getPage(response.nextPageLink);
|
||||
if (!response) {
|
||||
return;
|
||||
}
|
||||
result = response.page as ContinuablePage<TElement, TPage>;
|
||||
result.continuationToken = response.nextPageLink;
|
||||
yield result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets for the value of nextLink in the body
|
||||
*/
|
||||
function getNextLink(body: unknown, nextLinkName?: string): string | undefined {
|
||||
if (!nextLinkName) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const nextLink = (body as Record<string, unknown>)[nextLinkName];
|
||||
|
||||
if (typeof nextLink !== "string" && typeof nextLink !== "undefined" && nextLink !== null) {
|
||||
throw new RestError(
|
||||
`Body Property ${nextLinkName} should be a string or undefined or null but got ${typeof nextLink}`,
|
||||
);
|
||||
}
|
||||
|
||||
if (nextLink === null) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return nextLink;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the elements of the current request in the body.
|
||||
*/
|
||||
function getElements<T = unknown>(body: unknown, itemName: string): T[] {
|
||||
const value = (body as Record<string, unknown>)[itemName] as T[];
|
||||
if (!Array.isArray(value)) {
|
||||
throw new RestError(
|
||||
`Couldn't paginate response\n Body doesn't contain an array property with name: ${itemName}`,
|
||||
);
|
||||
}
|
||||
|
||||
return value ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a request failed
|
||||
*/
|
||||
function checkPagingRequest(response: PathUncheckedResponse): void {
|
||||
if (isUnexpected(response)) {
|
||||
throw createRestError(
|
||||
`Pagination failed with unexpected statusCode ${response.status}`,
|
||||
response,
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { EdgeZonesContext } from "../../api/edgeZonesContext.js";
|
||||
import { ExtendedZone } from "../../models/models.js";
|
||||
import { get, listBySubscription, register, unregister } from "../../api/extendedZones/index.js";
|
||||
import { PagedAsyncIterableIterator } from "../../models/pagingTypes.js";
|
||||
import {
|
||||
ExtendedZonesGetOptionalParams,
|
||||
ExtendedZonesListBySubscriptionOptionalParams,
|
||||
ExtendedZonesRegisterOptionalParams,
|
||||
ExtendedZonesUnregisterOptionalParams,
|
||||
} from "../../models/options.js";
|
||||
|
||||
/** Interface representing a ExtendedZones operations. */
|
||||
export interface ExtendedZonesOperations {
|
||||
/** Gets an Azure Extended Zone for a subscription */
|
||||
get: (
|
||||
extendedZoneName: string,
|
||||
options?: ExtendedZonesGetOptionalParams,
|
||||
) => Promise<ExtendedZone>;
|
||||
/** Lists the Azure Extended Zones available to a subscription */
|
||||
listBySubscription: (
|
||||
options?: ExtendedZonesListBySubscriptionOptionalParams,
|
||||
) => PagedAsyncIterableIterator<ExtendedZone>;
|
||||
/** Registers a subscription for an Extended Zone */
|
||||
register: (
|
||||
extendedZoneName: string,
|
||||
options?: ExtendedZonesRegisterOptionalParams,
|
||||
) => Promise<ExtendedZone>;
|
||||
/** Unregisters a subscription for an Extended Zone */
|
||||
unregister: (
|
||||
extendedZoneName: string,
|
||||
options?: ExtendedZonesUnregisterOptionalParams,
|
||||
) => Promise<ExtendedZone>;
|
||||
}
|
||||
|
||||
export function getExtendedZones(context: EdgeZonesContext, subscriptionId: string) {
|
||||
return {
|
||||
get: (extendedZoneName: string, options?: ExtendedZonesGetOptionalParams) =>
|
||||
get(context, subscriptionId, extendedZoneName, options),
|
||||
listBySubscription: (options?: ExtendedZonesListBySubscriptionOptionalParams) =>
|
||||
listBySubscription(context, subscriptionId, options),
|
||||
register: (extendedZoneName: string, options?: ExtendedZonesRegisterOptionalParams) =>
|
||||
register(context, subscriptionId, extendedZoneName, options),
|
||||
unregister: (extendedZoneName: string, options?: ExtendedZonesUnregisterOptionalParams) =>
|
||||
unregister(context, subscriptionId, extendedZoneName, options),
|
||||
};
|
||||
}
|
||||
|
||||
export function getExtendedZonesOperations(
|
||||
context: EdgeZonesContext,
|
||||
subscriptionId: string,
|
||||
): ExtendedZonesOperations {
|
||||
return {
|
||||
...getExtendedZones(context, subscriptionId),
|
||||
};
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
export { ExtendedZonesOperations } from "./extendedZones/index.js";
|
||||
export { OperationsOperations } from "./operations/index.js";
|
|
@ -0,0 +1,26 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { EdgeZonesContext } from "../../api/edgeZonesContext.js";
|
||||
import { Operation } from "../../models/models.js";
|
||||
import { list } from "../../api/operations/index.js";
|
||||
import { PagedAsyncIterableIterator } from "../../models/pagingTypes.js";
|
||||
import { OperationsListOptionalParams } from "../../models/options.js";
|
||||
|
||||
/** Interface representing a Operations operations. */
|
||||
export interface OperationsOperations {
|
||||
/** List the operations for the provider */
|
||||
list: (options?: OperationsListOptionalParams) => PagedAsyncIterableIterator<Operation>;
|
||||
}
|
||||
|
||||
export function getOperations(context: EdgeZonesContext) {
|
||||
return {
|
||||
list: (options?: OperationsListOptionalParams) => list(context, options),
|
||||
};
|
||||
}
|
||||
|
||||
export function getOperationsOperations(context: EdgeZonesContext): OperationsOperations {
|
||||
return {
|
||||
...getOperations(context),
|
||||
};
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { TokenCredential } from "@azure/core-auth";
|
||||
import { Pipeline } from "@azure/core-rest-pipeline";
|
||||
import { getOperationsOperations, OperationsOperations } from "./classic/operations/index.js";
|
||||
import {
|
||||
getExtendedZonesOperations,
|
||||
ExtendedZonesOperations,
|
||||
} from "./classic/extendedZones/index.js";
|
||||
import { createEdgeZones, EdgeZonesClientOptionalParams, EdgeZonesContext } from "./api/index.js";
|
||||
|
||||
export { EdgeZonesClientOptionalParams } from "./api/edgeZonesContext.js";
|
||||
|
||||
export class EdgeZonesClient {
|
||||
private _client: EdgeZonesContext;
|
||||
/** The pipeline used by this client to make requests */
|
||||
public readonly pipeline: Pipeline;
|
||||
|
||||
constructor(
|
||||
credential: TokenCredential,
|
||||
subscriptionId: string,
|
||||
options: EdgeZonesClientOptionalParams = {},
|
||||
) {
|
||||
const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix;
|
||||
const userAgentPrefix = prefixFromOptions
|
||||
? `${prefixFromOptions} azsdk-js-client`
|
||||
: "azsdk-js-client";
|
||||
|
||||
this._client = createEdgeZones(credential, {
|
||||
...options,
|
||||
userAgentOptions: { userAgentPrefix },
|
||||
});
|
||||
this.pipeline = this._client.pipeline;
|
||||
this.operations = getOperationsOperations(this._client);
|
||||
this.extendedZones = getExtendedZonesOperations(this._client, subscriptionId);
|
||||
}
|
||||
|
||||
/** The operation groups for Operations */
|
||||
public readonly operations: OperationsOperations;
|
||||
/** The operation groups for ExtendedZones */
|
||||
public readonly extendedZones: ExtendedZonesOperations;
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
export function serializeRecord<T extends string | number | boolean | Date | null, R>(
|
||||
item: Record<string, T>,
|
||||
): Record<string, R>;
|
||||
export function serializeRecord<T, R>(
|
||||
item: Record<string, T>,
|
||||
serializer: (item: T) => R,
|
||||
): Record<string, R>;
|
||||
export function serializeRecord<T, R>(
|
||||
item: Record<string, T>,
|
||||
serializer?: (item: T) => R,
|
||||
): Record<string, R> {
|
||||
return Object.keys(item).reduce(
|
||||
(acc, key) => {
|
||||
if (isSupportedRecordType(item[key])) {
|
||||
acc[key] = item[key] as any;
|
||||
} else if (serializer) {
|
||||
const value = item[key];
|
||||
if (value !== undefined) {
|
||||
acc[key] = serializer(value);
|
||||
}
|
||||
} else {
|
||||
console.warn(`Don't know how to serialize ${item[key]}`);
|
||||
acc[key] = item[key] as any;
|
||||
}
|
||||
return acc;
|
||||
},
|
||||
{} as Record<string, R>,
|
||||
);
|
||||
}
|
||||
|
||||
function isSupportedRecordType(t: any) {
|
||||
return ["number", "string", "boolean", "null"].includes(typeof t) || t instanceof Date;
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
export { EdgeZonesClient, EdgeZonesClientOptionalParams } from "./edgeZonesClient.js";
|
||||
export {
|
||||
Resource,
|
||||
SystemData,
|
||||
KnownCreatedByType,
|
||||
CreatedByType,
|
||||
ProxyResource,
|
||||
ExtendedZone,
|
||||
ExtendedZoneProperties,
|
||||
KnownResourceProvisioningState,
|
||||
ResourceProvisioningState,
|
||||
KnownRegistrationState,
|
||||
RegistrationState,
|
||||
ErrorResponse,
|
||||
ErrorDetail,
|
||||
ErrorAdditionalInfo,
|
||||
Operation,
|
||||
OperationDisplay,
|
||||
KnownOrigin,
|
||||
Origin,
|
||||
KnownActionType,
|
||||
ActionType,
|
||||
ProvisioningState,
|
||||
OperationsListOptionalParams,
|
||||
ExtendedZonesGetOptionalParams,
|
||||
ExtendedZonesListBySubscriptionOptionalParams,
|
||||
ExtendedZonesRegisterOptionalParams,
|
||||
ExtendedZonesUnregisterOptionalParams,
|
||||
PageSettings,
|
||||
ContinuablePage,
|
||||
PagedAsyncIterableIterator,
|
||||
} from "./models/index.js";
|
||||
export { ExtendedZonesOperations, OperationsOperations } from "./classic/index.js";
|
|
@ -0,0 +1,5 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { createClientLogger } from "@azure/logger";
|
||||
export const logger = createClientLogger("arm-edgezones");
|
|
@ -0,0 +1,34 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
export {
|
||||
Resource,
|
||||
SystemData,
|
||||
KnownCreatedByType,
|
||||
CreatedByType,
|
||||
ProxyResource,
|
||||
ExtendedZone,
|
||||
ExtendedZoneProperties,
|
||||
KnownResourceProvisioningState,
|
||||
ResourceProvisioningState,
|
||||
KnownRegistrationState,
|
||||
RegistrationState,
|
||||
ErrorResponse,
|
||||
ErrorDetail,
|
||||
ErrorAdditionalInfo,
|
||||
Operation,
|
||||
OperationDisplay,
|
||||
KnownOrigin,
|
||||
Origin,
|
||||
KnownActionType,
|
||||
ActionType,
|
||||
ProvisioningState,
|
||||
} from "./models.js";
|
||||
export {
|
||||
OperationsListOptionalParams,
|
||||
ExtendedZonesGetOptionalParams,
|
||||
ExtendedZonesListBySubscriptionOptionalParams,
|
||||
ExtendedZonesRegisterOptionalParams,
|
||||
ExtendedZonesUnregisterOptionalParams,
|
||||
} from "./options.js";
|
||||
export { PageSettings, ContinuablePage, PagedAsyncIterableIterator } from "./pagingTypes.js";
|
|
@ -0,0 +1,249 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
/** Common fields that are returned in the response for all Azure Resource Manager resources */
|
||||
export interface Resource {
|
||||
/** Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} */
|
||||
readonly id?: string;
|
||||
/** The name of the resource */
|
||||
readonly name?: string;
|
||||
/** The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" */
|
||||
readonly type?: string;
|
||||
/** Azure Resource Manager metadata containing createdBy and modifiedBy information. */
|
||||
readonly systemData?: SystemData;
|
||||
}
|
||||
|
||||
/** Metadata pertaining to creation and last modification of the resource. */
|
||||
export interface SystemData {
|
||||
/** The identity that created the resource. */
|
||||
createdBy?: string;
|
||||
/** The type of identity that created the resource. */
|
||||
createdByType?: CreatedByType;
|
||||
/** The timestamp of resource creation (UTC). */
|
||||
createdAt?: Date;
|
||||
/** The identity that last modified the resource. */
|
||||
lastModifiedBy?: string;
|
||||
/** The type of identity that last modified the resource. */
|
||||
lastModifiedByType?: CreatedByType;
|
||||
/** The timestamp of resource last modification (UTC) */
|
||||
lastModifiedAt?: Date;
|
||||
}
|
||||
|
||||
/** Known values of {@link CreatedByType} that the service accepts. */
|
||||
export enum KnownCreatedByType {
|
||||
/** User */
|
||||
User = "User",
|
||||
/** Application */
|
||||
Application = "Application",
|
||||
/** ManagedIdentity */
|
||||
ManagedIdentity = "ManagedIdentity",
|
||||
/** Key */
|
||||
Key = "Key",
|
||||
}
|
||||
|
||||
/**
|
||||
* The kind of entity that created the resource. \
|
||||
* {@link KnownCreatedByType} can be used interchangeably with CreatedByType,
|
||||
* this enum contains the known values that the service supports.
|
||||
* ### Known values supported by the service
|
||||
* **User** \
|
||||
* **Application** \
|
||||
* **ManagedIdentity** \
|
||||
* **Key**
|
||||
*/
|
||||
export type CreatedByType = string;
|
||||
|
||||
/** The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location */
|
||||
export interface ProxyResource extends Resource {}
|
||||
|
||||
/** Resource that represents an Azure Extended Zone available to a subscription for registering and unregistering. */
|
||||
export interface ExtendedZone extends ProxyResource {
|
||||
/** The resource-specific properties for this resource. */
|
||||
properties?: ExtendedZoneProperties;
|
||||
}
|
||||
|
||||
/** The properties of an Extended Zone resource. */
|
||||
export interface ExtendedZoneProperties {
|
||||
/** Status of the last operation performed by the subscription on the Edge Zone resource */
|
||||
readonly provisioningState?: ProvisioningState;
|
||||
/** Indicates the Azure Extended Zone registration’s approval status. */
|
||||
readonly registrationState?: RegistrationState;
|
||||
/** Display name of the Azure Extended Zone. */
|
||||
readonly displayName: string;
|
||||
/** Regional display name of the Azure Extended Zone. */
|
||||
readonly regionalDisplayName: string;
|
||||
/** Type of region for the Azure Extended Zone. */
|
||||
readonly regionType: string;
|
||||
/** Category of region for the Azure Extended Zone. */
|
||||
readonly regionCategory: string;
|
||||
/** Geography of the Azure Extended Zone. */
|
||||
readonly geography: string;
|
||||
/** The Geography Group of the Azure Extended Zone. */
|
||||
readonly geographyGroup: string;
|
||||
/** The Longitude of the Azure Extended Zone. */
|
||||
readonly longitude: string;
|
||||
/** The Latitude of the Azure Extended Zone. */
|
||||
readonly latitude: string;
|
||||
/** The Home Location of the Azure Extended Zone. */
|
||||
readonly homeLocation: string;
|
||||
}
|
||||
|
||||
/** Known values of {@link ResourceProvisioningState} that the service accepts. */
|
||||
export enum KnownResourceProvisioningState {
|
||||
/** Succeeded */
|
||||
Succeeded = "Succeeded",
|
||||
/** Failed */
|
||||
Failed = "Failed",
|
||||
/** Canceled */
|
||||
Canceled = "Canceled",
|
||||
}
|
||||
|
||||
/**
|
||||
* The provisioning state of a resource type. \
|
||||
* {@link KnownResourceProvisioningState} can be used interchangeably with ResourceProvisioningState,
|
||||
* this enum contains the known values that the service supports.
|
||||
* ### Known values supported by the service
|
||||
* **Succeeded** \
|
||||
* **Failed** \
|
||||
* **Canceled**
|
||||
*/
|
||||
export type ResourceProvisioningState = string;
|
||||
|
||||
/** Known values of {@link RegistrationState} that the service accepts. */
|
||||
export enum KnownRegistrationState {
|
||||
/** NotRegistered */
|
||||
NotRegistered = "NotRegistered",
|
||||
/** PendingRegister */
|
||||
PendingRegister = "PendingRegister",
|
||||
/** Registered */
|
||||
Registered = "Registered",
|
||||
/** PendingUnregister */
|
||||
PendingUnregister = "PendingUnregister",
|
||||
}
|
||||
|
||||
/**
|
||||
* The Azure Extended Zone registration status for a subscription \
|
||||
* {@link KnownRegistrationState} can be used interchangeably with RegistrationState,
|
||||
* this enum contains the known values that the service supports.
|
||||
* ### Known values supported by the service
|
||||
* **NotRegistered** \
|
||||
* **PendingRegister** \
|
||||
* **Registered** \
|
||||
* **PendingUnregister**
|
||||
*/
|
||||
export type RegistrationState = string;
|
||||
|
||||
/** Common error response for all Azure Resource Manager APIs to return error details for failed operations. */
|
||||
export interface ErrorResponse {
|
||||
/** The error object. */
|
||||
error?: ErrorDetail;
|
||||
}
|
||||
|
||||
/** The error detail. */
|
||||
export interface ErrorDetail {
|
||||
/** The error code. */
|
||||
readonly code?: string;
|
||||
/** The error message. */
|
||||
readonly message?: string;
|
||||
/** The error target. */
|
||||
readonly target?: string;
|
||||
/** The error details. */
|
||||
readonly details?: ErrorDetail[];
|
||||
/** The error additional info. */
|
||||
readonly additionalInfo?: ErrorAdditionalInfo[];
|
||||
}
|
||||
|
||||
/** The resource management error additional info. */
|
||||
export interface ErrorAdditionalInfo {
|
||||
/** The additional info type. */
|
||||
readonly type?: string;
|
||||
/** The additional info. */
|
||||
readonly info?: Record<string, any>;
|
||||
}
|
||||
|
||||
/** The response of a ExtendedZone list operation. */
|
||||
export interface _ExtendedZoneListResult {
|
||||
/** The ExtendedZone items on this page */
|
||||
value: ExtendedZone[];
|
||||
/** The link to the next page of items */
|
||||
nextLink?: string;
|
||||
}
|
||||
|
||||
/** A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. */
|
||||
export interface _OperationListResult {
|
||||
/** The Operation items on this page */
|
||||
value: Operation[];
|
||||
/** The link to the next page of items */
|
||||
nextLink?: string;
|
||||
}
|
||||
|
||||
/** Details of a REST API operation, returned from the Resource Provider Operations API */
|
||||
export interface Operation {
|
||||
/** The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action" */
|
||||
readonly name?: string;
|
||||
/** Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for Azure Resource Manager/control-plane operations. */
|
||||
readonly isDataAction?: boolean;
|
||||
/** Localized display information for this particular operation. */
|
||||
display?: OperationDisplay;
|
||||
/** The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" */
|
||||
readonly origin?: Origin;
|
||||
/** Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. */
|
||||
actionType?: ActionType;
|
||||
}
|
||||
|
||||
/** Localized display information for and operation. */
|
||||
export interface OperationDisplay {
|
||||
/** The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". */
|
||||
provider?: string;
|
||||
/** The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job Schedule Collections". */
|
||||
resource?: string;
|
||||
/** The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". */
|
||||
operation?: string;
|
||||
/** The short, localized friendly description of the operation; suitable for tool tips and detailed views. */
|
||||
description?: string;
|
||||
}
|
||||
|
||||
/** Known values of {@link Origin} that the service accepts. */
|
||||
export enum KnownOrigin {
|
||||
/** user */
|
||||
user = "user",
|
||||
/** system */
|
||||
system = "system",
|
||||
/** user,system */
|
||||
"user,system" = "user,system",
|
||||
}
|
||||
|
||||
/**
|
||||
* The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" \
|
||||
* {@link KnownOrigin} can be used interchangeably with Origin,
|
||||
* this enum contains the known values that the service supports.
|
||||
* ### Known values supported by the service
|
||||
* **user** \
|
||||
* **system** \
|
||||
* **user,system**
|
||||
*/
|
||||
export type Origin = string;
|
||||
|
||||
/** Known values of {@link ActionType} that the service accepts. */
|
||||
export enum KnownActionType {
|
||||
/** Internal */
|
||||
Internal = "Internal",
|
||||
}
|
||||
|
||||
/**
|
||||
* Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. \
|
||||
* {@link KnownActionType} can be used interchangeably with ActionType,
|
||||
* this enum contains the known values that the service supports.
|
||||
* ### Known values supported by the service
|
||||
* **Internal**
|
||||
*/
|
||||
export type ActionType = string;
|
||||
|
||||
/** Alias for ProvisioningState */
|
||||
export type ProvisioningState =
|
||||
| string
|
||||
| ResourceProvisioningState
|
||||
| "Provisioning"
|
||||
| "Updating"
|
||||
| "Deleting"
|
||||
| "Accepted";
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { OperationOptions } from "@azure-rest/core-client";
|
||||
|
||||
/** Optional parameters. */
|
||||
export interface OperationsListOptionalParams extends OperationOptions {}
|
||||
|
||||
/** Optional parameters. */
|
||||
export interface ExtendedZonesGetOptionalParams extends OperationOptions {}
|
||||
|
||||
/** Optional parameters. */
|
||||
export interface ExtendedZonesListBySubscriptionOptionalParams extends OperationOptions {}
|
||||
|
||||
/** Optional parameters. */
|
||||
export interface ExtendedZonesRegisterOptionalParams extends OperationOptions {}
|
||||
|
||||
/** Optional parameters. */
|
||||
export interface ExtendedZonesUnregisterOptionalParams extends OperationOptions {}
|
|
@ -0,0 +1,79 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
/**
|
||||
* Options for the byPage method
|
||||
*/
|
||||
export interface PageSettings {
|
||||
/**
|
||||
* A reference to a specific page to start iterating from.
|
||||
*/
|
||||
continuationToken?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* An interface that describes a page of results.
|
||||
*/
|
||||
export type ContinuablePage<TElement, TPage = TElement[]> = TPage & {
|
||||
/**
|
||||
* The token that keeps track of where to continue the iterator
|
||||
*/
|
||||
continuationToken?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* An interface that allows async iterable iteration both to completion and by page.
|
||||
*/
|
||||
export interface PagedAsyncIterableIterator<
|
||||
TElement,
|
||||
TPage = TElement[],
|
||||
TPageSettings extends PageSettings = PageSettings,
|
||||
> {
|
||||
/**
|
||||
* The next method, part of the iteration protocol
|
||||
*/
|
||||
next(): Promise<IteratorResult<TElement>>;
|
||||
/**
|
||||
* The connection to the async iterator, part of the iteration protocol
|
||||
*/
|
||||
[Symbol.asyncIterator](): PagedAsyncIterableIterator<TElement, TPage, TPageSettings>;
|
||||
/**
|
||||
* Return an AsyncIterableIterator that works a page at a time
|
||||
*/
|
||||
byPage: (settings?: TPageSettings) => AsyncIterableIterator<ContinuablePage<TElement, TPage>>;
|
||||
}
|
||||
|
||||
/**
|
||||
* An interface that describes how to communicate with the service.
|
||||
*/
|
||||
export interface PagedResult<
|
||||
TElement,
|
||||
TPage = TElement[],
|
||||
TPageSettings extends PageSettings = PageSettings,
|
||||
> {
|
||||
/**
|
||||
* Link to the first page of results.
|
||||
*/
|
||||
firstPageLink?: string;
|
||||
/**
|
||||
* A method that returns a page of results.
|
||||
*/
|
||||
getPage: (pageLink?: string) => Promise<{ page: TPage; nextPageLink?: string } | undefined>;
|
||||
/**
|
||||
* a function to implement the `byPage` method on the paged async iterator.
|
||||
*/
|
||||
byPage?: (settings?: TPageSettings) => AsyncIterableIterator<ContinuablePage<TElement, TPage>>;
|
||||
|
||||
/**
|
||||
* A function to extract elements from a page.
|
||||
*/
|
||||
toElements?: (page: TPage) => TElement[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for the paging helper
|
||||
*/
|
||||
export interface BuildPagedAsyncIteratorOptions {
|
||||
itemName?: string;
|
||||
nextLinkName?: string;
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import {
|
||||
ListParameters,
|
||||
GetParameters,
|
||||
ListBySubscriptionParameters,
|
||||
RegisterParameters,
|
||||
UnregisterParameters,
|
||||
} from "./parameters.js";
|
||||
import {
|
||||
List200Response,
|
||||
ListDefaultResponse,
|
||||
Get200Response,
|
||||
GetDefaultResponse,
|
||||
ListBySubscription200Response,
|
||||
ListBySubscriptionDefaultResponse,
|
||||
Register200Response,
|
||||
RegisterDefaultResponse,
|
||||
Unregister200Response,
|
||||
UnregisterDefaultResponse,
|
||||
} from "./responses.js";
|
||||
import { Client, StreamableMethod } from "@azure-rest/core-client";
|
||||
|
||||
export interface List {
|
||||
/** List the operations for the provider */
|
||||
get(options?: ListParameters): StreamableMethod<List200Response | ListDefaultResponse>;
|
||||
}
|
||||
|
||||
export interface Get {
|
||||
/** Gets an Azure Extended Zone for a subscription */
|
||||
get(options?: GetParameters): StreamableMethod<Get200Response | GetDefaultResponse>;
|
||||
}
|
||||
|
||||
export interface ListBySubscription {
|
||||
/** Lists the Azure Extended Zones available to a subscription */
|
||||
get(
|
||||
options?: ListBySubscriptionParameters,
|
||||
): StreamableMethod<ListBySubscription200Response | ListBySubscriptionDefaultResponse>;
|
||||
}
|
||||
|
||||
export interface Register {
|
||||
/** Registers a subscription for an Extended Zone */
|
||||
post(
|
||||
options: RegisterParameters,
|
||||
): StreamableMethod<Register200Response | RegisterDefaultResponse>;
|
||||
}
|
||||
|
||||
export interface Unregister {
|
||||
/** Unregisters a subscription for an Extended Zone */
|
||||
post(
|
||||
options: UnregisterParameters,
|
||||
): StreamableMethod<Unregister200Response | UnregisterDefaultResponse>;
|
||||
}
|
||||
|
||||
export interface Routes {
|
||||
/** Resource for '/providers/Microsoft.EdgeZones/operations' has methods for the following verbs: get */
|
||||
(path: "/providers/Microsoft.EdgeZones/operations"): List;
|
||||
/** Resource for '/subscriptions/\{subscriptionId\}/providers/Microsoft.EdgeZones/extendedZones/\{extendedZoneName\}' has methods for the following verbs: get */
|
||||
(
|
||||
path: "/subscriptions/{subscriptionId}/providers/Microsoft.EdgeZones/extendedZones/{extendedZoneName}",
|
||||
subscriptionId: string,
|
||||
extendedZoneName: string,
|
||||
): Get;
|
||||
/** Resource for '/subscriptions/\{subscriptionId\}/providers/Microsoft.EdgeZones/extendedZones' has methods for the following verbs: get */
|
||||
(
|
||||
path: "/subscriptions/{subscriptionId}/providers/Microsoft.EdgeZones/extendedZones",
|
||||
subscriptionId: string,
|
||||
): ListBySubscription;
|
||||
/** Resource for '/subscriptions/\{subscriptionId\}/providers/Microsoft.EdgeZones/extendedZones/\{extendedZoneName\}/register' has methods for the following verbs: post */
|
||||
(
|
||||
path: "/subscriptions/{subscriptionId}/providers/Microsoft.EdgeZones/extendedZones/{extendedZoneName}/register",
|
||||
subscriptionId: string,
|
||||
extendedZoneName: string,
|
||||
): Register;
|
||||
/** Resource for '/subscriptions/\{subscriptionId\}/providers/Microsoft.EdgeZones/extendedZones/\{extendedZoneName\}/unregister' has methods for the following verbs: post */
|
||||
(
|
||||
path: "/subscriptions/{subscriptionId}/providers/Microsoft.EdgeZones/extendedZones/{extendedZoneName}/unregister",
|
||||
subscriptionId: string,
|
||||
extendedZoneName: string,
|
||||
): Unregister;
|
||||
}
|
||||
|
||||
export type EdgeZonesContext = Client & {
|
||||
path: Routes;
|
||||
};
|
|
@ -0,0 +1,61 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { getClient, ClientOptions } from "@azure-rest/core-client";
|
||||
import { logger } from "../logger.js";
|
||||
import { TokenCredential } from "@azure/core-auth";
|
||||
import { EdgeZonesContext } from "./clientDefinitions.js";
|
||||
|
||||
/** The optional parameters for the client */
|
||||
export interface EdgeZonesContextOptions extends ClientOptions {
|
||||
/** The api version option of the client */
|
||||
apiVersion?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a new instance of `EdgeZonesContext`
|
||||
* @param credentials - uniquely identify client credential
|
||||
* @param options - the parameter for all optional parameters
|
||||
*/
|
||||
export default function createClient(
|
||||
credentials: TokenCredential,
|
||||
{ apiVersion = "2024-04-01-preview", ...options }: EdgeZonesContextOptions = {},
|
||||
): EdgeZonesContext {
|
||||
const endpointUrl = options.endpoint ?? options.baseUrl ?? `https://management.azure.com`;
|
||||
const userAgentInfo = `azsdk-js-arm-edgezones/1.0.0-beta.1`;
|
||||
const userAgentPrefix =
|
||||
options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
||||
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
|
||||
: `${userAgentInfo}`;
|
||||
options = {
|
||||
...options,
|
||||
userAgentOptions: {
|
||||
userAgentPrefix,
|
||||
},
|
||||
loggingOptions: {
|
||||
logger: options.loggingOptions?.logger ?? logger.info,
|
||||
},
|
||||
credentials: {
|
||||
scopes: options.credentials?.scopes ?? [`${endpointUrl}/.default`],
|
||||
},
|
||||
};
|
||||
const client = getClient(endpointUrl, credentials, options) as EdgeZonesContext;
|
||||
|
||||
client.pipeline.removePolicy({ name: "ApiVersionPolicy" });
|
||||
client.pipeline.addPolicy({
|
||||
name: "ClientApiVersionPolicy",
|
||||
sendRequest: (req, next) => {
|
||||
// Use the apiVersion defined in request url directly
|
||||
// Append one if there is no apiVersion and we have one at client options
|
||||
const url = new URL(req.url);
|
||||
if (!url.searchParams.get("api-version") && apiVersion) {
|
||||
req.url = `${req.url}${
|
||||
Array.from(url.searchParams.keys()).length > 0 ? "&" : "?"
|
||||
}api-version=${apiVersion}`;
|
||||
}
|
||||
|
||||
return next(req);
|
||||
},
|
||||
});
|
||||
return client;
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import EdgeZonesClient from "./edgeZonesClient.js";
|
||||
|
||||
export * from "./edgeZonesClient.js";
|
||||
export * from "./parameters.js";
|
||||
export * from "./responses.js";
|
||||
export * from "./clientDefinitions.js";
|
||||
export * from "./isUnexpected.js";
|
||||
export * from "./outputModels.js";
|
||||
export * from "./paginateHelper.js";
|
||||
|
||||
export default EdgeZonesClient;
|
|
@ -0,0 +1,135 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import {
|
||||
List200Response,
|
||||
ListDefaultResponse,
|
||||
Get200Response,
|
||||
GetDefaultResponse,
|
||||
ListBySubscription200Response,
|
||||
ListBySubscriptionDefaultResponse,
|
||||
Register200Response,
|
||||
RegisterDefaultResponse,
|
||||
Unregister200Response,
|
||||
UnregisterDefaultResponse,
|
||||
} from "./responses.js";
|
||||
|
||||
const responseMap: Record<string, string[]> = {
|
||||
"GET /providers/Microsoft.EdgeZones/operations": ["200"],
|
||||
"GET /subscriptions/{subscriptionId}/providers/Microsoft.EdgeZones/extendedZones/{extendedZoneName}":
|
||||
["200"],
|
||||
"GET /subscriptions/{subscriptionId}/providers/Microsoft.EdgeZones/extendedZones": ["200"],
|
||||
"POST /subscriptions/{subscriptionId}/providers/Microsoft.EdgeZones/extendedZones/{extendedZoneName}/register":
|
||||
["200"],
|
||||
"POST /subscriptions/{subscriptionId}/providers/Microsoft.EdgeZones/extendedZones/{extendedZoneName}/unregister":
|
||||
["200"],
|
||||
};
|
||||
|
||||
export function isUnexpected(
|
||||
response: List200Response | ListDefaultResponse,
|
||||
): response is ListDefaultResponse;
|
||||
export function isUnexpected(
|
||||
response: Get200Response | GetDefaultResponse,
|
||||
): response is GetDefaultResponse;
|
||||
export function isUnexpected(
|
||||
response: ListBySubscription200Response | ListBySubscriptionDefaultResponse,
|
||||
): response is ListBySubscriptionDefaultResponse;
|
||||
export function isUnexpected(
|
||||
response: Register200Response | RegisterDefaultResponse,
|
||||
): response is RegisterDefaultResponse;
|
||||
export function isUnexpected(
|
||||
response: Unregister200Response | UnregisterDefaultResponse,
|
||||
): response is UnregisterDefaultResponse;
|
||||
export function isUnexpected(
|
||||
response:
|
||||
| List200Response
|
||||
| ListDefaultResponse
|
||||
| Get200Response
|
||||
| GetDefaultResponse
|
||||
| ListBySubscription200Response
|
||||
| ListBySubscriptionDefaultResponse
|
||||
| Register200Response
|
||||
| RegisterDefaultResponse
|
||||
| Unregister200Response
|
||||
| UnregisterDefaultResponse,
|
||||
): response is
|
||||
| ListDefaultResponse
|
||||
| GetDefaultResponse
|
||||
| ListBySubscriptionDefaultResponse
|
||||
| RegisterDefaultResponse
|
||||
| UnregisterDefaultResponse {
|
||||
const lroOriginal = response.headers["x-ms-original-url"];
|
||||
const url = new URL(lroOriginal ?? response.request.url);
|
||||
const method = response.request.method;
|
||||
let pathDetails = responseMap[`${method} ${url.pathname}`];
|
||||
if (!pathDetails) {
|
||||
pathDetails = getParametrizedPathSuccess(method, url.pathname);
|
||||
}
|
||||
return !pathDetails.includes(response.status);
|
||||
}
|
||||
|
||||
function getParametrizedPathSuccess(method: string, path: string): string[] {
|
||||
const pathParts = path.split("/");
|
||||
|
||||
// Traverse list to match the longest candidate
|
||||
// matchedLen: the length of candidate path
|
||||
// matchedValue: the matched status code array
|
||||
let matchedLen = -1,
|
||||
matchedValue: string[] = [];
|
||||
|
||||
// Iterate the responseMap to find a match
|
||||
for (const [key, value] of Object.entries(responseMap)) {
|
||||
// Extracting the path from the map key which is in format
|
||||
// GET /path/foo
|
||||
if (!key.startsWith(method)) {
|
||||
continue;
|
||||
}
|
||||
const candidatePath = getPathFromMapKey(key);
|
||||
// Get each part of the url path
|
||||
const candidateParts = candidatePath.split("/");
|
||||
|
||||
// track if we have found a match to return the values found.
|
||||
let found = true;
|
||||
for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {
|
||||
if (candidateParts[i]?.startsWith("{") && candidateParts[i]?.indexOf("}") !== -1) {
|
||||
const start = candidateParts[i]!.indexOf("}") + 1,
|
||||
end = candidateParts[i]?.length;
|
||||
// If the current part of the candidate is a "template" part
|
||||
// Try to use the suffix of pattern to match the path
|
||||
// {guid} ==> $
|
||||
// {guid}:export ==> :export$
|
||||
const isMatched = new RegExp(`${candidateParts[i]?.slice(start, end)}`).test(
|
||||
pathParts[j] || "",
|
||||
);
|
||||
|
||||
if (!isMatched) {
|
||||
found = false;
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// If the candidate part is not a template and
|
||||
// the parts don't match mark the candidate as not found
|
||||
// to move on with the next candidate path.
|
||||
if (candidateParts[i] !== pathParts[j]) {
|
||||
found = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// We finished evaluating the current candidate parts
|
||||
// Update the matched value if and only if we found the longer pattern
|
||||
if (found && candidatePath.length > matchedLen) {
|
||||
matchedLen = candidatePath.length;
|
||||
matchedValue = value;
|
||||
}
|
||||
}
|
||||
|
||||
return matchedValue;
|
||||
}
|
||||
|
||||
function getPathFromMapKey(mapKey: string): string {
|
||||
const pathStart = mapKey.indexOf("/");
|
||||
return mapKey.slice(pathStart);
|
||||
}
|
|
@ -0,0 +1,274 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { Paged } from "@azure/core-paging";
|
||||
|
||||
/** Details of a REST API operation, returned from the Resource Provider Operations API */
|
||||
export interface OperationOutput {
|
||||
/** The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action" */
|
||||
readonly name?: string;
|
||||
/** Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for Azure Resource Manager/control-plane operations. */
|
||||
readonly isDataAction?: boolean;
|
||||
/** Localized display information for this particular operation. */
|
||||
display?: OperationDisplayOutput;
|
||||
/** The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" */
|
||||
readonly origin?: OriginOutput;
|
||||
/** Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. */
|
||||
actionType?: ActionTypeOutput;
|
||||
}
|
||||
|
||||
/** Localized display information for and operation. */
|
||||
export interface OperationDisplayOutput {
|
||||
/** The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". */
|
||||
provider?: string;
|
||||
/** The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job Schedule Collections". */
|
||||
resource?: string;
|
||||
/** The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". */
|
||||
operation?: string;
|
||||
/** The short, localized friendly description of the operation; suitable for tool tips and detailed views. */
|
||||
description?: string;
|
||||
}
|
||||
|
||||
/** Common error response for all Azure Resource Manager APIs to return error details for failed operations. */
|
||||
export interface ErrorResponseOutput {
|
||||
/** The error object. */
|
||||
error?: ErrorDetailOutput;
|
||||
}
|
||||
|
||||
/** The error detail. */
|
||||
export interface ErrorDetailOutput {
|
||||
/** The error code. */
|
||||
readonly code?: string;
|
||||
/** The error message. */
|
||||
readonly message?: string;
|
||||
/** The error target. */
|
||||
readonly target?: string;
|
||||
/** The error details. */
|
||||
readonly details?: Array<ErrorDetailOutput>;
|
||||
/** The error additional info. */
|
||||
readonly additionalInfo?: Array<ErrorAdditionalInfoOutput>;
|
||||
}
|
||||
|
||||
/** The resource management error additional info. */
|
||||
export interface ErrorAdditionalInfoOutput {
|
||||
/** The additional info type. */
|
||||
readonly type?: string;
|
||||
/** The additional info. */
|
||||
readonly info?: Record<string, any>;
|
||||
}
|
||||
|
||||
/** Resource that represents an Azure Extended Zone available to a subscription for registering and unregistering. */
|
||||
export interface ExtendedZoneOutput extends ProxyResourceOutput {
|
||||
/** The resource-specific properties for this resource. */
|
||||
properties?: ExtendedZonePropertiesOutput;
|
||||
}
|
||||
|
||||
/** The properties of an Extended Zone resource. */
|
||||
export interface ExtendedZonePropertiesOutput {
|
||||
/** Status of the last operation performed by the subscription on the Edge Zone resource */
|
||||
readonly provisioningState?: ProvisioningStateOutput;
|
||||
/** Indicates the Azure Extended Zone registration’s approval status. */
|
||||
readonly registrationState?: RegistrationStateOutput;
|
||||
/** Display name of the Azure Extended Zone. */
|
||||
readonly displayName: string;
|
||||
/** Regional display name of the Azure Extended Zone. */
|
||||
readonly regionalDisplayName: string;
|
||||
/** Type of region for the Azure Extended Zone. */
|
||||
readonly regionType: string;
|
||||
/** Category of region for the Azure Extended Zone. */
|
||||
readonly regionCategory: string;
|
||||
/** Geography of the Azure Extended Zone. */
|
||||
readonly geography: string;
|
||||
/** The Geography Group of the Azure Extended Zone. */
|
||||
readonly geographyGroup: string;
|
||||
/** The Longitude of the Azure Extended Zone. */
|
||||
readonly longitude: string;
|
||||
/** The Latitude of the Azure Extended Zone. */
|
||||
readonly latitude: string;
|
||||
/** The Home Location of the Azure Extended Zone. */
|
||||
readonly homeLocation: string;
|
||||
}
|
||||
|
||||
/** The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location */
|
||||
export interface ProxyResourceOutput extends ResourceOutput {}
|
||||
|
||||
/** Common fields that are returned in the response for all Azure Resource Manager resources */
|
||||
export interface ResourceOutput {
|
||||
/** Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} */
|
||||
readonly id?: string;
|
||||
/** The name of the resource */
|
||||
readonly name?: string;
|
||||
/** The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" */
|
||||
readonly type?: string;
|
||||
/** Azure Resource Manager metadata containing createdBy and modifiedBy information. */
|
||||
readonly systemData?: SystemDataOutput;
|
||||
}
|
||||
|
||||
/** Metadata pertaining to creation and last modification of the resource. */
|
||||
export interface SystemDataOutput {
|
||||
/** The identity that created the resource. */
|
||||
createdBy?: string;
|
||||
/** The type of identity that created the resource. */
|
||||
createdByType?: CreatedByTypeOutput;
|
||||
/** The timestamp of resource creation (UTC). */
|
||||
createdAt?: string;
|
||||
/** The identity that last modified the resource. */
|
||||
lastModifiedBy?: string;
|
||||
/** The type of identity that last modified the resource. */
|
||||
lastModifiedByType?: CreatedByTypeOutput;
|
||||
/** The timestamp of resource last modification (UTC) */
|
||||
lastModifiedAt?: string;
|
||||
}
|
||||
|
||||
/** The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location' */
|
||||
export interface TrackedResourceOutput extends ResourceOutput {
|
||||
/** Resource tags. */
|
||||
tags?: Record<string, string>;
|
||||
/** The geo-location where the resource lives */
|
||||
location: string;
|
||||
}
|
||||
|
||||
/** The resource model definition containing the full set of allowed properties for a resource. Except properties bag, there cannot be a top level property outside of this set. */
|
||||
export interface ResourceModelWithAllowedPropertySetOutput extends TrackedResourceOutput {
|
||||
/**
|
||||
* The fully qualified resource ID of the resource that manages this resource. Indicates if this resource is managed by another Azure resource.
|
||||
* If this is present, complete mode deployment will not delete the resource if it is removed from the template since it is managed by another resource.
|
||||
*/
|
||||
managedBy?: string;
|
||||
/**
|
||||
* Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type.
|
||||
* If supported, the resource provider must validate and persist this value.
|
||||
*/
|
||||
kind?: string;
|
||||
/**
|
||||
* The etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal etag convention.
|
||||
* Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19),
|
||||
* If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields.
|
||||
*/
|
||||
eTag?: string;
|
||||
identity?: IdentityOutput;
|
||||
sku?: SkuOutput;
|
||||
plan?: PlanOutput;
|
||||
}
|
||||
|
||||
/** Identity for the resource. */
|
||||
export interface IdentityOutput {
|
||||
/** The principal ID of resource identity. The value must be an UUID. */
|
||||
readonly principalId?: string;
|
||||
/** The tenant ID of resource. The value must be an UUID. */
|
||||
readonly tenantId?: string;
|
||||
/** The identity type. */
|
||||
type?: ResourceIdentityTypeOutput;
|
||||
}
|
||||
|
||||
/** The resource model definition representing SKU */
|
||||
export interface SkuOutput {
|
||||
/** The name of the SKU. Ex - P3. It is typically a letter+number code */
|
||||
name: string;
|
||||
/** This field is required to be implemented by the Resource Provider if the service has more than one tier, but is not required on a PUT. */
|
||||
tier?: SkuTierOutput;
|
||||
/** The SKU size. When the name field is the combination of tier and some other value, this would be the standalone code. */
|
||||
size?: string;
|
||||
/** If the service has different generations of hardware, for the same SKU, then that can be captured here. */
|
||||
family?: string;
|
||||
/** If the SKU supports scale out/in then the capacity integer should be included. If scale out/in is not possible for the resource this may be omitted. */
|
||||
capacity?: number;
|
||||
}
|
||||
|
||||
/** Plan for the resource. */
|
||||
export interface PlanOutput {
|
||||
/** A user defined name of the 3rd Party Artifact that is being procured. */
|
||||
name: string;
|
||||
/** The publisher of the 3rd Party Artifact that is being bought. E.g. NewRelic */
|
||||
publisher: string;
|
||||
/** The 3rd Party artifact that is being procured. E.g. NewRelic. Product maps to the OfferID specified for the artifact at the time of Data Market onboarding. */
|
||||
product: string;
|
||||
/** A publisher provided promotion code as provisioned in Data Market for the said product/artifact. */
|
||||
promotionCode?: string;
|
||||
/** The version of the desired product/artifact. */
|
||||
version?: string;
|
||||
}
|
||||
|
||||
/** The base extension resource. */
|
||||
export interface ExtensionResourceOutput extends ResourceOutput {}
|
||||
|
||||
/** The resource model definition for an Azure Resource Manager resource with an etag. */
|
||||
export interface AzureEntityResourceOutput extends ResourceOutput {
|
||||
/** Resource Etag. */
|
||||
readonly etag?: string;
|
||||
}
|
||||
|
||||
/** A private link resource. */
|
||||
export interface PrivateLinkResourceOutput extends ResourceOutput {
|
||||
/** Resource properties. */
|
||||
properties?: PrivateLinkResourcePropertiesOutput;
|
||||
}
|
||||
|
||||
/** Properties of a private link resource. */
|
||||
export interface PrivateLinkResourcePropertiesOutput {
|
||||
/** The private link resource group id. */
|
||||
readonly groupId?: string;
|
||||
/** The private link resource required member names. */
|
||||
readonly requiredMembers?: string[];
|
||||
/** The private link resource private link DNS zone name. */
|
||||
requiredZoneNames?: string[];
|
||||
}
|
||||
|
||||
/** The private endpoint connection resource */
|
||||
export interface PrivateEndpointConnectionOutput extends ResourceOutput {
|
||||
/** The private endpoint connection properties */
|
||||
properties?: PrivateEndpointConnectionPropertiesOutput;
|
||||
}
|
||||
|
||||
/** Properties of the private endpoint connection. */
|
||||
export interface PrivateEndpointConnectionPropertiesOutput {
|
||||
/** The group ids for the private endpoint resource. */
|
||||
readonly groupIds?: string[];
|
||||
/** The private endpoint resource. */
|
||||
privateEndpoint?: PrivateEndpointOutput;
|
||||
/** A collection of information about the state of the connection between service consumer and provider. */
|
||||
privateLinkServiceConnectionState: PrivateLinkServiceConnectionStateOutput;
|
||||
/** The provisioning state of the private endpoint connection resource. */
|
||||
readonly provisioningState?: PrivateEndpointConnectionProvisioningStateOutput;
|
||||
}
|
||||
|
||||
/** The Private Endpoint resource. */
|
||||
export interface PrivateEndpointOutput {
|
||||
/** The resource identifier for private endpoint */
|
||||
readonly id?: string;
|
||||
}
|
||||
|
||||
/** A collection of information about the state of the connection between service consumer and provider. */
|
||||
export interface PrivateLinkServiceConnectionStateOutput {
|
||||
/** Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service. */
|
||||
status?: PrivateEndpointServiceConnectionStatusOutput;
|
||||
/** The reason for approval/rejection of the connection. */
|
||||
description?: string;
|
||||
/** A message indicating if changes on the service provider require any updates on the consumer. */
|
||||
actionsRequired?: string;
|
||||
}
|
||||
|
||||
/** A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. */
|
||||
export type OperationListResultOutput = Paged<OperationOutput>;
|
||||
/** Alias for OriginOutput */
|
||||
export type OriginOutput = string;
|
||||
/** Alias for ActionTypeOutput */
|
||||
export type ActionTypeOutput = string;
|
||||
/** Alias for ResourceProvisioningStateOutput */
|
||||
export type ResourceProvisioningStateOutput = string;
|
||||
/** Alias for ProvisioningStateOutput */
|
||||
export type ProvisioningStateOutput = string;
|
||||
/** Alias for RegistrationStateOutput */
|
||||
export type RegistrationStateOutput = string;
|
||||
/** Alias for CreatedByTypeOutput */
|
||||
export type CreatedByTypeOutput = string;
|
||||
/** Alias for ResourceIdentityTypeOutput */
|
||||
export type ResourceIdentityTypeOutput = "SystemAssigned";
|
||||
/** Alias for SkuTierOutput */
|
||||
export type SkuTierOutput = "Free" | "Basic" | "Standard" | "Premium";
|
||||
/** Alias for PrivateEndpointServiceConnectionStatusOutput */
|
||||
export type PrivateEndpointServiceConnectionStatusOutput = string;
|
||||
/** Alias for PrivateEndpointConnectionProvisioningStateOutput */
|
||||
export type PrivateEndpointConnectionProvisioningStateOutput = string;
|
||||
/** The response of a ExtendedZone list operation. */
|
||||
export type ExtendedZoneListResultOutput = Paged<ExtendedZoneOutput>;
|
|
@ -0,0 +1,131 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { getPagedAsyncIterator, PagedAsyncIterableIterator, PagedResult } from "@azure/core-paging";
|
||||
import { Client, createRestError, PathUncheckedResponse } from "@azure-rest/core-client";
|
||||
|
||||
/**
|
||||
* Helper type to extract the type of an array
|
||||
*/
|
||||
export type GetArrayType<T> = T extends Array<infer TData> ? TData : never;
|
||||
|
||||
/**
|
||||
* The type of a custom function that defines how to get a page and a link to the next one if any.
|
||||
*/
|
||||
export type GetPage<TPage> = (
|
||||
pageLink: string,
|
||||
maxPageSize?: number,
|
||||
) => Promise<{
|
||||
page: TPage;
|
||||
nextPageLink?: string;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* Options for the paging helper
|
||||
*/
|
||||
export interface PagingOptions<TResponse> {
|
||||
/**
|
||||
* Custom function to extract pagination details for crating the PagedAsyncIterableIterator
|
||||
*/
|
||||
customGetPage?: GetPage<PaginateReturn<TResponse>[]>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper type to infer the Type of the paged elements from the response type
|
||||
* This type is generated based on the swagger information for x-ms-pageable
|
||||
* specifically on the itemName property which indicates the property of the response
|
||||
* where the page items are found. The default value is `value`.
|
||||
* This type will allow us to provide strongly typed Iterator based on the response we get as second parameter
|
||||
*/
|
||||
export type PaginateReturn<TResult> = TResult extends {
|
||||
body: { value?: infer TPage };
|
||||
}
|
||||
? GetArrayType<TPage>
|
||||
: Array<unknown>;
|
||||
|
||||
/**
|
||||
* Helper to paginate results from an initial response that follows the specification of Autorest `x-ms-pageable` extension
|
||||
* @param client - Client to use for sending the next page requests
|
||||
* @param initialResponse - Initial response containing the nextLink and current page of elements
|
||||
* @param customGetPage - Optional - Function to define how to extract the page and next link to be used to paginate the results
|
||||
* @returns - PagedAsyncIterableIterator to iterate the elements
|
||||
*/
|
||||
export function paginate<TResponse extends PathUncheckedResponse>(
|
||||
client: Client,
|
||||
initialResponse: TResponse,
|
||||
options: PagingOptions<TResponse> = {},
|
||||
): PagedAsyncIterableIterator<PaginateReturn<TResponse>> {
|
||||
// Extract element type from initial response
|
||||
type TElement = PaginateReturn<TResponse>;
|
||||
let firstRun = true;
|
||||
const itemName = "value";
|
||||
const nextLinkName = "nextLink";
|
||||
const { customGetPage } = options;
|
||||
const pagedResult: PagedResult<TElement[]> = {
|
||||
firstPageLink: "",
|
||||
getPage:
|
||||
typeof customGetPage === "function"
|
||||
? customGetPage
|
||||
: async (pageLink: string) => {
|
||||
const result = firstRun ? initialResponse : await client.pathUnchecked(pageLink).get();
|
||||
firstRun = false;
|
||||
checkPagingRequest(result);
|
||||
const nextLink = getNextLink(result.body, nextLinkName);
|
||||
const values = getElements<TElement>(result.body, itemName);
|
||||
return {
|
||||
page: values,
|
||||
nextPageLink: nextLink,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
return getPagedAsyncIterator(pagedResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets for the value of nextLink in the body
|
||||
*/
|
||||
function getNextLink(body: unknown, nextLinkName?: string): string | undefined {
|
||||
if (!nextLinkName) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const nextLink = (body as Record<string, unknown>)[nextLinkName];
|
||||
|
||||
if (typeof nextLink !== "string" && typeof nextLink !== "undefined") {
|
||||
throw new Error(`Body Property ${nextLinkName} should be a string or undefined`);
|
||||
}
|
||||
|
||||
return nextLink;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the elements of the current request in the body.
|
||||
*/
|
||||
function getElements<T = unknown>(body: unknown, itemName: string): T[] {
|
||||
const value = (body as Record<string, unknown>)[itemName] as T[];
|
||||
|
||||
// value has to be an array according to the x-ms-pageable extension.
|
||||
// The fact that this must be an array is used above to calculate the
|
||||
// type of elements in the page in PaginateReturn
|
||||
if (!Array.isArray(value)) {
|
||||
throw new Error(
|
||||
`Couldn't paginate response\n Body doesn't contain an array property with name: ${itemName}`,
|
||||
);
|
||||
}
|
||||
|
||||
return value ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a request failed
|
||||
*/
|
||||
function checkPagingRequest(response: PathUncheckedResponse): void {
|
||||
const Http2xxStatusCodes = ["200", "201", "202", "203", "204", "205", "206", "207", "208", "226"];
|
||||
if (!Http2xxStatusCodes.includes(response.status)) {
|
||||
throw createRestError(
|
||||
`Pagination failed with unexpected statusCode ${response.status}`,
|
||||
response,
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { RequestParameters } from "@azure-rest/core-client";
|
||||
|
||||
export type ListParameters = RequestParameters;
|
||||
export type GetParameters = RequestParameters;
|
||||
export type ListBySubscriptionParameters = RequestParameters;
|
||||
export type RegisterParameters = RequestParameters;
|
||||
export type UnregisterParameters = RequestParameters;
|
|
@ -0,0 +1,65 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { HttpResponse } from "@azure-rest/core-client";
|
||||
import {
|
||||
OperationListResultOutput,
|
||||
ErrorResponseOutput,
|
||||
ExtendedZoneOutput,
|
||||
ExtendedZoneListResultOutput,
|
||||
} from "./outputModels.js";
|
||||
|
||||
/** Azure operation completed successfully. */
|
||||
export interface List200Response extends HttpResponse {
|
||||
status: "200";
|
||||
body: OperationListResultOutput;
|
||||
}
|
||||
|
||||
export interface ListDefaultResponse extends HttpResponse {
|
||||
status: string;
|
||||
body: ErrorResponseOutput;
|
||||
}
|
||||
|
||||
/** Azure operation completed successfully. */
|
||||
export interface Get200Response extends HttpResponse {
|
||||
status: "200";
|
||||
body: ExtendedZoneOutput;
|
||||
}
|
||||
|
||||
export interface GetDefaultResponse extends HttpResponse {
|
||||
status: string;
|
||||
body: ErrorResponseOutput;
|
||||
}
|
||||
|
||||
/** Azure operation completed successfully. */
|
||||
export interface ListBySubscription200Response extends HttpResponse {
|
||||
status: "200";
|
||||
body: ExtendedZoneListResultOutput;
|
||||
}
|
||||
|
||||
export interface ListBySubscriptionDefaultResponse extends HttpResponse {
|
||||
status: string;
|
||||
body: ErrorResponseOutput;
|
||||
}
|
||||
|
||||
/** Azure operation completed successfully. */
|
||||
export interface Register200Response extends HttpResponse {
|
||||
status: "200";
|
||||
body: ExtendedZoneOutput;
|
||||
}
|
||||
|
||||
export interface RegisterDefaultResponse extends HttpResponse {
|
||||
status: string;
|
||||
body: ErrorResponseOutput;
|
||||
}
|
||||
|
||||
/** Azure operation completed successfully. */
|
||||
export interface Unregister200Response extends HttpResponse {
|
||||
status: "200";
|
||||
body: ExtendedZoneOutput;
|
||||
}
|
||||
|
||||
export interface UnregisterDefaultResponse extends HttpResponse {
|
||||
status: string;
|
||||
body: ErrorResponseOutput;
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* 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 { env, Recorder, isPlaybackMode, delay } from "@azure-tools/test-recorder";
|
||||
import { createTestCredential } from "@azure-tools/test-credential";
|
||||
import { assert, beforeEach, afterEach, it, describe } from "vitest";
|
||||
import { createRecorder } from "./utils/recordedClient.js";
|
||||
import { EdgeZonesClient } from "../../src/edgeZonesClient.js";
|
||||
|
||||
export const testPollingOptions = {
|
||||
updateIntervalInMs: isPlaybackMode() ? 0 : undefined,
|
||||
};
|
||||
|
||||
describe("extendedZones test", () => {
|
||||
let recorder: Recorder;
|
||||
let subscriptionId: string;
|
||||
let client: EdgeZonesClient;
|
||||
let location: string;
|
||||
let resourceGroup: string;
|
||||
let resourcename: string;
|
||||
let resourcename1: string;
|
||||
|
||||
beforeEach(async (context) => {
|
||||
process.env.SystemRoot = process.env.SystemRoot || "C:\\Windows";
|
||||
recorder = await createRecorder(context);
|
||||
subscriptionId = env.SUBSCRIPTION_ID || "";
|
||||
// This is an example of how the environment variables are used
|
||||
const credential = createTestCredential();
|
||||
client = new EdgeZonesClient(credential, subscriptionId, recorder.configureClientOptions({}));
|
||||
location = "eastus";
|
||||
resourceGroup = "myjstest";
|
||||
resourcename = "losangeles";
|
||||
resourcename1 = "losangeless";
|
||||
});
|
||||
|
||||
afterEach(async function () {
|
||||
await recorder.stop();
|
||||
});
|
||||
|
||||
it("extendedZones register test", async function () {
|
||||
const res = await client.extendedZones.register(resourcename);
|
||||
assert.equal(res.name, resourcename);
|
||||
});
|
||||
|
||||
it("extendedZones get test", async function () {
|
||||
const res = await client.extendedZones.get(resourcename);
|
||||
assert.equal(res.name, resourcename);
|
||||
});
|
||||
|
||||
it("extendedZones list test", async function () {
|
||||
const resArray = new Array();
|
||||
for await (let item of client.extendedZones.listBySubscription().byPage()) {
|
||||
resArray.push(item);
|
||||
}
|
||||
assert.equal(resArray.length, 1);
|
||||
});
|
||||
|
||||
it("extendedZones unregister test", async function () {
|
||||
const res = await client.extendedZones.unregister(resourcename);
|
||||
});
|
||||
|
||||
it("operations list test", async function () {
|
||||
const resArray = new Array();
|
||||
for await (let item of client.operations.list()) {
|
||||
resArray.push(item);
|
||||
}
|
||||
assert.notEqual(resArray.length, 0);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,27 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { Recorder, RecorderStartOptions, VitestTestContext } from "@azure-tools/test-recorder";
|
||||
|
||||
const replaceableVariables: Record<string, string> = {
|
||||
SUBSCRIPTION_ID: "azure_subscription_id",
|
||||
};
|
||||
|
||||
const recorderEnvSetup: RecorderStartOptions = {
|
||||
envSetupForPlayback: replaceableVariables,
|
||||
removeCentralSanitizers: [
|
||||
"AZSDK3493", // .name in the body is not a secret and is listed below in the beforeEach section
|
||||
"AZSDK3430", // .id in the body is not a secret and is listed below in the beforeEach section
|
||||
],
|
||||
};
|
||||
|
||||
/**
|
||||
* creates the recorder and reads the environment variables from the `.env` file.
|
||||
* Should be called first in the test suite to make sure environment variables are
|
||||
* read before they are being used.
|
||||
*/
|
||||
export async function createRecorder(context: VitestTestContext): Promise<Recorder> {
|
||||
const recorder = new Recorder(context);
|
||||
await recorder.start(recorderEnvSetup);
|
||||
return recorder;
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"extends": "./.tshy/build.json",
|
||||
"include": ["./src/**/*.ts", "./src/**/*.mts", "./test/**/*.spec.ts"],
|
||||
"exclude": ["./test/**/node/**/*.ts"],
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist-test/browser",
|
||||
"rootDir": ".",
|
||||
"skipLibCheck": true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"extends": "../../../tsconfig",
|
||||
"compilerOptions": {
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"rootDir": "."
|
||||
},
|
||||
"include": ["./src/**/*.ts", "./src/**/*.mts", "./src/**/*.cts", "test/**/*.ts", "./test/**/*.ts"]
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
directory: specification/edgezones/EdgeZones.Management
|
||||
commit: ab064e0047ec560a700d6b501097d99471ad817b
|
||||
repo: Azure/azure-rest-api-specs
|
|
@ -0,0 +1,37 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { defineConfig } from "vitest/config";
|
||||
import { relativeRecordingsPath } from "@azure-tools/test-recorder";
|
||||
|
||||
process.env.RECORDINGS_RELATIVE_PATH = relativeRecordingsPath();
|
||||
|
||||
export default defineConfig({
|
||||
define: {
|
||||
"process.env": process.env,
|
||||
},
|
||||
test: {
|
||||
reporters: ["basic", "junit"],
|
||||
outputFile: {
|
||||
junit: "test-results.browser.xml",
|
||||
},
|
||||
browser: {
|
||||
enabled: true,
|
||||
headless: true,
|
||||
name: "chromium",
|
||||
provider: "playwright",
|
||||
},
|
||||
fakeTimers: {
|
||||
toFake: ["setTimeout", "Date"],
|
||||
},
|
||||
watch: false,
|
||||
include: ["dist-test/browser/**/*.spec.js"],
|
||||
coverage: {
|
||||
include: ["dist-test/browser/**/*.spec.js"],
|
||||
provider: "istanbul",
|
||||
reporter: ["text", "json", "html"],
|
||||
reportsDirectory: "coverage-browser",
|
||||
},
|
||||
testTimeout: 1200000,
|
||||
},
|
||||
});
|
|
@ -0,0 +1,33 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { defineConfig } from "vitest/config";
|
||||
import { relativeRecordingsPath } from "@azure-tools/test-recorder";
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
reporters: ["basic", "junit"],
|
||||
outputFile: {
|
||||
junit: "test-results.browser.xml",
|
||||
},
|
||||
fakeTimers: {
|
||||
toFake: ["setTimeout", "Date"],
|
||||
},
|
||||
watch: false,
|
||||
include: ["test/**/*.spec.ts"],
|
||||
exclude: ["test/**/browser/*.spec.ts"],
|
||||
coverage: {
|
||||
include: ["src/**/*.ts"],
|
||||
exclude: [
|
||||
"src/**/*-browser.mts",
|
||||
"src/**/*-react-native.mts",
|
||||
"vitest*.config.ts",
|
||||
"samples-dev/**/*.ts",
|
||||
],
|
||||
provider: "istanbul",
|
||||
reporter: ["text", "json", "html"],
|
||||
reportsDirectory: "coverage",
|
||||
},
|
||||
testTimeout: 1200000,
|
||||
},
|
||||
});
|
|
@ -0,0 +1,32 @@
|
|||
# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file.
|
||||
|
||||
trigger:
|
||||
branches:
|
||||
include:
|
||||
- main
|
||||
- release/*
|
||||
- hotfix/*
|
||||
paths:
|
||||
include:
|
||||
- sdk/edgezones/ci.mgmt.yml
|
||||
- sdk/edgezones/arm-edgezones
|
||||
pr:
|
||||
branches:
|
||||
include:
|
||||
- main
|
||||
- feature/*
|
||||
- release/*
|
||||
- hotfix/*
|
||||
exclude:
|
||||
- feature/v4
|
||||
paths:
|
||||
include:
|
||||
- sdk/edgezones/ci.mgmt.yml
|
||||
- sdk/edgezones/arm-edgezones
|
||||
extends:
|
||||
template: /eng/pipelines/templates/stages/archetype-sdk-client.yml
|
||||
parameters:
|
||||
ServiceDirectory: edgezones
|
||||
Artifacts:
|
||||
- name: azure-arm-edgezones
|
||||
safeName: azurearmedgezones
|
Загрузка…
Ссылка в новой задаче