From e8066e8f863b1f7fef09e3cdfb2a6bba190ee537 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Tue, 8 Aug 2023 07:06:55 +0000 Subject: [PATCH] CodeGen from PR 24817 in Azure/azure-rest-api-specs Merge a1a116ca80cfcc6e31ddd5ab14b55feae48352e0 into ad997e99eccc15b7ab4cd66ae3f1f9534a1e2628 --- common/config/rush/pnpm-lock.yaml | 9 ++-- .../arm-networkfunction/CHANGELOG.md | 17 +++--- .../arm-networkfunction/LICENSE | 2 +- .../arm-networkfunction/_meta.json | 8 +-- .../arm-networkfunction/package.json | 21 +++----- .../review/arm-networkfunction.api.md | 15 +++--- .../src/azureTrafficCollectorClient.ts | 24 +++++++-- .../arm-networkfunction/src/lroImpl.ts | 54 +++++++++++-------- .../src/operations/azureTrafficCollectors.ts | 53 ++++++++++-------- .../azureTrafficCollectorsByResourceGroup.ts | 1 - .../azureTrafficCollectorsBySubscription.ts | 1 - .../src/operations/collectorPolicies.ts | 54 ++++++++++--------- .../azureTrafficCollectors.ts | 8 +-- .../operationsInterfaces/collectorPolicies.ts | 8 +-- .../arm-networkfunction/src/pagingHelper.ts | 8 +-- .../arm-networkfunction/test/sampleTest.ts | 43 +++++++++++++++ .../arm-networkfunction/tsconfig.json | 10 +--- 17 files changed, 200 insertions(+), 136 deletions(-) create mode 100644 sdk/networkfunction/arm-networkfunction/test/sampleTest.ts diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 894f50308d26..8ec815b1e9d1 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -15301,7 +15301,7 @@ packages: dev: false file:projects/arm-networkfunction.tgz: - resolution: {integrity: sha512-SEo8YLW6VV9/d2QX9L7Y3x8p1ZKc2f5wSLDiSS9HXkSlUJkfuheVs2jNocksczuf7oV3/bz6wjzZ72nvaSh9jg==, tarball: file:projects/arm-networkfunction.tgz} + resolution: {integrity: sha512-Ak31FtfXrkJZrHjXWB4t0LjP7d17eFmg5WLlpCaTvktpd4s3JZiy1HlZoaPXaEym0Zap9P4gWKcAAtBz5Gc6Cw==, tarball: file:projects/arm-networkfunction.tgz} name: '@rush-temp/arm-networkfunction' version: 0.0.0 dependencies: @@ -15315,7 +15315,8 @@ packages: '@types/node': 14.18.54 chai: 4.3.7 cross-env: 7.0.3 - mkdirp: 1.0.4 + dotenv: 16.3.1 + mkdirp: 2.1.6 mocha: 7.2.0 rimraf: 3.0.2 rollup: 2.79.1 @@ -20276,7 +20277,7 @@ packages: dev: false file:projects/openai.tgz: - resolution: {integrity: sha512-P2Kt7ieMv/lI2IQF2IYFl/xUaX++zno8QLczqULMhbQpAQ+0i19LZ+pAZR9tnL3BpMS/dyuz3QxIMekW2cyOUA==, tarball: file:projects/openai.tgz} + resolution: {integrity: sha512-N8E0x1oZNJ/0S88emgJ97tMxe0iZmc59ZDKR/eNoY5XEqZumAlO1u4R5KLKOHphDdDt30md1DVa/VY68Ql8x2A==, tarball: file:projects/openai.tgz} name: '@rush-temp/openai' version: 0.0.0 dependencies: @@ -20368,7 +20369,7 @@ packages: dev: false file:projects/perf-ai-form-recognizer.tgz: - resolution: {integrity: sha512-+05JR31WLH5d8FD+GslDQxNHYPLOrvExWUugJJNalgNZpbtoqzQF0837G7tKGDg98VU4XjK6qZA7Gjo2n7O3yg==, tarball: file:projects/perf-ai-form-recognizer.tgz} + resolution: {integrity: sha512-W/M7XPCsmg8eZBzlsl8J6yyEH+1DoeC7F4keU6px84ohKSVn3vZHTYM2xj9e61MzYDWUjormNqquQD9oeB+qEA==, tarball: file:projects/perf-ai-form-recognizer.tgz} name: '@rush-temp/perf-ai-form-recognizer' version: 0.0.0 dependencies: diff --git a/sdk/networkfunction/arm-networkfunction/CHANGELOG.md b/sdk/networkfunction/arm-networkfunction/CHANGELOG.md index b01b0e78adab..6d5f137961ce 100644 --- a/sdk/networkfunction/arm-networkfunction/CHANGELOG.md +++ b/sdk/networkfunction/arm-networkfunction/CHANGELOG.md @@ -1,15 +1,12 @@ # Release History + +## 3.0.0 (2023-08-08) + +**Breaking Changes** -## 2.0.1 (Unreleased) - -### Features Added - -### Breaking Changes - -### Bugs Fixed - -### Other Changes - + - Class AzureTrafficCollectorClient has a new signature + + ## 2.0.0 (2022-11-24) **Features** diff --git a/sdk/networkfunction/arm-networkfunction/LICENSE b/sdk/networkfunction/arm-networkfunction/LICENSE index 5d1d36e0af80..3a1d9b6f24f7 100644 --- a/sdk/networkfunction/arm-networkfunction/LICENSE +++ b/sdk/networkfunction/arm-networkfunction/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2022 Microsoft +Copyright (c) 2023 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 diff --git a/sdk/networkfunction/arm-networkfunction/_meta.json b/sdk/networkfunction/arm-networkfunction/_meta.json index dac77c02dbb0..1f717679c279 100644 --- a/sdk/networkfunction/arm-networkfunction/_meta.json +++ b/sdk/networkfunction/arm-networkfunction/_meta.json @@ -1,8 +1,8 @@ { - "commit": "c583b05741fadfdca116be3b9ccb1c4be8a73258", + "commit": "ca20fc1b03e12ebccae8529f117600b55c9e0c8b", "readme": "specification/networkfunction/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\\networkfunction\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-rc.3.20221108.1 --generate-sample=true", + "autorest_command": "autorest --version=3.9.3 --typescript --modelerfour.lenient-model-deduplication --azure-arm --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-js ../azure-rest-api-specs/specification/networkfunction/resource-manager/readme.md --use=@autorest/typescript@^6.0.4", "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.3.20221108.1" + "release_tool": "@azure-tools/js-sdk-release-tools@2.7.1", + "use": "@autorest/typescript@^6.0.4" } \ No newline at end of file diff --git a/sdk/networkfunction/arm-networkfunction/package.json b/sdk/networkfunction/arm-networkfunction/package.json index f27035c31c19..7d68e680b8b3 100644 --- a/sdk/networkfunction/arm-networkfunction/package.json +++ b/sdk/networkfunction/arm-networkfunction/package.json @@ -3,15 +3,15 @@ "sdk-type": "mgmt", "author": "Microsoft Corporation", "description": "A generated SDK for AzureTrafficCollectorClient.", - "version": "2.0.1", + "version": "3.0.0", "engines": { "node": ">=14.0.0" }, "dependencies": { - "@azure/core-lro": "^2.2.0", + "@azure/core-lro": "^2.5.4", "@azure/abort-controller": "^1.0.0", "@azure/core-paging": "^1.2.0", - "@azure/core-client": "^1.6.1", + "@azure/core-client": "^1.7.0", "@azure/core-auth": "^1.3.0", "@azure/core-rest-pipeline": "^1.8.0", "tslib": "^2.2.0" @@ -33,12 +33,13 @@ "@rollup/plugin-json": "^6.0.0", "@rollup/plugin-multi-entry": "^6.0.0", "@rollup/plugin-node-resolve": "^13.1.3", - "mkdirp": "^1.0.4", + "mkdirp": "^2.1.2", "rollup": "^2.66.1", "rollup-plugin-sourcemaps": "^0.6.3", "typescript": "~5.0.0", "uglify-js": "^3.4.9", "rimraf": "^3.0.0", + "dotenv": "^16.0.0", "@azure/identity": "^2.0.1", "@azure-tools/test-recorder": "^3.0.0", "@azure-tools/test-credential": "^1.0.0", @@ -49,7 +50,6 @@ "@types/node": "^14.0.0", "@azure/dev-tool": "^1.0.0" }, - "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/networkfunction/arm-networkfunction", "repository": { "type": "git", "url": "https://github.com/Azure/azure-sdk-for-js.git" @@ -111,12 +111,5 @@ ] }, "autoPublish": true, - "//sampleConfiguration": { - "productName": "", - "productSlugs": [ - "azure" - ], - "disableDocsMs": true, - "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-networkfunction?view=azure-node-preview" - } -} + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/networkfunction/arm-networkfunction" +} \ No newline at end of file diff --git a/sdk/networkfunction/arm-networkfunction/review/arm-networkfunction.api.md b/sdk/networkfunction/arm-networkfunction/review/arm-networkfunction.api.md index 70a316473958..e6375b6bfb22 100644 --- a/sdk/networkfunction/arm-networkfunction/review/arm-networkfunction.api.md +++ b/sdk/networkfunction/arm-networkfunction/review/arm-networkfunction.api.md @@ -6,9 +6,9 @@ import * as coreAuth from '@azure/core-auth'; import * as coreClient from '@azure/core-client'; +import { OperationState } from '@azure/core-lro'; import { PagedAsyncIterableIterator } from '@azure/core-paging'; -import { PollerLike } from '@azure/core-lro'; -import { PollOperationState } from '@azure/core-lro'; +import { SimplePollerLike } from '@azure/core-lro'; // @public export type ApiVersionParameter = string; @@ -26,6 +26,7 @@ export class AzureTrafficCollectorClient extends coreClient.ServiceClient { // (undocumented) $host: string; constructor(credentials: coreAuth.TokenCredential, subscriptionId: string, options?: AzureTrafficCollectorClientOptionalParams); + constructor(credentials: coreAuth.TokenCredential, options?: AzureTrafficCollectorClientOptionalParams); // (undocumented) apiVersion: string; // (undocumented) @@ -39,7 +40,7 @@ export class AzureTrafficCollectorClient extends coreClient.ServiceClient { // (undocumented) networkFunction: NetworkFunction; // (undocumented) - subscriptionId: string; + subscriptionId?: string; } // @public @@ -57,9 +58,9 @@ export interface AzureTrafficCollectorListResult { // @public export interface AzureTrafficCollectors { - beginCreateOrUpdate(resourceGroupName: string, azureTrafficCollectorName: string, location: string, options?: AzureTrafficCollectorsCreateOrUpdateOptionalParams): Promise, AzureTrafficCollectorsCreateOrUpdateResponse>>; + beginCreateOrUpdate(resourceGroupName: string, azureTrafficCollectorName: string, location: string, options?: AzureTrafficCollectorsCreateOrUpdateOptionalParams): Promise, AzureTrafficCollectorsCreateOrUpdateResponse>>; beginCreateOrUpdateAndWait(resourceGroupName: string, azureTrafficCollectorName: string, location: string, options?: AzureTrafficCollectorsCreateOrUpdateOptionalParams): Promise; - beginDelete(resourceGroupName: string, azureTrafficCollectorName: string, options?: AzureTrafficCollectorsDeleteOptionalParams): Promise, void>>; + beginDelete(resourceGroupName: string, azureTrafficCollectorName: string, options?: AzureTrafficCollectorsDeleteOptionalParams): Promise, void>>; beginDeleteAndWait(resourceGroupName: string, azureTrafficCollectorName: string, options?: AzureTrafficCollectorsDeleteOptionalParams): Promise; get(resourceGroupName: string, azureTrafficCollectorName: string, options?: AzureTrafficCollectorsGetOptionalParams): Promise; updateTags(resourceGroupName: string, azureTrafficCollectorName: string, parameters: TagsObject, options?: AzureTrafficCollectorsUpdateTagsOptionalParams): Promise; @@ -151,9 +152,9 @@ export interface CloudErrorBody { // @public export interface CollectorPolicies { - beginCreateOrUpdate(resourceGroupName: string, azureTrafficCollectorName: string, collectorPolicyName: string, location: string, options?: CollectorPoliciesCreateOrUpdateOptionalParams): Promise, CollectorPoliciesCreateOrUpdateResponse>>; + beginCreateOrUpdate(resourceGroupName: string, azureTrafficCollectorName: string, collectorPolicyName: string, location: string, options?: CollectorPoliciesCreateOrUpdateOptionalParams): Promise, CollectorPoliciesCreateOrUpdateResponse>>; beginCreateOrUpdateAndWait(resourceGroupName: string, azureTrafficCollectorName: string, collectorPolicyName: string, location: string, options?: CollectorPoliciesCreateOrUpdateOptionalParams): Promise; - beginDelete(resourceGroupName: string, azureTrafficCollectorName: string, collectorPolicyName: string, options?: CollectorPoliciesDeleteOptionalParams): Promise, void>>; + beginDelete(resourceGroupName: string, azureTrafficCollectorName: string, collectorPolicyName: string, options?: CollectorPoliciesDeleteOptionalParams): Promise, void>>; beginDeleteAndWait(resourceGroupName: string, azureTrafficCollectorName: string, collectorPolicyName: string, options?: CollectorPoliciesDeleteOptionalParams): Promise; get(resourceGroupName: string, azureTrafficCollectorName: string, collectorPolicyName: string, options?: CollectorPoliciesGetOptionalParams): Promise; list(resourceGroupName: string, azureTrafficCollectorName: string, options?: CollectorPoliciesListOptionalParams): PagedAsyncIterableIterator; diff --git a/sdk/networkfunction/arm-networkfunction/src/azureTrafficCollectorClient.ts b/sdk/networkfunction/arm-networkfunction/src/azureTrafficCollectorClient.ts index ff172a59a0d9..9c0e69758a79 100644 --- a/sdk/networkfunction/arm-networkfunction/src/azureTrafficCollectorClient.ts +++ b/sdk/networkfunction/arm-networkfunction/src/azureTrafficCollectorClient.ts @@ -33,7 +33,7 @@ import { AzureTrafficCollectorClientOptionalParams } from "./models"; export class AzureTrafficCollectorClient extends coreClient.ServiceClient { $host: string; apiVersion: string; - subscriptionId: string; + subscriptionId?: string; /** * Initializes a new instance of the AzureTrafficCollectorClient class. @@ -45,12 +45,28 @@ export class AzureTrafficCollectorClient extends coreClient.ServiceClient { credentials: coreAuth.TokenCredential, subscriptionId: string, options?: AzureTrafficCollectorClientOptionalParams + ); + constructor( + credentials: coreAuth.TokenCredential, + options?: AzureTrafficCollectorClientOptionalParams + ); + constructor( + credentials: coreAuth.TokenCredential, + subscriptionIdOrOptions?: + | AzureTrafficCollectorClientOptionalParams + | string, + options?: AzureTrafficCollectorClientOptionalParams ) { if (credentials === undefined) { throw new Error("'credentials' cannot be null"); } - if (subscriptionId === undefined) { - throw new Error("'subscriptionId' cannot be null"); + + let subscriptionId: string | undefined; + + if (typeof subscriptionIdOrOptions === "string") { + subscriptionId = subscriptionIdOrOptions; + } else if (typeof subscriptionIdOrOptions === "object") { + options = subscriptionIdOrOptions; } // Initializing default values for options @@ -62,7 +78,7 @@ export class AzureTrafficCollectorClient extends coreClient.ServiceClient { credential: credentials }; - const packageDetails = `azsdk-js-arm-networkfunction/2.0.1`; + const packageDetails = `azsdk-js-arm-networkfunction/3.0.0`; const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` diff --git a/sdk/networkfunction/arm-networkfunction/src/lroImpl.ts b/sdk/networkfunction/arm-networkfunction/src/lroImpl.ts index 518d5f053b4e..dd803cd5e28c 100644 --- a/sdk/networkfunction/arm-networkfunction/src/lroImpl.ts +++ b/sdk/networkfunction/arm-networkfunction/src/lroImpl.ts @@ -6,29 +6,37 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { AbortSignalLike } from "@azure/abort-controller"; import { LongRunningOperation, LroResponse } from "@azure/core-lro"; -export class LroImpl implements LongRunningOperation { - constructor( - private sendOperationFn: (args: any, spec: any) => Promise>, - private args: Record, - private spec: { - readonly requestBody?: unknown; - readonly path?: string; - readonly httpMethod: string; - } & Record, - public requestPath: string = spec.path!, - public requestMethod: string = spec.httpMethod - ) {} - public async sendInitialRequest(): Promise> { - return this.sendOperationFn(this.args, this.spec); - } - public async sendPollRequest(path: string): Promise> { - const { requestBody, ...restSpec } = this.spec; - return this.sendOperationFn(this.args, { - ...restSpec, - path, - httpMethod: "GET" - }); - } +export function createLroSpec(inputs: { + sendOperationFn: (args: any, spec: any) => Promise>; + args: Record; + spec: { + readonly requestBody?: unknown; + readonly path?: string; + readonly httpMethod: string; + } & Record; +}): LongRunningOperation { + const { args, spec, sendOperationFn } = inputs; + return { + requestMethod: spec.httpMethod, + requestPath: spec.path!, + sendInitialRequest: () => sendOperationFn(args, spec), + sendPollRequest: ( + path: string, + options?: { abortSignal?: AbortSignalLike } + ) => { + const { requestBody, ...restSpec } = spec; + return sendOperationFn(args, { + ...restSpec, + httpMethod: "GET", + path, + abortSignal: options?.abortSignal + }); + } + }; } diff --git a/sdk/networkfunction/arm-networkfunction/src/operations/azureTrafficCollectors.ts b/sdk/networkfunction/arm-networkfunction/src/operations/azureTrafficCollectors.ts index 5ff0e5444a04..60dd07e47d9b 100644 --- a/sdk/networkfunction/arm-networkfunction/src/operations/azureTrafficCollectors.ts +++ b/sdk/networkfunction/arm-networkfunction/src/operations/azureTrafficCollectors.ts @@ -11,8 +11,12 @@ import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; import { AzureTrafficCollectorClient } from "../azureTrafficCollectorClient"; -import { PollerLike, PollOperationState, LroEngine } from "@azure/core-lro"; -import { LroImpl } from "../lroImpl"; +import { + SimplePollerLike, + OperationState, + createHttpPoller +} from "@azure/core-lro"; +import { createLroSpec } from "../lroImpl"; import { AzureTrafficCollectorsGetOptionalParams, AzureTrafficCollectorsGetResponse, @@ -66,8 +70,8 @@ export class AzureTrafficCollectorsImpl implements AzureTrafficCollectors { location: string, options?: AzureTrafficCollectorsCreateOrUpdateOptionalParams ): Promise< - PollerLike< - PollOperationState, + SimplePollerLike< + OperationState, AzureTrafficCollectorsCreateOrUpdateResponse > > { @@ -77,7 +81,7 @@ export class AzureTrafficCollectorsImpl implements AzureTrafficCollectors { ): Promise => { return this.client.sendOperationRequest(args, spec); }; - const sendOperation = async ( + const sendOperationFn = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ) => { @@ -110,15 +114,18 @@ export class AzureTrafficCollectorsImpl implements AzureTrafficCollectors { }; }; - const lro = new LroImpl( - sendOperation, - { resourceGroupName, azureTrafficCollectorName, location, options }, - createOrUpdateOperationSpec - ); - const poller = new LroEngine(lro, { - resumeFrom: options?.resumeFrom, + const lro = createLroSpec({ + sendOperationFn, + args: { resourceGroupName, azureTrafficCollectorName, location, options }, + spec: createOrUpdateOperationSpec + }); + const poller = await createHttpPoller< + AzureTrafficCollectorsCreateOrUpdateResponse, + OperationState + >(lro, { + restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, - lroResourceLocationConfig: "azure-async-operation" + resourceLocationConfig: "azure-async-operation" }); await poller.poll(); return poller; @@ -156,14 +163,14 @@ export class AzureTrafficCollectorsImpl implements AzureTrafficCollectors { resourceGroupName: string, azureTrafficCollectorName: string, options?: AzureTrafficCollectorsDeleteOptionalParams - ): Promise, void>> { + ): Promise, void>> { const directSendOperation = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ): Promise => { return this.client.sendOperationRequest(args, spec); }; - const sendOperation = async ( + const sendOperationFn = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ) => { @@ -196,15 +203,15 @@ export class AzureTrafficCollectorsImpl implements AzureTrafficCollectors { }; }; - const lro = new LroImpl( - sendOperation, - { resourceGroupName, azureTrafficCollectorName, options }, - deleteOperationSpec - ); - const poller = new LroEngine(lro, { - resumeFrom: options?.resumeFrom, + const lro = createLroSpec({ + sendOperationFn, + args: { resourceGroupName, azureTrafficCollectorName, options }, + spec: deleteOperationSpec + }); + const poller = await createHttpPoller>(lro, { + restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, - lroResourceLocationConfig: "location" + resourceLocationConfig: "location" }); await poller.poll(); return poller; diff --git a/sdk/networkfunction/arm-networkfunction/src/operations/azureTrafficCollectorsByResourceGroup.ts b/sdk/networkfunction/arm-networkfunction/src/operations/azureTrafficCollectorsByResourceGroup.ts index d158cf5e42d3..86305525b1d3 100644 --- a/sdk/networkfunction/arm-networkfunction/src/operations/azureTrafficCollectorsByResourceGroup.ts +++ b/sdk/networkfunction/arm-networkfunction/src/operations/azureTrafficCollectorsByResourceGroup.ts @@ -164,7 +164,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, diff --git a/sdk/networkfunction/arm-networkfunction/src/operations/azureTrafficCollectorsBySubscription.ts b/sdk/networkfunction/arm-networkfunction/src/operations/azureTrafficCollectorsBySubscription.ts index dbccf3dae572..7fc71cb67339 100644 --- a/sdk/networkfunction/arm-networkfunction/src/operations/azureTrafficCollectorsBySubscription.ts +++ b/sdk/networkfunction/arm-networkfunction/src/operations/azureTrafficCollectorsBySubscription.ts @@ -145,7 +145,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, diff --git a/sdk/networkfunction/arm-networkfunction/src/operations/collectorPolicies.ts b/sdk/networkfunction/arm-networkfunction/src/operations/collectorPolicies.ts index 3bf2cbbf2ae4..f7a11a540fea 100644 --- a/sdk/networkfunction/arm-networkfunction/src/operations/collectorPolicies.ts +++ b/sdk/networkfunction/arm-networkfunction/src/operations/collectorPolicies.ts @@ -13,8 +13,12 @@ import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; import { AzureTrafficCollectorClient } from "../azureTrafficCollectorClient"; -import { PollerLike, PollOperationState, LroEngine } from "@azure/core-lro"; -import { LroImpl } from "../lroImpl"; +import { + SimplePollerLike, + OperationState, + createHttpPoller +} from "@azure/core-lro"; +import { createLroSpec } from "../lroImpl"; import { CollectorPolicy, CollectorPoliciesListNextOptionalParams, @@ -184,8 +188,8 @@ export class CollectorPoliciesImpl implements CollectorPolicies { location: string, options?: CollectorPoliciesCreateOrUpdateOptionalParams ): Promise< - PollerLike< - PollOperationState, + SimplePollerLike< + OperationState, CollectorPoliciesCreateOrUpdateResponse > > { @@ -195,7 +199,7 @@ export class CollectorPoliciesImpl implements CollectorPolicies { ): Promise => { return this.client.sendOperationRequest(args, spec); }; - const sendOperation = async ( + const sendOperationFn = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ) => { @@ -228,21 +232,24 @@ export class CollectorPoliciesImpl implements CollectorPolicies { }; }; - const lro = new LroImpl( - sendOperation, - { + const lro = createLroSpec({ + sendOperationFn, + args: { resourceGroupName, azureTrafficCollectorName, collectorPolicyName, location, options }, - createOrUpdateOperationSpec - ); - const poller = new LroEngine(lro, { - resumeFrom: options?.resumeFrom, + spec: createOrUpdateOperationSpec + }); + const poller = await createHttpPoller< + CollectorPoliciesCreateOrUpdateResponse, + OperationState + >(lro, { + restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, - lroResourceLocationConfig: "azure-async-operation" + resourceLocationConfig: "azure-async-operation" }); await poller.poll(); return poller; @@ -285,14 +292,14 @@ export class CollectorPoliciesImpl implements CollectorPolicies { azureTrafficCollectorName: string, collectorPolicyName: string, options?: CollectorPoliciesDeleteOptionalParams - ): Promise, void>> { + ): Promise, void>> { const directSendOperation = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ): Promise => { return this.client.sendOperationRequest(args, spec); }; - const sendOperation = async ( + const sendOperationFn = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ) => { @@ -325,20 +332,20 @@ export class CollectorPoliciesImpl implements CollectorPolicies { }; }; - const lro = new LroImpl( - sendOperation, - { + const lro = createLroSpec({ + sendOperationFn, + args: { resourceGroupName, azureTrafficCollectorName, collectorPolicyName, options }, - deleteOperationSpec - ); - const poller = new LroEngine(lro, { - resumeFrom: options?.resumeFrom, + spec: deleteOperationSpec + }); + const poller = await createHttpPoller>(lro, { + restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, - lroResourceLocationConfig: "location" + resourceLocationConfig: "location" }); await poller.poll(); return poller; @@ -562,7 +569,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, diff --git a/sdk/networkfunction/arm-networkfunction/src/operationsInterfaces/azureTrafficCollectors.ts b/sdk/networkfunction/arm-networkfunction/src/operationsInterfaces/azureTrafficCollectors.ts index ca39f72cf40e..2bf1d0e7241e 100644 --- a/sdk/networkfunction/arm-networkfunction/src/operationsInterfaces/azureTrafficCollectors.ts +++ b/sdk/networkfunction/arm-networkfunction/src/operationsInterfaces/azureTrafficCollectors.ts @@ -6,7 +6,7 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PollerLike, PollOperationState } from "@azure/core-lro"; +import { SimplePollerLike, OperationState } from "@azure/core-lro"; import { AzureTrafficCollectorsGetOptionalParams, AzureTrafficCollectorsGetResponse, @@ -44,8 +44,8 @@ export interface AzureTrafficCollectors { location: string, options?: AzureTrafficCollectorsCreateOrUpdateOptionalParams ): Promise< - PollerLike< - PollOperationState, + SimplePollerLike< + OperationState, AzureTrafficCollectorsCreateOrUpdateResponse > >; @@ -72,7 +72,7 @@ export interface AzureTrafficCollectors { resourceGroupName: string, azureTrafficCollectorName: string, options?: AzureTrafficCollectorsDeleteOptionalParams - ): Promise, void>>; + ): Promise, void>>; /** * Deletes a specified Azure Traffic Collector resource. * @param resourceGroupName The name of the resource group. diff --git a/sdk/networkfunction/arm-networkfunction/src/operationsInterfaces/collectorPolicies.ts b/sdk/networkfunction/arm-networkfunction/src/operationsInterfaces/collectorPolicies.ts index 1a39341dd5db..e850670c6a73 100644 --- a/sdk/networkfunction/arm-networkfunction/src/operationsInterfaces/collectorPolicies.ts +++ b/sdk/networkfunction/arm-networkfunction/src/operationsInterfaces/collectorPolicies.ts @@ -7,7 +7,7 @@ */ import { PagedAsyncIterableIterator } from "@azure/core-paging"; -import { PollerLike, PollOperationState } from "@azure/core-lro"; +import { SimplePollerLike, OperationState } from "@azure/core-lro"; import { CollectorPolicy, CollectorPoliciesListOptionalParams, @@ -63,8 +63,8 @@ export interface CollectorPolicies { location: string, options?: CollectorPoliciesCreateOrUpdateOptionalParams ): Promise< - PollerLike< - PollOperationState, + SimplePollerLike< + OperationState, CollectorPoliciesCreateOrUpdateResponse > >; @@ -95,7 +95,7 @@ export interface CollectorPolicies { azureTrafficCollectorName: string, collectorPolicyName: string, options?: CollectorPoliciesDeleteOptionalParams - ): Promise, void>>; + ): Promise, void>>; /** * Deletes a specified Collector Policy resource. * @param resourceGroupName The name of the resource group. diff --git a/sdk/networkfunction/arm-networkfunction/src/pagingHelper.ts b/sdk/networkfunction/arm-networkfunction/src/pagingHelper.ts index d85fc13bce1e..269a2b9814b5 100644 --- a/sdk/networkfunction/arm-networkfunction/src/pagingHelper.ts +++ b/sdk/networkfunction/arm-networkfunction/src/pagingHelper.ts @@ -13,11 +13,11 @@ export interface PageInfo { const pageMap = new WeakMap(); /** - * Given a result page from a pageable operation, returns a - * continuation token that can be used to begin paging from + * Given the last `.value` produced by the `byPage` iterator, + * 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(). + * @param page An object from accessing `value` on the IteratorResult from a `byPage` iterator. + * @returns The continuation token that can be passed into byPage() during future calls. */ export function getContinuationToken(page: unknown): string | undefined { if (typeof page !== "object" || page === null) { diff --git a/sdk/networkfunction/arm-networkfunction/test/sampleTest.ts b/sdk/networkfunction/arm-networkfunction/test/sampleTest.ts new file mode 100644 index 000000000000..25aeb3ebcc36 --- /dev/null +++ b/sdk/networkfunction/arm-networkfunction/test/sampleTest.ts @@ -0,0 +1,43 @@ +/* + * 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 { + Recorder, + RecorderStartOptions, + env +} from "@azure-tools/test-recorder"; +import { assert } from "chai"; +import { Context } from "mocha"; + +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(this: Context) { + recorder = new Recorder(this.currentTest); + await recorder.start(recorderOptions); + }); + + afterEach(async function() { + await recorder.stop(); + }); + + it("sample test", async function() { + console.log("Hi, I'm a test!"); + }); +}); diff --git a/sdk/networkfunction/arm-networkfunction/tsconfig.json b/sdk/networkfunction/arm-networkfunction/tsconfig.json index 16f2e23a1d30..3e6ae96443f3 100644 --- a/sdk/networkfunction/arm-networkfunction/tsconfig.json +++ b/sdk/networkfunction/arm-networkfunction/tsconfig.json @@ -15,17 +15,11 @@ ], "declaration": true, "outDir": "./dist-esm", - "importHelpers": true, - "paths": { - "@azure/arm-networkfunction": [ - "./src/index" - ] - } + "importHelpers": true }, "include": [ "./src/**/*.ts", - "./test/**/*.ts", - "samples-dev/**/*.ts" + "./test/**/*.ts" ], "exclude": [ "node_modules"