diff --git a/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/CHANGELOG.md b/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/CHANGELOG.md index baaa3ee5d6b2..430db7c9a4e0 100644 --- a/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/CHANGELOG.md +++ b/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/CHANGELOG.md @@ -1,15 +1,20 @@ # Release History - -## 5.0.1 (Unreleased) - -### Features Added - -### Breaking Changes - -### Bugs Fixed - -### Other Changes - + +## 5.1.0 (2022-06-10) + +**Features** + + - Added Interface AzureBlobDefinition + - Added Interface AzureBlobPatchDefinition + - Added Interface ManagedIdentityDefinition + - Added Interface ManagedIdentityPatchDefinition + - Added Interface ServicePrincipalDefinition + - Added Interface ServicePrincipalPatchDefinition + - Interface FluxConfigurationPatch has a new optional parameter azureBlob + - Type Alias FluxConfiguration has a new parameter azureBlob + - Enum KnownSourceKindType has a new value AzureBlob + + ## 5.0.0 (2022-04-06) The package of @azure/arm-kubernetesconfiguration is using our next generation design principles since version 5.0.0, which contains breaking changes. diff --git a/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/_meta.json b/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/_meta.json index 88f6f7278747..735f919d9342 100644 --- a/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/_meta.json +++ b/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/_meta.json @@ -1,8 +1,8 @@ { - "commit": "e4b7e666673125aeb2b130f2a196e6aa7f8aca72", + "commit": "fbbfd912a72207722744a9d7706e198626554fec", "readme": "specification/kubernetesconfiguration/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\\kubernetesconfiguration\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-alpha.18.20220329.1 --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/kubernetesconfiguration/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.1", - "use": "@autorest/typescript@6.0.0-alpha.18.20220329.1" + "release_tool": "@azure-tools/js-sdk-release-tools@2.3.1", + "use": "@autorest/typescript@6.0.0-alpha.19.20220425.1" } \ No newline at end of file diff --git a/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/package.json b/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/package.json index cef51fe5492c..f5217429b34a 100644 --- a/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/package.json +++ b/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/package.json @@ -3,7 +3,7 @@ "sdk-type": "mgmt", "author": "Microsoft Corporation", "description": "A generated SDK for SourceControlConfigurationClient.", - "version": "5.0.1", + "version": "5.1.0", "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/kubernetesconfiguration/arm-kubernetesconfiguration", "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-kubernetesconfiguration?view=azure-node-preview" - } -} + "autoPublish": true +} \ No newline at end of file diff --git a/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/review/arm-kubernetesconfiguration.api.md b/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/review/arm-kubernetesconfiguration.api.md index c3fa1413646e..86bae6a136a9 100644 --- a/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/review/arm-kubernetesconfiguration.api.md +++ b/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/review/arm-kubernetesconfiguration.api.md @@ -13,6 +13,32 @@ import { PollOperationState } from '@azure/core-lro'; // @public export type AKSIdentityType = "SystemAssigned" | "UserAssigned"; +// @public +export interface AzureBlobDefinition { + accountKey?: string; + containerName?: string; + localAuthRef?: string; + managedIdentity?: ManagedIdentityDefinition; + sasToken?: string; + servicePrincipal?: ServicePrincipalDefinition; + syncIntervalInSeconds?: number; + timeoutInSeconds?: number; + url?: string; +} + +// @public +export interface AzureBlobPatchDefinition { + accountKey?: string; + containerName?: string; + localAuthRef?: string; + managedIdentity?: ManagedIdentityPatchDefinition; + sasToken?: string; + servicePrincipal?: ServicePrincipalPatchDefinition; + syncIntervalInSeconds?: number; + timeoutInSeconds?: number; + url?: string; +} + // @public export interface BucketDefinition { accessKey?: string; @@ -199,6 +225,7 @@ export type FluxConfiguration = ProxyResource & { suspend?: boolean; gitRepository?: GitRepositoryDefinition; bucket?: BucketDefinition; + azureBlob?: AzureBlobDefinition; kustomizations?: { [propertyName: string]: KustomizationDefinition | null; }; @@ -217,6 +244,7 @@ export type FluxConfiguration = ProxyResource & { // @public export interface FluxConfigurationPatch { + azureBlob?: AzureBlobPatchDefinition; bucket?: BucketPatchDefinition; configurationProtectedSettings?: { [propertyName: string]: string; @@ -463,6 +491,8 @@ export enum KnownScopeType { // @public export enum KnownSourceKindType { + // (undocumented) + AzureBlob = "AzureBlob", // (undocumented) Bucket = "Bucket", // (undocumented) @@ -498,6 +528,16 @@ export type KustomizationValidationType = string; // @public export type LevelType = string; +// @public +export interface ManagedIdentityDefinition { + clientId?: string; +} + +// @public +export interface ManagedIdentityPatchDefinition { + clientId?: string; +} + // @public export type MessageLevelType = string; @@ -674,6 +714,26 @@ export interface ScopeNamespace { // @public export type ScopeType = string; +// @public +export interface ServicePrincipalDefinition { + clientCertificate?: string; + clientCertificatePassword?: string; + clientCertificateSendChain?: boolean; + clientId?: string; + clientSecret?: string; + tenantId?: string; +} + +// @public +export interface ServicePrincipalPatchDefinition { + clientCertificate?: string; + clientCertificatePassword?: string; + clientCertificateSendChain?: boolean; + clientId?: string; + clientSecret?: string; + tenantId?: string; +} + // @public export type SourceControlConfiguration = ProxyResource & { readonly systemData?: SystemData; diff --git a/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/src/models/index.ts b/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/src/models/index.ts index 3c68a46ada40..a88f7d2b3e70 100644 --- a/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/src/models/index.ts +++ b/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/src/models/index.ts @@ -235,7 +235,7 @@ export interface RepositoryRefDefinition { commit?: string; } -/** Parameters to reconcile to the GitRepository source kind type. */ +/** Parameters to reconcile to the Bucket source kind type. */ export interface BucketDefinition { /** The URL to sync for the flux configuration S3 bucket. */ url?: string; @@ -243,9 +243,9 @@ export interface BucketDefinition { bucketName?: string; /** Specify whether to use insecure communication when puling data from the S3 bucket. */ insecure?: boolean; - /** The maximum time to attempt to reconcile the cluster git repository source with the remote. */ + /** The maximum time to attempt to reconcile the cluster bucket source with the remote. */ timeoutInSeconds?: number; - /** The interval at which to re-reconcile the cluster git repository source with the remote. */ + /** The interval at which to re-reconcile the cluster bucket source with the remote. */ syncIntervalInSeconds?: number; /** Plaintext access key used to securely access the S3 bucket */ accessKey?: string; @@ -253,6 +253,50 @@ export interface BucketDefinition { localAuthRef?: string; } +/** Parameters to reconcile to the AzureBlob source kind type. */ +export interface AzureBlobDefinition { + /** The URL to sync for the flux configuration Azure Blob storage account. */ + url?: string; + /** The Azure Blob container name to sync from the url endpoint for the flux configuration. */ + containerName?: string; + /** The maximum time to attempt to reconcile the cluster Azure Blob source with the remote. */ + timeoutInSeconds?: number; + /** The interval at which to re-reconcile the cluster Azure Blob source with the remote. */ + syncIntervalInSeconds?: number; + /** Parameters to authenticate using Service Principal. */ + servicePrincipal?: ServicePrincipalDefinition; + /** The account key (shared key) to access the storage account */ + accountKey?: string; + /** The Shared Access token to access the storage container */ + sasToken?: string; + /** Parameters to authenticate using a Managed Identity. */ + managedIdentity?: ManagedIdentityDefinition; + /** Name of a local secret on the Kubernetes cluster to use as the authentication secret rather than the managed or user-provided configuration secrets. */ + localAuthRef?: string; +} + +/** Parameters to authenticate using Service Principal. */ +export interface ServicePrincipalDefinition { + /** The client Id for authenticating a Service Principal. */ + clientId?: string; + /** The tenant Id for authenticating a Service Principal */ + tenantId?: string; + /** The client secret for authenticating a Service Principal */ + clientSecret?: string; + /** Base64-encoded certificate used to authenticate a Service Principal */ + clientCertificate?: string; + /** The password for the certificate used to authenticate a Service Principal */ + clientCertificatePassword?: string; + /** Specifies whether to include x5c header in client claims when acquiring a token to enable subject name / issuer based authentication for the Client Certificate */ + clientCertificateSendChain?: boolean; +} + +/** Parameters to authenticate using a Managed Identity. */ +export interface ManagedIdentityDefinition { + /** The client Id for authenticating a Managed Identity. */ + clientId?: string; +} + /** The Kustomization defining how to reconcile the artifact pulled by the source type on the cluster. */ export interface KustomizationDefinition { /** @@ -340,6 +384,8 @@ export interface FluxConfigurationPatch { gitRepository?: GitRepositoryPatchDefinition; /** Parameters to reconcile to the Bucket source kind type. */ bucket?: BucketPatchDefinition; + /** Parameters to reconcile to the AzureBlob source kind type. */ + azureBlob?: AzureBlobPatchDefinition; /** Array of kustomizations used to reconcile the artifact pulled by the source type on the cluster. */ kustomizations?: { [propertyName: string]: KustomizationPatchDefinition | null; @@ -368,7 +414,7 @@ export interface GitRepositoryPatchDefinition { localAuthRef?: string; } -/** Parameters to reconcile to the GitRepository source kind type. */ +/** Parameters to reconcile to the Bucket source kind type. */ export interface BucketPatchDefinition { /** The URL to sync for the flux configuration S3 bucket. */ url?: string; @@ -376,9 +422,9 @@ export interface BucketPatchDefinition { bucketName?: string; /** Specify whether to use insecure communication when puling data from the S3 bucket. */ insecure?: boolean; - /** The maximum time to attempt to reconcile the cluster git repository source with the remote. */ + /** The maximum time to attempt to reconcile the cluster bucket source with the remote. */ timeoutInSeconds?: number; - /** The interval at which to re-reconcile the cluster git repository source with the remote. */ + /** The interval at which to re-reconcile the cluster bucket source with the remote. */ syncIntervalInSeconds?: number; /** Plaintext access key used to securely access the S3 bucket */ accessKey?: string; @@ -386,6 +432,50 @@ export interface BucketPatchDefinition { localAuthRef?: string; } +/** Parameters to reconcile to the AzureBlob source kind type. */ +export interface AzureBlobPatchDefinition { + /** The URL to sync for the flux configuration Azure Blob storage account. */ + url?: string; + /** The Azure Blob container name to sync from the url endpoint for the flux configuration. */ + containerName?: string; + /** The maximum time to attempt to reconcile the cluster Azure Blob source with the remote. */ + timeoutInSeconds?: number; + /** The interval at which to re-reconcile the cluster Azure Blob source with the remote. */ + syncIntervalInSeconds?: number; + /** Parameters to authenticate using Service Principal. */ + servicePrincipal?: ServicePrincipalPatchDefinition; + /** The account key (shared key) to access the storage account */ + accountKey?: string; + /** The Shared Access token to access the storage container */ + sasToken?: string; + /** Parameters to authenticate using a Managed Identity. */ + managedIdentity?: ManagedIdentityPatchDefinition; + /** Name of a local secret on the Kubernetes cluster to use as the authentication secret rather than the managed or user-provided configuration secrets. */ + localAuthRef?: string; +} + +/** Parameters to authenticate using Service Principal. */ +export interface ServicePrincipalPatchDefinition { + /** The client Id for authenticating a Service Principal. */ + clientId?: string; + /** The tenant Id for authenticating a Service Principal */ + tenantId?: string; + /** The client secret for authenticating a Service Principal */ + clientSecret?: string; + /** Base64-encoded certificate used to authenticate a Service Principal */ + clientCertificate?: string; + /** The password for the certificate used to authenticate a Service Principal */ + clientCertificatePassword?: string; + /** Specifies whether to include x5c header in client claims when acquiring a token to enable subject name / issuer based authentication for the Client Certificate */ + clientCertificateSendChain?: boolean; +} + +/** Parameters to authenticate using a Managed Identity. */ +export interface ManagedIdentityPatchDefinition { + /** The client Id for authenticating a Managed Identity. */ + clientId?: string; +} + /** The Kustomization defining how to reconcile the artifact pulled by the source type on the cluster. */ export interface KustomizationPatchDefinition { /** The path in the source reference to reconcile on the cluster. */ @@ -586,6 +676,8 @@ export type FluxConfiguration = ProxyResource & { gitRepository?: GitRepositoryDefinition; /** Parameters to reconcile to the Bucket source kind type. */ bucket?: BucketDefinition; + /** Parameters to reconcile to the AzureBlob source kind type. */ + azureBlob?: AzureBlobDefinition; /** Array of kustomizations used to reconcile the artifact pulled by the source type on the cluster. */ kustomizations?: { [propertyName: string]: KustomizationDefinition | null }; /** Key-value pairs of protected configuration settings for the configuration */ @@ -757,7 +849,8 @@ export type ScopeType = string; /** Known values of {@link SourceKindType} that the service accepts. */ export enum KnownSourceKindType { GitRepository = "GitRepository", - Bucket = "Bucket" + Bucket = "Bucket", + AzureBlob = "AzureBlob" } /** @@ -766,7 +859,8 @@ export enum KnownSourceKindType { * this enum contains the known values that the service supports. * ### Known values supported by the service * **GitRepository** \ - * **Bucket** + * **Bucket** \ + * **AzureBlob** */ export type SourceKindType = string; diff --git a/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/src/models/mappers.ts b/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/src/models/mappers.ts index e3e49d8796b4..0d26bc06991f 100644 --- a/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/src/models/mappers.ts +++ b/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/src/models/mappers.ts @@ -613,6 +613,147 @@ export const BucketDefinition: coreClient.CompositeMapper = { } }; +export const AzureBlobDefinition: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AzureBlobDefinition", + modelProperties: { + url: { + serializedName: "url", + nullable: true, + type: { + name: "String" + } + }, + containerName: { + serializedName: "containerName", + nullable: true, + type: { + name: "String" + } + }, + timeoutInSeconds: { + defaultValue: 600, + serializedName: "timeoutInSeconds", + nullable: true, + type: { + name: "Number" + } + }, + syncIntervalInSeconds: { + defaultValue: 600, + serializedName: "syncIntervalInSeconds", + nullable: true, + type: { + name: "Number" + } + }, + servicePrincipal: { + serializedName: "servicePrincipal", + type: { + name: "Composite", + className: "ServicePrincipalDefinition" + } + }, + accountKey: { + serializedName: "accountKey", + nullable: true, + type: { + name: "String" + } + }, + sasToken: { + serializedName: "sasToken", + nullable: true, + type: { + name: "String" + } + }, + managedIdentity: { + serializedName: "managedIdentity", + type: { + name: "Composite", + className: "ManagedIdentityDefinition" + } + }, + localAuthRef: { + serializedName: "localAuthRef", + nullable: true, + type: { + name: "String" + } + } + } + } +}; + +export const ServicePrincipalDefinition: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ServicePrincipalDefinition", + modelProperties: { + clientId: { + serializedName: "clientId", + nullable: true, + type: { + name: "String" + } + }, + tenantId: { + serializedName: "tenantId", + nullable: true, + type: { + name: "String" + } + }, + clientSecret: { + serializedName: "clientSecret", + nullable: true, + type: { + name: "String" + } + }, + clientCertificate: { + serializedName: "clientCertificate", + nullable: true, + type: { + name: "String" + } + }, + clientCertificatePassword: { + serializedName: "clientCertificatePassword", + nullable: true, + type: { + name: "String" + } + }, + clientCertificateSendChain: { + defaultValue: false, + serializedName: "clientCertificateSendChain", + type: { + name: "Boolean" + } + } + } + } +}; + +export const ManagedIdentityDefinition: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ManagedIdentityDefinition", + modelProperties: { + clientId: { + serializedName: "clientId", + nullable: true, + type: { + name: "String" + } + } + } + } +}; + export const KustomizationDefinition: coreClient.CompositeMapper = { type: { name: "Composite", @@ -883,6 +1024,13 @@ export const FluxConfigurationPatch: coreClient.CompositeMapper = { className: "BucketPatchDefinition" } }, + azureBlob: { + serializedName: "properties.azureBlob", + type: { + name: "Composite", + className: "AzureBlobPatchDefinition" + } + }, kustomizations: { serializedName: "properties.kustomizations", nullable: true, @@ -1031,6 +1179,144 @@ export const BucketPatchDefinition: coreClient.CompositeMapper = { } }; +export const AzureBlobPatchDefinition: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AzureBlobPatchDefinition", + modelProperties: { + url: { + serializedName: "url", + nullable: true, + type: { + name: "String" + } + }, + containerName: { + serializedName: "containerName", + nullable: true, + type: { + name: "String" + } + }, + timeoutInSeconds: { + serializedName: "timeoutInSeconds", + nullable: true, + type: { + name: "Number" + } + }, + syncIntervalInSeconds: { + serializedName: "syncIntervalInSeconds", + nullable: true, + type: { + name: "Number" + } + }, + servicePrincipal: { + serializedName: "servicePrincipal", + type: { + name: "Composite", + className: "ServicePrincipalPatchDefinition" + } + }, + accountKey: { + serializedName: "accountKey", + nullable: true, + type: { + name: "String" + } + }, + sasToken: { + serializedName: "sasToken", + nullable: true, + type: { + name: "String" + } + }, + managedIdentity: { + serializedName: "managedIdentity", + type: { + name: "Composite", + className: "ManagedIdentityPatchDefinition" + } + }, + localAuthRef: { + serializedName: "localAuthRef", + nullable: true, + type: { + name: "String" + } + } + } + } +}; + +export const ServicePrincipalPatchDefinition: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ServicePrincipalPatchDefinition", + modelProperties: { + clientId: { + serializedName: "clientId", + nullable: true, + type: { + name: "String" + } + }, + tenantId: { + serializedName: "tenantId", + nullable: true, + type: { + name: "String" + } + }, + clientSecret: { + serializedName: "clientSecret", + nullable: true, + type: { + name: "String" + } + }, + clientCertificate: { + serializedName: "clientCertificate", + nullable: true, + type: { + name: "String" + } + }, + clientCertificatePassword: { + serializedName: "clientCertificatePassword", + nullable: true, + type: { + name: "String" + } + }, + clientCertificateSendChain: { + serializedName: "clientCertificateSendChain", + type: { + name: "Boolean" + } + } + } + } +}; + +export const ManagedIdentityPatchDefinition: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ManagedIdentityPatchDefinition", + modelProperties: { + clientId: { + serializedName: "clientId", + nullable: true, + type: { + name: "String" + } + } + } + } +}; + export const KustomizationPatchDefinition: coreClient.CompositeMapper = { type: { name: "Composite", @@ -1530,6 +1816,13 @@ export const FluxConfiguration: coreClient.CompositeMapper = { className: "BucketDefinition" } }, + azureBlob: { + serializedName: "properties.azureBlob", + type: { + name: "Composite", + className: "AzureBlobDefinition" + } + }, kustomizations: { serializedName: "properties.kustomizations", nullable: true, diff --git a/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/src/models/parameters.ts b/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/src/models/parameters.ts index 80b2a09fb1e3..15e8a0c9771d 100644 --- a/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/src/models/parameters.ts +++ b/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/src/models/parameters.ts @@ -136,7 +136,7 @@ export const extensionName: OperationURLParameter = { export const apiVersion: OperationQueryParameter = { parameterPath: "apiVersion", mapper: { - defaultValue: "2022-03-01", + defaultValue: "2022-07-01", isConstant: true, serializedName: "api-version", type: { diff --git a/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/src/sourceControlConfigurationClient.ts b/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/src/sourceControlConfigurationClient.ts index 950e3bd52a49..917b3dd07cc5 100644 --- a/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/src/sourceControlConfigurationClient.ts +++ b/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/src/sourceControlConfigurationClient.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 { ExtensionsImpl, @@ -58,7 +64,7 @@ export class SourceControlConfigurationClient extends coreClient.ServiceClient { credential: credentials }; - const packageDetails = `azsdk-js-arm-kubernetesconfiguration/5.0.1`; + const packageDetails = `azsdk-js-arm-kubernetesconfiguration/5.1.0`; const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` @@ -77,12 +83,35 @@ export class SourceControlConfigurationClient 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; // Assigning values to Constant parameters this.$host = options.$host || "https://management.azure.com"; - this.apiVersion = options.apiVersion || "2022-03-01"; + this.apiVersion = options.apiVersion || "2022-07-01"; this.extensions = new ExtensionsImpl(this); this.operationStatus = new OperationStatusImpl(this); this.fluxConfigurations = new FluxConfigurationsImpl(this); @@ -91,6 +120,35 @@ export class SourceControlConfigurationClient extends coreClient.ServiceClient { this ); this.operations = new OperationsImpl(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); } extensions: Extensions; diff --git a/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/test/sampleTest.ts b/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/test/sampleTest.ts index 7ed89b043e1b..25aeb3ebcc36 100644 --- a/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/test/sampleTest.ts +++ b/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/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/kubernetesconfiguration/arm-kubernetesconfiguration/tsconfig.json b/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/tsconfig.json index 5341a8d13163..3e6ae96443f3 100644 --- a/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/tsconfig.json +++ b/sdk/kubernetesconfiguration/arm-kubernetesconfiguration/tsconfig.json @@ -15,17 +15,11 @@ ], "declaration": true, "outDir": "./dist-esm", - "importHelpers": true, - "paths": { - "@azure/arm-kubernetesconfiguration": [ - "./src/index" - ] - } + "importHelpers": true }, "include": [ "./src/**/*.ts", - "./test/**/*.ts", - "samples-dev/**/*.ts" + "./test/**/*.ts" ], "exclude": [ "node_modules"