diff --git a/sdk/appconfiguration/app-configuration/review/app-configuration.api.md b/sdk/appconfiguration/app-configuration/review/app-configuration.api.md index e0026786e94e..2eacf0a0c391 100644 --- a/sdk/appconfiguration/app-configuration/review/app-configuration.api.md +++ b/sdk/appconfiguration/app-configuration/review/app-configuration.api.md @@ -16,23 +16,16 @@ export type AddConfigurationSettingOptions = ModelConfigurationClientCreateOrUpd // @public (undocumented) export type AddConfigurationSettingsResponse = ModelCreateOrUpdateConfigurationSettingResponse; -// @public (undocumented) +// @public export class AppConfigurationClient { constructor(connectionString: string); constructor(uri: string, credential: TokenCredential); - // (undocumented) addConfigurationSetting(key: string, configSettings: AddConfigurationSettingConfig, options?: AddConfigurationSettingOptions): Promise; - // (undocumented) deleteConfigurationSetting(key: string, options: DeleteConfigurationSettingOptions): Promise; - // (undocumented) getConfigurationSetting(key: string, options?: GetConfigurationSettingOptions): Promise; - // (undocumented) listConfigurationSettings(options?: ListConfigurationSettingsOptions): Promise; - // (undocumented) listRevisions(options?: ListRevisionsOptions): Promise; - // (undocumented) setConfigurationSetting(key: string, configSettings: SetConfigurationSettingConfig, options?: SetConfigurationSettingOptions): Promise; - // (undocumented) updateConfigurationSetting(key: string, configSettings: UpdateConfigurationSettingConfig, options?: UpdateConfigurationSettingOptions): Promise; } @@ -50,7 +43,6 @@ export type DeleteConfigurationSettingResponse = ModelDeleteConfigurationSetting // @public (undocumented) export interface ETagOption { - // (undocumented) etag?: string; } diff --git a/sdk/appconfiguration/app-configuration/src/appConfigCredential.ts b/sdk/appconfiguration/app-configuration/src/appConfigCredential.ts index 2133154b5ed1..be8d08facff4 100644 --- a/sdk/appconfiguration/app-configuration/src/appConfigCredential.ts +++ b/sdk/appconfiguration/app-configuration/src/appConfigCredential.ts @@ -1,6 +1,10 @@ import * as crypto from "crypto"; import { ServiceClientCredentials, WebResource, URLBuilder } from "@azure/core-http"; +/** + * @internal + * @ignore + */ export class AppConfigCredential implements ServiceClientCredentials { private credential: string; private secret: string; @@ -10,31 +14,40 @@ export class AppConfigCredential implements ServiceClientCredentials { this.secret = secret; } + /** + * Signs a request with the values provided in the credential and secret parameter. + * + * @param {WebResource} webResource The WebResource to be signed. + * @returns {Promise} The signed request object. + */ signRequest(webResource: WebResource): Promise { - const verb = webResource.method.toUpperCase() + const verb = webResource.method.toUpperCase(); const utcNow = new Date().toUTCString(); - const contentHash = - crypto.createHash("sha256") - .update(webResource.body || "") - .digest("base64"); + const contentHash = crypto + .createHash("sha256") + .update(webResource.body || "") + .digest("base64"); const signedHeaders = "x-ms-date;host;x-ms-content-sha256"; const url = URLBuilder.parse(webResource.url); const query = url.getQuery(); - const urlPathAndQuery = `${url.getPath()}${ query ? "?" + query : "" }` + const urlPathAndQuery = `${url.getPath()}${query ? "?" + query : ""}`; const stringToSign = `${verb}\n${urlPathAndQuery}\n${utcNow};${url.getHost()};${contentHash}`; const decodedSecret = Buffer.from(this.secret, "base64"); - var signature = - crypto.createHmac("sha256", decodedSecret) + var signature = crypto + .createHmac("sha256", decodedSecret) .update(stringToSign) .digest("base64"); webResource.headers.set("x-ms-date", utcNow); webResource.headers.set("x-ms-content-sha256", contentHash); - webResource.headers.set("Authorization", `HMAC-SHA256 Credential=${this.credential}, SignedHeaders=${signedHeaders}, Signature=${signature}`); + webResource.headers.set( + "Authorization", + `HMAC-SHA256 Credential=${this.credential}, SignedHeaders=${signedHeaders}, Signature=${signature}` + ); return Promise.resolve(webResource); } diff --git a/sdk/appconfiguration/app-configuration/src/generated/configurationClient.ts b/sdk/appconfiguration/app-configuration/src/generated/configurationClient.ts index d8cefa150f2a..1cf6e1500735 100644 --- a/sdk/appconfiguration/app-configuration/src/generated/configurationClient.ts +++ b/sdk/appconfiguration/app-configuration/src/generated/configurationClient.ts @@ -14,14 +14,16 @@ import * as Mappers from "./models/mappers"; import * as Parameters from "./models/parameters"; import { ConfigurationClientContext } from "./configurationClientContext"; - class ConfigurationClient extends ConfigurationClientContext { /** * Initializes a new instance of the ConfigurationClient class. * @param credentials Credentials needed for the client to connect to Azure. * @param [options] The parameter options */ - constructor(credentials: coreHttp.TokenCredential | coreHttp.ServiceClientCredentials, options?: Models.ConfigurationClientOptions) { + constructor( + credentials: coreHttp.TokenCredential | coreHttp.ServiceClientCredentials, + options?: Models.ConfigurationClientOptions + ) { super(credentials, options); } @@ -31,23 +33,36 @@ class ConfigurationClient extends ConfigurationClientContext { * @param [options] The optional parameters * @returns Promise */ - listConfigurationSettings(options?: Models.ConfigurationClientListConfigurationSettingsOptionalParams): Promise; + listConfigurationSettings( + options?: Models.ConfigurationClientListConfigurationSettingsOptionalParams + ): Promise; /** * @param callback The callback */ - listConfigurationSettings(callback: coreHttp.ServiceCallback): void; + listConfigurationSettings( + callback: coreHttp.ServiceCallback + ): void; /** * @param options The optional parameters * @param callback The callback */ - listConfigurationSettings(options: Models.ConfigurationClientListConfigurationSettingsOptionalParams, callback: coreHttp.ServiceCallback): void; - listConfigurationSettings(options?: Models.ConfigurationClientListConfigurationSettingsOptionalParams | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { + listConfigurationSettings( + options: Models.ConfigurationClientListConfigurationSettingsOptionalParams, + callback: coreHttp.ServiceCallback + ): void; + listConfigurationSettings( + options?: + | Models.ConfigurationClientListConfigurationSettingsOptionalParams + | coreHttp.ServiceCallback, + callback?: coreHttp.ServiceCallback + ): Promise { return this.sendOperationRequest( { options }, listConfigurationSettingsOperationSpec, - callback) as Promise; + callback + ) as Promise; } /** @@ -57,26 +72,43 @@ class ConfigurationClient extends ConfigurationClientContext { * @param [options] The optional parameters * @returns Promise */ - getConfigurationSetting(key: string, options?: Models.ConfigurationClientGetConfigurationSettingOptionalParams): Promise; + getConfigurationSetting( + key: string, + options?: Models.ConfigurationClientGetConfigurationSettingOptionalParams + ): Promise; /** * @param key string * @param callback The callback */ - getConfigurationSetting(key: string, callback: coreHttp.ServiceCallback): void; + getConfigurationSetting( + key: string, + callback: coreHttp.ServiceCallback + ): void; /** * @param key string * @param options The optional parameters * @param callback The callback */ - getConfigurationSetting(key: string, options: Models.ConfigurationClientGetConfigurationSettingOptionalParams, callback: coreHttp.ServiceCallback): void; - getConfigurationSetting(key: string, options?: Models.ConfigurationClientGetConfigurationSettingOptionalParams | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { + getConfigurationSetting( + key: string, + options: Models.ConfigurationClientGetConfigurationSettingOptionalParams, + callback: coreHttp.ServiceCallback + ): void; + getConfigurationSetting( + key: string, + options?: + | Models.ConfigurationClientGetConfigurationSettingOptionalParams + | coreHttp.ServiceCallback, + callback?: coreHttp.ServiceCallback + ): Promise { return this.sendOperationRequest( { key, options }, getConfigurationSettingOperationSpec, - callback) as Promise; + callback + ) as Promise; } /** @@ -87,21 +119,41 @@ class ConfigurationClient extends ConfigurationClientContext { * @param [options] The optional parameters * @returns Promise */ - createOrUpdateConfigurationSetting(configurationSetting: Models.ConfigurationSetting, key: string, options?: Models.ConfigurationClientCreateOrUpdateConfigurationSettingOptionalParams): Promise; + createOrUpdateConfigurationSetting( + configurationSetting: Models.ConfigurationSetting, + key: string, + options?: Models.ConfigurationClientCreateOrUpdateConfigurationSettingOptionalParams + ): Promise; /** * @param configurationSetting * @param key string * @param callback The callback */ - createOrUpdateConfigurationSetting(configurationSetting: Models.ConfigurationSetting, key: string, callback: coreHttp.ServiceCallback): void; + createOrUpdateConfigurationSetting( + configurationSetting: Models.ConfigurationSetting, + key: string, + callback: coreHttp.ServiceCallback + ): void; /** * @param configurationSetting * @param key string * @param options The optional parameters * @param callback The callback */ - createOrUpdateConfigurationSetting(configurationSetting: Models.ConfigurationSetting, key: string, options: Models.ConfigurationClientCreateOrUpdateConfigurationSettingOptionalParams, callback: coreHttp.ServiceCallback): void; - createOrUpdateConfigurationSetting(configurationSetting: Models.ConfigurationSetting, key: string, options?: Models.ConfigurationClientCreateOrUpdateConfigurationSettingOptionalParams | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { + createOrUpdateConfigurationSetting( + configurationSetting: Models.ConfigurationSetting, + key: string, + options: Models.ConfigurationClientCreateOrUpdateConfigurationSettingOptionalParams, + callback: coreHttp.ServiceCallback + ): void; + createOrUpdateConfigurationSetting( + configurationSetting: Models.ConfigurationSetting, + key: string, + options?: + | Models.ConfigurationClientCreateOrUpdateConfigurationSettingOptionalParams + | coreHttp.ServiceCallback, + callback?: coreHttp.ServiceCallback + ): Promise { return this.sendOperationRequest( { configurationSetting, @@ -109,7 +161,8 @@ class ConfigurationClient extends ConfigurationClientContext { options }, createOrUpdateConfigurationSettingOperationSpec, - callback) as Promise; + callback + ) as Promise; } /** @@ -118,33 +171,52 @@ class ConfigurationClient extends ConfigurationClientContext { * @param [options] The optional parameters * @returns Promise */ - deleteConfigurationSetting(key: string, options?: Models.ConfigurationClientDeleteConfigurationSettingOptionalParams): Promise; + deleteConfigurationSetting( + key: string, + options?: Models.ConfigurationClientDeleteConfigurationSettingOptionalParams + ): Promise; /** * @param key string * @param callback The callback */ - deleteConfigurationSetting(key: string, callback: coreHttp.ServiceCallback): void; + deleteConfigurationSetting( + key: string, + callback: coreHttp.ServiceCallback + ): void; /** * @param key string * @param options The optional parameters * @param callback The callback */ - deleteConfigurationSetting(key: string, options: Models.ConfigurationClientDeleteConfigurationSettingOptionalParams, callback: coreHttp.ServiceCallback): void; - deleteConfigurationSetting(key: string, options?: Models.ConfigurationClientDeleteConfigurationSettingOptionalParams | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { + deleteConfigurationSetting( + key: string, + options: Models.ConfigurationClientDeleteConfigurationSettingOptionalParams, + callback: coreHttp.ServiceCallback + ): void; + deleteConfigurationSetting( + key: string, + options?: + | Models.ConfigurationClientDeleteConfigurationSettingOptionalParams + | coreHttp.ServiceCallback, + callback?: coreHttp.ServiceCallback + ): Promise { return this.sendOperationRequest( { key, options }, deleteConfigurationSettingOperationSpec, - callback) as Promise; + callback + ) as Promise; } /** * @param [options] The optional parameters * @returns Promise */ - listKeys(options?: Models.ConfigurationClientListKeysOptionalParams): Promise; + listKeys( + options?: Models.ConfigurationClientListKeysOptionalParams + ): Promise; /** * @param callback The callback */ @@ -153,14 +225,23 @@ class ConfigurationClient extends ConfigurationClientContext { * @param options The optional parameters * @param callback The callback */ - listKeys(options: Models.ConfigurationClientListKeysOptionalParams, callback: coreHttp.ServiceCallback): void; - listKeys(options?: Models.ConfigurationClientListKeysOptionalParams | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { + listKeys( + options: Models.ConfigurationClientListKeysOptionalParams, + callback: coreHttp.ServiceCallback + ): void; + listKeys( + options?: + | Models.ConfigurationClientListKeysOptionalParams + | coreHttp.ServiceCallback, + callback?: coreHttp.ServiceCallback + ): Promise { return this.sendOperationRequest( { options }, listKeysOperationSpec, - callback) as Promise; + callback + ) as Promise; } /** @@ -168,7 +249,9 @@ class ConfigurationClient extends ConfigurationClientContext { * @param [options] The optional parameters * @returns Promise */ - listLabels(options?: Models.ConfigurationClientListLabelsOptionalParams): Promise; + listLabels( + options?: Models.ConfigurationClientListLabelsOptionalParams + ): Promise; /** * @param callback The callback */ @@ -177,14 +260,23 @@ class ConfigurationClient extends ConfigurationClientContext { * @param options The optional parameters * @param callback The callback */ - listLabels(options: Models.ConfigurationClientListLabelsOptionalParams, callback: coreHttp.ServiceCallback): void; - listLabels(options?: Models.ConfigurationClientListLabelsOptionalParams | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { + listLabels( + options: Models.ConfigurationClientListLabelsOptionalParams, + callback: coreHttp.ServiceCallback + ): void; + listLabels( + options?: + | Models.ConfigurationClientListLabelsOptionalParams + | coreHttp.ServiceCallback, + callback?: coreHttp.ServiceCallback + ): Promise { return this.sendOperationRequest( { options }, listLabelsOperationSpec, - callback) as Promise; + callback + ) as Promise; } /** @@ -192,26 +284,43 @@ class ConfigurationClient extends ConfigurationClientContext { * @param [options] The optional parameters * @returns Promise */ - lockConfigurationSetting(key: string, options?: Models.ConfigurationClientLockConfigurationSettingOptionalParams): Promise; + lockConfigurationSetting( + key: string, + options?: Models.ConfigurationClientLockConfigurationSettingOptionalParams + ): Promise; /** * @param key * @param callback The callback */ - lockConfigurationSetting(key: string, callback: coreHttp.ServiceCallback): void; + lockConfigurationSetting( + key: string, + callback: coreHttp.ServiceCallback + ): void; /** * @param key * @param options The optional parameters * @param callback The callback */ - lockConfigurationSetting(key: string, options: Models.ConfigurationClientLockConfigurationSettingOptionalParams, callback: coreHttp.ServiceCallback): void; - lockConfigurationSetting(key: string, options?: Models.ConfigurationClientLockConfigurationSettingOptionalParams | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { + lockConfigurationSetting( + key: string, + options: Models.ConfigurationClientLockConfigurationSettingOptionalParams, + callback: coreHttp.ServiceCallback + ): void; + lockConfigurationSetting( + key: string, + options?: + | Models.ConfigurationClientLockConfigurationSettingOptionalParams + | coreHttp.ServiceCallback, + callback?: coreHttp.ServiceCallback + ): Promise { return this.sendOperationRequest( { key, options }, lockConfigurationSettingOperationSpec, - callback) as Promise; + callback + ) as Promise; } /** @@ -219,33 +328,52 @@ class ConfigurationClient extends ConfigurationClientContext { * @param [options] The optional parameters * @returns Promise */ - unlockConfigurationSetting(key: string, options?: Models.ConfigurationClientUnlockConfigurationSettingOptionalParams): Promise; + unlockConfigurationSetting( + key: string, + options?: Models.ConfigurationClientUnlockConfigurationSettingOptionalParams + ): Promise; /** * @param key * @param callback The callback */ - unlockConfigurationSetting(key: string, callback: coreHttp.ServiceCallback): void; + unlockConfigurationSetting( + key: string, + callback: coreHttp.ServiceCallback + ): void; /** * @param key * @param options The optional parameters * @param callback The callback */ - unlockConfigurationSetting(key: string, options: Models.ConfigurationClientUnlockConfigurationSettingOptionalParams, callback: coreHttp.ServiceCallback): void; - unlockConfigurationSetting(key: string, options?: Models.ConfigurationClientUnlockConfigurationSettingOptionalParams | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { + unlockConfigurationSetting( + key: string, + options: Models.ConfigurationClientUnlockConfigurationSettingOptionalParams, + callback: coreHttp.ServiceCallback + ): void; + unlockConfigurationSetting( + key: string, + options?: + | Models.ConfigurationClientUnlockConfigurationSettingOptionalParams + | coreHttp.ServiceCallback, + callback?: coreHttp.ServiceCallback + ): Promise { return this.sendOperationRequest( { key, options }, unlockConfigurationSettingOperationSpec, - callback) as Promise; + callback + ) as Promise; } /** * @param [options] The optional parameters * @returns Promise */ - listRevisions(options?: Models.ConfigurationClientListRevisionsOptionalParams): Promise; + listRevisions( + options?: Models.ConfigurationClientListRevisionsOptionalParams + ): Promise; /** * @param callback The callback */ @@ -254,14 +382,23 @@ class ConfigurationClient extends ConfigurationClientContext { * @param options The optional parameters * @param callback The callback */ - listRevisions(options: Models.ConfigurationClientListRevisionsOptionalParams, callback: coreHttp.ServiceCallback): void; - listRevisions(options?: Models.ConfigurationClientListRevisionsOptionalParams | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { + listRevisions( + options: Models.ConfigurationClientListRevisionsOptionalParams, + callback: coreHttp.ServiceCallback + ): void; + listRevisions( + options?: + | Models.ConfigurationClientListRevisionsOptionalParams + | coreHttp.ServiceCallback, + callback?: coreHttp.ServiceCallback + ): Promise { return this.sendOperationRequest( { options }, listRevisionsOperationSpec, - callback) as Promise; + callback + ) as Promise; } /** @@ -271,26 +408,43 @@ class ConfigurationClient extends ConfigurationClientContext { * @param [options] The optional parameters * @returns Promise */ - listConfigurationSettingsNext(nextPageLink: string, options?: Models.ConfigurationClientListConfigurationSettingsNextOptionalParams): Promise; + listConfigurationSettingsNext( + nextPageLink: string, + options?: Models.ConfigurationClientListConfigurationSettingsNextOptionalParams + ): Promise; /** * @param nextPageLink The NextLink from the previous successful call to List operation. * @param callback The callback */ - listConfigurationSettingsNext(nextPageLink: string, callback: coreHttp.ServiceCallback): void; + listConfigurationSettingsNext( + nextPageLink: string, + callback: coreHttp.ServiceCallback + ): void; /** * @param nextPageLink The NextLink from the previous successful call to List operation. * @param options The optional parameters * @param callback The callback */ - listConfigurationSettingsNext(nextPageLink: string, options: Models.ConfigurationClientListConfigurationSettingsNextOptionalParams, callback: coreHttp.ServiceCallback): void; - listConfigurationSettingsNext(nextPageLink: string, options?: Models.ConfigurationClientListConfigurationSettingsNextOptionalParams | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { + listConfigurationSettingsNext( + nextPageLink: string, + options: Models.ConfigurationClientListConfigurationSettingsNextOptionalParams, + callback: coreHttp.ServiceCallback + ): void; + listConfigurationSettingsNext( + nextPageLink: string, + options?: + | Models.ConfigurationClientListConfigurationSettingsNextOptionalParams + | coreHttp.ServiceCallback, + callback?: coreHttp.ServiceCallback + ): Promise { return this.sendOperationRequest( { nextPageLink, options }, listConfigurationSettingsNextOperationSpec, - callback) as Promise; + callback + ) as Promise; } /** @@ -298,26 +452,43 @@ class ConfigurationClient extends ConfigurationClientContext { * @param [options] The optional parameters * @returns Promise */ - listRevisionsNext(nextPageLink: string, options?: Models.ConfigurationClientListRevisionsNextOptionalParams): Promise; + listRevisionsNext( + nextPageLink: string, + options?: Models.ConfigurationClientListRevisionsNextOptionalParams + ): Promise; /** * @param nextPageLink The NextLink from the previous successful call to List operation. * @param callback The callback */ - listRevisionsNext(nextPageLink: string, callback: coreHttp.ServiceCallback): void; + listRevisionsNext( + nextPageLink: string, + callback: coreHttp.ServiceCallback + ): void; /** * @param nextPageLink The NextLink from the previous successful call to List operation. * @param options The optional parameters * @param callback The callback */ - listRevisionsNext(nextPageLink: string, options: Models.ConfigurationClientListRevisionsNextOptionalParams, callback: coreHttp.ServiceCallback): void; - listRevisionsNext(nextPageLink: string, options?: Models.ConfigurationClientListRevisionsNextOptionalParams | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { + listRevisionsNext( + nextPageLink: string, + options: Models.ConfigurationClientListRevisionsNextOptionalParams, + callback: coreHttp.ServiceCallback + ): void; + listRevisionsNext( + nextPageLink: string, + options?: + | Models.ConfigurationClientListRevisionsNextOptionalParams + | coreHttp.ServiceCallback, + callback?: coreHttp.ServiceCallback + ): Promise { return this.sendOperationRequest( { nextPageLink, options }, listRevisionsNextOperationSpec, - callback) as Promise; + callback + ) as Promise; } } @@ -326,15 +497,8 @@ const serializer = new coreHttp.Serializer(Mappers); const listConfigurationSettingsOperationSpec: coreHttp.OperationSpec = { httpMethod: "GET", path: "kv", - queryParameters: [ - Parameters.label0, - Parameters.key0, - Parameters.fields - ], - headerParameters: [ - Parameters.acceptDateTime, - Parameters.acceptLanguage - ], + queryParameters: [Parameters.label0, Parameters.key0, Parameters.fields], + headerParameters: [Parameters.acceptDateTime, Parameters.acceptLanguage], responses: { 200: { bodyMapper: Mappers.ConfigurationSettingList @@ -349,16 +513,9 @@ const listConfigurationSettingsOperationSpec: coreHttp.OperationSpec = { const getConfigurationSettingOperationSpec: coreHttp.OperationSpec = { httpMethod: "GET", path: "kv/{key}", - urlParameters: [ - Parameters.key1 - ], - queryParameters: [ - Parameters.label1 - ], - headerParameters: [ - Parameters.acceptDateTime, - Parameters.acceptLanguage - ], + urlParameters: [Parameters.key1], + queryParameters: [Parameters.label1], + headerParameters: [Parameters.acceptDateTime, Parameters.acceptLanguage], responses: { 200: { bodyMapper: Mappers.ConfigurationSetting, @@ -377,15 +534,9 @@ const getConfigurationSettingOperationSpec: coreHttp.OperationSpec = { const createOrUpdateConfigurationSettingOperationSpec: coreHttp.OperationSpec = { httpMethod: "PUT", path: "kv/{key}", - urlParameters: [ - Parameters.key1 - ], - queryParameters: [ - Parameters.label1 - ], - headerParameters: [ - Parameters.acceptLanguage - ], + urlParameters: [Parameters.key1], + queryParameters: [Parameters.label1], + headerParameters: [Parameters.acceptLanguage], requestBody: { parameterPath: "configurationSetting", mapper: { @@ -407,15 +558,9 @@ const createOrUpdateConfigurationSettingOperationSpec: coreHttp.OperationSpec = const deleteConfigurationSettingOperationSpec: coreHttp.OperationSpec = { httpMethod: "DELETE", path: "kv/{key}", - urlParameters: [ - Parameters.key1 - ], - queryParameters: [ - Parameters.label2 - ], - headerParameters: [ - Parameters.acceptLanguage - ], + urlParameters: [Parameters.key1], + queryParameters: [Parameters.label2], + headerParameters: [Parameters.acceptLanguage], responses: { 200: { bodyMapper: Mappers.ConfigurationSetting @@ -431,13 +576,8 @@ const deleteConfigurationSettingOperationSpec: coreHttp.OperationSpec = { const listKeysOperationSpec: coreHttp.OperationSpec = { httpMethod: "GET", path: "keys", - queryParameters: [ - Parameters.name - ], - headerParameters: [ - Parameters.acceptDateTime, - Parameters.acceptLanguage - ], + queryParameters: [Parameters.name], + headerParameters: [Parameters.acceptDateTime, Parameters.acceptLanguage], responses: { 200: { bodyMapper: Mappers.KeyList @@ -452,14 +592,8 @@ const listKeysOperationSpec: coreHttp.OperationSpec = { const listLabelsOperationSpec: coreHttp.OperationSpec = { httpMethod: "GET", path: "labels", - queryParameters: [ - Parameters.fields, - Parameters.name - ], - headerParameters: [ - Parameters.acceptDateTime, - Parameters.acceptLanguage - ], + queryParameters: [Parameters.fields, Parameters.name], + headerParameters: [Parameters.acceptDateTime, Parameters.acceptLanguage], responses: { 200: { bodyMapper: Mappers.LabelList @@ -474,15 +608,9 @@ const listLabelsOperationSpec: coreHttp.OperationSpec = { const lockConfigurationSettingOperationSpec: coreHttp.OperationSpec = { httpMethod: "PUT", path: "locks/{key}", - urlParameters: [ - Parameters.key1 - ], - queryParameters: [ - Parameters.label2 - ], - headerParameters: [ - Parameters.acceptLanguage - ], + urlParameters: [Parameters.key1], + queryParameters: [Parameters.label2], + headerParameters: [Parameters.acceptLanguage], responses: { 200: { bodyMapper: Mappers.ConfigurationSetting @@ -497,15 +625,9 @@ const lockConfigurationSettingOperationSpec: coreHttp.OperationSpec = { const unlockConfigurationSettingOperationSpec: coreHttp.OperationSpec = { httpMethod: "DELETE", path: "locks/{key}", - urlParameters: [ - Parameters.key1 - ], - queryParameters: [ - Parameters.label2 - ], - headerParameters: [ - Parameters.acceptLanguage - ], + urlParameters: [Parameters.key1], + queryParameters: [Parameters.label2], + headerParameters: [Parameters.acceptLanguage], responses: { 200: { bodyMapper: Mappers.ConfigurationSetting @@ -520,15 +642,8 @@ const unlockConfigurationSettingOperationSpec: coreHttp.OperationSpec = { const listRevisionsOperationSpec: coreHttp.OperationSpec = { httpMethod: "GET", path: "revisions", - queryParameters: [ - Parameters.label0, - Parameters.key0, - Parameters.fields - ], - headerParameters: [ - Parameters.acceptDateTime, - Parameters.acceptLanguage - ], + queryParameters: [Parameters.label0, Parameters.key0, Parameters.fields], + headerParameters: [Parameters.acceptDateTime, Parameters.acceptLanguage], responses: { 200: { bodyMapper: Mappers.ConfigurationSettingList @@ -544,13 +659,8 @@ const listConfigurationSettingsNextOperationSpec: coreHttp.OperationSpec = { httpMethod: "GET", baseUrl: "http://localhost", path: "{nextLink}", - urlParameters: [ - Parameters.nextPageLink - ], - headerParameters: [ - Parameters.acceptDateTime, - Parameters.acceptLanguage - ], + urlParameters: [Parameters.nextPageLink], + headerParameters: [Parameters.acceptDateTime, Parameters.acceptLanguage], responses: { 200: { bodyMapper: Mappers.ConfigurationSettingList @@ -566,13 +676,8 @@ const listRevisionsNextOperationSpec: coreHttp.OperationSpec = { httpMethod: "GET", baseUrl: "http://localhost", path: "{nextLink}", - urlParameters: [ - Parameters.nextPageLink - ], - headerParameters: [ - Parameters.acceptDateTime, - Parameters.acceptLanguage - ], + urlParameters: [Parameters.nextPageLink], + headerParameters: [Parameters.acceptDateTime, Parameters.acceptLanguage], responses: { 200: { bodyMapper: Mappers.ConfigurationSettingList diff --git a/sdk/appconfiguration/app-configuration/src/generated/configurationClientContext.ts b/sdk/appconfiguration/app-configuration/src/generated/configurationClientContext.ts index 8a3eed9b73d2..71bd6d7f8b52 100644 --- a/sdk/appconfiguration/app-configuration/src/generated/configurationClientContext.ts +++ b/sdk/appconfiguration/app-configuration/src/generated/configurationClientContext.ts @@ -24,32 +24,38 @@ export class ConfigurationClientContext extends coreArm.AzureServiceClient { * @param credentials Credentials needed for the client to connect to Azure. * @param [options] The parameter options */ - constructor(credentials: coreHttp.TokenCredential | coreHttp.ServiceClientCredentials, options?: Models.ConfigurationClientOptions) { + constructor( + credentials: coreHttp.TokenCredential | coreHttp.ServiceClientCredentials, + options?: Models.ConfigurationClientOptions + ) { if (credentials == undefined) { - throw new Error('\'credentials\' cannot be null.'); + throw new Error("'credentials' cannot be null."); } if (!options) { options = {}; } - if(!options.userAgent) { + if (!options.userAgent) { const defaultUserAgent = coreArm.getDefaultUserAgentValue(); options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent}`; } super(credentials, options); - this.apiVersion = '2019-01-01'; - this.acceptLanguage = 'en-US'; + this.apiVersion = "2019-01-01"; + this.acceptLanguage = "en-US"; this.longRunningOperationRetryTimeout = 30; this.baseUri = options.baseUri || this.baseUri || "http://localhost"; this.requestContentType = "application/json; charset=utf-8"; this.credentials = credentials; - if(options.acceptLanguage !== null && options.acceptLanguage !== undefined) { + if (options.acceptLanguage !== null && options.acceptLanguage !== undefined) { this.acceptLanguage = options.acceptLanguage; } - if(options.longRunningOperationRetryTimeout !== null && options.longRunningOperationRetryTimeout !== undefined) { + if ( + options.longRunningOperationRetryTimeout !== null && + options.longRunningOperationRetryTimeout !== undefined + ) { this.longRunningOperationRetryTimeout = options.longRunningOperationRetryTimeout; } } diff --git a/sdk/appconfiguration/app-configuration/src/generated/models/index.ts b/sdk/appconfiguration/app-configuration/src/generated/models/index.ts index ab5c83290254..f54db4380664 100644 --- a/sdk/appconfiguration/app-configuration/src/generated/models/index.ts +++ b/sdk/appconfiguration/app-configuration/src/generated/models/index.ts @@ -52,7 +52,8 @@ export interface Label { /** * Optional Parameters. */ -export interface ConfigurationClientListConfigurationSettingsOptionalParams extends coreHttp.RequestOptionsBase { +export interface ConfigurationClientListConfigurationSettingsOptionalParams + extends coreHttp.RequestOptionsBase { /** * Filter returned values based on their label. '*' can be used as wildcard in the beginning or * end of the filter @@ -76,7 +77,8 @@ export interface ConfigurationClientListConfigurationSettingsOptionalParams exte /** * Optional Parameters. */ -export interface ConfigurationClientGetConfigurationSettingOptionalParams extends coreHttp.RequestOptionsBase { +export interface ConfigurationClientGetConfigurationSettingOptionalParams + extends coreHttp.RequestOptionsBase { /** * Label of key to retreive. Default value: '%00'. */ @@ -90,7 +92,8 @@ export interface ConfigurationClientGetConfigurationSettingOptionalParams extend /** * Optional Parameters. */ -export interface ConfigurationClientCreateOrUpdateConfigurationSettingOptionalParams extends coreHttp.RequestOptionsBase { +export interface ConfigurationClientCreateOrUpdateConfigurationSettingOptionalParams + extends coreHttp.RequestOptionsBase { /** * Default value: '%00'. */ @@ -100,7 +103,8 @@ export interface ConfigurationClientCreateOrUpdateConfigurationSettingOptionalPa /** * Optional Parameters. */ -export interface ConfigurationClientDeleteConfigurationSettingOptionalParams extends coreHttp.RequestOptionsBase { +export interface ConfigurationClientDeleteConfigurationSettingOptionalParams + extends coreHttp.RequestOptionsBase { label?: string; } @@ -133,21 +137,24 @@ export interface ConfigurationClientListLabelsOptionalParams extends coreHttp.Re /** * Optional Parameters. */ -export interface ConfigurationClientLockConfigurationSettingOptionalParams extends coreHttp.RequestOptionsBase { +export interface ConfigurationClientLockConfigurationSettingOptionalParams + extends coreHttp.RequestOptionsBase { label?: string; } /** * Optional Parameters. */ -export interface ConfigurationClientUnlockConfigurationSettingOptionalParams extends coreHttp.RequestOptionsBase { +export interface ConfigurationClientUnlockConfigurationSettingOptionalParams + extends coreHttp.RequestOptionsBase { label?: string; } /** * Optional Parameters. */ -export interface ConfigurationClientListRevisionsOptionalParams extends coreHttp.RequestOptionsBase { +export interface ConfigurationClientListRevisionsOptionalParams + extends coreHttp.RequestOptionsBase { /** * Filter returned values based on their label. '*' can be used as wildcard in the beginning or * end of the filter @@ -171,7 +178,8 @@ export interface ConfigurationClientListRevisionsOptionalParams extends coreHttp /** * Optional Parameters. */ -export interface ConfigurationClientListConfigurationSettingsNextOptionalParams extends coreHttp.RequestOptionsBase { +export interface ConfigurationClientListConfigurationSettingsNextOptionalParams + extends coreHttp.RequestOptionsBase { /** * Obtain representation of the result related to past time. */ @@ -181,7 +189,8 @@ export interface ConfigurationClientListConfigurationSettingsNextOptionalParams /** * Optional Parameters. */ -export interface ConfigurationClientListRevisionsNextOptionalParams extends coreHttp.RequestOptionsBase { +export interface ConfigurationClientListRevisionsNextOptionalParams + extends coreHttp.RequestOptionsBase { /** * Obtain representation of the result related to past time. */ @@ -240,26 +249,27 @@ export type ListConfigurationSettingsResponse = ConfigurationSettingList & { * The underlying HTTP response. */ _response: coreHttp.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: ConfigurationSettingList; - }; + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: ConfigurationSettingList; + }; }; /** * Contains response data for the getConfigurationSetting operation. */ -export type GetConfigurationSettingResponse = ConfigurationSetting & GetConfigurationSettingHeaders & { - /** - * The underlying HTTP response. - */ - _response: coreHttp.HttpResponse & { +export type GetConfigurationSettingResponse = ConfigurationSetting & + GetConfigurationSettingHeaders & { + /** + * The underlying HTTP response. + */ + _response: coreHttp.HttpResponse & { /** * The parsed HTTP response headers. */ @@ -275,7 +285,7 @@ export type GetConfigurationSettingResponse = ConfigurationSetting & GetConfigur */ parsedBody: ConfigurationSetting; }; -}; + }; /** * Contains response data for the createOrUpdateConfigurationSetting operation. @@ -285,16 +295,16 @@ export type CreateOrUpdateConfigurationSettingResponse = ConfigurationSetting & * The underlying HTTP response. */ _response: coreHttp.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: ConfigurationSetting; - }; + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: ConfigurationSetting; + }; }; /** @@ -305,16 +315,16 @@ export type DeleteConfigurationSettingResponse = ConfigurationSetting & { * The underlying HTTP response. */ _response: coreHttp.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: ConfigurationSetting; - }; + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: ConfigurationSetting; + }; }; /** @@ -325,16 +335,16 @@ export type ListKeysResponse = KeyList & { * The underlying HTTP response. */ _response: coreHttp.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: KeyList; - }; + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: KeyList; + }; }; /** @@ -345,16 +355,16 @@ export type ListLabelsResponse = LabelList & { * The underlying HTTP response. */ _response: coreHttp.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: LabelList; - }; + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: LabelList; + }; }; /** @@ -365,16 +375,16 @@ export type LockConfigurationSettingResponse = ConfigurationSetting & { * The underlying HTTP response. */ _response: coreHttp.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: ConfigurationSetting; - }; + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: ConfigurationSetting; + }; }; /** @@ -385,16 +395,16 @@ export type UnlockConfigurationSettingResponse = ConfigurationSetting & { * The underlying HTTP response. */ _response: coreHttp.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: ConfigurationSetting; - }; + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: ConfigurationSetting; + }; }; /** @@ -405,16 +415,16 @@ export type ListRevisionsResponse = ConfigurationSettingList & { * The underlying HTTP response. */ _response: coreHttp.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: ConfigurationSettingList; - }; + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: ConfigurationSettingList; + }; }; /** @@ -425,16 +435,16 @@ export type ListConfigurationSettingsNextResponse = ConfigurationSettingList & { * The underlying HTTP response. */ _response: coreHttp.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: ConfigurationSettingList; - }; + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: ConfigurationSettingList; + }; }; /** @@ -445,14 +455,14 @@ export type ListRevisionsNextResponse = ConfigurationSettingList & { * The underlying HTTP response. */ _response: coreHttp.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: ConfigurationSettingList; - }; + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: ConfigurationSettingList; + }; }; diff --git a/sdk/appconfiguration/app-configuration/src/generated/models/parameters.ts b/sdk/appconfiguration/app-configuration/src/generated/models/parameters.ts index 9d14e56a6450..28c2692ecd2d 100644 --- a/sdk/appconfiguration/app-configuration/src/generated/models/parameters.ts +++ b/sdk/appconfiguration/app-configuration/src/generated/models/parameters.ts @@ -11,10 +11,7 @@ import * as coreHttp from "@azure/core-http"; export const acceptDateTime: coreHttp.OperationParameter = { - parameterPath: [ - "options", - "acceptDateTime" - ], + parameterPath: ["options", "acceptDateTime"], mapper: { serializedName: "Accept-DateTime", type: { @@ -26,17 +23,14 @@ export const acceptLanguage: coreHttp.OperationParameter = { parameterPath: "acceptLanguage", mapper: { serializedName: "accept-language", - defaultValue: 'en-US', + defaultValue: "en-US", type: { name: "String" } } }; export const fields: coreHttp.OperationQueryParameter = { - parameterPath: [ - "options", - "fields" - ], + parameterPath: ["options", "fields"], mapper: { serializedName: "fields", type: { @@ -51,10 +45,7 @@ export const fields: coreHttp.OperationQueryParameter = { collectionFormat: coreHttp.QueryCollectionFormat.Csv }; export const key0: coreHttp.OperationQueryParameter = { - parameterPath: [ - "options", - "key" - ], + parameterPath: ["options", "key"], mapper: { serializedName: "key", type: { @@ -79,10 +70,7 @@ export const key1: coreHttp.OperationURLParameter = { } }; export const label0: coreHttp.OperationQueryParameter = { - parameterPath: [ - "options", - "label" - ], + parameterPath: ["options", "label"], mapper: { serializedName: "label", constraints: { @@ -100,23 +88,17 @@ export const label0: coreHttp.OperationQueryParameter = { collectionFormat: coreHttp.QueryCollectionFormat.Csv }; export const label1: coreHttp.OperationQueryParameter = { - parameterPath: [ - "options", - "label" - ], + parameterPath: ["options", "label"], mapper: { serializedName: "label", - defaultValue: '%00', + defaultValue: "%00", type: { name: "String" } } }; export const label2: coreHttp.OperationQueryParameter = { - parameterPath: [ - "options", - "label" - ], + parameterPath: ["options", "label"], mapper: { serializedName: "label", type: { @@ -125,10 +107,7 @@ export const label2: coreHttp.OperationQueryParameter = { } }; export const name: coreHttp.OperationQueryParameter = { - parameterPath: [ - "options", - "name" - ], + parameterPath: ["options", "name"], mapper: { serializedName: "name", type: { diff --git a/sdk/appconfiguration/app-configuration/src/index.ts b/sdk/appconfiguration/app-configuration/src/index.ts index 0f15c35bb951..7684ea5b421e 100644 --- a/sdk/appconfiguration/app-configuration/src/index.ts +++ b/sdk/appconfiguration/app-configuration/src/index.ts @@ -13,13 +13,10 @@ import { DeleteConfigurationSettingResponse as ModelDeleteConfigurationSettingResponse, GetConfigurationSettingResponse as ModelGetConfigurationSettingResponse, ListConfigurationSettingsResponse as ModelListConfigurationSettingsResponse, - ListRevisionsResponse as ModelListRevisionsResponse, + ListRevisionsResponse as ModelListRevisionsResponse } from "./generated/models"; -export { - ConfigurationSettingList, - GetConfigurationSettingHeaders -} from "./generated/models"; +export { ConfigurationSettingList, GetConfigurationSettingHeaders } from "./generated/models"; export { ModelConfigurationSetting, @@ -33,7 +30,7 @@ export { ModelGetConfigurationSettingResponse, ModelListConfigurationSettingsResponse, ModelListRevisionsResponse -} +}; const ConnectionStringRegex = /Endpoint=(.*);Id=(.*);Secret=(.*)/; const deserializationContentTypes = { @@ -44,39 +41,70 @@ const deserializationContentTypes = { "application/vnd.microsoft.appconfig.keyset+json", "application/vnd.microsoft.appconfig.revs+json" ] -} +}; export interface ETagOption { + /** + * Entity tag (etag) of the object + */ etag?: string; } -export type AddConfigurationSettingConfig = Pick>; +export type AddConfigurationSettingConfig = Pick< + ModelConfigurationSetting, + Exclude +>; export type AddConfigurationSettingOptions = ModelConfigurationClientCreateOrUpdateConfigurationSettingOptionalParams; export type AddConfigurationSettingsResponse = ModelCreateOrUpdateConfigurationSettingResponse; -export type DeleteConfigurationSettingOptions = ModelConfigurationClientDeleteConfigurationSettingOptionalParams & ETagOption; + +export type DeleteConfigurationSettingOptions = ModelConfigurationClientDeleteConfigurationSettingOptionalParams & + ETagOption; export type DeleteConfigurationSettingResponse = ModelDeleteConfigurationSettingResponse; + export type GetConfigurationSettingOptions = ModelConfigurationClientGetConfigurationSettingOptionalParams; export type GetConfigurationSettingResponse = ModelGetConfigurationSettingResponse; + export type ListConfigurationSettingsOptions = ModelConfigurationClientListConfigurationSettingsOptionalParams; export type ListConfigurationSettingsResponse = ModelListConfigurationSettingsResponse; + export type ListRevisionsOptions = ModelConfigurationClientListRevisionsOptionalParams; export type ListRevisionsResponse = ModelListRevisionsResponse; -export type SetConfigurationSettingConfig = Pick>; + +export type SetConfigurationSettingConfig = Pick< + ModelConfigurationSetting, + Exclude +>; export type SetConfigurationSettingOptions = ModelConfigurationClientCreateOrUpdateConfigurationSettingOptionalParams; export type SetConfigurationSettingResponse = ModelCreateOrUpdateConfigurationSettingResponse; -export type UpdateConfigurationSettingConfig = Pick>; + +export type UpdateConfigurationSettingConfig = Pick< + ModelConfigurationSetting, + Exclude +>; export type UpdateConfigurationSettingOptions = ModelConfigurationClientCreateOrUpdateConfigurationSettingOptionalParams; export type UpdateConfigurationSettingResponse = ModelCreateOrUpdateConfigurationSettingResponse; +/** + * Client for the Azure App Configuration service. + */ export class AppConfigurationClient { private client: ConfigurationClient; + /** + * Initializes a new instance of the AppConfigurationClient class. + * @param connectionString Connection string needed for a client to connect to Azure. + */ constructor(connectionString: string); + /** + * Initializes a new instance of the AppConfigurationClient class. + * @param uri The base URI for the Azure service + * @param credential The credentials to use for authentication. + */ constructor(uri: string, credential: TokenCredential); constructor(uriOrConnectionString: string, credential?: TokenCredential) { const regexMatch = uriOrConnectionString.match(ConnectionStringRegex); if (regexMatch) { - const credential = new AppConfigCredential(regexMatch[2], regexMatch[3]) + const credential = new AppConfigCredential(regexMatch[2], regexMatch[3]); this.client = new ConfigurationClient(credential, { baseUri: regexMatch[1], deserializationContentTypes @@ -85,13 +113,31 @@ export class AppConfigurationClient { this.client = new ConfigurationClient(credential, { baseUri: uriOrConnectionString, deserializationContentTypes - }) + }); } else { - throw new Error("You must provide either a connection string or a URL and a ManagedIdentityCredential.") + throw new Error( + "You must provide either a connection string or a URL and a ManagedIdentityCredential." + ); } } - addConfigurationSetting(key: string, configSettings: AddConfigurationSettingConfig, options: AddConfigurationSettingOptions = {}): Promise { + /** + * Add a setting into the Azure App Configuration service, failing if it + * already exists. + * + * Example usage: + * ```ts + * const result = await client.addConfigurationSetting("MyKey", { label: "MyLabel", value: "MyValue" }); + * ``` + * @param key The name of the key. + * @param configSettings A configuration value. + * @param options Optional parameters for the request. + */ + addConfigurationSetting( + key: string, + configSettings: AddConfigurationSettingConfig, + options: AddConfigurationSettingOptions = {} + ): Promise { // add the custom header if-none-match=* to only add the key-value if it doesn't already exist // create a copy of the options to avoid modifying the user's options options = { ...options }; @@ -105,7 +151,20 @@ export class AppConfigurationClient { return this.client.createOrUpdateConfigurationSetting(configSettings, key, options); } - deleteConfigurationSetting(key: string, options: DeleteConfigurationSettingOptions): Promise { + /** + * Delete a setting from the Azure App Configuration service + * + * Example usage: + * ```ts + * const deletedSetting = await client.deleteConfigurationSetting("MyKey", { label: "MyLabel" }); + * ``` + * @param key The name of the key. + * @param options Optional parameters for the request. + */ + deleteConfigurationSetting( + key: string, + options: DeleteConfigurationSettingOptions + ): Promise { // hoist the etag into a custom header to ensure this update fails if the setting has been updated options = { ...options }; const customHeaders: typeof options.customHeaders = { ...options.customHeaders }; @@ -118,19 +177,68 @@ export class AppConfigurationClient { return this.client.deleteConfigurationSetting(key, options); } - getConfigurationSetting(key: string, options?: GetConfigurationSettingOptions): Promise { + /** + * Gets a setting from the Azure App Configuration service. + * + * Example code: + * ```ts + * const setting = await client.getConfigurationSetting("MyKey", { label: "MyLabel" }); + * ``` + * @param key The name of the key. + * @param options Optional parameters for the request. + */ + getConfigurationSetting( + key: string, + options?: GetConfigurationSettingOptions + ): Promise { return this.client.getConfigurationSetting(key, options); } - listConfigurationSettings(options?: ListConfigurationSettingsOptions): Promise { + /** + * Lists settings from the Azure App Configuration service, optionally filtered by label, + * accept date time or name. + * + * Example code: + * ```ts + * const allSettingsWithLabel = await client.listConfigurationSettings({ label: "MyLabel" }); + * ``` + * @param options Optional parameters for the request. + */ + listConfigurationSettings( + options?: ListConfigurationSettingsOptions + ): Promise { return this.client.listConfigurationSettings(options); } + /** + * Lists revisions of a set of keys within the Azure App Configuration service. + * + * Example code: + * ```ts + * const revisionsForMyKey = await client.listRevisions({ key: ["MyKey"] }); + * ``` + * @param options Optional parameters for the request. + */ listRevisions(options?: ListRevisionsOptions): Promise { return this.client.listRevisions(options); } - setConfigurationSetting(key: string, configSettings: SetConfigurationSettingConfig, options: SetConfigurationSettingOptions = {}): Promise { + /** + * Sets the value of a key in the Azure App Configuration service, allowing for an optional etag. + * @param key The name of the key. + * @param configSettings A configuration value. + * @param options Optional parameters for the request. + * + * Example code: + * ```ts + * let result = await client.setConfigurationSetting("MyKey", { value: "MyValue" }); + * ``` + */ + setConfigurationSetting( + key: string, + configSettings: SetConfigurationSettingConfig, + options: SetConfigurationSettingOptions = {} + ): Promise { // hoist the etag into a custom header to ensure this update fails if the setting has been updated options = { ...options }; @@ -145,10 +253,28 @@ export class AppConfigurationClient { if (configSettings.label) { options.label = configSettings.label; } - return this.client.createOrUpdateConfigurationSetting(configSettings, key, { ...options, customHeaders }); + return this.client.createOrUpdateConfigurationSetting(configSettings, key, { + ...options, + customHeaders + }); } - async updateConfigurationSetting(key: string, configSettings: UpdateConfigurationSettingConfig, options: UpdateConfigurationSettingOptions = {}): Promise { + /** + * Updates the value of a key in the Azure App Configuration service. + * + * Example code: + * ```ts + * await client.updateConfigurationSetting("MyKey", { label: "MyLabel", value: "MyValue" }); + * ``` + * @param key The name of the key. + * @param configSettings A configuration value. + * @param options Optional parameters for the request. + */ + async updateConfigurationSetting( + key: string, + configSettings: UpdateConfigurationSettingConfig, + options: UpdateConfigurationSettingOptions = {} + ): Promise { // retrieve existing configuration, and populate configSettings for missing fields that aren't null const existingConfigurationSettings = await this.getConfigurationSetting(key, { abortSignal: options.abortSignal, @@ -156,6 +282,7 @@ export class AppConfigurationClient { }); const updateConfigSettings = { ...configSettings }; + if (typeof updateConfigSettings.value === "undefined") { updateConfigSettings.value = existingConfigurationSettings.value; } diff --git a/sdk/appconfiguration/app-configuration/test/index.spec.ts b/sdk/appconfiguration/app-configuration/test/index.spec.ts index 3816cb007f0f..fc410fea43c5 100644 --- a/sdk/appconfiguration/app-configuration/test/index.spec.ts +++ b/sdk/appconfiguration/app-configuration/test/index.spec.ts @@ -8,7 +8,7 @@ import { AppConfigurationClient } from "../src"; dotenv.config(); describe("AppConfigurationClient", () => { - const settings: Array<{ key: string, label?: string }> = []; + const settings: Array<{ key: string; label?: string }> = []; const connectionString: string = process.env["APPCONFIG_CONNECTION_STRING"]!; let client: AppConfigurationClient; @@ -35,17 +35,34 @@ describe("AppConfigurationClient", () => { }); describe("addConfigurationSetting", () => { + it("sample works", async () => { + const key = `addConfigSample-${Date.now()}`; + let result = await client.setConfigurationSetting(key, { + value: "MyValue" + }); + + assert.equal(key, result.key); + }); + it("adds a configuration setting", async () => { const key = `addConfigTest-${Date.now()}`; - const label = "test"; - const value = "foo"; + const label = "MyLabel"; + const value = "MyValue"; const result = await client.addConfigurationSetting(key, { label, value }); settings.push({ key, label }); assert.equal(result.key, key, "Unexpected key in result from addConfigurationSetting()."); - assert.equal(result.label, label, "Unexpected label in result from addConfigurationSetting()."); - assert.equal(result.value, value, "Unexpected value in result from addConfigurationSetting()."); + assert.equal( + result.label, + label, + "Unexpected label in result from addConfigurationSetting()." + ); + assert.equal( + result.value, + value, + "Unexpected value in result from addConfigurationSetting()." + ); }); it("throws an error if the configuration setting already exists", async () => { @@ -57,8 +74,16 @@ describe("AppConfigurationClient", () => { settings.push({ key, label }); assert.equal(result.key, key, "Unexpected key in result from addConfigurationSetting()."); - assert.equal(result.label, label, "Unexpected label in result from addConfigurationSetting()."); - assert.equal(result.value, value, "Unexpected value in result from addConfigurationSetting()."); + assert.equal( + result.label, + label, + "Unexpected label in result from addConfigurationSetting()." + ); + assert.equal( + result.value, + value, + "Unexpected value in result from addConfigurationSetting()." + ); // attempt to add the same setting try { @@ -73,21 +98,41 @@ describe("AppConfigurationClient", () => { describe("deleteConfigurationSetting", () => { it("deletes an existing configuration setting", async () => { const key = `deleteConfigTest-${Date.now()}`; - const label = "test"; - const value = "foo"; + const label = "MyLabel"; + const value = "MyValue"; // create configuration const result = await client.addConfigurationSetting(key, { label, value }); assert.equal(result.key, key, "Unexpected key in result from addConfigurationSetting()."); - assert.equal(result.label, label, "Unexpected label in result from addConfigurationSetting()."); - assert.equal(result.value, value, "Unexpected value in result from addConfigurationSetting()."); + assert.equal( + result.label, + label, + "Unexpected label in result from addConfigurationSetting()." + ); + assert.equal( + result.value, + value, + "Unexpected value in result from addConfigurationSetting()." + ); // delete configuration const deletedSetting = await client.deleteConfigurationSetting(key, { label }); - assert.equal(deletedSetting.key, key, "Unexpected key in result from deleteConfigurationSetting()."); - assert.equal(deletedSetting.label, label, "Unexpected label in result from deleteConfigurationSetting()."); - assert.equal(deletedSetting.value, value, "Unexpected value in result from deleteConfigurationSetting()."); + assert.equal( + deletedSetting.key, + key, + "Unexpected key in result from deleteConfigurationSetting()." + ); + assert.equal( + deletedSetting.label, + label, + "Unexpected label in result from deleteConfigurationSetting()." + ); + assert.equal( + deletedSetting.value, + value, + "Unexpected value in result from deleteConfigurationSetting()." + ); // confirm setting no longer exists try { @@ -107,14 +152,37 @@ describe("AppConfigurationClient", () => { const result = await client.addConfigurationSetting(key, { label, value }); assert.equal(result.key, key, "Unexpected key in result from addConfigurationSetting()."); - assert.equal(result.label, label, "Unexpected label in result from addConfigurationSetting()."); - assert.equal(result.value, value, "Unexpected value in result from addConfigurationSetting()."); + assert.equal( + result.label, + label, + "Unexpected label in result from addConfigurationSetting()." + ); + assert.equal( + result.value, + value, + "Unexpected value in result from addConfigurationSetting()." + ); // delete configuration - const deletedSetting = await client.deleteConfigurationSetting(key, { label, etag: result.etag }); - assert.equal(deletedSetting.key, key, "Unexpected key in result from deleteConfigurationSetting()."); - assert.equal(deletedSetting.label, label, "Unexpected label in result from deleteConfigurationSetting()."); - assert.equal(deletedSetting.value, value, "Unexpected value in result from deleteConfigurationSetting()."); + const deletedSetting = await client.deleteConfigurationSetting(key, { + label, + etag: result.etag + }); + assert.equal( + deletedSetting.key, + key, + "Unexpected key in result from deleteConfigurationSetting()." + ); + assert.equal( + deletedSetting.label, + label, + "Unexpected label in result from deleteConfigurationSetting()." + ); + assert.equal( + deletedSetting.value, + value, + "Unexpected value in result from deleteConfigurationSetting()." + ); // confirm setting no longer exists try { @@ -142,8 +210,16 @@ describe("AppConfigurationClient", () => { const result = await client.addConfigurationSetting(key, { label, value }); assert.equal(result.key, key, "Unexpected key in result from addConfigurationSetting()."); - assert.equal(result.label, label, "Unexpected label in result from addConfigurationSetting()."); - assert.equal(result.value, value, "Unexpected value in result from addConfigurationSetting()."); + assert.equal( + result.label, + label, + "Unexpected label in result from addConfigurationSetting()." + ); + assert.equal( + result.value, + value, + "Unexpected value in result from addConfigurationSetting()." + ); settings.push({ key, label }); @@ -155,7 +231,6 @@ describe("AppConfigurationClient", () => { assert.notEqual(err.message, "Test failure"); } }); - }); describe("getConfigurationSetting", () => { @@ -175,22 +250,74 @@ describe("AppConfigurationClient", () => { settings.push({ key, label }); assert.equal(result.key, key, "Unexpected key in result from addConfigurationSetting()."); - assert.equal(result.label, label, "Unexpected label in result from addConfigurationSetting()."); - assert.equal(result.value, value, "Unexpected value in result from addConfigurationSetting()."); - assert.equal(result.lastModified instanceof Date, true, "Unexpected lastModified in result from addConfigurationSetting()."); - assert.equal(result.locked, false, "Unexpected locked in result from addConfigurationSetting()."); - assert.deepEqual(result.tags, tags, "Unexpected tags in result from addConfigurationSetting()."); - assert.equal(result.contentType, contentType, "Unexpected contentType in result from addConfigurationSetting()."); + assert.equal( + result.label, + label, + "Unexpected label in result from addConfigurationSetting()." + ); + assert.equal( + result.value, + value, + "Unexpected value in result from addConfigurationSetting()." + ); + assert.equal( + result.lastModified instanceof Date, + true, + "Unexpected lastModified in result from addConfigurationSetting()." + ); + assert.equal( + result.locked, + false, + "Unexpected locked in result from addConfigurationSetting()." + ); + assert.deepEqual( + result.tags, + tags, + "Unexpected tags in result from addConfigurationSetting()." + ); + assert.equal( + result.contentType, + contentType, + "Unexpected contentType in result from addConfigurationSetting()." + ); // retrieve the value from the service const remoteResult = await client.getConfigurationSetting(key, { label }); - assert.equal(remoteResult.key, key, "Unexpected key in result from getConfigurationSetting()."); - assert.equal(remoteResult.label, label, "Unexpected label in result from getConfigurationSetting()."); - assert.equal(remoteResult.value, value, "Unexpected value in result from getConfigurationSetting()."); - assert.equal(remoteResult.lastModified instanceof Date, true, "Unexpected lastModified in result from getConfigurationSetting()."); - assert.equal(remoteResult.locked, false, "Unexpected locked in result from getConfigurationSetting()."); - assert.deepEqual(remoteResult.tags, tags, "Unexpected tags in result from getConfigurationSetting()."); - assert.equal(remoteResult.contentType, contentType, "Unexpected contentType in result from getConfigurationSetting()."); + assert.equal( + remoteResult.key, + key, + "Unexpected key in result from getConfigurationSetting()." + ); + assert.equal( + remoteResult.label, + label, + "Unexpected label in result from getConfigurationSetting()." + ); + assert.equal( + remoteResult.value, + value, + "Unexpected value in result from getConfigurationSetting()." + ); + assert.equal( + remoteResult.lastModified instanceof Date, + true, + "Unexpected lastModified in result from getConfigurationSetting()." + ); + assert.equal( + remoteResult.locked, + false, + "Unexpected locked in result from getConfigurationSetting()." + ); + assert.deepEqual( + remoteResult.tags, + tags, + "Unexpected tags in result from getConfigurationSetting()." + ); + assert.equal( + remoteResult.contentType, + contentType, + "Unexpected contentType in result from getConfigurationSetting()." + ); }); it("throws when retrieving a non-existent configuration setting", async () => { @@ -228,15 +355,26 @@ describe("AppConfigurationClient", () => { assert.equal(results.length, keys.length); // sort keys to make assertions easier - results.sort((a, b) => a.key! < b.key! ? -1 : 1); + results.sort((a, b) => (a.key! < b.key! ? -1 : 1)); for (let i = 0; i < keys.length; i++) { - assert.equal(results[i].key, keys[i], "Unexpected key in result from listConfigurationSettings()."); - assert.equal(results[i].label, label, "Unexpected label in result from listConfigurationSettings()."); - assert.equal(results[i].value, value, "Unexpected value in result from listConfigurationSettings()."); + assert.equal( + results[i].key, + keys[i], + "Unexpected key in result from listConfigurationSettings()." + ); + assert.equal( + results[i].label, + label, + "Unexpected label in result from listConfigurationSettings()." + ); + assert.equal( + results[i].value, + value, + "Unexpected value in result from listConfigurationSettings()." + ); } }); - }); describe("listRevisions", () => { it("lists revisions for a configuration setting", async () => { @@ -251,6 +389,21 @@ describe("AppConfigurationClient", () => { assert.equal(result.length, 2); }); + + it("sample code works", async () => { + const key = `listRevisionsSample-${Date.now()}`; + + // create a new setting + await client.addConfigurationSetting(key, { value: "foo1" }); + + // update it with a new value + await client.setConfigurationSetting(key, { value: "foo2" }); + + // retrieves all revisions matching that label + const result = await client.listRevisions({ key: [key] }); + + assert.equal(result.length, 2); + }); }); describe("setConfigurationSetting", () => { @@ -264,27 +417,84 @@ describe("AppConfigurationClient", () => { }; // create configuration - const result = await client.addConfigurationSetting(key, { label, value: "foo", contentType, tags }); + const result = await client.addConfigurationSetting(key, { + label, + value: "foo", + contentType, + tags + }); settings.push({ key, label }); assert.equal(result.key, key, "Unexpected key in result from addConfigurationSetting()."); - assert.equal(result.label, label, "Unexpected label in result from addConfigurationSetting()."); - assert.equal(result.value, "foo", "Unexpected value in result from addConfigurationSetting()."); - assert.equal(result.lastModified instanceof Date, true, "Unexpected lastModified in result from addConfigurationSetting()."); - assert.equal(result.locked, false, "Unexpected locked in result from addConfigurationSetting()."); - assert.deepEqual(result.tags, tags, "Unexpected tags in result from addConfigurationSetting()."); - assert.equal(result.contentType, contentType, "Unexpected contentType in result from addConfigurationSetting()."); + assert.equal( + result.label, + label, + "Unexpected label in result from addConfigurationSetting()." + ); + assert.equal( + result.value, + "foo", + "Unexpected value in result from addConfigurationSetting()." + ); + assert.equal( + result.lastModified instanceof Date, + true, + "Unexpected lastModified in result from addConfigurationSetting()." + ); + assert.equal( + result.locked, + false, + "Unexpected locked in result from addConfigurationSetting()." + ); + assert.deepEqual( + result.tags, + tags, + "Unexpected tags in result from addConfigurationSetting()." + ); + assert.equal( + result.contentType, + contentType, + "Unexpected contentType in result from addConfigurationSetting()." + ); const replacedResult = await client.setConfigurationSetting(key, { label, value: "foo2" }); - assert.equal(replacedResult.key, key, "Unexpected key in result from setConfigurationSetting()."); - assert.equal(replacedResult.label, label, "Unexpected label in result from setConfigurationSetting()."); - assert.equal(replacedResult.value, "foo2", "Unexpected value in result from setConfigurationSetting()."); - assert.equal(replacedResult.lastModified instanceof Date, true, "Unexpected lastModified in result from setConfigurationSetting()."); - assert.equal(replacedResult.locked, false, "Unexpected locked in result from setConfigurationSetting()."); - assert.deepEqual(replacedResult.tags, {}, "Unexpected tags in result from setConfigurationSetting()."); - assert.strictEqual(replacedResult.contentType, null, "Unexpected contentType in result from setConfigurationSetting()."); + assert.equal( + replacedResult.key, + key, + "Unexpected key in result from setConfigurationSetting()." + ); + assert.equal( + replacedResult.label, + label, + "Unexpected label in result from setConfigurationSetting()." + ); + assert.equal( + replacedResult.value, + "foo2", + "Unexpected value in result from setConfigurationSetting()." + ); + assert.equal( + replacedResult.lastModified instanceof Date, + true, + "Unexpected lastModified in result from setConfigurationSetting()." + ); + assert.equal( + replacedResult.locked, + false, + "Unexpected locked in result from setConfigurationSetting()." + ); + assert.deepEqual( + replacedResult.tags, + {}, + "Unexpected tags in result from setConfigurationSetting()." + ); + assert.strictEqual( + replacedResult.contentType, + null, + "Unexpected contentType in result from setConfigurationSetting()." + ); }); it("replaces a configuration setting (valid etag)", async () => { @@ -297,27 +507,88 @@ describe("AppConfigurationClient", () => { }; // create configuration - const result = await client.addConfigurationSetting(key, { label, value: "foo", contentType, tags }); + const result = await client.addConfigurationSetting(key, { + label, + value: "foo", + contentType, + tags + }); settings.push({ key, label }); assert.equal(result.key, key, "Unexpected key in result from addConfigurationSetting()."); - assert.equal(result.label, label, "Unexpected label in result from addConfigurationSetting()."); - assert.equal(result.value, "foo", "Unexpected value in result from addConfigurationSetting()."); - assert.equal(result.lastModified instanceof Date, true, "Unexpected lastModified in result from addConfigurationSetting()."); - assert.equal(result.locked, false, "Unexpected locked in result from addConfigurationSetting()."); - assert.deepEqual(result.tags, tags, "Unexpected tags in result from addConfigurationSetting()."); - assert.equal(result.contentType, contentType, "Unexpected contentType in result from addConfigurationSetting()."); - - const replacedResult = await client.setConfigurationSetting(key, { label, value: "foo2", etag: result.etag }); - - assert.equal(replacedResult.key, key, "Unexpected key in result from setConfigurationSetting()."); - assert.equal(replacedResult.label, label, "Unexpected label in result from setConfigurationSetting()."); - assert.equal(replacedResult.value, "foo2", "Unexpected value in result from setConfigurationSetting()."); - assert.equal(replacedResult.lastModified instanceof Date, true, "Unexpected lastModified in result from setConfigurationSetting()."); - assert.equal(replacedResult.locked, false, "Unexpected locked in result from setConfigurationSetting()."); - assert.deepEqual(replacedResult.tags, {}, "Unexpected tags in result from setConfigurationSetting()."); - assert.strictEqual(replacedResult.contentType, null, "Unexpected contentType in result from setConfigurationSetting()."); + assert.equal( + result.label, + label, + "Unexpected label in result from addConfigurationSetting()." + ); + assert.equal( + result.value, + "foo", + "Unexpected value in result from addConfigurationSetting()." + ); + assert.equal( + result.lastModified instanceof Date, + true, + "Unexpected lastModified in result from addConfigurationSetting()." + ); + assert.equal( + result.locked, + false, + "Unexpected locked in result from addConfigurationSetting()." + ); + assert.deepEqual( + result.tags, + tags, + "Unexpected tags in result from addConfigurationSetting()." + ); + assert.equal( + result.contentType, + contentType, + "Unexpected contentType in result from addConfigurationSetting()." + ); + + const replacedResult = await client.setConfigurationSetting(key, { + label, + value: "foo2", + etag: result.etag + }); + + assert.equal( + replacedResult.key, + key, + "Unexpected key in result from setConfigurationSetting()." + ); + assert.equal( + replacedResult.label, + label, + "Unexpected label in result from setConfigurationSetting()." + ); + assert.equal( + replacedResult.value, + "foo2", + "Unexpected value in result from setConfigurationSetting()." + ); + assert.equal( + replacedResult.lastModified instanceof Date, + true, + "Unexpected lastModified in result from setConfigurationSetting()." + ); + assert.equal( + replacedResult.locked, + false, + "Unexpected locked in result from setConfigurationSetting()." + ); + assert.deepEqual( + replacedResult.tags, + {}, + "Unexpected tags in result from setConfigurationSetting()." + ); + assert.strictEqual( + replacedResult.contentType, + null, + "Unexpected contentType in result from setConfigurationSetting()." + ); }); it("creates a configuration setting if it doesn't exist", async () => { @@ -327,12 +598,36 @@ describe("AppConfigurationClient", () => { const result = await client.setConfigurationSetting(key, { label, value: "foo" }); assert.equal(result.key, key, "Unexpected key in result from setConfigurationSetting()."); - assert.equal(result.label, label, "Unexpected label in result from setConfigurationSetting()."); - assert.equal(result.value, value, "Unexpected value in result from setConfigurationSetting()."); - assert.equal(result.lastModified instanceof Date, true, "Unexpected lastModified in result from setConfigurationSetting()."); - assert.equal(result.locked, false, "Unexpected locked in result from setConfigurationSetting()."); - assert.deepEqual(result.tags, {}, "Unexpected tags in result from setConfigurationSetting()."); - assert.strictEqual(result.contentType, null, "Unexpected contentType in result from setConfigurationSetting()."); + assert.equal( + result.label, + label, + "Unexpected label in result from setConfigurationSetting()." + ); + assert.equal( + result.value, + value, + "Unexpected value in result from setConfigurationSetting()." + ); + assert.equal( + result.lastModified instanceof Date, + true, + "Unexpected lastModified in result from setConfigurationSetting()." + ); + assert.equal( + result.locked, + false, + "Unexpected locked in result from setConfigurationSetting()." + ); + assert.deepEqual( + result.tags, + {}, + "Unexpected tags in result from setConfigurationSetting()." + ); + assert.strictEqual( + result.contentType, + null, + "Unexpected contentType in result from setConfigurationSetting()." + ); }); it("throws when replacing a configuration setting (invalid etag)", async () => { @@ -345,17 +640,46 @@ describe("AppConfigurationClient", () => { }; // create configuration - const result = await client.addConfigurationSetting(key, { label, value: "foo", contentType, tags }); + const result = await client.addConfigurationSetting(key, { + label, + value: "foo", + contentType, + tags + }); settings.push({ key, label }); assert.equal(result.key, key, "Unexpected key in result from addConfigurationSetting()."); - assert.equal(result.label, label, "Unexpected label in result from addConfigurationSetting()."); - assert.equal(result.value, "foo", "Unexpected value in result from addConfigurationSetting()."); - assert.equal(result.lastModified instanceof Date, true, "Unexpected lastModified in result from addConfigurationSetting()."); - assert.equal(result.locked, false, "Unexpected locked in result from addConfigurationSetting()."); - assert.deepEqual(result.tags, tags, "Unexpected tags in result from addConfigurationSetting()."); - assert.equal(result.contentType, contentType, "Unexpected contentType in result from addConfigurationSetting()."); + assert.equal( + result.label, + label, + "Unexpected label in result from addConfigurationSetting()." + ); + assert.equal( + result.value, + "foo", + "Unexpected value in result from addConfigurationSetting()." + ); + assert.equal( + result.lastModified instanceof Date, + true, + "Unexpected lastModified in result from addConfigurationSetting()." + ); + assert.equal( + result.locked, + false, + "Unexpected locked in result from addConfigurationSetting()." + ); + assert.deepEqual( + result.tags, + tags, + "Unexpected tags in result from addConfigurationSetting()." + ); + assert.equal( + result.contentType, + contentType, + "Unexpected contentType in result from addConfigurationSetting()." + ); try { await client.setConfigurationSetting(key, { label, value: "foo2", etag: "incorrect" }); @@ -377,27 +701,84 @@ describe("AppConfigurationClient", () => { }; // create configuration - const result = await client.addConfigurationSetting(key, { label, value: "foo", contentType, tags }); + const result = await client.addConfigurationSetting(key, { + label, + value: "foo", + contentType, + tags + }); settings.push({ key, label }); assert.equal(result.key, key, "Unexpected key in result from addConfigurationSetting()."); - assert.equal(result.label, label, "Unexpected label in result from addConfigurationSetting()."); - assert.equal(result.value, "foo", "Unexpected value in result from addConfigurationSetting()."); - assert.equal(result.lastModified instanceof Date, true, "Unexpected lastModified in result from addConfigurationSetting()."); - assert.equal(result.locked, false, "Unexpected locked in result from addConfigurationSetting()."); - assert.deepEqual(result.tags, tags, "Unexpected tags in result from addConfigurationSetting()."); - assert.equal(result.contentType, contentType, "Unexpected contentType in result from addConfigurationSetting()."); + assert.equal( + result.label, + label, + "Unexpected label in result from addConfigurationSetting()." + ); + assert.equal( + result.value, + "foo", + "Unexpected value in result from addConfigurationSetting()." + ); + assert.equal( + result.lastModified instanceof Date, + true, + "Unexpected lastModified in result from addConfigurationSetting()." + ); + assert.equal( + result.locked, + false, + "Unexpected locked in result from addConfigurationSetting()." + ); + assert.deepEqual( + result.tags, + tags, + "Unexpected tags in result from addConfigurationSetting()." + ); + assert.equal( + result.contentType, + contentType, + "Unexpected contentType in result from addConfigurationSetting()." + ); const updatedResult = await client.updateConfigurationSetting(key, { label, value: "foo2" }); - assert.equal(updatedResult.key, key, "Unexpected key in result from updateConfigurationSetting()."); - assert.equal(updatedResult.label, label, "Unexpected label in result from updateConfigurationSetting()."); - assert.equal(updatedResult.value, "foo2", "Unexpected value in result from updateConfigurationSetting()."); - assert.equal(updatedResult.lastModified instanceof Date, true, "Unexpected lastModified in result from updateConfigurationSetting()."); - assert.equal(updatedResult.locked, false, "Unexpected locked in result from updateConfigurationSetting()."); - assert.deepEqual(updatedResult.tags, tags, "Unexpected tags in result from updateConfigurationSetting()."); - assert.strictEqual(updatedResult.contentType, contentType, "Unexpected contentType in result from updateConfigurationSetting()."); + assert.equal( + updatedResult.key, + key, + "Unexpected key in result from updateConfigurationSetting()." + ); + assert.equal( + updatedResult.label, + label, + "Unexpected label in result from updateConfigurationSetting()." + ); + assert.equal( + updatedResult.value, + "foo2", + "Unexpected value in result from updateConfigurationSetting()." + ); + assert.equal( + updatedResult.lastModified instanceof Date, + true, + "Unexpected lastModified in result from updateConfigurationSetting()." + ); + assert.equal( + updatedResult.locked, + false, + "Unexpected locked in result from updateConfigurationSetting()." + ); + assert.deepEqual( + updatedResult.tags, + tags, + "Unexpected tags in result from updateConfigurationSetting()." + ); + assert.strictEqual( + updatedResult.contentType, + contentType, + "Unexpected contentType in result from updateConfigurationSetting()." + ); }); it("updates an existing configuration setting (valid etag)", async () => { @@ -410,27 +791,88 @@ describe("AppConfigurationClient", () => { }; // create configuration - const result = await client.addConfigurationSetting(key, { label, value: "foo", contentType, tags }); + const result = await client.addConfigurationSetting(key, { + label, + value: "foo", + contentType, + tags + }); settings.push({ key, label }); assert.equal(result.key, key, "Unexpected key in result from addConfigurationSetting()."); - assert.equal(result.label, label, "Unexpected label in result from addConfigurationSetting()."); - assert.equal(result.value, "foo", "Unexpected value in result from addConfigurationSetting()."); - assert.equal(result.lastModified instanceof Date, true, "Unexpected lastModified in result from addConfigurationSetting()."); - assert.equal(result.locked, false, "Unexpected locked in result from addConfigurationSetting()."); - assert.deepEqual(result.tags, tags, "Unexpected tags in result from addConfigurationSetting()."); - assert.equal(result.contentType, contentType, "Unexpected contentType in result from addConfigurationSetting()."); - - const updatedResult = await client.updateConfigurationSetting(key, { label, value: "foo2", etag: result.etag }); - - assert.equal(updatedResult.key, key, "Unexpected key in result from updateConfigurationSetting()."); - assert.equal(updatedResult.label, label, "Unexpected label in result from updateConfigurationSetting()."); - assert.equal(updatedResult.value, "foo2", "Unexpected value in result from updateConfigurationSetting()."); - assert.equal(updatedResult.lastModified instanceof Date, true, "Unexpected lastModified in result from updateConfigurationSetting()."); - assert.equal(updatedResult.locked, false, "Unexpected locked in result from updateConfigurationSetting()."); - assert.deepEqual(updatedResult.tags, tags, "Unexpected tags in result from updateConfigurationSetting()."); - assert.strictEqual(updatedResult.contentType, contentType, "Unexpected contentType in result from updateConfigurationSetting()."); + assert.equal( + result.label, + label, + "Unexpected label in result from addConfigurationSetting()." + ); + assert.equal( + result.value, + "foo", + "Unexpected value in result from addConfigurationSetting()." + ); + assert.equal( + result.lastModified instanceof Date, + true, + "Unexpected lastModified in result from addConfigurationSetting()." + ); + assert.equal( + result.locked, + false, + "Unexpected locked in result from addConfigurationSetting()." + ); + assert.deepEqual( + result.tags, + tags, + "Unexpected tags in result from addConfigurationSetting()." + ); + assert.equal( + result.contentType, + contentType, + "Unexpected contentType in result from addConfigurationSetting()." + ); + + const updatedResult = await client.updateConfigurationSetting(key, { + label, + value: "foo2", + etag: result.etag + }); + + assert.equal( + updatedResult.key, + key, + "Unexpected key in result from updateConfigurationSetting()." + ); + assert.equal( + updatedResult.label, + label, + "Unexpected label in result from updateConfigurationSetting()." + ); + assert.equal( + updatedResult.value, + "foo2", + "Unexpected value in result from updateConfigurationSetting()." + ); + assert.equal( + updatedResult.lastModified instanceof Date, + true, + "Unexpected lastModified in result from updateConfigurationSetting()." + ); + assert.equal( + updatedResult.locked, + false, + "Unexpected locked in result from updateConfigurationSetting()." + ); + assert.deepEqual( + updatedResult.tags, + tags, + "Unexpected tags in result from updateConfigurationSetting()." + ); + assert.strictEqual( + updatedResult.contentType, + contentType, + "Unexpected contentType in result from updateConfigurationSetting()." + ); }); it("throws when updating a non-existent configuration setting", async () => { @@ -455,17 +897,46 @@ describe("AppConfigurationClient", () => { }; // create configuration - const result = await client.addConfigurationSetting(key, { label, value: "foo", contentType, tags }); + const result = await client.addConfigurationSetting(key, { + label, + value: "foo", + contentType, + tags + }); settings.push({ key, label }); assert.equal(result.key, key, "Unexpected key in result from addConfigurationSetting()."); - assert.equal(result.label, label, "Unexpected label in result from addConfigurationSetting()."); - assert.equal(result.value, "foo", "Unexpected value in result from addConfigurationSetting()."); - assert.equal(result.lastModified instanceof Date, true, "Unexpected lastModified in result from addConfigurationSetting()."); - assert.equal(result.locked, false, "Unexpected locked in result from addConfigurationSetting()."); - assert.deepEqual(result.tags, tags, "Unexpected tags in result from addConfigurationSetting()."); - assert.equal(result.contentType, contentType, "Unexpected contentType in result from addConfigurationSetting()."); + assert.equal( + result.label, + label, + "Unexpected label in result from addConfigurationSetting()." + ); + assert.equal( + result.value, + "foo", + "Unexpected value in result from addConfigurationSetting()." + ); + assert.equal( + result.lastModified instanceof Date, + true, + "Unexpected lastModified in result from addConfigurationSetting()." + ); + assert.equal( + result.locked, + false, + "Unexpected locked in result from addConfigurationSetting()." + ); + assert.deepEqual( + result.tags, + tags, + "Unexpected tags in result from addConfigurationSetting()." + ); + assert.equal( + result.contentType, + contentType, + "Unexpected contentType in result from addConfigurationSetting()." + ); try { await client.updateConfigurationSetting(key, { label, value: "foo2", etag: "incorrect" }); diff --git a/sdk/appconfiguration/app-configuration/tsconfig.json b/sdk/appconfiguration/app-configuration/tsconfig.json index c2b3a3953063..d13e7b6390a3 100644 --- a/sdk/appconfiguration/app-configuration/tsconfig.json +++ b/sdk/appconfiguration/app-configuration/tsconfig.json @@ -15,13 +15,6 @@ "importHelpers": true, "newLine": "LF" }, - "exclude": [ - "node_modules", - "types/**", - "./samples/**/*.ts" - ], - "include": [ - "./src/**/*.ts", - "./test/**/*.ts" - ] + "exclude": ["node_modules", "types/**", "./samples/**/*.ts"], + "include": ["./src/**/*.ts", "./test/**/*.ts"] }