From 2f461d2ae1b3b154862d12a5f957b17cd03a045a Mon Sep 17 00:00:00 2001 From: Wei Dong <40835867+dw511214992@users.noreply.github.com> Date: Thu, 15 Jul 2021 17:05:12 +0800 Subject: [PATCH] track2 @azure/arm-links (#16211) * track2 @azure/arm-links * update * update * update * update changelog * update links changelog Co-authored-by: qiaozha --- common/config/rush/pnpm-lock.yaml | 22 + rush.json | 5 + sdk/links/arm-links/CHANGELOG.md | 14 + sdk/links/arm-links/{LICENSE.txt => LICENSE} | 4 +- sdk/links/arm-links/README.md | 135 ++-- sdk/links/arm-links/_meta.json | 7 + sdk/links/arm-links/api-extractor.json | 18 + sdk/links/arm-links/package.json | 70 +- sdk/links/arm-links/review/arm-links.api.md | 188 +++++ sdk/links/arm-links/rollup.config.js | 211 +++++- sdk/links/arm-links/src/index.ts | 13 + .../arm-links/src/managementLinkClient.ts | 50 +- .../src/managementLinkClientContext.ts | 86 ++- sdk/links/arm-links/src/models/index.ts | 426 ++++------- sdk/links/arm-links/src/models/mappers.ts | 164 ++--- .../arm-links/src/models/operationsMappers.ts | 14 - sdk/links/arm-links/src/models/parameters.ts | 113 ++- .../src/models/resourceLinksMappers.ts | 15 - sdk/links/arm-links/src/operations/index.ts | 8 +- .../arm-links/src/operations/operations.ts | 225 ++++-- .../arm-links/src/operations/resourceLinks.ts | 692 ++++++++++-------- .../src/operationsInterfaces/index.ts | 10 + .../src/operationsInterfaces/operations.ts | 36 + .../src/operationsInterfaces/resourceLinks.ts | 103 +++ sdk/links/arm-links/tsconfig.json | 5 +- sdk/links/ci.yml | 28 + 26 files changed, 1679 insertions(+), 983 deletions(-) create mode 100644 sdk/links/arm-links/CHANGELOG.md rename sdk/links/arm-links/{LICENSE.txt => LICENSE} (96%) create mode 100644 sdk/links/arm-links/_meta.json create mode 100644 sdk/links/arm-links/api-extractor.json create mode 100644 sdk/links/arm-links/review/arm-links.api.md create mode 100644 sdk/links/arm-links/src/index.ts delete mode 100644 sdk/links/arm-links/src/models/operationsMappers.ts delete mode 100644 sdk/links/arm-links/src/models/resourceLinksMappers.ts create mode 100644 sdk/links/arm-links/src/operationsInterfaces/index.ts create mode 100644 sdk/links/arm-links/src/operationsInterfaces/operations.ts create mode 100644 sdk/links/arm-links/src/operationsInterfaces/resourceLinks.ts create mode 100644 sdk/links/ci.yml diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 8acfa2ea2c40..402c2f25fdde 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -8,6 +8,7 @@ dependencies: '@rush-temp/ai-text-analytics': file:projects/ai-text-analytics.tgz '@rush-temp/app-configuration': file:projects/app-configuration.tgz '@rush-temp/arm-features': file:projects/arm-features.tgz + '@rush-temp/arm-links': file:projects/arm-links.tgz '@rush-temp/arm-locks': file:projects/arm-locks.tgz '@rush-temp/arm-policy': file:projects/arm-policy.tgz '@rush-temp/attestation': file:projects/attestation.tgz @@ -8509,6 +8510,26 @@ packages: integrity: sha512-Jdqy3BnYfdYfUwQ4L97IVWbg0zwT9HuL1PJ/8JZrmqMo6RZOE1jUDnYcSRA2h7Ke1Rhe8rHi0g80U3EWbWvr9A== tarball: file:projects/arm-features.tgz version: 0.0.0 + file:projects/arm-links.tgz: + dependencies: + '@microsoft/api-extractor': 7.7.11 + '@rollup/plugin-commonjs': 11.0.2_rollup@1.32.1 + '@rollup/plugin-json': 4.1.0_rollup@1.32.1 + '@rollup/plugin-multi-entry': 3.0.1_rollup@1.32.1 + '@rollup/plugin-node-resolve': 8.4.0_rollup@1.32.1 + mkdirp: 1.0.4 + rollup: 1.32.1 + rollup-plugin-node-resolve: 3.4.0 + rollup-plugin-sourcemaps: 0.4.2_rollup@1.32.1 + tslib: 2.3.0 + typescript: 4.2.4 + uglify-js: 3.13.10 + dev: false + name: '@rush-temp/arm-links' + resolution: + integrity: sha512-rp7358CAZYQTk14rux456WPw0drTcb6tLaCbzxS10sUYP18FSZAdXMThbRk6FWXcyGiNdiYWIDg99JUxOoS2hQ== + tarball: file:projects/arm-links.tgz + version: 0.0.0 file:projects/arm-locks.tgz: dependencies: '@microsoft/api-extractor': 7.7.11 @@ -12104,6 +12125,7 @@ specifiers: '@rush-temp/ai-text-analytics': file:./projects/ai-text-analytics.tgz '@rush-temp/app-configuration': file:./projects/app-configuration.tgz '@rush-temp/arm-features': file:./projects/arm-features.tgz + '@rush-temp/arm-links': file:./projects/arm-links.tgz '@rush-temp/arm-locks': file:./projects/arm-locks.tgz '@rush-temp/arm-policy': file:./projects/arm-policy.tgz '@rush-temp/attestation': file:./projects/attestation.tgz diff --git a/rush.json b/rush.json index 81b978e0f1db..84742f6dab08 100644 --- a/rush.json +++ b/rush.json @@ -794,6 +794,11 @@ "projectFolder": "sdk/remoterendering/mixed-reality-remote-rendering", "versionPolicyName": "client" }, + { + "packageName": "@azure/arm-links", + "projectFolder": "sdk/links/arm-links", + "versionPolicyName": "management" + }, { "packageName": "@azure/arm-policy", "projectFolder": "sdk/policy/arm-policy", diff --git a/sdk/links/arm-links/CHANGELOG.md b/sdk/links/arm-links/CHANGELOG.md new file mode 100644 index 000000000000..d79f7e304c23 --- /dev/null +++ b/sdk/links/arm-links/CHANGELOG.md @@ -0,0 +1,14 @@ +## 30.0.0-beta.1 (2021-07-15) + +This is the first preview for the new version of the `@azure/arm-links` package that follows the new [guidelines for TypeScript SDKs](https://azure.github.io/azure-sdk/typescript_introduction.html) for Azure services. + +While this package remains auto generated, the SDK generator itself has undergone changes to comply with the above guidelines in order to generate packages that are idiomatic to the JavaScript/TypeScript ecosystem and consistent with other packages for Azure services. For more on this, please see [State of the Azure SDK 2021](https://devblogs.microsoft.com/azure-sdk/state-of-the-azure-sdk-2021/). + +Please note that this version has breaking changes, all of which were made after careful consideration during the authoring of the guidelines and user studies. + +**Noteworthy changes and features** +- Authentication: The packages `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` are no longer supported. Use package [@azure/identity](https://www.npmjs.com/package/@azure/identity) instead. Select a credential from Azure Identity examples based on the authentication method of your choice. +- Callbacks: Method overloads that used callbacks have been removed and the use of promises is encouraged instead. +- List operations now return an iterable result that follows the `PagedAsyncIterableIterator` interface as opposed to the previous model where you had to make a new request using the link to the next page. +- Long running operations i.e. the methods whose names started with `begin` now return a poller object that gives you a better control over the operation. To get the final result like before use the corresponding method that will have the suffix `AndWait`. +- The SDK only supports ECMAScript 2015 (ES6) and beyond, all projects that referenced this SDK should be upgraded to use ES6. diff --git a/sdk/links/arm-links/LICENSE.txt b/sdk/links/arm-links/LICENSE similarity index 96% rename from sdk/links/arm-links/LICENSE.txt rename to sdk/links/arm-links/LICENSE index b73b4a1293c3..ccb63b166732 100644 --- a/sdk/links/arm-links/LICENSE.txt +++ b/sdk/links/arm-links/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2019 Microsoft +Copyright (c) 2021 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 @@ -18,4 +18,4 @@ 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. +SOFTWARE. \ No newline at end of file diff --git a/sdk/links/arm-links/README.md b/sdk/links/arm-links/README.md index c03709a56234..ba249620c054 100644 --- a/sdk/links/arm-links/README.md +++ b/sdk/links/arm-links/README.md @@ -1,98 +1,91 @@ -## Azure ManagementLinkClient SDK for JavaScript +# Azure ManagementLink client library for JavaScript -This package contains an isomorphic SDK for ManagementLinkClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for Azure ManagementLink client. + +Azure resources can be linked together to form logical relationships. You can establish links between resources belonging to different resource groups. However, all the linked resources must belong to the same subscription. Each resource can be linked to 50 other resources. If any of the linked resources are deleted or moved, the link owner must clean up the remaining link. + +[Source code](https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/links/arm-links) | +[Package (NPM)](https://www.npmjs.com/package/@azure/arm-links) | +[API reference documentation](https://docs.microsoft.com/javascript/api/@azure/arm-links) | +[Samples](https://github.com/Azure-Samples/azure-samples-js-management) + +## Getting started ### Currently supported environments -- Node.js version 6.x.x or higher -- Browser JavaScript +- [LTS versions of Node.js](https://nodejs.org/about/releases/) +- Latest versions of Safari, Chrome, Edge and Firefox. + +### Prerequisites + +- An [Azure subscription][azure_sub]. -### How to Install +### Install the `@azure/arm-links` package + +Install the Azure ManagementLink client library for JavaScript with `npm`: ```bash npm install @azure/arm-links ``` -### How to use +### Create and authenticate a `ManagementLinkClient` + +To create a client object to access the Azure ManagementLink API, you will need the `endpoint` of your Azure ManagementLink resource and a `credential`. The Azure ManagementLink client can use Azure Active Directory credentials to authenticate. +You can find the endpoint for your Azure ManagementLink resource in the [Azure Portal][azure_portal]. -#### nodejs - Authentication, client creation and list operations as an example written in TypeScript. +#### Using an Azure Active Directory Credential -##### Install @azure/ms-rest-nodeauth +You can authenticate with Azure Active Directory using the [Azure Identity library][azure_identity]. 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/ms-rest-nodeauth +npm install @azure/identity ``` -##### Sample code - -```typescript -import * as msRest from "@azure/ms-rest-js"; -import * as msRestAzure from "@azure/ms-rest-azure-js"; -import * as msRestNodeAuth from "@azure/ms-rest-nodeauth"; -import { ManagementLinkClient, ManagementLinkModels, ManagementLinkMappers } from "@azure/arm-links"; -const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; - -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new ManagementLinkClient(creds, subscriptionId); - client.operations.list().then((result) => { - console.log("The result is:"); - console.log(result); - }); -}).catch((err) => { - console.error(err); -}); +You will also need to register a new AAD application and grant access to Azure ManagementLink 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`. + +```javascript +const { ManagementLinkClient } = require("@azure/arm-links"); +const { DefaultAzureCredential } = require("@azure/identity"); +const client = new ManagementLinkClient("", new DefaultAzureCredential()); ``` -#### browser - Authentication, client creation and list operations as an example written in JavaScript. +## Key concepts -##### Install @azure/ms-rest-browserauth +### ManagementLinkClient -```bash -npm install @azure/ms-rest-browserauth -``` +`ManagementLinkClient` is the primary interface for developers using the Azure ManagementLink client library. Explore the methods on this client object to understand the different features of the Azure ManagementLink service that you can access. -##### Sample code - -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - -- index.html -```html - - - - @azure/arm-links sample - - - - - - - - +## 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 +import { setLogLevel } from "@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/master/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/master/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) +- [Microsoft Azure SDK for JavaScript](https://github.com/Azure/azure-sdk-for-js) ![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Flinks%2Farm-links%2FREADME.png) + +[azure_cli]: https://docs.microsoft.com/cli/azure +[azure_sub]: https://azure.microsoft.com/free/ +[azure_sub]: https://azure.microsoft.com/free/ +[azure_portal]: https://portal.azure.com +[azure_identity]: https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/identity/identity +[defaultazurecredential]: https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/identity/identity#defaultazurecredential diff --git a/sdk/links/arm-links/_meta.json b/sdk/links/arm-links/_meta.json new file mode 100644 index 000000000000..2a37388e4c35 --- /dev/null +++ b/sdk/links/arm-links/_meta.json @@ -0,0 +1,7 @@ +{ + "commit": "406474c3807f2dec010af72286f22aa7a9a54920", + "readme": "specification/resources/resource-manager/readme.md", + "autorest_command": "autorest --version=3.1.3 --typescript --modelerfour.lenient-model-deduplication --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --typescript-sdks-folder=/Users/zhangqiaoqiao/work/code/azure-sdk-for-js ../azure-rest-api-specs/specification/resources/resource-manager/readme.md --use=@autorest/typescript@6.0.0-beta.7", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "use": "@autorest/typescript@6.0.0-beta.7" +} \ No newline at end of file diff --git a/sdk/links/arm-links/api-extractor.json b/sdk/links/arm-links/api-extractor.json new file mode 100644 index 000000000000..5fb5b21b56f2 --- /dev/null +++ b/sdk/links/arm-links/api-extractor.json @@ -0,0 +1,18 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", + "mainEntryPointFilePath": "./esm/index.d.ts", + "docModel": { "enabled": true }, + "apiReport": { "enabled": true, "reportFolder": "./review" }, + "dtsRollup": { + "enabled": true, + "untrimmedFilePath": "", + "publicTrimmedFilePath": "./esm/index.d.ts" + }, + "messages": { + "tsdocMessageReporting": { "default": { "logLevel": "none" } }, + "extractorMessageReporting": { + "ae-missing-release-tag": { "logLevel": "none" }, + "ae-unresolved-link": { "logLevel": "none" } + } + } +} diff --git a/sdk/links/arm-links/package.json b/sdk/links/arm-links/package.json index c75839f25ffd..c278cf66a1fe 100644 --- a/sdk/links/arm-links/package.json +++ b/sdk/links/arm-links/package.json @@ -1,12 +1,18 @@ { "name": "@azure/arm-links", + "sdk-type": "mgmt", "author": "Microsoft Corporation", - "description": "ManagementLinkClient Library with typescript type definitions for node.js and browser.", - "version": "1.0.2", + "description": "A generated SDK for ManagementLinkClient.", + "version": "30.0.0-beta.1", + "engines": { + "node": ">=12.0.0" + }, "dependencies": { - "@azure/ms-rest-azure-js": "^1.3.2", - "@azure/ms-rest-js": "^1.8.1", - "tslib": "^1.9.3" + "@azure/core-paging": "^1.1.1", + "@azure/core-client": "^1.0.0", + "@azure/core-auth": "^1.3.0", + "@azure/core-rest-pipeline": "^1.1.0", + "tslib": "^2.2.0" }, "keywords": [ "node", @@ -16,14 +22,20 @@ "isomorphic" ], "license": "MIT", - "main": "./dist/arm-links.js", - "module": "./esm/managementLinkClient.js", - "types": "./esm/managementLinkClient.d.ts", + "main": "./dist/index.js", + "module": "./esm/index.js", + "types": "./esm/index.d.ts", "devDependencies": { - "typescript": "^3.1.1", - "rollup": "^0.66.2", - "rollup-plugin-node-resolve": "^3.4.0", + "@microsoft/api-extractor": "7.7.11", + "@rollup/plugin-commonjs": "11.0.2", + "@rollup/plugin-json": "^4.0.0", + "@rollup/plugin-multi-entry": "^3.0.0", + "@rollup/plugin-node-resolve": "^8.0.0", + "mkdirp": "^1.0.4", + "rollup": "^1.16.3", "rollup-plugin-sourcemaps": "^0.4.2", + "rollup-plugin-node-resolve": "^3.4.0", + "typescript": "~4.2.0", "uglify-js": "^3.4.9" }, "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/links/arm-links", @@ -45,14 +57,40 @@ "esm/**/*.d.ts.map", "src/**/*.ts", "README.md", + "LICENSE", "rollup.config.js", - "tsconfig.json" + "tsconfig.json", + "review/*", + "CHANGELOG.md" ], "scripts": { - "build": "tsc && rollup -c rollup.config.js && npm run minify", - "minify": "uglifyjs -c -m --comments --source-map \"content='./dist/arm-links.js.map'\" -o ./dist/arm-links.min.js ./dist/arm-links.js", - "prepack": "npm install && npm run build" + "build": "tsc && rollup -c rollup.config.js && npm run minify && mkdirp ./review && npm run extract-api", + "minify": "uglifyjs -c -m --comments --source-map \"content='./dist/index.js.map'\" -o ./dist/index.min.js ./dist/index.js", + "prepack": "npm run build", + "pack": "npm pack 2>&1", + "extract-api": "mkdirp ./review && api-extractor run --local", + "lint": "echo skipped", + "audit": "echo skipped", + "clean": "echo skipped", + "build:node": "echo skipped", + "build:browser": "echo skipped", + "build:test": "echo skipped", + "build:samples": "echo skipped.", + "check-format": "echo skipped", + "execute:samples": "echo skipped", + "format": "echo skipped", + "test": "echo skipped", + "prebuild": "echo skipped", + "test:node": "echo skipped", + "test:browser": "echo skipped", + "unit-test": "echo skipped", + "unit-test:node": "echo skipped", + "unit-test:browser": "echo skipped", + "integration-test:browser": "echo skipped", + "integration-test:node": "echo skipped", + "integration-test": "echo skipped", + "docs": "echo skipped" }, "sideEffects": false, "autoPublish": true -} +} \ No newline at end of file diff --git a/sdk/links/arm-links/review/arm-links.api.md b/sdk/links/arm-links/review/arm-links.api.md new file mode 100644 index 000000000000..ed82b4b10b66 --- /dev/null +++ b/sdk/links/arm-links/review/arm-links.api.md @@ -0,0 +1,188 @@ +## API Report File for "@azure/arm-links" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import * as coreAuth from '@azure/core-auth'; +import * as coreClient from '@azure/core-client'; +import { PagedAsyncIterableIterator } from '@azure/core-paging'; + +// @public (undocumented) +export class ManagementLinkClient extends ManagementLinkClientContext { + constructor(credentials: coreAuth.TokenCredential, subscriptionId: string, options?: ManagementLinkClientOptionalParams); + // (undocumented) + operations: Operations; + // (undocumented) + resourceLinks: ResourceLinks; +} + +// @public (undocumented) +export class ManagementLinkClientContext extends coreClient.ServiceClient { + // (undocumented) + $host: string; + constructor(credentials: coreAuth.TokenCredential, subscriptionId: string, options?: ManagementLinkClientOptionalParams); + // (undocumented) + apiVersion: string; + // (undocumented) + subscriptionId: string; +} + +// @public +export interface ManagementLinkClientOptionalParams extends coreClient.ServiceClientOptions { + $host?: string; + apiVersion?: string; + endpoint?: string; +} + +// @public +export interface Operation { + display?: OperationDisplay; + name?: string; +} + +// @public +export interface OperationDisplay { + description?: string; + operation?: string; + provider?: string; + resource?: string; +} + +// @public +export interface OperationListResult { + nextLink?: string; + value?: Operation[]; +} + +// @public +export interface Operations { + list(options?: OperationsListOptionalParams): PagedAsyncIterableIterator; + listNext(nextLink: string, options?: OperationsListNextOptionalParams): PagedAsyncIterableIterator; +} + +// @public +export interface OperationsListNextNextOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type OperationsListNextNextResponse = OperationListResult; + +// @public +export interface OperationsListNextOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type OperationsListNextResponse = OperationListResult; + +// @public +export interface OperationsListOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type OperationsListResponse = OperationListResult; + +// @public +export interface ResourceLink { + readonly id?: string; + readonly name?: string; + properties?: ResourceLinkProperties; + readonly type?: Record; +} + +// @public +export interface ResourceLinkFilter { + targetId: string; +} + +// @public +export interface ResourceLinkProperties { + notes?: string; + readonly sourceId?: string; + targetId: string; +} + +// @public +export interface ResourceLinkResult { + readonly nextLink?: string; + value: ResourceLink[]; +} + +// @public +export interface ResourceLinks { + createOrUpdate(linkId: string, parameters: ResourceLink, options?: ResourceLinksCreateOrUpdateOptionalParams): Promise; + delete(linkId: string, options?: ResourceLinksDeleteOptionalParams): Promise; + get(linkId: string, options?: ResourceLinksGetOptionalParams): Promise; + listAtSourceScope(scope: string, options?: ResourceLinksListAtSourceScopeOptionalParams): PagedAsyncIterableIterator; + listAtSourceScopeNext(scope: string, nextLink: string, options?: ResourceLinksListAtSourceScopeNextOptionalParams): PagedAsyncIterableIterator; + listAtSubscription(options?: ResourceLinksListAtSubscriptionOptionalParams): PagedAsyncIterableIterator; + listAtSubscriptionNext(nextLink: string, options?: ResourceLinksListAtSubscriptionNextOptionalParams): PagedAsyncIterableIterator; +} + +// @public +export interface ResourceLinksCreateOrUpdateOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type ResourceLinksCreateOrUpdateResponse = ResourceLink; + +// @public +export interface ResourceLinksDeleteOptionalParams extends coreClient.OperationOptions { +} + +// @public +export interface ResourceLinksGetOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type ResourceLinksGetResponse = ResourceLink; + +// @public +export interface ResourceLinksListAtSourceScopeNextNextOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type ResourceLinksListAtSourceScopeNextNextResponse = ResourceLinkResult; + +// @public +export interface ResourceLinksListAtSourceScopeNextOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type ResourceLinksListAtSourceScopeNextResponse = ResourceLinkResult; + +// @public +export interface ResourceLinksListAtSourceScopeOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type ResourceLinksListAtSourceScopeResponse = ResourceLinkResult; + +// @public +export interface ResourceLinksListAtSubscriptionNextNextOptionalParams extends coreClient.OperationOptions { + filter?: string; +} + +// @public +export type ResourceLinksListAtSubscriptionNextNextResponse = ResourceLinkResult; + +// @public +export interface ResourceLinksListAtSubscriptionNextOptionalParams extends coreClient.OperationOptions { + filter?: string; +} + +// @public +export type ResourceLinksListAtSubscriptionNextResponse = ResourceLinkResult; + +// @public +export interface ResourceLinksListAtSubscriptionOptionalParams extends coreClient.OperationOptions { + filter?: string; +} + +// @public +export type ResourceLinksListAtSubscriptionResponse = ResourceLinkResult; + + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/links/arm-links/rollup.config.js b/sdk/links/arm-links/rollup.config.js index 1f09437f6444..9be1955eb7f1 100644 --- a/sdk/links/arm-links/rollup.config.js +++ b/sdk/links/arm-links/rollup.config.js @@ -1,37 +1,188 @@ -import rollup from "rollup"; -import nodeResolve from "rollup-plugin-node-resolve"; +/* + * 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 nodeResolve from "@rollup/plugin-node-resolve"; +import cjs from "@rollup/plugin-commonjs"; import sourcemaps from "rollup-plugin-sourcemaps"; +import multiEntry from "@rollup/plugin-multi-entry"; +import json from "@rollup/plugin-json"; + +import nodeBuiltins from "builtin-modules"; + +/** + * Gets the proper configuration needed for rollup's commonJS plugin for @opentelemetry/api. + * + * NOTE: this manual configuration is only needed because OpenTelemetry uses an + * __exportStar downleveled helper function to declare its exports which confuses + * rollup's automatic discovery mechanism. + * + * @returns an object reference that can be `...`'d into your cjs() configuration. + */ +export function openTelemetryCommonJs() { + const namedExports = {}; + + for (const key of [ + "@opentelemetry/api", + "@azure/core-tracing/node_modules/@opentelemetry/api" + ]) { + namedExports[key] = [ + "SpanKind", + "TraceFlags", + "getSpan", + "setSpan", + "SpanStatusCode", + "getSpanContext", + "setSpanContext" + ]; + } + + const releasedOpenTelemetryVersions = ["0.10.2", "1.0.0-rc.0"]; + + for (const version of releasedOpenTelemetryVersions) { + namedExports[ + // working around a limitation in the rollup common.js plugin - it's not able to resolve these modules so the named exports listed above will not get applied. We have to drill down to the actual path. + `../../../common/temp/node_modules/.pnpm/@opentelemetry/api@${version}/node_modules/@opentelemetry/api/build/src/index.js` + ] = [ + "SpanKind", + "TraceFlags", + "getSpan", + "setSpan", + "StatusCode", + "CanonicalCode", + "getSpanContext", + "setSpanContext" + ]; + } + + return namedExports; +} + +// #region Warning Handler /** - * @type {rollup.RollupFileOptions} + * A function that can determine whether a rollupwarning should be ignored. If + * the function returns `true`, then the warning will not be displayed. */ -const config = { - input: "./esm/managementLinkClient.js", - external: [ - "@azure/ms-rest-js", - "@azure/ms-rest-azure-js" - ], - output: { - file: "./dist/arm-links.js", - format: "umd", - name: "Azure.ArmLinks", - sourcemap: true, - globals: { - "@azure/ms-rest-js": "msRest", - "@azure/ms-rest-azure-js": "msRestAzure" + +function ignoreNiseSinonEvalWarnings(warning) { + return ( + warning.code === "EVAL" && + warning.id && + (warning.id.includes("node_modules/nise") || + warning.id.includes("node_modules/sinon")) === true + ); +} + +function ignoreChaiCircularDependencyWarnings(warning) { + return ( + warning.code === "CIRCULAR_DEPENDENCY" && + warning.importer && warning.importer.includes("node_modules/chai") === true + ); +} + +const warningInhibitors = [ + ignoreChaiCircularDependencyWarnings, + ignoreNiseSinonEvalWarnings +]; + +/** + * Construct a warning handler for the shared rollup configuration + * that ignores certain warnings that are not relevant to testing. + */ +function makeOnWarnForTesting() { + return (warning, warn) => { + // If every inhibitor returns false (i.e. no inhibitors), then show the warning + if (warningInhibitors.every((inhib) => !inhib(warning))) { + warn(warning); + } + }; +} + +// #endregion + +function makeBrowserTestConfig() { + const config = { + input: { + include: ["dist-esm/test/**/*.spec.js"], + exclude: ["dist-esm/test/**/node/**"] }, - banner: `/* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */` - }, - plugins: [ - nodeResolve({ module: true }), - sourcemaps() - ] + output: { + file: `dist-test/index.browser.js`, + format: "umd", + sourcemap: true + }, + preserveSymlinks: false, + plugins: [ + multiEntry({ exports: false }), + nodeResolve({ + mainFields: ["module", "browser"] + }), + cjs({ + namedExports: { + // Chai's strange internal architecture makes it impossible to statically + // analyze its exports. + chai: [ + "version", + "use", + "util", + "config", + "expect", + "should", + "assert" + ], + ...openTelemetryCommonJs() + } + }), + json(), + sourcemaps() + //viz({ filename: "dist-test/browser-stats.html", sourcemap: true }) + ], + onwarn: makeOnWarnForTesting(), + // Disable tree-shaking of test code. In rollup-plugin-node-resolve@5.0.0, + // rollup started respecting the "sideEffects" field in package.json. Since + // our package.json sets "sideEffects=false", this also applies to test + // code, which causes all tests to be removed by tree-shaking. + treeshake: false + }; + + return config; +} + +const defaultConfigurationOptions = { + disableBrowserBundle: false }; -export default config; +export function makeConfig(pkg, options) { + options = { + ...defaultConfigurationOptions, + ...(options || {}) + }; + + const baseConfig = { + // Use the package's module field if it has one + input: pkg["module"] || "dist-esm/src/index.js", + external: [ + ...nodeBuiltins, + ...Object.keys(pkg.dependencies), + ...Object.keys(pkg.devDependencies) + ], + output: { file: "dist/index.js", format: "cjs", sourcemap: true }, + preserveSymlinks: false, + plugins: [sourcemaps(), nodeResolve(), cjs()] + }; + + const config = [baseConfig]; + + if (!options.disableBrowserBundle) { + config.push(makeBrowserTestConfig()); + } + + return config; +} + +export default makeConfig(require("./package.json")); diff --git a/sdk/links/arm-links/src/index.ts b/sdk/links/arm-links/src/index.ts new file mode 100644 index 000000000000..9d87fb1d0d7e --- /dev/null +++ b/sdk/links/arm-links/src/index.ts @@ -0,0 +1,13 @@ +/* + * 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. + */ + +/// +export * from "./models"; +export { ManagementLinkClient } from "./managementLinkClient"; +export { ManagementLinkClientContext } from "./managementLinkClientContext"; +export * from "./operationsInterfaces"; diff --git a/sdk/links/arm-links/src/managementLinkClient.ts b/sdk/links/arm-links/src/managementLinkClient.ts index e501aa9f38a6..6ee22bcf0990 100644 --- a/sdk/links/arm-links/src/managementLinkClient.ts +++ b/sdk/links/arm-links/src/managementLinkClient.ts @@ -1,44 +1,34 @@ /* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. + * 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. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import * as msRest from "@azure/ms-rest-js"; -import * as Models from "./models"; -import * as Mappers from "./models/mappers"; -import * as operations from "./operations"; +import * as coreAuth from "@azure/core-auth"; +import { OperationsImpl, ResourceLinksImpl } from "./operations"; +import { Operations, ResourceLinks } from "./operationsInterfaces"; import { ManagementLinkClientContext } from "./managementLinkClientContext"; +import { ManagementLinkClientOptionalParams } from "./models"; - -class ManagementLinkClient extends ManagementLinkClientContext { - // Operation groups - operations: operations.Operations; - resourceLinks: operations.ResourceLinks; - +export class ManagementLinkClient extends ManagementLinkClientContext { /** * Initializes a new instance of the ManagementLinkClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Subscription credentials which uniquely identify client subscription. * @param subscriptionId The ID of the target subscription. - * @param [options] The parameter options + * @param options The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.ManagementLinkClientOptions) { + constructor( + credentials: coreAuth.TokenCredential, + subscriptionId: string, + options?: ManagementLinkClientOptionalParams + ) { super(credentials, subscriptionId, options); - this.operations = new operations.Operations(this); - this.resourceLinks = new operations.ResourceLinks(this); + this.operations = new OperationsImpl(this); + this.resourceLinks = new ResourceLinksImpl(this); } -} -// Operation Specifications - -export { - ManagementLinkClient, - ManagementLinkClientContext, - Models as ManagementLinkModels, - Mappers as ManagementLinkMappers -}; -export * from "./operations"; + operations: Operations; + resourceLinks: ResourceLinks; +} diff --git a/sdk/links/arm-links/src/managementLinkClientContext.ts b/sdk/links/arm-links/src/managementLinkClientContext.ts index 429c7805a4f8..c800425137b0 100644 --- a/sdk/links/arm-links/src/managementLinkClientContext.ts +++ b/sdk/links/arm-links/src/managementLinkClientContext.ts @@ -1,62 +1,70 @@ /* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. + * 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. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import * as Models from "./models"; -import * as msRest from "@azure/ms-rest-js"; -import * as msRestAzure from "@azure/ms-rest-azure-js"; +import * as coreClient from "@azure/core-client"; +import * as coreAuth from "@azure/core-auth"; +import { ManagementLinkClientOptionalParams } from "./models"; -const packageName = "@azure/arm-links"; -const packageVersion = "1.0.2"; - -export class ManagementLinkClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; +export class ManagementLinkClientContext extends coreClient.ServiceClient { + $host: string; + apiVersion: string; subscriptionId: string; - apiVersion?: string; /** - * Initializes a new instance of the ManagementLinkClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * Initializes a new instance of the ManagementLinkClientContext class. + * @param credentials Subscription credentials which uniquely identify client subscription. * @param subscriptionId The ID of the target subscription. - * @param [options] The parameter options + * @param options The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.ManagementLinkClientOptions) { - if (credentials == undefined) { - throw new Error('\'credentials\' cannot be null.'); + constructor( + credentials: coreAuth.TokenCredential, + subscriptionId: string, + options?: ManagementLinkClientOptionalParams + ) { + if (credentials === undefined) { + throw new Error("'credentials' cannot be null"); } - if (subscriptionId == undefined) { - throw new Error('\'subscriptionId\' cannot be null.'); + if (subscriptionId === undefined) { + throw new Error("'subscriptionId' cannot be null"); } + // Initializing default values for options if (!options) { options = {}; } - if(!options.userAgent) { - const defaultUserAgent = msRestAzure.getDefaultUserAgentValue(); - options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent}`; - } + const defaults: ManagementLinkClientOptionalParams = { + requestContentType: "application/json; charset=utf-8", + credential: credentials + }; - super(credentials, options); + const packageDetails = `azsdk-js-arm-links/30.0.0-beta.1`; + const userAgentPrefix = + options.userAgentOptions && options.userAgentOptions.userAgentPrefix + ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` + : `${packageDetails}`; - this.apiVersion = '2016-09-01'; - this.acceptLanguage = 'en-US'; - this.longRunningOperationRetryTimeout = 30; - this.baseUri = options.baseUri || this.baseUri || "https://management.azure.com"; - this.requestContentType = "application/json; charset=utf-8"; - this.credentials = credentials; + if (!options.credentialScopes) { + options.credentialScopes = ["https://management.azure.com/.default"]; + } + const optionsWithDefaults = { + ...defaults, + ...options, + userAgentOptions: { + userAgentPrefix + }, + baseUri: options.endpoint || "https://management.azure.com" + }; + super(optionsWithDefaults); + // Parameter assignments this.subscriptionId = subscriptionId; - if(options.acceptLanguage !== null && options.acceptLanguage !== undefined) { - this.acceptLanguage = options.acceptLanguage; - } - if(options.longRunningOperationRetryTimeout !== null && options.longRunningOperationRetryTimeout !== undefined) { - this.longRunningOperationRetryTimeout = options.longRunningOperationRetryTimeout; - } + // Assigning values to Constant parameters + this.$host = options.$host || "https://management.azure.com"; + this.apiVersion = options.apiVersion || "2016-09-01"; } } diff --git a/sdk/links/arm-links/src/models/index.ts b/sdk/links/arm-links/src/models/index.ts index 74fd365235e5..8ae9f485adfa 100644 --- a/sdk/links/arm-links/src/models/index.ts +++ b/sdk/links/arm-links/src/models/index.ts @@ -1,325 +1,189 @@ /* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. + * 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 { BaseResource, CloudError, AzureServiceClientOptions } from "@azure/ms-rest-azure-js"; -import * as msRest from "@azure/ms-rest-js"; +import * as coreClient from "@azure/core-client"; -export { BaseResource, CloudError }; +/** Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. */ +export interface OperationListResult { + /** List of Microsoft.Resources operations. */ + value?: Operation[]; + /** URL to get the next set of operation list results if there are any. */ + nextLink?: string; +} -/** - * Resource link filter. - */ -export interface ResourceLinkFilter { - /** - * The ID of the target resource. - */ - targetId: string; +/** Microsoft.Resources operation */ +export interface Operation { + /** Operation name: {provider}/{resource}/{operation} */ + name?: string; + /** The object that represents the operation. */ + display?: OperationDisplay; } -/** - * The resource link properties. - */ -export interface ResourceLinkProperties { - /** - * The fully qualified ID of the source resource in the link. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly sourceId?: string; - /** - * The fully qualified ID of the target resource in the link. - */ - targetId: string; - /** - * Notes about the resource link. - */ - notes?: string; +/** The object that represents the operation. */ +export interface OperationDisplay { + /** Service provider: Microsoft.Resources */ + provider?: string; + /** Resource on which the operation is performed: Profile, endpoint, etc. */ + resource?: string; + /** Operation type: Read, write, delete, etc. */ + operation?: string; + /** Description of the operation. */ + description?: string; } -/** - * The resource link. - */ -export interface ResourceLink extends BaseResource { +/** The resource link. */ +export interface ResourceLink { /** * The fully qualified ID of the resource link. - * **NOTE: This property will not be serialized. It can only be populated by the server.** + * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly id?: string; /** * The name of the resource link. - * **NOTE: This property will not be serialized. It can only be populated by the server.** + * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly name?: string; /** * The resource link object. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly type?: any; - /** - * Properties for resource link. + * NOTE: This property will not be serialized. It can only be populated by the server. */ + readonly type?: Record; + /** Properties for resource link. */ properties?: ResourceLinkProperties; } -/** - * The object that represents the operation. - */ -export interface OperationDisplay { - /** - * Service provider: Microsoft.Resources - */ - provider?: string; - /** - * Resource on which the operation is performed: Profile, endpoint, etc. - */ - resource?: string; - /** - * Operation type: Read, write, delete, etc. - */ - operation?: string; +/** The resource link properties. */ +export interface ResourceLinkProperties { /** - * Description of the operation. + * The fully qualified ID of the source resource in the link. + * NOTE: This property will not be serialized. It can only be populated by the server. */ - description?: string; + readonly sourceId?: string; + /** The fully qualified ID of the target resource in the link. */ + targetId: string; + /** Notes about the resource link. */ + notes?: string; } -/** - * Microsoft.Resources operation - */ -export interface Operation { +/** List of resource links. */ +export interface ResourceLinkResult { + /** An array of resource links. */ + value: ResourceLink[]; /** - * Operation name: {provider}/{resource}/{operation} - */ - name?: string; - /** - * The object that represents the operation. + * The URL to use for getting the next set of results. + * NOTE: This property will not be serialized. It can only be populated by the server. */ - display?: OperationDisplay; + readonly nextLink?: string; } -/** - * Optional Parameters. - */ -export interface ResourceLinksListAtSubscriptionOptionalParams extends msRest.RequestOptionsBase { - /** - * The filter to apply on the list resource links operation. The supported filter for list - * resource links is targetId. For example, $filter=targetId eq {value} - */ - filter?: string; +/** Resource link filter. */ +export interface ResourceLinkFilter { + /** The ID of the target resource. */ + targetId: string; } -/** - * Optional Parameters. - */ -export interface ResourceLinksListAtSourceScopeOptionalParams extends msRest.RequestOptionsBase { - /** - * The filter to apply when getting resource links. To get links only at the specified scope (not - * below the scope), use Filter.atScope(). - */ +/** Optional parameters. */ +export interface OperationsListOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the list operation. */ +export type OperationsListResponse = OperationListResult; + +/** Optional parameters. */ +export interface OperationsListNextOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listNext operation. */ +export type OperationsListNextResponse = OperationListResult; + +/** Optional parameters. */ +export interface OperationsListNextNextOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listNextNext operation. */ +export type OperationsListNextNextResponse = OperationListResult; + +/** Optional parameters. */ +export interface ResourceLinksDeleteOptionalParams + extends coreClient.OperationOptions {} + +/** Optional parameters. */ +export interface ResourceLinksCreateOrUpdateOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the createOrUpdate operation. */ +export type ResourceLinksCreateOrUpdateResponse = ResourceLink; + +/** Optional parameters. */ +export interface ResourceLinksGetOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the get operation. */ +export type ResourceLinksGetResponse = ResourceLink; + +/** Optional parameters. */ +export interface ResourceLinksListAtSubscriptionOptionalParams + extends coreClient.OperationOptions { + /** The filter to apply on the list resource links operation. The supported filter for list resource links is targetId. For example, $filter=targetId eq {value} */ filter?: string; } -/** - * An interface representing ManagementLinkClientOptions. - */ -export interface ManagementLinkClientOptions extends AzureServiceClientOptions { - baseUri?: string; -} +/** Contains response data for the listAtSubscription operation. */ +export type ResourceLinksListAtSubscriptionResponse = ResourceLinkResult; -/** - * @interface - * Result of the request to list Microsoft.Resources operations. It contains a list of operations - * and a URL link to get the next set of results. - * @extends Array - */ -export interface OperationListResult extends Array { - /** - * URL to get the next set of operation list results if there are any. - */ - nextLink?: string; -} +/** Optional parameters. */ +export interface ResourceLinksListAtSourceScopeOptionalParams + extends coreClient.OperationOptions {} -/** - * @interface - * List of resource links. - * @extends Array - */ -export interface ResourceLinkResult extends Array { - /** - * The URL to use for getting the next set of results. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly nextLink?: string; +/** Contains response data for the listAtSourceScope operation. */ +export type ResourceLinksListAtSourceScopeResponse = ResourceLinkResult; + +/** Optional parameters. */ +export interface ResourceLinksListAtSubscriptionNextOptionalParams + extends coreClient.OperationOptions { + /** The filter to apply on the list resource links operation. The supported filter for list resource links is targetId. For example, $filter=targetId eq {value} */ + filter?: string; } -/** - * Defines values for Filter. - * Possible values include: 'atScope()' - * @readonly - * @enum {string} - */ -export type Filter = 'atScope()'; +/** Contains response data for the listAtSubscriptionNext operation. */ +export type ResourceLinksListAtSubscriptionNextResponse = ResourceLinkResult; -/** - * Contains response data for the list operation. - */ -export type OperationsListResponse = OperationListResult & { - /** - * The underlying HTTP response. - */ - _response: msRest.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: OperationListResult; - }; -}; - -/** - * Contains response data for the listNext operation. - */ -export type OperationsListNextResponse = OperationListResult & { - /** - * The underlying HTTP response. - */ - _response: msRest.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: OperationListResult; - }; -}; - -/** - * Contains response data for the createOrUpdate operation. - */ -export type ResourceLinksCreateOrUpdateResponse = ResourceLink & { - /** - * The underlying HTTP response. - */ - _response: msRest.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: ResourceLink; - }; -}; - -/** - * Contains response data for the get operation. - */ -export type ResourceLinksGetResponse = ResourceLink & { - /** - * The underlying HTTP response. - */ - _response: msRest.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: ResourceLink; - }; -}; - -/** - * Contains response data for the listAtSubscription operation. - */ -export type ResourceLinksListAtSubscriptionResponse = ResourceLinkResult & { - /** - * The underlying HTTP response. - */ - _response: msRest.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: ResourceLinkResult; - }; -}; - -/** - * Contains response data for the listAtSourceScope operation. - */ -export type ResourceLinksListAtSourceScopeResponse = ResourceLinkResult & { - /** - * The underlying HTTP response. - */ - _response: msRest.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: ResourceLinkResult; - }; -}; - -/** - * Contains response data for the listAtSubscriptionNext operation. - */ -export type ResourceLinksListAtSubscriptionNextResponse = ResourceLinkResult & { - /** - * The underlying HTTP response. - */ - _response: msRest.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: ResourceLinkResult; - }; -}; - -/** - * Contains response data for the listAtSourceScopeNext operation. - */ -export type ResourceLinksListAtSourceScopeNextResponse = ResourceLinkResult & { - /** - * The underlying HTTP response. - */ - _response: msRest.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: ResourceLinkResult; - }; -}; +/** Optional parameters. */ +export interface ResourceLinksListAtSourceScopeNextOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listAtSourceScopeNext operation. */ +export type ResourceLinksListAtSourceScopeNextResponse = ResourceLinkResult; + +/** Optional parameters. */ +export interface ResourceLinksListAtSubscriptionNextNextOptionalParams + extends coreClient.OperationOptions { + /** The filter to apply on the list resource links operation. The supported filter for list resource links is targetId. For example, $filter=targetId eq {value} */ + filter?: string; +} + +/** Contains response data for the listAtSubscriptionNextNext operation. */ +export type ResourceLinksListAtSubscriptionNextNextResponse = ResourceLinkResult; + +/** Optional parameters. */ +export interface ResourceLinksListAtSourceScopeNextNextOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listAtSourceScopeNextNext operation. */ +export type ResourceLinksListAtSourceScopeNextNextResponse = ResourceLinkResult; + +/** Optional parameters. */ +export interface ManagementLinkClientOptionalParams + extends coreClient.ServiceClientOptions { + /** server parameter */ + $host?: string; + /** Api Version */ + apiVersion?: string; + /** Overrides client endpoint. */ + endpoint?: string; +} diff --git a/sdk/links/arm-links/src/models/mappers.ts b/sdk/links/arm-links/src/models/mappers.ts index 06f26097fb37..6dc8e79de789 100644 --- a/sdk/links/arm-links/src/models/mappers.ts +++ b/sdk/links/arm-links/src/models/mappers.ts @@ -1,56 +1,32 @@ /* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. + * 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 { CloudErrorMapper, BaseResourceMapper } from "@azure/ms-rest-azure-js"; -import * as msRest from "@azure/ms-rest-js"; +import * as coreClient from "@azure/core-client"; -export const CloudError = CloudErrorMapper; -export const BaseResource = BaseResourceMapper; - -export const ResourceLinkFilter: msRest.CompositeMapper = { - serializedName: "ResourceLinkFilter", - type: { - name: "Composite", - className: "ResourceLinkFilter", - modelProperties: { - targetId: { - required: true, - serializedName: "targetId", - type: { - name: "String" - } - } - } - } -}; - -export const ResourceLinkProperties: msRest.CompositeMapper = { - serializedName: "ResourceLinkProperties", +export const OperationListResult: coreClient.CompositeMapper = { type: { name: "Composite", - className: "ResourceLinkProperties", + className: "OperationListResult", modelProperties: { - sourceId: { - readOnly: true, - serializedName: "sourceId", - type: { - name: "String" - } - }, - targetId: { - required: true, - serializedName: "targetId", + value: { + serializedName: "value", type: { - name: "String" + name: "Sequence", + element: { + type: { + name: "Composite", + className: "Operation" + } + } } }, - notes: { - serializedName: "notes", + nextLink: { + serializedName: "nextLink", type: { name: "String" } @@ -59,46 +35,29 @@ export const ResourceLinkProperties: msRest.CompositeMapper = { } }; -export const ResourceLink: msRest.CompositeMapper = { - serializedName: "ResourceLink", +export const Operation: coreClient.CompositeMapper = { type: { name: "Composite", - className: "ResourceLink", + className: "Operation", modelProperties: { - id: { - readOnly: true, - serializedName: "id", - type: { - name: "String" - } - }, name: { - readOnly: true, serializedName: "name", type: { name: "String" } }, - type: { - readOnly: true, - serializedName: "type", - type: { - name: "Object" - } - }, - properties: { - serializedName: "properties", + display: { + serializedName: "display", type: { name: "Composite", - className: "ResourceLinkProperties" + className: "OperationDisplay" } } } } }; -export const OperationDisplay: msRest.CompositeMapper = { - serializedName: "Operation_display", +export const OperationDisplay: coreClient.CompositeMapper = { type: { name: "Composite", className: "OperationDisplay", @@ -131,49 +90,65 @@ export const OperationDisplay: msRest.CompositeMapper = { } }; -export const Operation: msRest.CompositeMapper = { - serializedName: "Operation", +export const ResourceLink: coreClient.CompositeMapper = { type: { name: "Composite", - className: "Operation", + className: "ResourceLink", modelProperties: { + id: { + serializedName: "id", + readOnly: true, + type: { + name: "String" + } + }, name: { serializedName: "name", + readOnly: true, type: { name: "String" } }, - display: { - serializedName: "display", + type: { + serializedName: "type", + readOnly: true, + type: { + name: "Dictionary", + value: { type: { name: "any" } } + } + }, + properties: { + serializedName: "properties", type: { name: "Composite", - className: "OperationDisplay" + className: "ResourceLinkProperties" } } } } }; -export const OperationListResult: msRest.CompositeMapper = { - serializedName: "OperationListResult", +export const ResourceLinkProperties: coreClient.CompositeMapper = { type: { name: "Composite", - className: "OperationListResult", + className: "ResourceLinkProperties", modelProperties: { - value: { - serializedName: "", + sourceId: { + serializedName: "sourceId", + readOnly: true, type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "Operation" - } - } + name: "String" } }, - nextLink: { - serializedName: "nextLink", + targetId: { + serializedName: "targetId", + required: true, + type: { + name: "String" + } + }, + notes: { + serializedName: "notes", type: { name: "String" } @@ -182,15 +157,14 @@ export const OperationListResult: msRest.CompositeMapper = { } }; -export const ResourceLinkResult: msRest.CompositeMapper = { - serializedName: "ResourceLinkResult", +export const ResourceLinkResult: coreClient.CompositeMapper = { type: { name: "Composite", className: "ResourceLinkResult", modelProperties: { value: { + serializedName: "value", required: true, - serializedName: "", type: { name: "Sequence", element: { @@ -202,8 +176,24 @@ export const ResourceLinkResult: msRest.CompositeMapper = { } }, nextLink: { - readOnly: true, serializedName: "nextLink", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const ResourceLinkFilter: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ResourceLinkFilter", + modelProperties: { + targetId: { + serializedName: "targetId", + required: true, type: { name: "String" } diff --git a/sdk/links/arm-links/src/models/operationsMappers.ts b/sdk/links/arm-links/src/models/operationsMappers.ts deleted file mode 100644 index 689688180be7..000000000000 --- a/sdk/links/arm-links/src/models/operationsMappers.ts +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -export { - CloudError, - Operation, - OperationDisplay, - OperationListResult -} from "../models/mappers"; diff --git a/sdk/links/arm-links/src/models/parameters.ts b/sdk/links/arm-links/src/models/parameters.ts index 22fba7f0c925..20df95fc66e0 100644 --- a/sdk/links/arm-links/src/models/parameters.ts +++ b/sdk/links/arm-links/src/models/parameters.ts @@ -1,85 +1,134 @@ /* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. + * 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. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import * as msRest from "@azure/ms-rest-js"; +import { + OperationParameter, + OperationURLParameter, + OperationQueryParameter +} from "@azure/core-client"; +import { ResourceLink as ResourceLinkMapper } from "../models/mappers"; -export const acceptLanguage: msRest.OperationParameter = { - parameterPath: "acceptLanguage", +export const accept: OperationParameter = { + parameterPath: "accept", mapper: { - serializedName: "accept-language", - defaultValue: 'en-US', + defaultValue: "application/json", + isConstant: true, + serializedName: "Accept", type: { name: "String" } } }; -export const apiVersion: msRest.OperationQueryParameter = { - parameterPath: "apiVersion", + +export const $host: OperationURLParameter = { + parameterPath: "$host", mapper: { + serializedName: "$host", required: true, - serializedName: "api-version", type: { name: "String" } - } + }, + skipEncoding: true }; -export const filter: msRest.OperationQueryParameter = { - parameterPath: [ - "options", - "filter" - ], + +export const apiVersion: OperationQueryParameter = { + parameterPath: "apiVersion", mapper: { - serializedName: "$filter", + defaultValue: "2016-09-01", + isConstant: true, + serializedName: "api-version", type: { name: "String" } } }; -export const linkId: msRest.OperationURLParameter = { - parameterPath: "linkId", + +export const nextLink: OperationURLParameter = { + parameterPath: "nextLink", mapper: { + serializedName: "nextLink", required: true, - serializedName: "linkId", type: { name: "String" } }, skipEncoding: true }; -export const nextPageLink: msRest.OperationURLParameter = { - parameterPath: "nextPageLink", + +export const linkId: OperationURLParameter = { + parameterPath: "linkId", mapper: { + serializedName: "linkId", required: true, - serializedName: "nextLink", type: { name: "String" } }, skipEncoding: true }; -export const scope: msRest.OperationURLParameter = { - parameterPath: "scope", + +export const contentType: OperationParameter = { + parameterPath: ["options", "contentType"], mapper: { + defaultValue: "application/json", + isConstant: true, + serializedName: "Content-Type", + type: { + name: "String" + } + } +}; + +export const parameters: OperationParameter = { + parameterPath: "parameters", + mapper: ResourceLinkMapper +}; + +export const filter: OperationQueryParameter = { + parameterPath: ["options", "filter"], + mapper: { + serializedName: "$filter", + type: { + name: "String" + } + } +}; + +export const subscriptionId: OperationURLParameter = { + parameterPath: "subscriptionId", + mapper: { + serializedName: "subscriptionId", required: true, + type: { + name: "String" + } + } +}; + +export const scope: OperationURLParameter = { + parameterPath: "scope", + mapper: { serializedName: "scope", + required: true, type: { name: "String" } }, skipEncoding: true }; -export const subscriptionId: msRest.OperationURLParameter = { - parameterPath: "subscriptionId", + +export const filter1: OperationQueryParameter = { + parameterPath: ["options", "filter"], mapper: { - required: true, - serializedName: "subscriptionId", + defaultValue: "atScope()", + isConstant: true, + serializedName: "$filter", type: { name: "String" } diff --git a/sdk/links/arm-links/src/models/resourceLinksMappers.ts b/sdk/links/arm-links/src/models/resourceLinksMappers.ts deleted file mode 100644 index aab3f2958219..000000000000 --- a/sdk/links/arm-links/src/models/resourceLinksMappers.ts +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -export { - BaseResource, - CloudError, - ResourceLink, - ResourceLinkProperties, - ResourceLinkResult -} from "../models/mappers"; diff --git a/sdk/links/arm-links/src/operations/index.ts b/sdk/links/arm-links/src/operations/index.ts index 13eac92de120..ab54dbae0f7f 100644 --- a/sdk/links/arm-links/src/operations/index.ts +++ b/sdk/links/arm-links/src/operations/index.ts @@ -1,11 +1,9 @@ /* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. + * 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. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ export * from "./operations"; diff --git a/sdk/links/arm-links/src/operations/operations.ts b/sdk/links/arm-links/src/operations/operations.ts index 7085709950df..b7480e782ebf 100644 --- a/sdk/links/arm-links/src/operations/operations.ts +++ b/sdk/links/arm-links/src/operations/operations.ts @@ -1,26 +1,36 @@ /* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. + * 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. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import * as msRest from "@azure/ms-rest-js"; -import * as Models from "../models"; -import * as Mappers from "../models/operationsMappers"; +import "@azure/core-paging"; +import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { Operations } from "../operationsInterfaces"; +import * as coreClient from "@azure/core-client"; +import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; import { ManagementLinkClientContext } from "../managementLinkClientContext"; +import { + Operation, + OperationsListNextOptionalParams, + OperationsListOptionalParams, + OperationsListNextNextOptionalParams, + OperationsListResponse, + OperationsListNextResponse, + OperationsListNextNextResponse +} from "../models"; +/// /** Class representing a Operations. */ -export class Operations { +export class OperationsImpl implements Operations { private readonly client: ManagementLinkClientContext; /** - * Create a Operations. - * @param {ManagementLinkClientContext} client Reference to the service client. + * Initialize a new instance of the class Operations class. + * @param client Reference to the service client */ constructor(client: ManagementLinkClientContext) { this.client = client; @@ -28,96 +38,171 @@ export class Operations { /** * Lists all of the available Microsoft.Resources REST API operations. - * @param [options] The optional parameters - * @returns Promise + * @param options The options parameters. */ - list(options?: msRest.RequestOptionsBase): Promise; - /** - * @param callback The callback - */ - list(callback: msRest.ServiceCallback): void; + public list( + options?: OperationsListOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listPagingAll(options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: () => { + return this.listPagingPage(options); + } + }; + } + + private async *listPagingPage( + options?: OperationsListOptionalParams + ): AsyncIterableIterator { + let result = await this._list(options); + yield result.value || []; + let continuationToken = result.nextLink; + while (continuationToken) { + result = await this._listNext(continuationToken, options); + continuationToken = result.nextLink; + yield result.value || []; + } + } + + private async *listPagingAll( + options?: OperationsListOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listPagingPage(options)) { + yield* page; + } + } + /** - * @param options The optional parameters - * @param callback The callback + * ListNext + * @param nextLink The nextLink from the previous successful call to the List method. + * @param options The options parameters. */ - list(options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - list(options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { - return this.client.sendOperationRequest( - { - options + public listNext( + nextLink: string, + options?: OperationsListNextOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listNextPagingAll(nextLink, options); + return { + next() { + return iter.next(); }, - listOperationSpec, - callback) as Promise; + [Symbol.asyncIterator]() { + return this; + }, + byPage: () => { + return this.listNextPagingPage(nextLink, options); + } + }; + } + + private async *listNextPagingPage( + nextLink: string, + options?: OperationsListNextOptionalParams + ): AsyncIterableIterator { + let result = await this._listNext(nextLink, options); + yield result.value || []; + let continuationToken = result.nextLink; + while (continuationToken) { + result = await this._listNextNext(continuationToken, options); + continuationToken = result.nextLink; + yield result.value || []; + } + } + + private async *listNextPagingAll( + nextLink: string, + options?: OperationsListNextOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listNextPagingPage(nextLink, options)) { + yield* page; + } } /** * Lists all of the available Microsoft.Resources REST API operations. - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param [options] The optional parameters - * @returns Promise + * @param options The options parameters. */ - listNext(nextPageLink: string, options?: msRest.RequestOptionsBase): Promise; + private _list( + options?: OperationsListOptionalParams + ): Promise { + return this.client.sendOperationRequest({ options }, listOperationSpec); + } + /** - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param callback The callback + * ListNext + * @param nextLink The nextLink from the previous successful call to the List method. + * @param options The options parameters. */ - listNext(nextPageLink: string, callback: msRest.ServiceCallback): void; + private _listNext( + nextLink: string, + options?: OperationsListNextOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { nextLink, options }, + listNextOperationSpec + ); + } + /** - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param options The optional parameters - * @param callback The callback + * ListNextNext + * @param nextLink The nextLink from the previous successful call to the ListNext method. + * @param options The options parameters. */ - listNext(nextPageLink: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - listNext(nextPageLink: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + private _listNextNext( + nextLink: string, + options?: OperationsListNextNextOptionalParams + ): Promise { return this.client.sendOperationRequest( - { - nextPageLink, - options - }, - listNextOperationSpec, - callback) as Promise; + { nextLink, options }, + listNextNextOperationSpec + ); } } - // Operation Specifications -const serializer = new msRest.Serializer(Mappers); -const listOperationSpec: msRest.OperationSpec = { +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const listOperationSpec: coreClient.OperationSpec = { + path: "/providers/Microsoft.Resources/operations", httpMethod: "GET", - path: "providers/Microsoft.Resources/operations", - queryParameters: [ - Parameters.apiVersion - ], - headerParameters: [ - Parameters.acceptLanguage - ], responses: { 200: { bodyMapper: Mappers.OperationListResult - }, - default: { - bodyMapper: Mappers.CloudError } }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host], + headerParameters: [Parameters.accept], serializer }; - -const listNextOperationSpec: msRest.OperationSpec = { +const listNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", httpMethod: "GET", - baseUrl: "https://management.azure.com", + responses: { + 200: { + bodyMapper: Mappers.OperationListResult + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.nextLink], + headerParameters: [Parameters.accept], + serializer +}; +const listNextNextOperationSpec: coreClient.OperationSpec = { path: "{nextLink}", - urlParameters: [ - Parameters.nextPageLink - ], - headerParameters: [ - Parameters.acceptLanguage - ], + httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.OperationListResult - }, - default: { - bodyMapper: Mappers.CloudError } }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.nextLink], + headerParameters: [Parameters.accept], serializer }; diff --git a/sdk/links/arm-links/src/operations/resourceLinks.ts b/sdk/links/arm-links/src/operations/resourceLinks.ts index 3cb445cba348..906ec7271a19 100644 --- a/sdk/links/arm-links/src/operations/resourceLinks.ts +++ b/sdk/links/arm-links/src/operations/resourceLinks.ts @@ -1,421 +1,535 @@ /* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. + * 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. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import * as msRest from "@azure/ms-rest-js"; -import * as Models from "../models"; -import * as Mappers from "../models/resourceLinksMappers"; +import "@azure/core-paging"; +import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { ResourceLinks } from "../operationsInterfaces"; +import * as coreClient from "@azure/core-client"; +import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; import { ManagementLinkClientContext } from "../managementLinkClientContext"; +import { + ResourceLink, + ResourceLinksListAtSubscriptionNextOptionalParams, + ResourceLinksListAtSubscriptionOptionalParams, + ResourceLinksListAtSourceScopeNextOptionalParams, + ResourceLinksListAtSourceScopeOptionalParams, + ResourceLinksListAtSubscriptionNextNextOptionalParams, + ResourceLinksListAtSourceScopeNextNextOptionalParams, + ResourceLinksDeleteOptionalParams, + ResourceLinksCreateOrUpdateOptionalParams, + ResourceLinksCreateOrUpdateResponse, + ResourceLinksGetOptionalParams, + ResourceLinksGetResponse, + ResourceLinksListAtSubscriptionResponse, + ResourceLinksListAtSourceScopeResponse, + ResourceLinksListAtSubscriptionNextResponse, + ResourceLinksListAtSourceScopeNextResponse, + ResourceLinksListAtSubscriptionNextNextResponse, + ResourceLinksListAtSourceScopeNextNextResponse +} from "../models"; +/// /** Class representing a ResourceLinks. */ -export class ResourceLinks { +export class ResourceLinksImpl implements ResourceLinks { private readonly client: ManagementLinkClientContext; /** - * Create a ResourceLinks. - * @param {ManagementLinkClientContext} client Reference to the service client. + * Initialize a new instance of the class ResourceLinks class. + * @param client Reference to the service client */ constructor(client: ManagementLinkClientContext) { this.client = client; } /** - * Deletes a resource link with the specified ID. - * @param linkId The fully qualified ID of the resource link. Use the format, - * /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{provider-namespace}/{resource-type}/{resource-name}/Microsoft.Resources/links/{link-name}. - * For example, - * /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink - * @param [options] The optional parameters - * @returns Promise + * Gets all the linked resources for the subscription. + * @param options The options parameters. */ - deleteMethod(linkId: string, options?: msRest.RequestOptionsBase): Promise; + public listAtSubscription( + options?: ResourceLinksListAtSubscriptionOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listAtSubscriptionPagingAll(options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: () => { + return this.listAtSubscriptionPagingPage(options); + } + }; + } + + private async *listAtSubscriptionPagingPage( + options?: ResourceLinksListAtSubscriptionOptionalParams + ): AsyncIterableIterator { + let result = await this._listAtSubscription(options); + yield result.value || []; + let continuationToken = result.nextLink; + while (continuationToken) { + result = await this._listAtSubscriptionNext(continuationToken, options); + continuationToken = result.nextLink; + yield result.value || []; + } + } + + private async *listAtSubscriptionPagingAll( + options?: ResourceLinksListAtSubscriptionOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listAtSubscriptionPagingPage(options)) { + yield* page; + } + } + /** - * @param linkId The fully qualified ID of the resource link. Use the format, - * /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{provider-namespace}/{resource-type}/{resource-name}/Microsoft.Resources/links/{link-name}. - * For example, - * /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink - * @param callback The callback + * Gets a list of resource links at and below the specified source scope. + * @param scope The fully qualified ID of the scope for getting the resource links. For example, to + * list resource links at and under a resource group, set the scope to + * /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup. + * @param options The options parameters. */ - deleteMethod(linkId: string, callback: msRest.ServiceCallback): void; + public listAtSourceScope( + scope: string, + options?: ResourceLinksListAtSourceScopeOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listAtSourceScopePagingAll(scope, options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: () => { + return this.listAtSourceScopePagingPage(scope, options); + } + }; + } + + private async *listAtSourceScopePagingPage( + scope: string, + options?: ResourceLinksListAtSourceScopeOptionalParams + ): AsyncIterableIterator { + let result = await this._listAtSourceScope(scope, options); + yield result.value || []; + let continuationToken = result.nextLink; + while (continuationToken) { + result = await this._listAtSourceScopeNext( + scope, + continuationToken, + options + ); + continuationToken = result.nextLink; + yield result.value || []; + } + } + + private async *listAtSourceScopePagingAll( + scope: string, + options?: ResourceLinksListAtSourceScopeOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listAtSourceScopePagingPage(scope, options)) { + yield* page; + } + } + /** - * @param linkId The fully qualified ID of the resource link. Use the format, - * /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{provider-namespace}/{resource-type}/{resource-name}/Microsoft.Resources/links/{link-name}. - * For example, - * /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink - * @param options The optional parameters - * @param callback The callback + * ListAtSubscriptionNext + * @param nextLink The nextLink from the previous successful call to the ListAtSubscription method. + * @param options The options parameters. */ - deleteMethod(linkId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - deleteMethod(linkId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { - return this.client.sendOperationRequest( - { - linkId, - options + public listAtSubscriptionNext( + nextLink: string, + options?: ResourceLinksListAtSubscriptionNextOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listAtSubscriptionNextPagingAll(nextLink, options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; }, - deleteMethodOperationSpec, - callback); + byPage: () => { + return this.listAtSubscriptionNextPagingPage(nextLink, options); + } + }; + } + + private async *listAtSubscriptionNextPagingPage( + nextLink: string, + options?: ResourceLinksListAtSubscriptionNextOptionalParams + ): AsyncIterableIterator { + let result = await this._listAtSubscriptionNext(nextLink, options); + yield result.value || []; + let continuationToken = result.nextLink; + while (continuationToken) { + result = await this._listAtSubscriptionNextNext( + continuationToken, + options + ); + continuationToken = result.nextLink; + yield result.value || []; + } + } + + private async *listAtSubscriptionNextPagingAll( + nextLink: string, + options?: ResourceLinksListAtSubscriptionNextOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listAtSubscriptionNextPagingPage( + nextLink, + options + )) { + yield* page; + } } /** - * Creates or updates a resource link between the specified resources. - * @param linkId The fully qualified ID of the resource link. Use the format, - * /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{provider-namespace}/{resource-type}/{resource-name}/Microsoft.Resources/links/{link-name}. - * For example, - * /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink - * @param parameters Parameters for creating or updating a resource link. - * @param [options] The optional parameters - * @returns Promise + * ListAtSourceScopeNext + * @param scope The fully qualified ID of the scope for getting the resource links. For example, to + * list resource links at and under a resource group, set the scope to + * /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup. + * @param nextLink The nextLink from the previous successful call to the ListAtSourceScope method. + * @param options The options parameters. */ - createOrUpdate(linkId: string, parameters: Models.ResourceLink, options?: msRest.RequestOptionsBase): Promise; + public listAtSourceScopeNext( + scope: string, + nextLink: string, + options?: ResourceLinksListAtSourceScopeNextOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listAtSourceScopeNextPagingAll(scope, nextLink, options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: () => { + return this.listAtSourceScopeNextPagingPage(scope, nextLink, options); + } + }; + } + + private async *listAtSourceScopeNextPagingPage( + scope: string, + nextLink: string, + options?: ResourceLinksListAtSourceScopeNextOptionalParams + ): AsyncIterableIterator { + let result = await this._listAtSourceScopeNext(scope, nextLink, options); + yield result.value || []; + let continuationToken = result.nextLink; + while (continuationToken) { + result = await this._listAtSourceScopeNextNext( + scope, + continuationToken, + options + ); + continuationToken = result.nextLink; + yield result.value || []; + } + } + + private async *listAtSourceScopeNextPagingAll( + scope: string, + nextLink: string, + options?: ResourceLinksListAtSourceScopeNextOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listAtSourceScopeNextPagingPage( + scope, + nextLink, + options + )) { + yield* page; + } + } + /** + * Deletes a resource link with the specified ID. * @param linkId The fully qualified ID of the resource link. Use the format, - * /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{provider-namespace}/{resource-type}/{resource-name}/Microsoft.Resources/links/{link-name}. - * For example, - * /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink - * @param parameters Parameters for creating or updating a resource link. - * @param callback The callback + * /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{provider-namespace}/{resource-type}/{resource-name}/Microsoft.Resources/links/{link-name}. + * For example, + * /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink + * @param options The options parameters. */ - createOrUpdate(linkId: string, parameters: Models.ResourceLink, callback: msRest.ServiceCallback): void; + delete( + linkId: string, + options?: ResourceLinksDeleteOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { linkId, options }, + deleteOperationSpec + ); + } + /** + * Creates or updates a resource link between the specified resources. * @param linkId The fully qualified ID of the resource link. Use the format, - * /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{provider-namespace}/{resource-type}/{resource-name}/Microsoft.Resources/links/{link-name}. - * For example, - * /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink + * /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{provider-namespace}/{resource-type}/{resource-name}/Microsoft.Resources/links/{link-name}. + * For example, + * /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink * @param parameters Parameters for creating or updating a resource link. - * @param options The optional parameters - * @param callback The callback + * @param options The options parameters. */ - createOrUpdate(linkId: string, parameters: Models.ResourceLink, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - createOrUpdate(linkId: string, parameters: Models.ResourceLink, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + createOrUpdate( + linkId: string, + parameters: ResourceLink, + options?: ResourceLinksCreateOrUpdateOptionalParams + ): Promise { return this.client.sendOperationRequest( - { - linkId, - parameters, - options - }, - createOrUpdateOperationSpec, - callback) as Promise; + { linkId, parameters, options }, + createOrUpdateOperationSpec + ); } /** * Gets a resource link with the specified ID. * @param linkId The fully qualified Id of the resource link. For example, - * /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink - * @param [options] The optional parameters - * @returns Promise + * /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink + * @param options The options parameters. */ - get(linkId: string, options?: msRest.RequestOptionsBase): Promise; - /** - * @param linkId The fully qualified Id of the resource link. For example, - * /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink - * @param callback The callback - */ - get(linkId: string, callback: msRest.ServiceCallback): void; - /** - * @param linkId The fully qualified Id of the resource link. For example, - * /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink - * @param options The optional parameters - * @param callback The callback - */ - get(linkId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - get(linkId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + get( + linkId: string, + options?: ResourceLinksGetOptionalParams + ): Promise { return this.client.sendOperationRequest( - { - linkId, - options - }, - getOperationSpec, - callback) as Promise; + { linkId, options }, + getOperationSpec + ); } /** * Gets all the linked resources for the subscription. - * @param [options] The optional parameters - * @returns Promise + * @param options The options parameters. */ - listAtSubscription(options?: Models.ResourceLinksListAtSubscriptionOptionalParams): Promise; - /** - * @param callback The callback - */ - listAtSubscription(callback: msRest.ServiceCallback): void; - /** - * @param options The optional parameters - * @param callback The callback - */ - listAtSubscription(options: Models.ResourceLinksListAtSubscriptionOptionalParams, callback: msRest.ServiceCallback): void; - listAtSubscription(options?: Models.ResourceLinksListAtSubscriptionOptionalParams | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + private _listAtSubscription( + options?: ResourceLinksListAtSubscriptionOptionalParams + ): Promise { return this.client.sendOperationRequest( - { - options - }, - listAtSubscriptionOperationSpec, - callback) as Promise; + { options }, + listAtSubscriptionOperationSpec + ); } /** * Gets a list of resource links at and below the specified source scope. * @param scope The fully qualified ID of the scope for getting the resource links. For example, to - * list resource links at and under a resource group, set the scope to - * /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup. - * @param [options] The optional parameters - * @returns Promise + * list resource links at and under a resource group, set the scope to + * /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup. + * @param options The options parameters. */ - listAtSourceScope(scope: string, options?: Models.ResourceLinksListAtSourceScopeOptionalParams): Promise; + private _listAtSourceScope( + scope: string, + options?: ResourceLinksListAtSourceScopeOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { scope, options }, + listAtSourceScopeOperationSpec + ); + } + /** - * @param scope The fully qualified ID of the scope for getting the resource links. For example, to - * list resource links at and under a resource group, set the scope to - * /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup. - * @param callback The callback + * ListAtSubscriptionNext + * @param nextLink The nextLink from the previous successful call to the ListAtSubscription method. + * @param options The options parameters. */ - listAtSourceScope(scope: string, callback: msRest.ServiceCallback): void; + private _listAtSubscriptionNext( + nextLink: string, + options?: ResourceLinksListAtSubscriptionNextOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { nextLink, options }, + listAtSubscriptionNextOperationSpec + ); + } + /** + * ListAtSourceScopeNext * @param scope The fully qualified ID of the scope for getting the resource links. For example, to - * list resource links at and under a resource group, set the scope to - * /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup. - * @param options The optional parameters - * @param callback The callback + * list resource links at and under a resource group, set the scope to + * /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup. + * @param nextLink The nextLink from the previous successful call to the ListAtSourceScope method. + * @param options The options parameters. */ - listAtSourceScope(scope: string, options: Models.ResourceLinksListAtSourceScopeOptionalParams, callback: msRest.ServiceCallback): void; - listAtSourceScope(scope: string, options?: Models.ResourceLinksListAtSourceScopeOptionalParams | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + private _listAtSourceScopeNext( + scope: string, + nextLink: string, + options?: ResourceLinksListAtSourceScopeNextOptionalParams + ): Promise { return this.client.sendOperationRequest( - { - scope, - options - }, - listAtSourceScopeOperationSpec, - callback) as Promise; + { scope, nextLink, options }, + listAtSourceScopeNextOperationSpec + ); } /** - * Gets all the linked resources for the subscription. - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param [options] The optional parameters - * @returns Promise - */ - listAtSubscriptionNext(nextPageLink: string, options?: msRest.RequestOptionsBase): Promise; - /** - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param callback The callback + * ListAtSubscriptionNextNext + * @param nextLink The nextLink from the previous successful call to the ListAtSubscriptionNext method. + * @param options The options parameters. */ - listAtSubscriptionNext(nextPageLink: string, callback: msRest.ServiceCallback): void; - /** - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param options The optional parameters - * @param callback The callback - */ - listAtSubscriptionNext(nextPageLink: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - listAtSubscriptionNext(nextPageLink: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + private _listAtSubscriptionNextNext( + nextLink: string, + options?: ResourceLinksListAtSubscriptionNextNextOptionalParams + ): Promise { return this.client.sendOperationRequest( - { - nextPageLink, - options - }, - listAtSubscriptionNextOperationSpec, - callback) as Promise; + { nextLink, options }, + listAtSubscriptionNextNextOperationSpec + ); } /** - * Gets a list of resource links at and below the specified source scope. - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param [options] The optional parameters - * @returns Promise - */ - listAtSourceScopeNext(nextPageLink: string, options?: msRest.RequestOptionsBase): Promise; - /** - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param callback The callback - */ - listAtSourceScopeNext(nextPageLink: string, callback: msRest.ServiceCallback): void; - /** - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param options The optional parameters - * @param callback The callback + * ListAtSourceScopeNextNext + * @param scope The fully qualified ID of the scope for getting the resource links. For example, to + * list resource links at and under a resource group, set the scope to + * /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup. + * @param nextLink The nextLink from the previous successful call to the ListAtSourceScopeNext method. + * @param options The options parameters. */ - listAtSourceScopeNext(nextPageLink: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - listAtSourceScopeNext(nextPageLink: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + private _listAtSourceScopeNextNext( + scope: string, + nextLink: string, + options?: ResourceLinksListAtSourceScopeNextNextOptionalParams + ): Promise { return this.client.sendOperationRequest( - { - nextPageLink, - options - }, - listAtSourceScopeNextOperationSpec, - callback) as Promise; + { scope, nextLink, options }, + listAtSourceScopeNextNextOperationSpec + ); } } - // Operation Specifications -const serializer = new msRest.Serializer(Mappers); -const deleteMethodOperationSpec: msRest.OperationSpec = { +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const deleteOperationSpec: coreClient.OperationSpec = { + path: "/{linkId}", httpMethod: "DELETE", - path: "{linkId}", - urlParameters: [ - Parameters.linkId - ], - queryParameters: [ - Parameters.apiVersion - ], - headerParameters: [ - Parameters.acceptLanguage - ], - responses: { - 200: {}, - 204: {}, - default: { - bodyMapper: Mappers.CloudError - } - }, + responses: { 200: {}, 204: {} }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.linkId], serializer }; - -const createOrUpdateOperationSpec: msRest.OperationSpec = { +const createOrUpdateOperationSpec: coreClient.OperationSpec = { + path: "/{linkId}", httpMethod: "PUT", - path: "{linkId}", - urlParameters: [ - Parameters.linkId - ], - queryParameters: [ - Parameters.apiVersion - ], - headerParameters: [ - Parameters.acceptLanguage - ], - requestBody: { - parameterPath: "parameters", - mapper: { - ...Mappers.ResourceLink, - required: true - } - }, responses: { 200: { bodyMapper: Mappers.ResourceLink }, 201: { bodyMapper: Mappers.ResourceLink - }, - default: { - bodyMapper: Mappers.CloudError } }, + requestBody: Parameters.parameters, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.linkId], + headerParameters: [Parameters.accept, Parameters.contentType], + mediaType: "json", serializer }; - -const getOperationSpec: msRest.OperationSpec = { +const getOperationSpec: coreClient.OperationSpec = { + path: "/{linkId}", httpMethod: "GET", - path: "{linkId}", - urlParameters: [ - Parameters.linkId - ], - queryParameters: [ - Parameters.apiVersion - ], - headerParameters: [ - Parameters.acceptLanguage - ], responses: { 200: { bodyMapper: Mappers.ResourceLink - }, - default: { - bodyMapper: Mappers.CloudError } }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.linkId], + headerParameters: [Parameters.accept], serializer }; - -const listAtSubscriptionOperationSpec: msRest.OperationSpec = { +const listAtSubscriptionOperationSpec: coreClient.OperationSpec = { + path: "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/links", httpMethod: "GET", - path: "subscriptions/{subscriptionId}/providers/Microsoft.Resources/links", - urlParameters: [ - Parameters.subscriptionId - ], - queryParameters: [ - Parameters.filter, - Parameters.apiVersion - ], - headerParameters: [ - Parameters.acceptLanguage - ], responses: { 200: { bodyMapper: Mappers.ResourceLinkResult - }, - default: { - bodyMapper: Mappers.CloudError } }, + queryParameters: [Parameters.apiVersion, Parameters.filter], + urlParameters: [Parameters.$host, Parameters.subscriptionId], + headerParameters: [Parameters.accept], serializer }; - -const listAtSourceScopeOperationSpec: msRest.OperationSpec = { +const listAtSourceScopeOperationSpec: coreClient.OperationSpec = { + path: "/{scope}/providers/Microsoft.Resources/links", httpMethod: "GET", - path: "{scope}/providers/Microsoft.Resources/links", - urlParameters: [ - Parameters.scope - ], - queryParameters: [ - Parameters.filter, - Parameters.apiVersion - ], - headerParameters: [ - Parameters.acceptLanguage - ], responses: { 200: { bodyMapper: Mappers.ResourceLinkResult - }, - default: { - bodyMapper: Mappers.CloudError } }, + queryParameters: [Parameters.apiVersion, Parameters.filter1], + urlParameters: [Parameters.$host, Parameters.scope], + headerParameters: [Parameters.accept], serializer }; - -const listAtSubscriptionNextOperationSpec: msRest.OperationSpec = { - httpMethod: "GET", - baseUrl: "https://management.azure.com", +const listAtSubscriptionNextOperationSpec: coreClient.OperationSpec = { path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.ResourceLinkResult + } + }, + queryParameters: [Parameters.apiVersion, Parameters.filter], urlParameters: [ - Parameters.nextPageLink - ], - headerParameters: [ - Parameters.acceptLanguage + Parameters.$host, + Parameters.nextLink, + Parameters.subscriptionId ], + headerParameters: [Parameters.accept], + serializer +}; +const listAtSourceScopeNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.ResourceLinkResult - }, - default: { - bodyMapper: Mappers.CloudError } }, + queryParameters: [Parameters.apiVersion, Parameters.filter1], + urlParameters: [Parameters.$host, Parameters.nextLink, Parameters.scope], + headerParameters: [Parameters.accept], serializer }; - -const listAtSourceScopeNextOperationSpec: msRest.OperationSpec = { - httpMethod: "GET", - baseUrl: "https://management.azure.com", +const listAtSubscriptionNextNextOperationSpec: coreClient.OperationSpec = { path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.ResourceLinkResult + } + }, + queryParameters: [Parameters.apiVersion, Parameters.filter], urlParameters: [ - Parameters.nextPageLink - ], - headerParameters: [ - Parameters.acceptLanguage + Parameters.$host, + Parameters.nextLink, + Parameters.subscriptionId ], + headerParameters: [Parameters.accept], + serializer +}; +const listAtSourceScopeNextNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.ResourceLinkResult - }, - default: { - bodyMapper: Mappers.CloudError } }, + queryParameters: [Parameters.apiVersion, Parameters.filter1], + urlParameters: [Parameters.$host, Parameters.nextLink, Parameters.scope], + headerParameters: [Parameters.accept], serializer }; diff --git a/sdk/links/arm-links/src/operationsInterfaces/index.ts b/sdk/links/arm-links/src/operationsInterfaces/index.ts new file mode 100644 index 000000000000..ab54dbae0f7f --- /dev/null +++ b/sdk/links/arm-links/src/operationsInterfaces/index.ts @@ -0,0 +1,10 @@ +/* + * 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. + */ + +export * from "./operations"; +export * from "./resourceLinks"; diff --git a/sdk/links/arm-links/src/operationsInterfaces/operations.ts b/sdk/links/arm-links/src/operationsInterfaces/operations.ts new file mode 100644 index 000000000000..22818c150d21 --- /dev/null +++ b/sdk/links/arm-links/src/operationsInterfaces/operations.ts @@ -0,0 +1,36 @@ +/* + * 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 "@azure/core-paging"; +import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { + Operation, + OperationsListNextOptionalParams, + OperationsListOptionalParams +} from "../models"; + +/// +/** Interface representing a Operations. */ +export interface Operations { + /** + * Lists all of the available Microsoft.Resources REST API operations. + * @param options The options parameters. + */ + list( + options?: OperationsListOptionalParams + ): PagedAsyncIterableIterator; + /** + * ListNext + * @param nextLink The nextLink from the previous successful call to the List method. + * @param options The options parameters. + */ + listNext( + nextLink: string, + options?: OperationsListNextOptionalParams + ): PagedAsyncIterableIterator; +} diff --git a/sdk/links/arm-links/src/operationsInterfaces/resourceLinks.ts b/sdk/links/arm-links/src/operationsInterfaces/resourceLinks.ts new file mode 100644 index 000000000000..740c007d3488 --- /dev/null +++ b/sdk/links/arm-links/src/operationsInterfaces/resourceLinks.ts @@ -0,0 +1,103 @@ +/* + * 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 "@azure/core-paging"; +import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { + ResourceLink, + ResourceLinksListAtSubscriptionNextOptionalParams, + ResourceLinksListAtSubscriptionOptionalParams, + ResourceLinksListAtSourceScopeNextOptionalParams, + ResourceLinksListAtSourceScopeOptionalParams, + ResourceLinksDeleteOptionalParams, + ResourceLinksCreateOrUpdateOptionalParams, + ResourceLinksCreateOrUpdateResponse, + ResourceLinksGetOptionalParams, + ResourceLinksGetResponse +} from "../models"; + +/// +/** Interface representing a ResourceLinks. */ +export interface ResourceLinks { + /** + * Gets all the linked resources for the subscription. + * @param options The options parameters. + */ + listAtSubscription( + options?: ResourceLinksListAtSubscriptionOptionalParams + ): PagedAsyncIterableIterator; + /** + * Gets a list of resource links at and below the specified source scope. + * @param scope The fully qualified ID of the scope for getting the resource links. For example, to + * list resource links at and under a resource group, set the scope to + * /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup. + * @param options The options parameters. + */ + listAtSourceScope( + scope: string, + options?: ResourceLinksListAtSourceScopeOptionalParams + ): PagedAsyncIterableIterator; + /** + * ListAtSubscriptionNext + * @param nextLink The nextLink from the previous successful call to the ListAtSubscription method. + * @param options The options parameters. + */ + listAtSubscriptionNext( + nextLink: string, + options?: ResourceLinksListAtSubscriptionNextOptionalParams + ): PagedAsyncIterableIterator; + /** + * ListAtSourceScopeNext + * @param scope The fully qualified ID of the scope for getting the resource links. For example, to + * list resource links at and under a resource group, set the scope to + * /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup. + * @param nextLink The nextLink from the previous successful call to the ListAtSourceScope method. + * @param options The options parameters. + */ + listAtSourceScopeNext( + scope: string, + nextLink: string, + options?: ResourceLinksListAtSourceScopeNextOptionalParams + ): PagedAsyncIterableIterator; + /** + * Deletes a resource link with the specified ID. + * @param linkId The fully qualified ID of the resource link. Use the format, + * /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{provider-namespace}/{resource-type}/{resource-name}/Microsoft.Resources/links/{link-name}. + * For example, + * /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink + * @param options The options parameters. + */ + delete( + linkId: string, + options?: ResourceLinksDeleteOptionalParams + ): Promise; + /** + * Creates or updates a resource link between the specified resources. + * @param linkId The fully qualified ID of the resource link. Use the format, + * /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{provider-namespace}/{resource-type}/{resource-name}/Microsoft.Resources/links/{link-name}. + * For example, + * /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink + * @param parameters Parameters for creating or updating a resource link. + * @param options The options parameters. + */ + createOrUpdate( + linkId: string, + parameters: ResourceLink, + options?: ResourceLinksCreateOrUpdateOptionalParams + ): Promise; + /** + * Gets a resource link with the specified ID. + * @param linkId The fully qualified Id of the resource link. For example, + * /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink + * @param options The options parameters. + */ + get( + linkId: string, + options?: ResourceLinksGetOptionalParams + ): Promise; +} diff --git a/sdk/links/arm-links/tsconfig.json b/sdk/links/arm-links/tsconfig.json index 87bbf5b5fa49..0ec8659c8e83 100644 --- a/sdk/links/arm-links/tsconfig.json +++ b/sdk/links/arm-links/tsconfig.json @@ -3,13 +3,14 @@ "module": "es6", "moduleResolution": "node", "strict": true, - "target": "es5", + "target": "es6", "sourceMap": true, "declarationMap": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true, "forceConsistentCasingInFileNames": true, - "lib": ["es6"], + "preserveConstEnums": true, + "lib": ["es6", "dom"], "declaration": true, "outDir": "./esm", "importHelpers": true diff --git a/sdk/links/ci.yml b/sdk/links/ci.yml new file mode 100644 index 000000000000..0d75c97cb1b8 --- /dev/null +++ b/sdk/links/ci.yml @@ -0,0 +1,28 @@ +trigger: + branches: + include: + - main + - release/* + - hotfix/* + paths: + include: + - sdk/links/ + +pr: + branches: + include: + - main + - release/* + - hotfix/* + paths: + include: + - sdk/links/ + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: links + Artifacts: + - name: azure-arm-links + safeName: azurearmlinks + \ No newline at end of file