diff --git a/sdk/cdn/arm-cdn/_meta.json b/sdk/cdn/arm-cdn/_meta.json index 041fb3efa0b7..d20e66a57b81 100644 --- a/sdk/cdn/arm-cdn/_meta.json +++ b/sdk/cdn/arm-cdn/_meta.json @@ -1,8 +1,8 @@ { - "commit": "82fdf284eea880a8e027c354911a814999a77178", + "commit": "1278b951080f769d400bb5d03090de8bc21dc355", "readme": "specification/cdn/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\\cdn\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-beta.17 --generate-sample=true", + "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=/mnt/vss/_work/1/s/azure-sdk-for-js ../azure-rest-api-specs/specification/cdn/resource-manager/readme.md --use=@autorest/typescript@6.0.0-alpha.19.20220425.1", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "release_tool": "@azure-tools/js-sdk-release-tools@2.2.0", - "use": "@autorest/typescript@6.0.0-beta.17" + "release_tool": "@azure-tools/js-sdk-release-tools@2.3.0", + "use": "@autorest/typescript@6.0.0-alpha.19.20220425.1" } \ No newline at end of file diff --git a/sdk/cdn/arm-cdn/package.json b/sdk/cdn/arm-cdn/package.json index 3eb8e9926133..0bc651f91e21 100644 --- a/sdk/cdn/arm-cdn/package.json +++ b/sdk/cdn/arm-cdn/package.json @@ -3,7 +3,7 @@ "sdk-type": "mgmt", "author": "Microsoft Corporation", "description": "A generated SDK for CdnManagementClient.", - "version": "7.0.1", + "version": "7.0.2", "engines": { "node": ">=12.0.0" }, @@ -11,9 +11,9 @@ "@azure/core-lro": "^2.2.0", "@azure/abort-controller": "^1.0.0", "@azure/core-paging": "^1.2.0", - "@azure/core-client": "^1.0.0", + "@azure/core-client": "^1.5.0", "@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": [ @@ -40,9 +40,11 @@ "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" + "cross-env": "^7.0.2", + "@azure/dev-tool": "^1.0.0" }, "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/cdn/arm-cdn", "repository": { @@ -93,7 +95,7 @@ "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:node": "dev-tool run test:node-ts-input -- --timeout 1200000 'test/*.ts'", "integration-test:browser": "echo skipped", "docs": "echo skipped" }, @@ -106,13 +108,5 @@ } ] }, - "autoPublish": true, - "//sampleConfiguration": { - "productName": "", - "productSlugs": [ - "azure" - ], - "disableDocsMs": true, - "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-cdn?view=azure-node-preview" - } -} + "autoPublish": true +} \ No newline at end of file diff --git a/sdk/cdn/arm-cdn/src/cdnManagementClient.ts b/sdk/cdn/arm-cdn/src/cdnManagementClient.ts index cf2e03046430..f97e1fd2ec77 100644 --- a/sdk/cdn/arm-cdn/src/cdnManagementClient.ts +++ b/sdk/cdn/arm-cdn/src/cdnManagementClient.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 { AfdProfilesImpl, @@ -105,7 +111,7 @@ export class CdnManagementClient extends coreClient.ServiceClient { credential: credentials }; - const packageDetails = `azsdk-js-arm-cdn/7.0.1`; + const packageDetails = `azsdk-js-arm-cdn/7.0.2`; const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` @@ -124,6 +130,29 @@ export class CdnManagementClient extends coreClient.ServiceClient { options.endpoint ?? options.baseUri ?? "https://management.azure.com" }; super(optionsWithDefaults); + + if (options?.pipeline && options.pipeline.getOrderedPolicies().length > 0) { + const pipelinePolicies: coreRestPipeline.PipelinePolicy[] = options.pipeline.getOrderedPolicies(); + const bearerTokenAuthenticationPolicyFound = pipelinePolicies.some( + (pipelinePolicy) => + pipelinePolicy.name === + coreRestPipeline.bearerTokenAuthenticationPolicyName + ); + if (!bearerTokenAuthenticationPolicyFound) { + this.pipeline.removePolicy({ + name: coreRestPipeline.bearerTokenAuthenticationPolicyName + }); + this.pipeline.addPolicy( + coreRestPipeline.bearerTokenAuthenticationPolicy({ + scopes: `${optionsWithDefaults.baseUri}/.default`, + challengeCallbacks: { + authorizeRequestOnChallenge: + coreClient.authorizeRequestOnClaimChallenge + } + }) + ); + } + } // Parameter assignments this.subscriptionId = subscriptionId; @@ -152,6 +181,35 @@ export class CdnManagementClient extends coreClient.ServiceClient { this.edgeNodes = new EdgeNodesImpl(this); this.policies = new PoliciesImpl(this); this.managedRuleSets = new ManagedRuleSetsImpl(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 item.replace(/(?<==).*$/, apiVersion); + } else { + return item; + } + }); + request.url = param[0] + "?" + newParams.join("&"); + } + return next(request); + } + }; + this.pipeline.addPolicy(apiVersionPolicy); } /** diff --git a/sdk/cdn/arm-cdn/src/operations/afdEndpoints.ts b/sdk/cdn/arm-cdn/src/operations/afdEndpoints.ts index ba46654dc1ba..d5b2305d0288 100644 --- a/sdk/cdn/arm-cdn/src/operations/afdEndpoints.ts +++ b/sdk/cdn/arm-cdn/src/operations/afdEndpoints.ts @@ -126,7 +126,7 @@ export class AfdEndpointsImpl implements AfdEndpoints { } /** - * Checks the quota and actual usage of endpoints under the given CDN profile. + * Checks the quota and actual usage of the given AzureFrontDoor endpoint under the given CDN profile. * @param resourceGroupName Name of the Resource group within the Azure subscription. * @param profileName Name of the Azure Front Door Standard or Azure Front Door Premium profile which * is unique within the resource group. @@ -651,7 +651,7 @@ export class AfdEndpointsImpl implements AfdEndpoints { } /** - * Checks the quota and actual usage of endpoints under the given CDN profile. + * Checks the quota and actual usage of the given AzureFrontDoor endpoint under the given CDN profile. * @param resourceGroupName Name of the Resource group within the Azure subscription. * @param profileName Name of the Azure Front Door Standard or Azure Front Door Premium profile which * is unique within the resource group. @@ -671,7 +671,8 @@ export class AfdEndpointsImpl implements AfdEndpoints { } /** - * Validates the custom domain mapping to ensure it maps to the correct CDN endpoint in DNS. + * Validates the custom domain mapping to ensure it maps to the correct CDN endpoint in DNS.This api + * isn't work for apex domain. * @param resourceGroupName Name of the Resource group within the Azure subscription. * @param profileName Name of the Azure Front Door Standard or Azure Front Door Premium profile which * is unique within the resource group. diff --git a/sdk/cdn/arm-cdn/src/operations/afdOriginGroups.ts b/sdk/cdn/arm-cdn/src/operations/afdOriginGroups.ts index 81ae0adcd7d4..f15e167d8358 100644 --- a/sdk/cdn/arm-cdn/src/operations/afdOriginGroups.ts +++ b/sdk/cdn/arm-cdn/src/operations/afdOriginGroups.ts @@ -121,7 +121,8 @@ export class AfdOriginGroupsImpl implements AfdOriginGroups { } /** - * Checks the quota and actual usage of endpoints under the given CDN profile. + * Checks the quota and actual usage of the given AzureFrontDoor origin group under the given CDN + * profile. * @param resourceGroupName Name of the Resource group within the Azure subscription. * @param profileName Name of the Azure Front Door Standard or Azure Front Door Premium profile which * is unique within the resource group. @@ -536,7 +537,8 @@ export class AfdOriginGroupsImpl implements AfdOriginGroups { } /** - * Checks the quota and actual usage of endpoints under the given CDN profile. + * Checks the quota and actual usage of the given AzureFrontDoor origin group under the given CDN + * profile. * @param resourceGroupName Name of the Resource group within the Azure subscription. * @param profileName Name of the Azure Front Door Standard or Azure Front Door Premium profile which * is unique within the resource group. diff --git a/sdk/cdn/arm-cdn/src/operations/afdProfiles.ts b/sdk/cdn/arm-cdn/src/operations/afdProfiles.ts index cc172de0ed8c..91a5fb44437d 100644 --- a/sdk/cdn/arm-cdn/src/operations/afdProfiles.ts +++ b/sdk/cdn/arm-cdn/src/operations/afdProfiles.ts @@ -37,7 +37,7 @@ export class AfdProfilesImpl implements AfdProfiles { } /** - * Checks the quota and actual usage of endpoints under the given CDN profile. + * Checks the quota and actual usage of AzureFrontDoor endpoints under the given CDN profile. * @param resourceGroupName Name of the Resource group within the Azure subscription. * @param profileName Name of the Azure Front Door Standard or Azure Front Door Premium or CDN profile * which is unique within the resource group. @@ -109,7 +109,7 @@ export class AfdProfilesImpl implements AfdProfiles { } /** - * Checks the quota and actual usage of endpoints under the given CDN profile. + * Checks the quota and actual usage of AzureFrontDoor endpoints under the given CDN profile. * @param resourceGroupName Name of the Resource group within the Azure subscription. * @param profileName Name of the Azure Front Door Standard or Azure Front Door Premium or CDN profile * which is unique within the resource group. @@ -127,7 +127,7 @@ export class AfdProfilesImpl implements AfdProfiles { } /** - * Validates the custom domain mapping to ensure it maps to the correct CDN endpoint in DNS. + * Check the name availability of a host name. * @param resourceGroupName Name of the Resource group within the Azure subscription. * @param profileName Name of the Azure Front Door Standard or Azure Front Door Premium or CDN profile * which is unique within the resource group. diff --git a/sdk/cdn/arm-cdn/src/operations/customDomains.ts b/sdk/cdn/arm-cdn/src/operations/customDomains.ts index a237f122c4d6..6fb21ccefdf1 100644 --- a/sdk/cdn/arm-cdn/src/operations/customDomains.ts +++ b/sdk/cdn/arm-cdn/src/operations/customDomains.ts @@ -10,7 +10,6 @@ import { PagedAsyncIterableIterator } from "@azure/core-paging"; import { CustomDomains } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; -import * as Models from "../models"; import * as Parameters from "../models/parameters"; import { CdnManagementClient } from "../cdnManagementClient"; import { PollerLike, PollOperationState, LroEngine } from "@azure/core-lro"; @@ -32,8 +31,6 @@ import { CustomDomainsEnableCustomHttpsResponse, CustomDomainsListByEndpointNextResponse } from "../models"; -import { ProfilesImpl } from "./profiles"; -import { type } from "os"; /// /** Class containing CustomDomains operations. */ @@ -423,37 +420,16 @@ export class CustomDomainsImpl implements CustomDomains { customDomainName: string, options?: CustomDomainsEnableCustomHttpsOptionalParams ): Promise { - // #region Added default values to add backwards compatibility - let newOptions: Models.CustomDomainsEnableCustomHttpsOptionalParams = {}; - newOptions = options as Models.CustomDomainsEnableCustomHttpsOptionalParams; - - if (!newOptions) { - newOptions = {}; - } - - let optionsPreparationPromise = Promise.resolve(options); - - if (!newOptions.customDomainHttpsParameters) { - let profiles = new ProfilesImpl(this.client); - optionsPreparationPromise = profiles.get(resourceGroupName, profileName).then(profile => { - newOptions.customDomainHttpsParameters = getDefaultCustomDomainHttpsParameters(profile); - return newOptions; - }) - } - - return optionsPreparationPromise.then(options => - this.client.sendOperationRequest( - { - resourceGroupName, - profileName, - endpointName, - customDomainName, - options - }, - enableCustomHttpsOperationSpec - ) + return this.client.sendOperationRequest( + { + resourceGroupName, + profileName, + endpointName, + customDomainName, + options + }, + enableCustomHttpsOperationSpec ); - // #endregion } /** @@ -477,50 +453,6 @@ export class CustomDomainsImpl implements CustomDomains { ); } } - -// #region Added default values to add backwards compatibility -class SkuNames { - public static get standard_microsoft() { return "Standard_Microsoft"; } - public static get standard_verizon() { return "Standard_Verizon"; } - public static get standard_akamai() { return "Standard_Akamai"; } -} - -function getDefaultCustomDomainHttpsParameters(profile: Models.Profile): Models.CdnManagedHttpsParameters | undefined { - switch (profile.sku.name) { - case SkuNames.standard_microsoft: - return { - certificateSource: "Cdn", - certificateSourceParameters: { - certificateType: "Dedicated", - typeName: "CdnCertificateSourceParameters" - }, - protocolType: "ServerNameIndication" - } - case SkuNames.standard_akamai: - return { - certificateSource: "Cdn", - certificateSourceParameters: { - certificateType: "Shared", - typeName: "CdnCertificateSourceParameters" - }, - protocolType: "ServerNameIndication" - } - case SkuNames.standard_verizon: - return { - certificateSource: "Cdn", - certificateSourceParameters: { - certificateType: "Shared", - typeName: "CdnCertificateSourceParameters" - }, - protocolType: "IPBased" - } - default: - return undefined; - } -} - -// #endregion - // Operation Specifications const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); diff --git a/sdk/cdn/arm-cdn/src/operations/ruleSets.ts b/sdk/cdn/arm-cdn/src/operations/ruleSets.ts index 5c67e7843a60..4646e6cb11a2 100644 --- a/sdk/cdn/arm-cdn/src/operations/ruleSets.ts +++ b/sdk/cdn/arm-cdn/src/operations/ruleSets.ts @@ -118,7 +118,7 @@ export class RuleSetsImpl implements RuleSets { } /** - * Checks the quota and actual usage of endpoints under the given CDN profile. + * Checks the quota and actual usage of the given AzureFrontDoor rule set under the given CDN profile. * @param resourceGroupName Name of the Resource group within the Azure subscription. * @param profileName Name of the Azure Front Door Standard or Azure Front Door Premium profile which * is unique within the resource group. @@ -350,7 +350,7 @@ export class RuleSetsImpl implements RuleSets { } /** - * Checks the quota and actual usage of endpoints under the given CDN profile. + * Checks the quota and actual usage of the given AzureFrontDoor rule set under the given CDN profile. * @param resourceGroupName Name of the Resource group within the Azure subscription. * @param profileName Name of the Azure Front Door Standard or Azure Front Door Premium profile which * is unique within the resource group. diff --git a/sdk/cdn/arm-cdn/src/operationsInterfaces/afdEndpoints.ts b/sdk/cdn/arm-cdn/src/operationsInterfaces/afdEndpoints.ts index 071b147c5994..216aa9febad4 100644 --- a/sdk/cdn/arm-cdn/src/operationsInterfaces/afdEndpoints.ts +++ b/sdk/cdn/arm-cdn/src/operationsInterfaces/afdEndpoints.ts @@ -44,7 +44,7 @@ export interface AfdEndpoints { options?: AfdEndpointsListByProfileOptionalParams ): PagedAsyncIterableIterator; /** - * Checks the quota and actual usage of endpoints under the given CDN profile. + * Checks the quota and actual usage of the given AzureFrontDoor endpoint under the given CDN profile. * @param resourceGroupName Name of the Resource group within the Azure subscription. * @param profileName Name of the Azure Front Door Standard or Azure Front Door Premium profile which * is unique within the resource group. @@ -221,7 +221,8 @@ export interface AfdEndpoints { options?: AfdEndpointsPurgeContentOptionalParams ): Promise; /** - * Validates the custom domain mapping to ensure it maps to the correct CDN endpoint in DNS. + * Validates the custom domain mapping to ensure it maps to the correct CDN endpoint in DNS.This api + * isn't work for apex domain. * @param resourceGroupName Name of the Resource group within the Azure subscription. * @param profileName Name of the Azure Front Door Standard or Azure Front Door Premium profile which * is unique within the resource group. diff --git a/sdk/cdn/arm-cdn/src/operationsInterfaces/afdOriginGroups.ts b/sdk/cdn/arm-cdn/src/operationsInterfaces/afdOriginGroups.ts index 4b29fd9bca96..b682942fe135 100644 --- a/sdk/cdn/arm-cdn/src/operationsInterfaces/afdOriginGroups.ts +++ b/sdk/cdn/arm-cdn/src/operationsInterfaces/afdOriginGroups.ts @@ -39,7 +39,8 @@ export interface AfdOriginGroups { options?: AfdOriginGroupsListByProfileOptionalParams ): PagedAsyncIterableIterator; /** - * Checks the quota and actual usage of endpoints under the given CDN profile. + * Checks the quota and actual usage of the given AzureFrontDoor origin group under the given CDN + * profile. * @param resourceGroupName Name of the Resource group within the Azure subscription. * @param profileName Name of the Azure Front Door Standard or Azure Front Door Premium profile which * is unique within the resource group. diff --git a/sdk/cdn/arm-cdn/src/operationsInterfaces/afdProfiles.ts b/sdk/cdn/arm-cdn/src/operationsInterfaces/afdProfiles.ts index 58cb25bf0a43..6178f5c7b8d8 100644 --- a/sdk/cdn/arm-cdn/src/operationsInterfaces/afdProfiles.ts +++ b/sdk/cdn/arm-cdn/src/operationsInterfaces/afdProfiles.ts @@ -19,7 +19,7 @@ import { /** Interface representing a AfdProfiles. */ export interface AfdProfiles { /** - * Checks the quota and actual usage of endpoints under the given CDN profile. + * Checks the quota and actual usage of AzureFrontDoor endpoints under the given CDN profile. * @param resourceGroupName Name of the Resource group within the Azure subscription. * @param profileName Name of the Azure Front Door Standard or Azure Front Door Premium or CDN profile * which is unique within the resource group. @@ -31,7 +31,7 @@ export interface AfdProfiles { options?: AfdProfilesListResourceUsageOptionalParams ): PagedAsyncIterableIterator; /** - * Validates the custom domain mapping to ensure it maps to the correct CDN endpoint in DNS. + * Check the name availability of a host name. * @param resourceGroupName Name of the Resource group within the Azure subscription. * @param profileName Name of the Azure Front Door Standard or Azure Front Door Premium or CDN profile * which is unique within the resource group. diff --git a/sdk/cdn/arm-cdn/src/operationsInterfaces/ruleSets.ts b/sdk/cdn/arm-cdn/src/operationsInterfaces/ruleSets.ts index 2adec0bcc7c1..02a7a0c27de0 100644 --- a/sdk/cdn/arm-cdn/src/operationsInterfaces/ruleSets.ts +++ b/sdk/cdn/arm-cdn/src/operationsInterfaces/ruleSets.ts @@ -36,7 +36,7 @@ export interface RuleSets { options?: RuleSetsListByProfileOptionalParams ): PagedAsyncIterableIterator; /** - * Checks the quota and actual usage of endpoints under the given CDN profile. + * Checks the quota and actual usage of the given AzureFrontDoor rule set under the given CDN profile. * @param resourceGroupName Name of the Resource group within the Azure subscription. * @param profileName Name of the Azure Front Door Standard or Azure Front Door Premium profile which * is unique within the resource group. diff --git a/sdk/cdn/arm-cdn/test/sampleTest.ts b/sdk/cdn/arm-cdn/test/sampleTest.ts new file mode 100644 index 000000000000..25aeb3ebcc36 --- /dev/null +++ b/sdk/cdn/arm-cdn/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/cdn/arm-cdn/tsconfig.json b/sdk/cdn/arm-cdn/tsconfig.json index d80de3340da5..3e6ae96443f3 100644 --- a/sdk/cdn/arm-cdn/tsconfig.json +++ b/sdk/cdn/arm-cdn/tsconfig.json @@ -15,17 +15,11 @@ ], "declaration": true, "outDir": "./dist-esm", - "importHelpers": true, - "paths": { - "@azure/arm-cdn": [ - "./src/index" - ] - } + "importHelpers": true }, "include": [ "./src/**/*.ts", - "./test/**/*.ts", - "samples-dev/**/*.ts" + "./test/**/*.ts" ], "exclude": [ "node_modules"