From d2f198923bfb1b4a02c85154c0ad6f2aa9ea46ea Mon Sep 17 00:00:00 2001 From: kazrael2119 <98569699+kazrael2119@users.noreply.github.com> Date: Mon, 14 Nov 2022 16:51:07 +0800 Subject: [PATCH] refresh 1 (#23821) * refresh 1 * update files * update files * update files * update files * update files * update files * update files * update files --- common/config/rush/pnpm-lock.yaml | 34 +++++---- sdk/advisor/arm-advisor/CHANGELOG.md | 20 +++-- sdk/advisor/arm-advisor/_meta.json | 6 +- sdk/advisor/arm-advisor/package.json | 24 +++--- .../node/my_test/recording_sample_test.js | 5 -- .../node/my_test/recording_sample_test.json | 4 + .../arm-advisor/review/arm-advisor.api.md | 72 +++++++----------- .../samples/v3/typescript/package.json | 2 +- .../src/advisorManagementClient.ts | 75 +++++++++++++++++-- sdk/advisor/arm-advisor/src/index.ts | 1 + sdk/advisor/arm-advisor/src/models/index.ts | 31 ++++++-- .../src/operations/configurations.ts | 50 +++++++++---- .../arm-advisor/src/operations/operations.ts | 29 +++++-- .../src/operations/recommendationMetadata.ts | 31 +++++--- .../src/operations/recommendations.ts | 31 +++++--- .../src/operations/suppressions.ts | 31 +++++--- sdk/advisor/arm-advisor/src/pagingHelper.ts | 39 ++++++++++ sdk/advisor/arm-advisor/test/sampleTest.ts | 39 +++++----- sdk/agrifood/arm-agrifood/CHANGELOG.md | 16 ++-- sdk/agrifood/arm-agrifood/_meta.json | 6 +- sdk/agrifood/arm-agrifood/package.json | 7 +- .../arm-agrifood/review/arm-agrifood.api.md | 3 + .../samples/v1-beta/typescript/package.json | 2 +- .../arm-agrifood/src/agriFoodMgmtClient.ts | 9 +-- sdk/agrifood/arm-agrifood/src/index.ts | 1 + .../arm-agrifood/src/operations/extensions.ts | 40 ++++++---- .../src/operations/farmBeatsExtensions.ts | 29 +++++-- .../src/operations/farmBeatsModels.ts | 63 +++++++++++----- .../arm-agrifood/src/operations/operations.ts | 29 +++++-- .../operations/privateEndpointConnections.ts | 20 +++-- .../src/operations/privateLinkResources.ts | 16 ++-- sdk/agrifood/arm-agrifood/src/pagingHelper.ts | 39 ++++++++++ .../arm-analysisservices/CHANGELOG.md | 10 +-- .../arm-analysisservices/_meta.json | 8 +- .../arm-analysisservices/package.json | 7 +- .../review/arm-analysisservices.api.md | 3 + .../src/azureAnalysisServices.ts | 9 +-- .../arm-analysisservices/src/index.ts | 1 + .../src/operations/operations.ts | 29 +++++-- .../src/operations/servers.ts | 36 ++++++--- .../arm-analysisservices/src/pagingHelper.ts | 39 ++++++++++ 41 files changed, 654 insertions(+), 292 deletions(-) delete mode 100644 sdk/advisor/arm-advisor/recordings/node/my_test/recording_sample_test.js create mode 100644 sdk/advisor/arm-advisor/recordings/node/my_test/recording_sample_test.json create mode 100644 sdk/advisor/arm-advisor/src/pagingHelper.ts create mode 100644 sdk/agrifood/arm-agrifood/src/pagingHelper.ts create mode 100644 sdk/analysisservices/arm-analysisservices/src/pagingHelper.ts diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 192291558a33..f6e546040b4a 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -1727,6 +1727,7 @@ packages: /@opentelemetry/api-metrics/0.33.0: resolution: {integrity: sha512-78evfPRRRnJA6uZ3xuBuS3VZlXTO/LRs+Ff1iv3O/7DgibCtq9k27T6Zlj8yRdJDFmcjcbQrvC0/CpDpWHaZYA==} engines: {node: '>=14'} + deprecated: Please use @opentelemetry/api >= 1.3.0 dependencies: '@opentelemetry/api': 1.2.0 dev: false @@ -3890,7 +3891,7 @@ packages: dependencies: semver: 7.3.8 shelljs: 0.8.5 - typescript: 5.0.0-dev.20221110 + typescript: 5.0.0-dev.20221113 dev: false /downlevel-dts/0.8.0: @@ -8838,8 +8839,8 @@ packages: hasBin: true dev: false - /typescript/5.0.0-dev.20221110: - resolution: {integrity: sha512-2ErQCfMJ/il4ipW6NRIqJdQvJ84k8nafDIXGCpjaedCdnF/ejRmtHAhPuS5m54AKhRz/uc31LxzKpcSOxVuJHQ==} + /typescript/5.0.0-dev.20221113: + resolution: {integrity: sha512-iNVo0p5OwpkxLl3hzf7zLw5fjcQnrFIgHwPh2BZgZOofcaFNxj42SOhR/OoZMYSbqkkRFrOi1gzVcsgw6ehDFg==} engines: {node: '>=4.2.0'} hasBin: true dev: false @@ -10039,7 +10040,7 @@ packages: dev: false file:projects/arm-advisor.tgz: - resolution: {integrity: sha512-xnexSrkxHEjQOevHW15YPdltHEkIQmh/lTrvWfM15/1g+sMjP3tM5YSKfj1p23/lNW2ko51DnQewx6meGWXC7Q==, tarball: file:projects/arm-advisor.tgz} + resolution: {integrity: sha512-v8TbBfh3Cd6ewFL8lt6++w0N3hZDNmvA2WlfJRWP0q6gm4kJCyZ9ir2tCI65cTpSC8iMp6+X6jrHKb7kdiK9sA==, tarball: file:projects/arm-advisor.tgz} name: '@rush-temp/arm-advisor' version: 0.0.0 dependencies: @@ -10050,23 +10051,24 @@ packages: '@rollup/plugin-json': 4.1.0_rollup@2.79.1 '@rollup/plugin-multi-entry': 4.1.0_rollup@2.79.1 '@rollup/plugin-node-resolve': 13.3.0_rollup@2.79.1 + '@types/chai': 4.3.3 + '@types/node': 14.18.33 + chai: 4.3.6 cross-env: 7.0.3 mkdirp: 1.0.4 mocha: 7.2.0 rimraf: 3.0.2 rollup: 2.79.1 - rollup-plugin-sourcemaps: 0.6.3_rollup@2.79.1 + rollup-plugin-sourcemaps: 0.6.3_1225c068d0546e507df7db46196a6444 tslib: 2.4.1 - typescript: 4.2.4 + typescript: 4.8.4 uglify-js: 3.17.4 transitivePeerDependencies: - - '@types/node' - - encoding - supports-color dev: false file:projects/arm-agrifood.tgz: - resolution: {integrity: sha512-SRUhoa6EzJb8/EF6VQg5dy28StH5phW5eAE48D3XJR6x8G6TsUKjUH4hUVcbueAIdzvScPmnqXzRR9sorGQW/A==, tarball: file:projects/arm-agrifood.tgz} + resolution: {integrity: sha512-gVxo5i35p+KzXDAsQFlsfNFmw3I24n7K1pQDcvMJe5rkVTEE5KgjJkhE0WInzUcHLtI1oXOfC2fAZmY66jrIog==, tarball: file:projects/arm-agrifood.tgz} name: '@rush-temp/arm-agrifood' version: 0.0.0 dependencies: @@ -10077,23 +10079,23 @@ packages: '@rollup/plugin-multi-entry': 4.1.0_rollup@2.79.1 '@rollup/plugin-node-resolve': 13.3.0_rollup@2.79.1 '@types/chai': 4.3.3 + '@types/node': 14.18.33 chai: 4.3.6 cross-env: 7.0.3 mkdirp: 1.0.4 mocha: 7.2.0 rimraf: 3.0.2 rollup: 2.79.1 - rollup-plugin-sourcemaps: 0.6.3_rollup@2.79.1 + rollup-plugin-sourcemaps: 0.6.3_1225c068d0546e507df7db46196a6444 tslib: 2.4.1 - typescript: 4.6.4 + typescript: 4.8.4 uglify-js: 3.17.4 transitivePeerDependencies: - - '@types/node' - supports-color dev: false file:projects/arm-analysisservices.tgz: - resolution: {integrity: sha512-Ldqb5ro4dQi4mV4SkHD0hnBJoQRpJLceJq9UqiZNfdYhbFigNt/KKJ4ib2q+nTV0Frngul18X3RVUBcNBbzrkA==, tarball: file:projects/arm-analysisservices.tgz} + resolution: {integrity: sha512-MvTQ9iEX+lWhzfM8ajtw92btkZvNUKv3Aqt54pHXh4Dc3/n9yUgX9PCiNry1mf8tMpemWN8tEanWVcihs3+rlg==, tarball: file:projects/arm-analysisservices.tgz} name: '@rush-temp/arm-analysisservices' version: 0.0.0 dependencies: @@ -10104,18 +10106,18 @@ packages: '@rollup/plugin-multi-entry': 4.1.0_rollup@2.79.1 '@rollup/plugin-node-resolve': 13.3.0_rollup@2.79.1 '@types/chai': 4.3.3 + '@types/node': 14.18.33 chai: 4.3.6 cross-env: 7.0.3 mkdirp: 1.0.4 mocha: 7.2.0 rimraf: 3.0.2 rollup: 2.79.1 - rollup-plugin-sourcemaps: 0.6.3_rollup@2.79.1 + rollup-plugin-sourcemaps: 0.6.3_1225c068d0546e507df7db46196a6444 tslib: 2.4.1 - typescript: 4.6.4 + typescript: 4.8.4 uglify-js: 3.17.4 transitivePeerDependencies: - - '@types/node' - supports-color dev: false diff --git a/sdk/advisor/arm-advisor/CHANGELOG.md b/sdk/advisor/arm-advisor/CHANGELOG.md index a91dfe29d04e..1034e014cab9 100644 --- a/sdk/advisor/arm-advisor/CHANGELOG.md +++ b/sdk/advisor/arm-advisor/CHANGELOG.md @@ -1,15 +1,13 @@ # Release History - -## 3.0.4 (Unreleased) - -### Features Added - -### Breaking Changes - -### Bugs Fixed - -### Other Changes - + +## 3.1.0 (2022-11-14) + +**Features** + + - Added Interface ConfigData + - Added Interface ResourceRecommendationBase + - Added Interface SuppressionContract + ## 3.0.3 (2022-10-08) **Bugs Fixed** diff --git a/sdk/advisor/arm-advisor/_meta.json b/sdk/advisor/arm-advisor/_meta.json index 2a30b7ef4fe2..b3ff1d9ee419 100644 --- a/sdk/advisor/arm-advisor/_meta.json +++ b/sdk/advisor/arm-advisor/_meta.json @@ -1,8 +1,8 @@ { "commit": "54ee1a9eb50c13e0790627749f986c886ad4f4db", "readme": "specification\\advisor\\resource-manager\\readme.md", - "autorest_command": "autorest --version=3.7.3 --typescript --modelerfour.lenient-model-deduplication --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\work\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\advisor\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-beta.17 --generate-sample=true", + "autorest_command": "autorest --version=3.8.4 --typescript --modelerfour.lenient-model-deduplication --azure-arm --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\Git\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\advisor\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-rc.3.20221108.1 --generate-sample=true", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "release_tool": "@azure-tools/js-sdk-release-tools@2.2.1", - "use": "@autorest/typescript@6.0.0-beta.17" + "release_tool": "@azure-tools/js-sdk-release-tools@2.4.2", + "use": "@autorest/typescript@6.0.0-rc.3.20221108.1" } \ No newline at end of file diff --git a/sdk/advisor/arm-advisor/package.json b/sdk/advisor/arm-advisor/package.json index be988aabd52b..75752251cef2 100644 --- a/sdk/advisor/arm-advisor/package.json +++ b/sdk/advisor/arm-advisor/package.json @@ -3,15 +3,15 @@ "sdk-type": "mgmt", "author": "Microsoft Corporation", "description": "A generated SDK for AdvisorManagementClient.", - "version": "3.0.4", + "version": "3.1.0", "engines": { "node": ">=14.0.0" }, "dependencies": { "@azure/core-paging": "^1.2.0", - "@azure/core-client": "^1.0.0", + "@azure/core-client": "^1.6.1", "@azure/core-auth": "^1.3.0", - "@azure/core-rest-pipeline": "^1.1.0", + "@azure/core-rest-pipeline": "^1.8.0", "tslib": "^2.2.0" }, "keywords": [ @@ -34,13 +34,18 @@ "mkdirp": "^1.0.4", "rollup": "^2.66.1", "rollup-plugin-sourcemaps": "^0.6.3", - "typescript": "~4.2.0", + "typescript": "~4.8.0", "uglify-js": "^3.4.9", "rimraf": "^3.0.0", "@azure/identity": "^2.0.1", - "@azure-tools/test-recorder": "^1.0.0", + "@azure-tools/test-recorder": "^2.0.0", + "@azure-tools/test-credential": "^1.0.0", "mocha": "^7.1.1", - "cross-env": "^7.0.2" + "@types/chai": "^4.2.8", + "chai": "^4.2.0", + "cross-env": "^7.0.2", + "@types/node": "^14.0.0", + "@azure/dev-tool": "^1.0.0" }, "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/advisor/arm-advisor", "repository": { @@ -91,9 +96,8 @@ "unit-test:node": "cross-env TEST_MODE=playback npm run integration-test:node", "unit-test:browser": "echo skipped", "integration-test": "npm run integration-test:node && npm run integration-test:browser", - "integration-test:node": "mocha -r esm --require ts-node/register --timeout 1200000 --full-trace test/*.ts --reporter ../../../common/tools/mocha-multi-reporter.js", - "integration-test:browser": "echo skipped", - "docs": "echo skipped" + "integration-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 'test/*.ts'", + "integration-test:browser": "echo skipped" }, "sideEffects": false, "//metadata": { @@ -113,4 +117,4 @@ "disableDocsMs": true, "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-advisor?view=azure-node-preview" } -} +} \ No newline at end of file diff --git a/sdk/advisor/arm-advisor/recordings/node/my_test/recording_sample_test.js b/sdk/advisor/arm-advisor/recordings/node/my_test/recording_sample_test.js deleted file mode 100644 index 0f6ecb857acf..000000000000 --- a/sdk/advisor/arm-advisor/recordings/node/my_test/recording_sample_test.js +++ /dev/null @@ -1,5 +0,0 @@ -let nock = require('nock'); - -module.exports.hash = "7a6be38bb8cb644d64b4094802301751"; - -module.exports.testInfo = {"uniqueName":{},"newDate":{}} diff --git a/sdk/advisor/arm-advisor/recordings/node/my_test/recording_sample_test.json b/sdk/advisor/arm-advisor/recordings/node/my_test/recording_sample_test.json new file mode 100644 index 000000000000..f721723386d8 --- /dev/null +++ b/sdk/advisor/arm-advisor/recordings/node/my_test/recording_sample_test.json @@ -0,0 +1,4 @@ +{ + "Entries": [], + "Variables": {} +} diff --git a/sdk/advisor/arm-advisor/review/arm-advisor.api.md b/sdk/advisor/arm-advisor/review/arm-advisor.api.md index f854eaf8258c..4613a9ce301d 100644 --- a/sdk/advisor/arm-advisor/review/arm-advisor.api.md +++ b/sdk/advisor/arm-advisor/review/arm-advisor.api.md @@ -51,11 +51,11 @@ export interface ARMErrorResponseBody { export type Category = string; // @public -export type ConfigData = Resource & { +export interface ConfigData extends Resource { + digests?: DigestConfig[]; exclude?: boolean; lowCpuThreshold?: CpuThreshold; - digests?: DigestConfig[]; -}; +} // @public export interface ConfigurationListResult { @@ -125,72 +125,56 @@ export interface DigestConfig { // @public export type DigestConfigState = string; +// @public +export function getContinuationToken(page: unknown): string | undefined; + // @public export type Impact = string; // @public export enum KnownCategory { - // (undocumented) Cost = "Cost", - // (undocumented) HighAvailability = "HighAvailability", - // (undocumented) OperationalExcellence = "OperationalExcellence", - // (undocumented) Performance = "Performance", - // (undocumented) Security = "Security" } // @public export enum KnownConfigurationName { - // (undocumented) Default = "default" } // @public export enum KnownCpuThreshold { - // (undocumented) Fifteen = "15", - // (undocumented) Five = "5", - // (undocumented) Ten = "10", - // (undocumented) Twenty = "20" } // @public export enum KnownDigestConfigState { - // (undocumented) Active = "Active", - // (undocumented) Disabled = "Disabled" } // @public export enum KnownImpact { - // (undocumented) High = "High", - // (undocumented) Low = "Low", - // (undocumented) Medium = "Medium" } // @public export enum KnownRisk { - // (undocumented) Error = "Error", - // (undocumented) None = "None", - // (undocumented) Warning = "Warning" } // @public export enum KnownScenario { - // (undocumented) Alerts = "Alerts" } @@ -354,37 +338,37 @@ export interface ResourceMetadata { } // @public -export type ResourceRecommendationBase = Resource & { +export interface ResourceRecommendationBase extends Resource { + actions?: { + [propertyName: string]: Record; + }[]; category?: Category; - impact?: Impact; - impactedField?: string; - impactedValue?: string; - lastUpdated?: Date; - metadata?: { + description?: string; + exposedMetadataProperties?: { [propertyName: string]: Record; }; - recommendationTypeId?: string; - risk?: Risk; - shortDescription?: ShortDescription; - suppressionIds?: string[]; extendedProperties?: { [propertyName: string]: string; }; - resourceMetadata?: ResourceMetadata; - description?: string; + impact?: Impact; + impactedField?: string; + impactedValue?: string; label?: string; + lastUpdated?: Date; learnMoreLink?: string; - potentialBenefits?: string; - actions?: { - [propertyName: string]: Record; - }[]; - remediation?: { + metadata?: { [propertyName: string]: Record; }; - exposedMetadataProperties?: { + potentialBenefits?: string; + recommendationTypeId?: string; + remediation?: { [propertyName: string]: Record; }; -}; + resourceMetadata?: ResourceMetadata; + risk?: Risk; + shortDescription?: ShortDescription; + suppressionIds?: string[]; +} // @public export interface ResourceRecommendationBaseListResult { @@ -405,11 +389,11 @@ export interface ShortDescription { } // @public -export type SuppressionContract = Resource & { +export interface SuppressionContract extends Resource { + readonly expirationTimeStamp?: Date; suppressionId?: string; ttl?: string; - readonly expirationTimeStamp?: Date; -}; +} // @public export interface SuppressionContractListResult { diff --git a/sdk/advisor/arm-advisor/samples/v3/typescript/package.json b/sdk/advisor/arm-advisor/samples/v3/typescript/package.json index 3e45411418de..b53fb0ab1e41 100644 --- a/sdk/advisor/arm-advisor/samples/v3/typescript/package.json +++ b/sdk/advisor/arm-advisor/samples/v3/typescript/package.json @@ -35,7 +35,7 @@ }, "devDependencies": { "@types/node": "^14.0.0", - "typescript": "~4.4.0", + "typescript": "~4.8.0", "rimraf": "latest" } } diff --git a/sdk/advisor/arm-advisor/src/advisorManagementClient.ts b/sdk/advisor/arm-advisor/src/advisorManagementClient.ts index 075778dd3f37..086a1eaa1cc2 100644 --- a/sdk/advisor/arm-advisor/src/advisorManagementClient.ts +++ b/sdk/advisor/arm-advisor/src/advisorManagementClient.ts @@ -7,6 +7,12 @@ */ import * as coreClient from "@azure/core-client"; +import * as coreRestPipeline from "@azure/core-rest-pipeline"; +import { + PipelineRequest, + PipelineResponse, + SendRequest +} from "@azure/core-rest-pipeline"; import * as coreAuth from "@azure/core-auth"; import { RecommendationMetadataImpl, @@ -56,26 +62,54 @@ export class AdvisorManagementClient extends coreClient.ServiceClient { credential: credentials }; - const packageDetails = `azsdk-js-arm-advisor/3.0.4`; + const packageDetails = `azsdk-js-arm-advisor/3.1.0`; const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` : `${packageDetails}`; - if (!options.credentialScopes) { - options.credentialScopes = ["https://management.azure.com/.default"]; - } - const optionsWithDefaults = { ...defaults, ...options, userAgentOptions: { userAgentPrefix }, - baseUri: + endpoint: options.endpoint ?? options.baseUri ?? "https://management.azure.com" }; super(optionsWithDefaults); + + let bearerTokenAuthenticationPolicyFound: boolean = false; + if (options?.pipeline && options.pipeline.getOrderedPolicies().length > 0) { + const pipelinePolicies: coreRestPipeline.PipelinePolicy[] = options.pipeline.getOrderedPolicies(); + bearerTokenAuthenticationPolicyFound = pipelinePolicies.some( + (pipelinePolicy) => + pipelinePolicy.name === + coreRestPipeline.bearerTokenAuthenticationPolicyName + ); + } + if ( + !options || + !options.pipeline || + options.pipeline.getOrderedPolicies().length == 0 || + !bearerTokenAuthenticationPolicyFound + ) { + this.pipeline.removePolicy({ + name: coreRestPipeline.bearerTokenAuthenticationPolicyName + }); + this.pipeline.addPolicy( + coreRestPipeline.bearerTokenAuthenticationPolicy({ + credential: credentials, + scopes: + optionsWithDefaults.credentialScopes ?? + `${optionsWithDefaults.endpoint}/.default`, + challengeCallbacks: { + authorizeRequestOnChallenge: + coreClient.authorizeRequestOnClaimChallenge + } + }) + ); + } // Parameter assignments this.subscriptionId = subscriptionId; @@ -87,6 +121,35 @@ export class AdvisorManagementClient extends coreClient.ServiceClient { this.recommendations = new RecommendationsImpl(this); this.operations = new OperationsImpl(this); this.suppressions = new SuppressionsImpl(this); + this.addCustomApiVersionPolicy(options.apiVersion); + } + + /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */ + private addCustomApiVersionPolicy(apiVersion?: string) { + if (!apiVersion) { + return; + } + const apiVersionPolicy = { + name: "CustomApiVersionPolicy", + async sendRequest( + request: PipelineRequest, + next: SendRequest + ): Promise { + const param = request.url.split("?"); + if (param.length > 1) { + const newParams = param[1].split("&").map((item) => { + if (item.indexOf("api-version") > -1) { + return "api-version=" + apiVersion; + } else { + return item; + } + }); + request.url = param[0] + "?" + newParams.join("&"); + } + return next(request); + } + }; + this.pipeline.addPolicy(apiVersionPolicy); } recommendationMetadata: RecommendationMetadata; diff --git a/sdk/advisor/arm-advisor/src/index.ts b/sdk/advisor/arm-advisor/src/index.ts index a2d4c891ee0f..fb2b88124318 100644 --- a/sdk/advisor/arm-advisor/src/index.ts +++ b/sdk/advisor/arm-advisor/src/index.ts @@ -7,6 +7,7 @@ */ /// +export { getContinuationToken } from "./pagingHelper"; export * from "./models"; export { AdvisorManagementClient } from "./advisorManagementClient"; export * from "./operationsInterfaces"; diff --git a/sdk/advisor/arm-advisor/src/models/index.ts b/sdk/advisor/arm-advisor/src/models/index.ts index de8f51d30e8f..9355d2dbca2c 100644 --- a/sdk/advisor/arm-advisor/src/models/index.ts +++ b/sdk/advisor/arm-advisor/src/models/index.ts @@ -165,17 +165,17 @@ export interface SuppressionContractListResult { } /** The Advisor configuration data structure. */ -export type ConfigData = Resource & { +export interface ConfigData extends Resource { /** Exclude the resource from Advisor evaluations. Valid values: False (default) or True. */ exclude?: boolean; /** Minimum percentage threshold for Advisor low CPU utilization evaluation. Valid only for subscriptions. Valid values: 5 (default), 10, 15 or 20. */ lowCpuThreshold?: CpuThreshold; /** Advisor digest configuration. Valid only for subscriptions */ digests?: DigestConfig[]; -}; +} /** Advisor Recommendation. */ -export type ResourceRecommendationBase = Resource & { +export interface ResourceRecommendationBase extends Resource { /** The category of the recommendation. */ category?: Category; /** The business impact of the recommendation. */ @@ -216,10 +216,10 @@ export type ResourceRecommendationBase = Resource & { exposedMetadataProperties?: { [propertyName: string]: Record; }; -}; +} /** The details of the snoozed or dismissed rule; for example, the duration, name, and GUID associated with the rule. */ -export type SuppressionContract = Resource & { +export interface SuppressionContract extends Resource { /** The GUID of the suppression. */ suppressionId?: string; /** The duration for which the suppression is valid. */ @@ -229,7 +229,7 @@ export type SuppressionContract = Resource & { * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly expirationTimeStamp?: Date; -}; +} /** Defines headers for Recommendations_generate operation. */ export interface RecommendationsGenerateHeaders { @@ -241,6 +241,7 @@ export interface RecommendationsGenerateHeaders { /** Known values of {@link Scenario} that the service accepts. */ export enum KnownScenario { + /** Alerts */ Alerts = "Alerts" } @@ -255,9 +256,13 @@ export type Scenario = string; /** Known values of {@link CpuThreshold} that the service accepts. */ export enum KnownCpuThreshold { + /** Five */ Five = "5", + /** Ten */ Ten = "10", + /** Fifteen */ Fifteen = "15", + /** Twenty */ Twenty = "20" } @@ -275,10 +280,15 @@ export type CpuThreshold = string; /** Known values of {@link Category} that the service accepts. */ export enum KnownCategory { + /** HighAvailability */ HighAvailability = "HighAvailability", + /** Security */ Security = "Security", + /** Performance */ Performance = "Performance", + /** Cost */ Cost = "Cost", + /** OperationalExcellence */ OperationalExcellence = "OperationalExcellence" } @@ -297,7 +307,9 @@ export type Category = string; /** Known values of {@link DigestConfigState} that the service accepts. */ export enum KnownDigestConfigState { + /** Active */ Active = "Active", + /** Disabled */ Disabled = "Disabled" } @@ -313,6 +325,7 @@ export type DigestConfigState = string; /** Known values of {@link ConfigurationName} that the service accepts. */ export enum KnownConfigurationName { + /** Default */ Default = "default" } @@ -327,8 +340,11 @@ export type ConfigurationName = string; /** Known values of {@link Impact} that the service accepts. */ export enum KnownImpact { + /** High */ High = "High", + /** Medium */ Medium = "Medium", + /** Low */ Low = "Low" } @@ -345,8 +361,11 @@ export type Impact = string; /** Known values of {@link Risk} that the service accepts. */ export enum KnownRisk { + /** Error */ Error = "Error", + /** Warning */ Warning = "Warning", + /** None */ None = "None" } diff --git a/sdk/advisor/arm-advisor/src/operations/configurations.ts b/sdk/advisor/arm-advisor/src/operations/configurations.ts index c7c2d2306d7c..891cb8f0e609 100644 --- a/sdk/advisor/arm-advisor/src/operations/configurations.ts +++ b/sdk/advisor/arm-advisor/src/operations/configurations.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { Configurations } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -16,12 +17,12 @@ import { ConfigData, ConfigurationsListBySubscriptionNextOptionalParams, ConfigurationsListBySubscriptionOptionalParams, - ConfigurationsListByResourceGroupOptionalParams, ConfigurationsListBySubscriptionResponse, + ConfigurationsListByResourceGroupOptionalParams, + ConfigurationsListByResourceGroupResponse, ConfigurationName, ConfigurationsCreateInSubscriptionOptionalParams, ConfigurationsCreateInSubscriptionResponse, - ConfigurationsListByResourceGroupResponse, ConfigurationsCreateInResourceGroupOptionalParams, ConfigurationsCreateInResourceGroupResponse, ConfigurationsListBySubscriptionNextResponse @@ -55,22 +56,34 @@ export class ConfigurationsImpl implements Configurations { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listBySubscriptionPagingPage(options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listBySubscriptionPagingPage(options, settings); } }; } private async *listBySubscriptionPagingPage( - options?: ConfigurationsListBySubscriptionOptionalParams + options?: ConfigurationsListBySubscriptionOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listBySubscription(options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: ConfigurationsListBySubscriptionResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listBySubscription(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listBySubscriptionNext(continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -99,17 +112,26 @@ export class ConfigurationsImpl implements Configurations { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listByResourceGroupPagingPage(resourceGroup, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listByResourceGroupPagingPage( + resourceGroup, + options, + settings + ); } }; } private async *listByResourceGroupPagingPage( resourceGroup: string, - options?: ConfigurationsListByResourceGroupOptionalParams + options?: ConfigurationsListByResourceGroupOptionalParams, + _settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listByResourceGroup(resourceGroup, options); + let result: ConfigurationsListByResourceGroupResponse; + result = await this._listByResourceGroup(resourceGroup, options); yield result.value || []; } diff --git a/sdk/advisor/arm-advisor/src/operations/operations.ts b/sdk/advisor/arm-advisor/src/operations/operations.ts index 2eb2ca8ae462..2dcaf392da44 100644 --- a/sdk/advisor/arm-advisor/src/operations/operations.ts +++ b/sdk/advisor/arm-advisor/src/operations/operations.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { Operations } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -48,22 +49,34 @@ export class OperationsImpl implements Operations { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(options, settings); } }; } private async *listPagingPage( - options?: OperationsListOptionalParams + options?: OperationsListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: OperationsListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext(continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } diff --git a/sdk/advisor/arm-advisor/src/operations/recommendationMetadata.ts b/sdk/advisor/arm-advisor/src/operations/recommendationMetadata.ts index 3529fe8c756b..f5ca57d2d8af 100644 --- a/sdk/advisor/arm-advisor/src/operations/recommendationMetadata.ts +++ b/sdk/advisor/arm-advisor/src/operations/recommendationMetadata.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { RecommendationMetadata } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -16,9 +17,9 @@ import { MetadataEntity, RecommendationMetadataListNextOptionalParams, RecommendationMetadataListOptionalParams, + RecommendationMetadataListResponse, RecommendationMetadataGetOptionalParams, RecommendationMetadataGetResponse, - RecommendationMetadataListResponse, RecommendationMetadataListNextResponse } from "../models"; @@ -50,22 +51,34 @@ export class RecommendationMetadataImpl implements RecommendationMetadata { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(options, settings); } }; } private async *listPagingPage( - options?: RecommendationMetadataListOptionalParams + options?: RecommendationMetadataListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: RecommendationMetadataListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext(continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } diff --git a/sdk/advisor/arm-advisor/src/operations/recommendations.ts b/sdk/advisor/arm-advisor/src/operations/recommendations.ts index 05b7ba5e3636..ddf518bd5b42 100644 --- a/sdk/advisor/arm-advisor/src/operations/recommendations.ts +++ b/sdk/advisor/arm-advisor/src/operations/recommendations.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { Recommendations } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -16,10 +17,10 @@ import { ResourceRecommendationBase, RecommendationsListNextOptionalParams, RecommendationsListOptionalParams, + RecommendationsListResponse, RecommendationsGenerateOptionalParams, RecommendationsGenerateResponse, RecommendationsGetGenerateStatusOptionalParams, - RecommendationsListResponse, RecommendationsGetOptionalParams, RecommendationsGetResponse, RecommendationsListNextResponse @@ -54,22 +55,34 @@ export class RecommendationsImpl implements Recommendations { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(options, settings); } }; } private async *listPagingPage( - options?: RecommendationsListOptionalParams + options?: RecommendationsListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: RecommendationsListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext(continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } diff --git a/sdk/advisor/arm-advisor/src/operations/suppressions.ts b/sdk/advisor/arm-advisor/src/operations/suppressions.ts index 5482938f0c64..4115cb837dfb 100644 --- a/sdk/advisor/arm-advisor/src/operations/suppressions.ts +++ b/sdk/advisor/arm-advisor/src/operations/suppressions.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { Suppressions } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -16,12 +17,12 @@ import { SuppressionContract, SuppressionsListNextOptionalParams, SuppressionsListOptionalParams, + SuppressionsListResponse, SuppressionsGetOptionalParams, SuppressionsGetResponse, SuppressionsCreateOptionalParams, SuppressionsCreateResponse, SuppressionsDeleteOptionalParams, - SuppressionsListResponse, SuppressionsListNextResponse } from "../models"; @@ -54,22 +55,34 @@ export class SuppressionsImpl implements Suppressions { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(options, settings); } }; } private async *listPagingPage( - options?: SuppressionsListOptionalParams + options?: SuppressionsListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: SuppressionsListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext(continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } diff --git a/sdk/advisor/arm-advisor/src/pagingHelper.ts b/sdk/advisor/arm-advisor/src/pagingHelper.ts new file mode 100644 index 000000000000..d85fc13bce1e --- /dev/null +++ b/sdk/advisor/arm-advisor/src/pagingHelper.ts @@ -0,0 +1,39 @@ +/* + * 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 interface PageInfo { + continuationToken?: string; +} + +const pageMap = new WeakMap(); + +/** + * Given a result page from a pageable operation, returns a + * continuation token that can be used to begin paging from + * that point later. + * @param page A result object from calling .byPage() on a paged operation. + * @returns The continuation token that can be passed into byPage(). + */ +export function getContinuationToken(page: unknown): string | undefined { + if (typeof page !== "object" || page === null) { + return undefined; + } + return pageMap.get(page)?.continuationToken; +} + +export function setContinuationToken( + page: unknown, + continuationToken: string | undefined +): void { + if (typeof page !== "object" || page === null || !continuationToken) { + return; + } + const pageInfo = pageMap.get(page) ?? {}; + pageInfo.continuationToken = continuationToken; + pageMap.set(page, pageInfo); +} diff --git a/sdk/advisor/arm-advisor/test/sampleTest.ts b/sdk/advisor/arm-advisor/test/sampleTest.ts index 7ed89b043e1b..25aeb3ebcc36 100644 --- a/sdk/advisor/arm-advisor/test/sampleTest.ts +++ b/sdk/advisor/arm-advisor/test/sampleTest.ts @@ -7,35 +7,30 @@ */ import { - env, - record, - RecorderEnvironmentSetup, - Recorder + Recorder, + RecorderStartOptions, + env } from "@azure-tools/test-recorder"; -import * as assert from "assert"; +import { assert } from "chai"; +import { Context } from "mocha"; -const recorderEnvSetup: RecorderEnvironmentSetup = { - replaceableVariables: { - AZURE_CLIENT_ID: "azure_client_id", - AZURE_CLIENT_SECRET: "azure_client_secret", - AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888", - SUBSCRIPTION_ID: "azure_subscription_id" - }, - customizationsOnRecordings: [ - (recording: any): any => - recording.replace( - /"access_token":"[^"]*"/g, - `"access_token":"access_token"` - ) - ], - queryParametersToSkip: [] +const replaceableVariables: Record = { + AZURE_CLIENT_ID: "azure_client_id", + AZURE_CLIENT_SECRET: "azure_client_secret", + AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888", + SUBSCRIPTION_ID: "azure_subscription_id" +}; + +const recorderOptions: RecorderStartOptions = { + envSetupForPlayback: replaceableVariables }; describe("My test", () => { let recorder: Recorder; - beforeEach(async function() { - recorder = record(this, recorderEnvSetup); + beforeEach(async function(this: Context) { + recorder = new Recorder(this.currentTest); + await recorder.start(recorderOptions); }); afterEach(async function() { diff --git a/sdk/agrifood/arm-agrifood/CHANGELOG.md b/sdk/agrifood/arm-agrifood/CHANGELOG.md index dad7117f711f..d6762d8a0dc6 100644 --- a/sdk/agrifood/arm-agrifood/CHANGELOG.md +++ b/sdk/agrifood/arm-agrifood/CHANGELOG.md @@ -1,15 +1,11 @@ # Release History + +## 1.0.0-beta.4 (2022-11-14) + +**Features** -## 1.0.0-beta.4 (Unreleased) - -### Features Added - -### Breaking Changes - -### Bugs Fixed - -### Other Changes - + - Bugs Fixed + ## 1.0.0-beta.3 (2022-10-08) **Bugs Fixed** diff --git a/sdk/agrifood/arm-agrifood/_meta.json b/sdk/agrifood/arm-agrifood/_meta.json index 056b4ead10fd..354ce2bff77c 100644 --- a/sdk/agrifood/arm-agrifood/_meta.json +++ b/sdk/agrifood/arm-agrifood/_meta.json @@ -1,8 +1,8 @@ { - "commit": "450b1618259d8b170b5cfcb37866d3fc5747b564", + "commit": "3eb2a407e29fa9c79cf537722384b12b9753d59e", "readme": "specification/agrifood/resource-manager/readme.md", - "autorest_command": "autorest --version=3.8.4 --typescript --modelerfour.lenient-model-deduplication --azure-arm --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\Git\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\agrifood\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-rc.1.20220727.1 --generate-sample=true", + "autorest_command": "autorest --version=3.8.4 --typescript --modelerfour.lenient-model-deduplication --azure-arm --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\Git\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\agrifood\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-rc.3.20221108.1 --generate-sample=true", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", "release_tool": "@azure-tools/js-sdk-release-tools@2.4.2", - "use": "@autorest/typescript@6.0.0-rc.1.20220727.1" + "use": "@autorest/typescript@6.0.0-rc.3.20221108.1" } \ No newline at end of file diff --git a/sdk/agrifood/arm-agrifood/package.json b/sdk/agrifood/arm-agrifood/package.json index ebad76821eff..9f79e0c57834 100644 --- a/sdk/agrifood/arm-agrifood/package.json +++ b/sdk/agrifood/arm-agrifood/package.json @@ -11,7 +11,7 @@ "@azure/core-lro": "^2.2.0", "@azure/abort-controller": "^1.0.0", "@azure/core-paging": "^1.2.0", - "@azure/core-client": "^1.5.0", + "@azure/core-client": "^1.6.1", "@azure/core-auth": "^1.3.0", "@azure/core-rest-pipeline": "^1.8.0", "tslib": "^2.2.0" @@ -36,7 +36,7 @@ "mkdirp": "^1.0.4", "rollup": "^2.66.1", "rollup-plugin-sourcemaps": "^0.6.3", - "typescript": "~4.6.0", + "typescript": "~4.8.0", "uglify-js": "^3.4.9", "rimraf": "^3.0.0", "@azure/identity": "^2.0.1", @@ -46,6 +46,7 @@ "@types/chai": "^4.2.8", "chai": "^4.2.0", "cross-env": "^7.0.2", + "@types/node": "^14.0.0", "@azure/dev-tool": "^1.0.0" }, "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/agrifood/arm-agrifood", @@ -118,4 +119,4 @@ "disableDocsMs": true, "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-agrifood?view=azure-node-preview" } -} +} \ No newline at end of file diff --git a/sdk/agrifood/arm-agrifood/review/arm-agrifood.api.md b/sdk/agrifood/arm-agrifood/review/arm-agrifood.api.md index 05e0589f5959..c02cbffb804a 100644 --- a/sdk/agrifood/arm-agrifood/review/arm-agrifood.api.md +++ b/sdk/agrifood/arm-agrifood/review/arm-agrifood.api.md @@ -347,6 +347,9 @@ export interface FarmBeatsUpdateRequestModel { }; } +// @public +export function getContinuationToken(page: unknown): string | undefined; + // @public export interface Identity { readonly principalId?: string; diff --git a/sdk/agrifood/arm-agrifood/samples/v1-beta/typescript/package.json b/sdk/agrifood/arm-agrifood/samples/v1-beta/typescript/package.json index 83ee2a13249f..9b2d164fbab8 100644 --- a/sdk/agrifood/arm-agrifood/samples/v1-beta/typescript/package.json +++ b/sdk/agrifood/arm-agrifood/samples/v1-beta/typescript/package.json @@ -35,7 +35,7 @@ }, "devDependencies": { "@types/node": "^14.0.0", - "typescript": "~4.6.0", + "typescript": "~4.8.0", "rimraf": "latest" } } diff --git a/sdk/agrifood/arm-agrifood/src/agriFoodMgmtClient.ts b/sdk/agrifood/arm-agrifood/src/agriFoodMgmtClient.ts index 7e18daae33df..9a987aafc94d 100644 --- a/sdk/agrifood/arm-agrifood/src/agriFoodMgmtClient.ts +++ b/sdk/agrifood/arm-agrifood/src/agriFoodMgmtClient.ts @@ -72,16 +72,13 @@ export class AgriFoodMgmtClient extends coreClient.ServiceClient { ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` : `${packageDetails}`; - if (!options.credentialScopes) { - options.credentialScopes = ["https://management.azure.com/.default"]; - } const optionsWithDefaults = { ...defaults, ...options, userAgentOptions: { userAgentPrefix }, - baseUri: + endpoint: options.endpoint ?? options.baseUri ?? "https://management.azure.com" }; super(optionsWithDefaults); @@ -107,7 +104,9 @@ export class AgriFoodMgmtClient extends coreClient.ServiceClient { this.pipeline.addPolicy( coreRestPipeline.bearerTokenAuthenticationPolicy({ credential: credentials, - scopes: `${optionsWithDefaults.credentialScopes}`, + scopes: + optionsWithDefaults.credentialScopes ?? + `${optionsWithDefaults.endpoint}/.default`, challengeCallbacks: { authorizeRequestOnChallenge: coreClient.authorizeRequestOnClaimChallenge diff --git a/sdk/agrifood/arm-agrifood/src/index.ts b/sdk/agrifood/arm-agrifood/src/index.ts index c51de85d1906..5b895ab1b95a 100644 --- a/sdk/agrifood/arm-agrifood/src/index.ts +++ b/sdk/agrifood/arm-agrifood/src/index.ts @@ -7,6 +7,7 @@ */ /// +export { getContinuationToken } from "./pagingHelper"; export * from "./models"; export { AgriFoodMgmtClient } from "./agriFoodMgmtClient"; export * from "./operationsInterfaces"; diff --git a/sdk/agrifood/arm-agrifood/src/operations/extensions.ts b/sdk/agrifood/arm-agrifood/src/operations/extensions.ts index fd892c653b65..fae4ddfd71b0 100644 --- a/sdk/agrifood/arm-agrifood/src/operations/extensions.ts +++ b/sdk/agrifood/arm-agrifood/src/operations/extensions.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { Extensions } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -16,6 +17,7 @@ import { Extension, ExtensionsListByFarmBeatsNextOptionalParams, ExtensionsListByFarmBeatsOptionalParams, + ExtensionsListByFarmBeatsResponse, ExtensionsCreateOptionalParams, ExtensionsCreateResponse, ExtensionsGetOptionalParams, @@ -23,7 +25,6 @@ import { ExtensionsUpdateOptionalParams, ExtensionsUpdateResponse, ExtensionsDeleteOptionalParams, - ExtensionsListByFarmBeatsResponse, ExtensionsListByFarmBeatsNextResponse } from "../models"; @@ -63,11 +64,15 @@ export class ExtensionsImpl implements Extensions { [Symbol.asyncIterator]() { return this; }, - byPage: () => { + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } return this.listByFarmBeatsPagingPage( resourceGroupName, farmBeatsResourceName, - options + options, + settings ); } }; @@ -76,15 +81,22 @@ export class ExtensionsImpl implements Extensions { private async *listByFarmBeatsPagingPage( resourceGroupName: string, farmBeatsResourceName: string, - options?: ExtensionsListByFarmBeatsOptionalParams + options?: ExtensionsListByFarmBeatsOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listByFarmBeats( - resourceGroupName, - farmBeatsResourceName, - options - ); - yield result.value || []; - let continuationToken = result.nextLink; + let result: ExtensionsListByFarmBeatsResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listByFarmBeats( + resourceGroupName, + farmBeatsResourceName, + options + ); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listByFarmBeatsNext( resourceGroupName, @@ -93,7 +105,9 @@ export class ExtensionsImpl implements Extensions { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } diff --git a/sdk/agrifood/arm-agrifood/src/operations/farmBeatsExtensions.ts b/sdk/agrifood/arm-agrifood/src/operations/farmBeatsExtensions.ts index 14572fa3067d..21fd45a22a6d 100644 --- a/sdk/agrifood/arm-agrifood/src/operations/farmBeatsExtensions.ts +++ b/sdk/agrifood/arm-agrifood/src/operations/farmBeatsExtensions.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { FarmBeatsExtensions } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -50,22 +51,34 @@ export class FarmBeatsExtensionsImpl implements FarmBeatsExtensions { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(options, settings); } }; } private async *listPagingPage( - options?: FarmBeatsExtensionsListOptionalParams + options?: FarmBeatsExtensionsListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: FarmBeatsExtensionsListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext(continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } diff --git a/sdk/agrifood/arm-agrifood/src/operations/farmBeatsModels.ts b/sdk/agrifood/arm-agrifood/src/operations/farmBeatsModels.ts index 666df85ec3c4..f0e4e6f98508 100644 --- a/sdk/agrifood/arm-agrifood/src/operations/farmBeatsModels.ts +++ b/sdk/agrifood/arm-agrifood/src/operations/farmBeatsModels.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { FarmBeatsModels } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -18,8 +19,10 @@ import { FarmBeats, FarmBeatsModelsListBySubscriptionNextOptionalParams, FarmBeatsModelsListBySubscriptionOptionalParams, + FarmBeatsModelsListBySubscriptionResponse, FarmBeatsModelsListByResourceGroupNextOptionalParams, FarmBeatsModelsListByResourceGroupOptionalParams, + FarmBeatsModelsListByResourceGroupResponse, FarmBeatsModelsGetOptionalParams, FarmBeatsModelsGetResponse, FarmBeatsModelsCreateOrUpdateOptionalParams, @@ -28,8 +31,6 @@ import { FarmBeatsModelsUpdateOptionalParams, FarmBeatsModelsUpdateResponse, FarmBeatsModelsDeleteOptionalParams, - FarmBeatsModelsListBySubscriptionResponse, - FarmBeatsModelsListByResourceGroupResponse, FarmBeatsModelsGetOperationResultOptionalParams, FarmBeatsModelsGetOperationResultResponse, FarmBeatsModelsListBySubscriptionNextResponse, @@ -64,22 +65,34 @@ export class FarmBeatsModelsImpl implements FarmBeatsModels { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listBySubscriptionPagingPage(options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listBySubscriptionPagingPage(options, settings); } }; } private async *listBySubscriptionPagingPage( - options?: FarmBeatsModelsListBySubscriptionOptionalParams + options?: FarmBeatsModelsListBySubscriptionOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listBySubscription(options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: FarmBeatsModelsListBySubscriptionResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listBySubscription(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listBySubscriptionNext(continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -108,19 +121,33 @@ export class FarmBeatsModelsImpl implements FarmBeatsModels { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listByResourceGroupPagingPage(resourceGroupName, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listByResourceGroupPagingPage( + resourceGroupName, + options, + settings + ); } }; } private async *listByResourceGroupPagingPage( resourceGroupName: string, - options?: FarmBeatsModelsListByResourceGroupOptionalParams + options?: FarmBeatsModelsListByResourceGroupOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listByResourceGroup(resourceGroupName, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: FarmBeatsModelsListByResourceGroupResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listByResourceGroup(resourceGroupName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listByResourceGroupNext( resourceGroupName, @@ -128,7 +155,9 @@ export class FarmBeatsModelsImpl implements FarmBeatsModels { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } diff --git a/sdk/agrifood/arm-agrifood/src/operations/operations.ts b/sdk/agrifood/arm-agrifood/src/operations/operations.ts index 1329371b9454..f63b79ac1d80 100644 --- a/sdk/agrifood/arm-agrifood/src/operations/operations.ts +++ b/sdk/agrifood/arm-agrifood/src/operations/operations.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { Operations } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -48,22 +49,34 @@ export class OperationsImpl implements Operations { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(options, settings); } }; } private async *listPagingPage( - options?: OperationsListOptionalParams + options?: OperationsListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: OperationsListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext(continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } diff --git a/sdk/agrifood/arm-agrifood/src/operations/privateEndpointConnections.ts b/sdk/agrifood/arm-agrifood/src/operations/privateEndpointConnections.ts index 81216eeda10f..41581045d45d 100644 --- a/sdk/agrifood/arm-agrifood/src/operations/privateEndpointConnections.ts +++ b/sdk/agrifood/arm-agrifood/src/operations/privateEndpointConnections.ts @@ -6,7 +6,7 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; import { PrivateEndpointConnections } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -17,12 +17,12 @@ import { LroImpl } from "../lroImpl"; import { PrivateEndpointConnection, PrivateEndpointConnectionsListByResourceOptionalParams, + PrivateEndpointConnectionsListByResourceResponse, PrivateEndpointConnectionsCreateOrUpdateOptionalParams, PrivateEndpointConnectionsCreateOrUpdateResponse, PrivateEndpointConnectionsGetOptionalParams, PrivateEndpointConnectionsGetResponse, - PrivateEndpointConnectionsDeleteOptionalParams, - PrivateEndpointConnectionsListByResourceResponse + PrivateEndpointConnectionsDeleteOptionalParams } from "../models"; /// @@ -62,11 +62,15 @@ export class PrivateEndpointConnectionsImpl [Symbol.asyncIterator]() { return this; }, - byPage: () => { + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } return this.listByResourcePagingPage( resourceGroupName, farmBeatsResourceName, - options + options, + settings ); } }; @@ -75,9 +79,11 @@ export class PrivateEndpointConnectionsImpl private async *listByResourcePagingPage( resourceGroupName: string, farmBeatsResourceName: string, - options?: PrivateEndpointConnectionsListByResourceOptionalParams + options?: PrivateEndpointConnectionsListByResourceOptionalParams, + _settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listByResource( + let result: PrivateEndpointConnectionsListByResourceResponse; + result = await this._listByResource( resourceGroupName, farmBeatsResourceName, options diff --git a/sdk/agrifood/arm-agrifood/src/operations/privateLinkResources.ts b/sdk/agrifood/arm-agrifood/src/operations/privateLinkResources.ts index 9360e984b90c..2696b45ffd3f 100644 --- a/sdk/agrifood/arm-agrifood/src/operations/privateLinkResources.ts +++ b/sdk/agrifood/arm-agrifood/src/operations/privateLinkResources.ts @@ -6,7 +6,7 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; import { PrivateLinkResources } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -56,11 +56,15 @@ export class PrivateLinkResourcesImpl implements PrivateLinkResources { [Symbol.asyncIterator]() { return this; }, - byPage: () => { + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } return this.listByResourcePagingPage( resourceGroupName, farmBeatsResourceName, - options + options, + settings ); } }; @@ -69,9 +73,11 @@ export class PrivateLinkResourcesImpl implements PrivateLinkResources { private async *listByResourcePagingPage( resourceGroupName: string, farmBeatsResourceName: string, - options?: PrivateLinkResourcesListByResourceOptionalParams + options?: PrivateLinkResourcesListByResourceOptionalParams, + _settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listByResource( + let result: PrivateLinkResourcesListByResourceResponse; + result = await this._listByResource( resourceGroupName, farmBeatsResourceName, options diff --git a/sdk/agrifood/arm-agrifood/src/pagingHelper.ts b/sdk/agrifood/arm-agrifood/src/pagingHelper.ts new file mode 100644 index 000000000000..d85fc13bce1e --- /dev/null +++ b/sdk/agrifood/arm-agrifood/src/pagingHelper.ts @@ -0,0 +1,39 @@ +/* + * 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 interface PageInfo { + continuationToken?: string; +} + +const pageMap = new WeakMap(); + +/** + * Given a result page from a pageable operation, returns a + * continuation token that can be used to begin paging from + * that point later. + * @param page A result object from calling .byPage() on a paged operation. + * @returns The continuation token that can be passed into byPage(). + */ +export function getContinuationToken(page: unknown): string | undefined { + if (typeof page !== "object" || page === null) { + return undefined; + } + return pageMap.get(page)?.continuationToken; +} + +export function setContinuationToken( + page: unknown, + continuationToken: string | undefined +): void { + if (typeof page !== "object" || page === null || !continuationToken) { + return; + } + const pageInfo = pageMap.get(page) ?? {}; + pageInfo.continuationToken = continuationToken; + pageMap.set(page, pageInfo); +} diff --git a/sdk/analysisservices/arm-analysisservices/CHANGELOG.md b/sdk/analysisservices/arm-analysisservices/CHANGELOG.md index 2aeafbadfab7..b2ffb3f9aff0 100644 --- a/sdk/analysisservices/arm-analysisservices/CHANGELOG.md +++ b/sdk/analysisservices/arm-analysisservices/CHANGELOG.md @@ -1,14 +1,8 @@ # Release History -## 4.1.3 (Unreleased) +## 4.1.3 (2022-11-14) -### Features Added - -### Breaking Changes - -### Bugs Fixed - -### Other Changes +- Bugs Fixed ## 4.1.2 (2022-10-08) diff --git a/sdk/analysisservices/arm-analysisservices/_meta.json b/sdk/analysisservices/arm-analysisservices/_meta.json index d87322660e76..51a0cb21ff9f 100644 --- a/sdk/analysisservices/arm-analysisservices/_meta.json +++ b/sdk/analysisservices/arm-analysisservices/_meta.json @@ -1,8 +1,8 @@ { "commit": "b5112cf604d9c89f250fb0810731a9a86e9d2230", - "readme": "specification/analysisservices/resource-manager/readme.md", - "autorest_command": "autorest --version=3.7.3 --typescript --modelerfour.lenient-model-deduplication --azure-arm --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\Git\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\analysisservices\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-rc.1.20220721.1 --generate-sample=true", + "readme": "specification\\analysisservices\\resource-manager\\readme.md", + "autorest_command": "autorest --version=3.8.4 --typescript --modelerfour.lenient-model-deduplication --azure-arm --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\Git\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\analysisservices\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-rc.3.20221108.1 --generate-sample=true", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "release_tool": "@azure-tools/js-sdk-release-tools@2.4.0", - "use": "@autorest/typescript@6.0.0-rc.1.20220721.1" + "release_tool": "@azure-tools/js-sdk-release-tools@2.4.2", + "use": "@autorest/typescript@6.0.0-rc.3.20221108.1" } \ No newline at end of file diff --git a/sdk/analysisservices/arm-analysisservices/package.json b/sdk/analysisservices/arm-analysisservices/package.json index bc648ca79d06..bb73b767513d 100644 --- a/sdk/analysisservices/arm-analysisservices/package.json +++ b/sdk/analysisservices/arm-analysisservices/package.json @@ -11,7 +11,7 @@ "@azure/core-lro": "^2.2.0", "@azure/abort-controller": "^1.0.0", "@azure/core-paging": "^1.2.0", - "@azure/core-client": "^1.5.0", + "@azure/core-client": "^1.6.1", "@azure/core-auth": "^1.3.0", "@azure/core-rest-pipeline": "^1.8.0", "tslib": "^2.2.0" @@ -36,7 +36,7 @@ "mkdirp": "^1.0.4", "rollup": "^2.66.1", "rollup-plugin-sourcemaps": "^0.6.3", - "typescript": "~4.6.0", + "typescript": "~4.8.0", "uglify-js": "^3.4.9", "rimraf": "^3.0.0", "@azure/identity": "^2.0.1", @@ -46,6 +46,7 @@ "@types/chai": "^4.2.8", "chai": "^4.2.0", "cross-env": "^7.0.2", + "@types/node": "^14.0.0", "@azure/dev-tool": "^1.0.0" }, "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/analysisservices/arm-analysisservices", @@ -118,4 +119,4 @@ "disableDocsMs": true, "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-analysisservices?view=azure-node-preview" } -} +} \ No newline at end of file diff --git a/sdk/analysisservices/arm-analysisservices/review/arm-analysisservices.api.md b/sdk/analysisservices/arm-analysisservices/review/arm-analysisservices.api.md index 380fefd5deab..6eae84d1a5f1 100644 --- a/sdk/analysisservices/arm-analysisservices/review/arm-analysisservices.api.md +++ b/sdk/analysisservices/arm-analysisservices/review/arm-analysisservices.api.md @@ -142,6 +142,9 @@ export interface GatewayListStatusLive { status?: 0; } +// @public +export function getContinuationToken(page: unknown): string | undefined; + // @public export interface IPv4FirewallRule { firewallRuleName?: string; diff --git a/sdk/analysisservices/arm-analysisservices/src/azureAnalysisServices.ts b/sdk/analysisservices/arm-analysisservices/src/azureAnalysisServices.ts index 428e7e134c2c..caeae001e967 100644 --- a/sdk/analysisservices/arm-analysisservices/src/azureAnalysisServices.ts +++ b/sdk/analysisservices/arm-analysisservices/src/azureAnalysisServices.ts @@ -57,16 +57,13 @@ export class AzureAnalysisServices extends coreClient.ServiceClient { ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` : `${packageDetails}`; - if (!options.credentialScopes) { - options.credentialScopes = ["https://management.azure.com/.default"]; - } const optionsWithDefaults = { ...defaults, ...options, userAgentOptions: { userAgentPrefix }, - baseUri: + endpoint: options.endpoint ?? options.baseUri ?? "https://management.azure.com" }; super(optionsWithDefaults); @@ -92,7 +89,9 @@ export class AzureAnalysisServices extends coreClient.ServiceClient { this.pipeline.addPolicy( coreRestPipeline.bearerTokenAuthenticationPolicy({ credential: credentials, - scopes: `${optionsWithDefaults.credentialScopes}`, + scopes: + optionsWithDefaults.credentialScopes ?? + `${optionsWithDefaults.endpoint}/.default`, challengeCallbacks: { authorizeRequestOnChallenge: coreClient.authorizeRequestOnClaimChallenge diff --git a/sdk/analysisservices/arm-analysisservices/src/index.ts b/sdk/analysisservices/arm-analysisservices/src/index.ts index 122c54a529d4..b4c2eca88ff3 100644 --- a/sdk/analysisservices/arm-analysisservices/src/index.ts +++ b/sdk/analysisservices/arm-analysisservices/src/index.ts @@ -7,6 +7,7 @@ */ /// +export { getContinuationToken } from "./pagingHelper"; export * from "./models"; export { AzureAnalysisServices } from "./azureAnalysisServices"; export * from "./operationsInterfaces"; diff --git a/sdk/analysisservices/arm-analysisservices/src/operations/operations.ts b/sdk/analysisservices/arm-analysisservices/src/operations/operations.ts index ebc5812f437c..8356e188b6aa 100644 --- a/sdk/analysisservices/arm-analysisservices/src/operations/operations.ts +++ b/sdk/analysisservices/arm-analysisservices/src/operations/operations.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { Operations } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -48,22 +49,34 @@ export class OperationsImpl implements Operations { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(options, settings); } }; } private async *listPagingPage( - options?: OperationsListOptionalParams + options?: OperationsListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: OperationsListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext(continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } diff --git a/sdk/analysisservices/arm-analysisservices/src/operations/servers.ts b/sdk/analysisservices/arm-analysisservices/src/operations/servers.ts index b57eec3155ff..0e2b1fcf9630 100644 --- a/sdk/analysisservices/arm-analysisservices/src/operations/servers.ts +++ b/sdk/analysisservices/arm-analysisservices/src/operations/servers.ts @@ -6,7 +6,7 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; import { Servers } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -17,7 +17,9 @@ import { LroImpl } from "../lroImpl"; import { AnalysisServicesServer, ServersListByResourceGroupOptionalParams, + ServersListByResourceGroupResponse, ServersListOptionalParams, + ServersListResponse, ServersGetDetailsOptionalParams, ServersGetDetailsResponse, ServersCreateOptionalParams, @@ -28,8 +30,6 @@ import { ServersUpdateResponse, ServersSuspendOptionalParams, ServersResumeOptionalParams, - ServersListByResourceGroupResponse, - ServersListResponse, ServersListSkusForNewOptionalParams, ServersListSkusForNewResponse, ServersListSkusForExistingOptionalParams, @@ -76,17 +76,26 @@ export class ServersImpl implements Servers { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listByResourceGroupPagingPage(resourceGroupName, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listByResourceGroupPagingPage( + resourceGroupName, + options, + settings + ); } }; } private async *listByResourceGroupPagingPage( resourceGroupName: string, - options?: ServersListByResourceGroupOptionalParams + options?: ServersListByResourceGroupOptionalParams, + _settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listByResourceGroup(resourceGroupName, options); + let result: ServersListByResourceGroupResponse; + result = await this._listByResourceGroup(resourceGroupName, options); yield result.value || []; } @@ -117,16 +126,21 @@ export class ServersImpl implements Servers { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(options, settings); } }; } private async *listPagingPage( - options?: ServersListOptionalParams + options?: ServersListOptionalParams, + _settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(options); + let result: ServersListResponse; + result = await this._list(options); yield result.value || []; } diff --git a/sdk/analysisservices/arm-analysisservices/src/pagingHelper.ts b/sdk/analysisservices/arm-analysisservices/src/pagingHelper.ts new file mode 100644 index 000000000000..d85fc13bce1e --- /dev/null +++ b/sdk/analysisservices/arm-analysisservices/src/pagingHelper.ts @@ -0,0 +1,39 @@ +/* + * 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 interface PageInfo { + continuationToken?: string; +} + +const pageMap = new WeakMap(); + +/** + * Given a result page from a pageable operation, returns a + * continuation token that can be used to begin paging from + * that point later. + * @param page A result object from calling .byPage() on a paged operation. + * @returns The continuation token that can be passed into byPage(). + */ +export function getContinuationToken(page: unknown): string | undefined { + if (typeof page !== "object" || page === null) { + return undefined; + } + return pageMap.get(page)?.continuationToken; +} + +export function setContinuationToken( + page: unknown, + continuationToken: string | undefined +): void { + if (typeof page !== "object" || page === null || !continuationToken) { + return; + } + const pageInfo = pageMap.get(page) ?? {}; + pageInfo.continuationToken = continuationToken; + pageMap.set(page, pageInfo); +}