UNPKG

@azure/template

Version:
1,590 lines (1,576 loc) • 43.7 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var coreHttp = require('@azure/core-http'); var coreTracing = require('@azure/core-tracing'); var logger$1 = require('@azure/logger'); // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. const SDK_VERSION = "1.0.11-beta.1"; // Copyright (c) Microsoft Corporation. /** * The \@azure/logger configuration for this package. * * @internal */ const logger = logger$1.createClientLogger("template"); /* * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. * * Code generated by Microsoft (R) AutoRest Code Generator. * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ const KeyListResult = { type: { name: "Composite", className: "KeyListResult", modelProperties: { items: { serializedName: "items", type: { name: "Sequence", element: { type: { name: "Composite", className: "Key" } } } }, nextLink: { serializedName: "@nextLink", type: { name: "String" } } } } }; const Key = { type: { name: "Composite", className: "Key", modelProperties: { name: { serializedName: "name", readOnly: true, type: { name: "String" } } } } }; const ErrorModel = { type: { name: "Composite", className: "ErrorModel", modelProperties: { type: { serializedName: "type", type: { name: "String" } }, title: { serializedName: "title", type: { name: "String" } }, name: { serializedName: "name", type: { name: "String" } }, detail: { serializedName: "detail", type: { name: "String" } }, status: { serializedName: "status", type: { name: "Number" } } } } }; const KeyValueListResult = { type: { name: "Composite", className: "KeyValueListResult", modelProperties: { items: { serializedName: "items", type: { name: "Sequence", element: { type: { name: "Composite", className: "ConfigurationSetting" } } } }, nextLink: { serializedName: "@nextLink", type: { name: "String" } } } } }; const ConfigurationSetting = { type: { name: "Composite", className: "ConfigurationSetting", modelProperties: { key: { serializedName: "key", required: true, type: { name: "String" } }, label: { serializedName: "label", type: { name: "String" } }, contentType: { serializedName: "content_type", type: { name: "String" } }, value: { serializedName: "value", type: { name: "String" } }, lastModified: { serializedName: "last_modified", type: { name: "DateTime" } }, tags: { serializedName: "tags", type: { name: "Dictionary", value: { type: { name: "String" } } } }, isReadOnly: { serializedName: "locked", type: { name: "Boolean" } }, etag: { serializedName: "etag", type: { name: "String" } } } } }; const LabelListResult = { type: { name: "Composite", className: "LabelListResult", modelProperties: { items: { serializedName: "items", type: { name: "Sequence", element: { type: { name: "Composite", className: "Label" } } } }, nextLink: { serializedName: "@nextLink", type: { name: "String" } } } } }; const Label = { type: { name: "Composite", className: "Label", modelProperties: { name: { serializedName: "name", readOnly: true, type: { name: "String" } } } } }; const GeneratedClientGetKeysHeaders = { type: { name: "Composite", className: "GeneratedClientGetKeysHeaders", modelProperties: { syncToken: { serializedName: "sync-token", type: { name: "String" } } } } }; const GeneratedClientCheckKeysHeaders = { type: { name: "Composite", className: "GeneratedClientCheckKeysHeaders", modelProperties: { syncToken: { serializedName: "sync-token", type: { name: "String" } } } } }; const GeneratedClientGetKeyValuesHeaders = { type: { name: "Composite", className: "GeneratedClientGetKeyValuesHeaders", modelProperties: { syncToken: { serializedName: "sync-token", type: { name: "String" } } } } }; const GeneratedClientCheckKeyValuesHeaders = { type: { name: "Composite", className: "GeneratedClientCheckKeyValuesHeaders", modelProperties: { syncToken: { serializedName: "sync-token", type: { name: "String" } } } } }; const GeneratedClientGetKeyValueHeaders = { type: { name: "Composite", className: "GeneratedClientGetKeyValueHeaders", modelProperties: { syncToken: { serializedName: "sync-token", type: { name: "String" } }, eTag: { serializedName: "etag", type: { name: "String" } }, lastModified: { serializedName: "last-modified", type: { name: "String" } } } } }; const GeneratedClientPutKeyValueHeaders = { type: { name: "Composite", className: "GeneratedClientPutKeyValueHeaders", modelProperties: { syncToken: { serializedName: "sync-token", type: { name: "String" } }, eTag: { serializedName: "etag", type: { name: "String" } } } } }; const GeneratedClientDeleteKeyValueHeaders = { type: { name: "Composite", className: "GeneratedClientDeleteKeyValueHeaders", modelProperties: { syncToken: { serializedName: "sync-token", type: { name: "String" } }, eTag: { serializedName: "etag", type: { name: "String" } } } } }; const GeneratedClientCheckKeyValueHeaders = { type: { name: "Composite", className: "GeneratedClientCheckKeyValueHeaders", modelProperties: { syncToken: { serializedName: "sync-token", type: { name: "String" } }, eTag: { serializedName: "etag", type: { name: "String" } }, lastModified: { serializedName: "last-modified", type: { name: "String" } } } } }; const GeneratedClientGetLabelsHeaders = { type: { name: "Composite", className: "GeneratedClientGetLabelsHeaders", modelProperties: { syncToken: { serializedName: "sync-token", type: { name: "String" } } } } }; const GeneratedClientCheckLabelsHeaders = { type: { name: "Composite", className: "GeneratedClientCheckLabelsHeaders", modelProperties: { syncToken: { serializedName: "sync-token", type: { name: "String" } } } } }; const GeneratedClientPutLockHeaders = { type: { name: "Composite", className: "GeneratedClientPutLockHeaders", modelProperties: { syncToken: { serializedName: "sync-token", type: { name: "String" } }, eTag: { serializedName: "etag", type: { name: "String" } } } } }; const GeneratedClientDeleteLockHeaders = { type: { name: "Composite", className: "GeneratedClientDeleteLockHeaders", modelProperties: { syncToken: { serializedName: "sync-token", type: { name: "String" } }, eTag: { serializedName: "etag", type: { name: "String" } } } } }; const GeneratedClientGetRevisionsHeaders = { type: { name: "Composite", className: "GeneratedClientGetRevisionsHeaders", modelProperties: { syncToken: { serializedName: "sync-token", type: { name: "String" } } } } }; const GeneratedClientCheckRevisionsHeaders = { type: { name: "Composite", className: "GeneratedClientCheckRevisionsHeaders", modelProperties: { syncToken: { serializedName: "sync-token", type: { name: "String" } } } } }; const GeneratedClientGetKeysNextHeaders = { type: { name: "Composite", className: "GeneratedClientGetKeysNextHeaders", modelProperties: { syncToken: { serializedName: "sync-token", type: { name: "String" } } } } }; const GeneratedClientGetKeyValuesNextHeaders = { type: { name: "Composite", className: "GeneratedClientGetKeyValuesNextHeaders", modelProperties: { syncToken: { serializedName: "sync-token", type: { name: "String" } } } } }; const GeneratedClientGetLabelsNextHeaders = { type: { name: "Composite", className: "GeneratedClientGetLabelsNextHeaders", modelProperties: { syncToken: { serializedName: "sync-token", type: { name: "String" } } } } }; const GeneratedClientGetRevisionsNextHeaders = { type: { name: "Composite", className: "GeneratedClientGetRevisionsNextHeaders", modelProperties: { syncToken: { serializedName: "sync-token", type: { name: "String" } } } } }; var Mappers = /*#__PURE__*/Object.freeze({ __proto__: null, KeyListResult: KeyListResult, Key: Key, ErrorModel: ErrorModel, KeyValueListResult: KeyValueListResult, ConfigurationSetting: ConfigurationSetting, LabelListResult: LabelListResult, Label: Label, GeneratedClientGetKeysHeaders: GeneratedClientGetKeysHeaders, GeneratedClientCheckKeysHeaders: GeneratedClientCheckKeysHeaders, GeneratedClientGetKeyValuesHeaders: GeneratedClientGetKeyValuesHeaders, GeneratedClientCheckKeyValuesHeaders: GeneratedClientCheckKeyValuesHeaders, GeneratedClientGetKeyValueHeaders: GeneratedClientGetKeyValueHeaders, GeneratedClientPutKeyValueHeaders: GeneratedClientPutKeyValueHeaders, GeneratedClientDeleteKeyValueHeaders: GeneratedClientDeleteKeyValueHeaders, GeneratedClientCheckKeyValueHeaders: GeneratedClientCheckKeyValueHeaders, GeneratedClientGetLabelsHeaders: GeneratedClientGetLabelsHeaders, GeneratedClientCheckLabelsHeaders: GeneratedClientCheckLabelsHeaders, GeneratedClientPutLockHeaders: GeneratedClientPutLockHeaders, GeneratedClientDeleteLockHeaders: GeneratedClientDeleteLockHeaders, GeneratedClientGetRevisionsHeaders: GeneratedClientGetRevisionsHeaders, GeneratedClientCheckRevisionsHeaders: GeneratedClientCheckRevisionsHeaders, GeneratedClientGetKeysNextHeaders: GeneratedClientGetKeysNextHeaders, GeneratedClientGetKeyValuesNextHeaders: GeneratedClientGetKeyValuesNextHeaders, GeneratedClientGetLabelsNextHeaders: GeneratedClientGetLabelsNextHeaders, GeneratedClientGetRevisionsNextHeaders: GeneratedClientGetRevisionsNextHeaders }); /* * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. * * Code generated by Microsoft (R) AutoRest Code Generator. * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ const accept = { parameterPath: "accept", mapper: { defaultValue: "application/vnd.microsoft.appconfig.keyset+json, application/json, application/problem+json", isConstant: true, serializedName: "Accept", type: { name: "String" } } }; const endpoint = { parameterPath: "endpoint", mapper: { serializedName: "endpoint", required: true, type: { name: "String" } }, skipEncoding: true }; const name = { parameterPath: ["options", "name"], mapper: { serializedName: "name", type: { name: "String" } } }; const syncToken = { parameterPath: "syncToken", mapper: { serializedName: "Sync-Token", type: { name: "String" } } }; const apiVersion = { parameterPath: "apiVersion", mapper: { defaultValue: "1.0", isConstant: true, serializedName: "api-version", type: { name: "String" } } }; const after = { parameterPath: ["options", "after"], mapper: { serializedName: "After", type: { name: "String" } } }; const acceptDatetime = { parameterPath: ["options", "acceptDatetime"], mapper: { serializedName: "Accept-Datetime", type: { name: "String" } } }; const accept1 = { parameterPath: "accept", mapper: { defaultValue: "application/vnd.microsoft.appconfig.kvset+json, application/json, application/problem+json", isConstant: true, serializedName: "Accept", type: { name: "String" } } }; const key = { parameterPath: ["options", "key"], mapper: { serializedName: "key", type: { name: "String" } } }; const label = { parameterPath: ["options", "label"], mapper: { serializedName: "label", type: { name: "String" } } }; const select = { parameterPath: ["options", "select"], mapper: { serializedName: "$Select", type: { name: "Sequence", element: { type: { name: "Enum", allowedValues: [ "key", "label", "content_type", "value", "last_modified", "tags", "locked", "etag" ] } } } }, collectionFormat: coreHttp.QueryCollectionFormat.Csv }; const accept2 = { parameterPath: "accept", mapper: { defaultValue: "application/vnd.microsoft.appconfig.kv+json, application/json, application/problem+json", isConstant: true, serializedName: "Accept", type: { name: "String" } } }; const key1 = { parameterPath: "key", mapper: { serializedName: "key", required: true, type: { name: "String" } } }; const ifMatch = { parameterPath: ["options", "ifMatch"], mapper: { serializedName: "If-Match", type: { name: "String" } } }; const ifNoneMatch = { parameterPath: ["options", "ifNoneMatch"], mapper: { serializedName: "If-None-Match", type: { name: "String" } } }; const contentType = { parameterPath: ["options", "contentType"], mapper: { defaultValue: "application/vnd.microsoft.appconfig.kv+json", isConstant: true, serializedName: "Content-Type", type: { name: "String" } } }; const entity = { parameterPath: ["options", "entity"], mapper: ConfigurationSetting }; const accept3 = { parameterPath: "accept", mapper: { defaultValue: "application/vnd.microsoft.appconfig.labelset+json, application/json, application/problem+json", isConstant: true, serializedName: "Accept", type: { name: "String" } } }; const select1 = { parameterPath: ["options", "select"], mapper: { serializedName: "$Select", type: { name: "Sequence", element: { defaultValue: "name", isConstant: true, type: { name: "String" } } } }, collectionFormat: coreHttp.QueryCollectionFormat.Csv }; const nextLink = { parameterPath: "nextLink", mapper: { serializedName: "nextLink", required: true, type: { name: "String" } }, skipEncoding: true }; /* * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. * * Code generated by Microsoft (R) AutoRest Code Generator. * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ const packageName = "@azure/template"; const packageVersion = "1.0.11-beta.1"; /** @hidden */ class GeneratedClientContext extends coreHttp.ServiceClient { /** * Initializes a new instance of the GeneratedClientContext class. * @param endpoint The endpoint of the App Configuration instance to send requests to. * @param options The parameter options */ constructor(endpoint, options) { if (endpoint === undefined) { throw new Error("'endpoint' cannot be null"); } // Initializing default values for options if (!options) { options = {}; } if (!options.userAgent) { const defaultUserAgent = coreHttp.getDefaultUserAgentValue(); options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent}`; } super(undefined, options); this.requestContentType = "application/json; charset=utf-8"; this.baseUri = options.endpoint || "{endpoint}"; // Parameter assignments this.endpoint = endpoint; // Assigning values to Constant parameters this.apiVersion = options.apiVersion || "1.0"; } } /* * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. * * Code generated by Microsoft (R) AutoRest Code Generator. * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ /** @hidden */ class GeneratedClient extends GeneratedClientContext { /** * Initializes a new instance of the GeneratedClient class. * @param endpoint The endpoint of the App Configuration instance to send requests to. * @param options The parameter options */ constructor(endpoint, options) { super(endpoint, options); } /** * Gets a list of keys. * @param options The options parameters. */ getKeys(options) { const operationArguments = { options: coreHttp.operationOptionsToRequestOptionsBase(options || {}) }; return this.sendOperationRequest(operationArguments, getKeysOperationSpec); } /** * Requests the headers and status of the given resource. * @param options The options parameters. */ checkKeys(options) { const operationArguments = { options: coreHttp.operationOptionsToRequestOptionsBase(options || {}) }; return this.sendOperationRequest(operationArguments, checkKeysOperationSpec); } /** * Gets a list of key-values. * @param options The options parameters. */ getKeyValues(options) { const operationArguments = { options: coreHttp.operationOptionsToRequestOptionsBase(options || {}) }; return this.sendOperationRequest(operationArguments, getKeyValuesOperationSpec); } /** * Requests the headers and status of the given resource. * @param options The options parameters. */ checkKeyValues(options) { const operationArguments = { options: coreHttp.operationOptionsToRequestOptionsBase(options || {}) }; return this.sendOperationRequest(operationArguments, checkKeyValuesOperationSpec); } /** * Gets a single key-value. * @param key The key of the key-value to retrieve. * @param options The options parameters. */ getKeyValue(key, options) { const operationArguments = { key, options: coreHttp.operationOptionsToRequestOptionsBase(options || {}) }; return this.sendOperationRequest(operationArguments, getKeyValueOperationSpec); } /** * Creates a key-value. * @param key The key of the key-value to create. * @param options The options parameters. */ putKeyValue(key, options) { const operationArguments = { key, options: coreHttp.operationOptionsToRequestOptionsBase(options || {}) }; return this.sendOperationRequest(operationArguments, putKeyValueOperationSpec); } /** * Deletes a key-value. * @param key The key of the key-value to delete. * @param options The options parameters. */ deleteKeyValue(key, options) { const operationArguments = { key, options: coreHttp.operationOptionsToRequestOptionsBase(options || {}) }; return this.sendOperationRequest(operationArguments, deleteKeyValueOperationSpec); } /** * Requests the headers and status of the given resource. * @param key The key of the key-value to retrieve. * @param options The options parameters. */ checkKeyValue(key, options) { const operationArguments = { key, options: coreHttp.operationOptionsToRequestOptionsBase(options || {}) }; return this.sendOperationRequest(operationArguments, checkKeyValueOperationSpec); } /** * Gets a list of labels. * @param options The options parameters. */ getLabels(options) { const operationArguments = { options: coreHttp.operationOptionsToRequestOptionsBase(options || {}) }; return this.sendOperationRequest(operationArguments, getLabelsOperationSpec); } /** * Requests the headers and status of the given resource. * @param options The options parameters. */ checkLabels(options) { const operationArguments = { options: coreHttp.operationOptionsToRequestOptionsBase(options || {}) }; return this.sendOperationRequest(operationArguments, checkLabelsOperationSpec); } /** * Locks a key-value. * @param key The key of the key-value to lock. * @param options The options parameters. */ putLock(key, options) { const operationArguments = { key, options: coreHttp.operationOptionsToRequestOptionsBase(options || {}) }; return this.sendOperationRequest(operationArguments, putLockOperationSpec); } /** * Unlocks a key-value. * @param key The key of the key-value to unlock. * @param options The options parameters. */ deleteLock(key, options) { const operationArguments = { key, options: coreHttp.operationOptionsToRequestOptionsBase(options || {}) }; return this.sendOperationRequest(operationArguments, deleteLockOperationSpec); } /** * Gets a list of key-value revisions. * @param options The options parameters. */ getRevisions(options) { const operationArguments = { options: coreHttp.operationOptionsToRequestOptionsBase(options || {}) }; return this.sendOperationRequest(operationArguments, getRevisionsOperationSpec); } /** * Requests the headers and status of the given resource. * @param options The options parameters. */ checkRevisions(options) { const operationArguments = { options: coreHttp.operationOptionsToRequestOptionsBase(options || {}) }; return this.sendOperationRequest(operationArguments, checkRevisionsOperationSpec); } /** * GetKeysNext * @param nextLink The nextLink from the previous successful call to the GetKeys method. * @param options The options parameters. */ getKeysNext(nextLink, options) { const operationArguments = { nextLink, options: coreHttp.operationOptionsToRequestOptionsBase(options || {}) }; return this.sendOperationRequest(operationArguments, getKeysNextOperationSpec); } /** * GetKeyValuesNext * @param nextLink The nextLink from the previous successful call to the GetKeyValues method. * @param options The options parameters. */ getKeyValuesNext(nextLink, options) { const operationArguments = { nextLink, options: coreHttp.operationOptionsToRequestOptionsBase(options || {}) }; return this.sendOperationRequest(operationArguments, getKeyValuesNextOperationSpec); } /** * GetLabelsNext * @param nextLink The nextLink from the previous successful call to the GetLabels method. * @param options The options parameters. */ getLabelsNext(nextLink, options) { const operationArguments = { nextLink, options: coreHttp.operationOptionsToRequestOptionsBase(options || {}) }; return this.sendOperationRequest(operationArguments, getLabelsNextOperationSpec); } /** * GetRevisionsNext * @param nextLink The nextLink from the previous successful call to the GetRevisions method. * @param options The options parameters. */ getRevisionsNext(nextLink, options) { const operationArguments = { nextLink, options: coreHttp.operationOptionsToRequestOptionsBase(options || {}) }; return this.sendOperationRequest(operationArguments, getRevisionsNextOperationSpec); } } // Operation Specifications const serializer = new coreHttp.Serializer(Mappers, /* isXml */ false); const getKeysOperationSpec = { path: "/keys", httpMethod: "GET", responses: { 200: { bodyMapper: KeyListResult, headersMapper: GeneratedClientGetKeysHeaders }, default: { bodyMapper: ErrorModel } }, queryParameters: [name, apiVersion, after], urlParameters: [endpoint], headerParameters: [ accept, syncToken, acceptDatetime ], serializer }; const checkKeysOperationSpec = { path: "/keys", httpMethod: "HEAD", responses: { 200: { headersMapper: GeneratedClientCheckKeysHeaders }, default: {} }, queryParameters: [name, apiVersion, after], urlParameters: [endpoint], headerParameters: [syncToken, acceptDatetime], serializer }; const getKeyValuesOperationSpec = { path: "/kv", httpMethod: "GET", responses: { 200: { bodyMapper: KeyValueListResult, headersMapper: GeneratedClientGetKeyValuesHeaders }, default: { bodyMapper: ErrorModel } }, queryParameters: [ apiVersion, after, key, label, select ], urlParameters: [endpoint], headerParameters: [ syncToken, acceptDatetime, accept1 ], serializer }; const checkKeyValuesOperationSpec = { path: "/kv", httpMethod: "HEAD", responses: { 200: { headersMapper: GeneratedClientCheckKeyValuesHeaders }, default: {} }, queryParameters: [ apiVersion, after, key, label, select ], urlParameters: [endpoint], headerParameters: [syncToken, acceptDatetime], serializer }; const getKeyValueOperationSpec = { path: "/kv/{key}", httpMethod: "GET", responses: { 200: { bodyMapper: ConfigurationSetting, headersMapper: GeneratedClientGetKeyValueHeaders }, default: { bodyMapper: ErrorModel } }, queryParameters: [apiVersion, label, select], urlParameters: [endpoint, key1], headerParameters: [ syncToken, acceptDatetime, accept2, ifMatch, ifNoneMatch ], serializer }; const putKeyValueOperationSpec = { path: "/kv/{key}", httpMethod: "PUT", responses: { 200: { bodyMapper: ConfigurationSetting, headersMapper: GeneratedClientPutKeyValueHeaders }, default: { bodyMapper: ErrorModel } }, requestBody: entity, queryParameters: [apiVersion, label], urlParameters: [endpoint, key1], headerParameters: [ syncToken, accept2, ifMatch, ifNoneMatch, contentType ], mediaType: "json", serializer }; const deleteKeyValueOperationSpec = { path: "/kv/{key}", httpMethod: "DELETE", responses: { 200: { bodyMapper: ConfigurationSetting, headersMapper: GeneratedClientDeleteKeyValueHeaders }, 204: { headersMapper: GeneratedClientDeleteKeyValueHeaders }, default: { bodyMapper: ErrorModel } }, queryParameters: [apiVersion, label], urlParameters: [endpoint, key1], headerParameters: [ syncToken, accept2, ifMatch ], serializer }; const checkKeyValueOperationSpec = { path: "/kv/{key}", httpMethod: "HEAD", responses: { 200: { headersMapper: GeneratedClientCheckKeyValueHeaders }, default: {} }, queryParameters: [apiVersion, label, select], urlParameters: [endpoint, key1], headerParameters: [ syncToken, acceptDatetime, ifMatch, ifNoneMatch ], serializer }; const getLabelsOperationSpec = { path: "/labels", httpMethod: "GET", responses: { 200: { bodyMapper: LabelListResult, headersMapper: GeneratedClientGetLabelsHeaders }, default: { bodyMapper: ErrorModel } }, queryParameters: [ name, apiVersion, after, select1 ], urlParameters: [endpoint], headerParameters: [ syncToken, acceptDatetime, accept3 ], serializer }; const checkLabelsOperationSpec = { path: "/labels", httpMethod: "HEAD", responses: { 200: { headersMapper: GeneratedClientCheckLabelsHeaders }, default: {} }, queryParameters: [ name, apiVersion, after, select1 ], urlParameters: [endpoint], headerParameters: [syncToken, acceptDatetime], serializer }; const putLockOperationSpec = { path: "/locks/{key}", httpMethod: "PUT", responses: { 200: { bodyMapper: ConfigurationSetting, headersMapper: GeneratedClientPutLockHeaders }, default: { bodyMapper: ErrorModel } }, queryParameters: [apiVersion, label], urlParameters: [endpoint, key1], headerParameters: [ syncToken, accept2, ifMatch, ifNoneMatch ], serializer }; const deleteLockOperationSpec = { path: "/locks/{key}", httpMethod: "DELETE", responses: { 200: { bodyMapper: ConfigurationSetting, headersMapper: GeneratedClientDeleteLockHeaders }, default: { bodyMapper: ErrorModel } }, queryParameters: [apiVersion, label], urlParameters: [endpoint, key1], headerParameters: [ syncToken, accept2, ifMatch, ifNoneMatch ], serializer }; const getRevisionsOperationSpec = { path: "/revisions", httpMethod: "GET", responses: { 200: { bodyMapper: KeyValueListResult, headersMapper: GeneratedClientGetRevisionsHeaders }, default: { bodyMapper: ErrorModel } }, queryParameters: [ apiVersion, after, key, label, select ], urlParameters: [endpoint], headerParameters: [ syncToken, acceptDatetime, accept1 ], serializer }; const checkRevisionsOperationSpec = { path: "/revisions", httpMethod: "HEAD", responses: { 200: { headersMapper: GeneratedClientCheckRevisionsHeaders }, default: {} }, queryParameters: [ apiVersion, after, key, label, select ], urlParameters: [endpoint], headerParameters: [syncToken, acceptDatetime], serializer }; const getKeysNextOperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: KeyListResult, headersMapper: GeneratedClientGetKeysNextHeaders }, default: { bodyMapper: ErrorModel } }, queryParameters: [name, apiVersion, after], urlParameters: [endpoint, nextLink], headerParameters: [ accept, syncToken, acceptDatetime ], serializer }; const getKeyValuesNextOperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: KeyValueListResult, headersMapper: GeneratedClientGetKeyValuesNextHeaders }, default: { bodyMapper: ErrorModel } }, queryParameters: [ apiVersion, after, key, label, select ], urlParameters: [endpoint, nextLink], headerParameters: [ syncToken, acceptDatetime, accept1 ], serializer }; const getLabelsNextOperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: LabelListResult, headersMapper: GeneratedClientGetLabelsNextHeaders }, default: { bodyMapper: ErrorModel } }, queryParameters: [ name, apiVersion, after, select1 ], urlParameters: [endpoint, nextLink], headerParameters: [ syncToken, acceptDatetime, accept3 ], serializer }; const getRevisionsNextOperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: KeyValueListResult, headersMapper: GeneratedClientGetRevisionsNextHeaders }, default: { bodyMapper: ErrorModel } }, queryParameters: [ apiVersion, after, key, label, select ], urlParameters: [endpoint, nextLink], headerParameters: [ syncToken, acceptDatetime, accept1 ], serializer }; // Copyright (c) Microsoft Corporation. /** * Creates a span using the global tracer. * * @param name - The name of the operation being performed. * @param tracingOptions - The options for the underlying http request. * * @internal */ const createSpan = coreTracing.createSpanFunction({ namespace: "Microsoft.Learn", packagePrefix: "Azure.Learn.ApiLearn" }); // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. /** * Handles etag quoting in AppConfig response objects. * * This is important because the etag inside the body of the configuration * object isn't quoted, even though the header is. * * @param etag - the tag to quote, if it isn't quoted already * * @internal */ function quoteETag(etag) { // https://tools.ietf.org/html/rfc7232#section-3.1 if (etag === undefined || etag === "*") { return etag; } if (etag.startsWith('"') && etag.endsWith('"')) { return etag; } if (etag.startsWith("'") && etag.endsWith("'")) { return etag; } return `"${etag}"`; } // Copyright (c) Microsoft Corporation. /** * The client class used to interact with the App Configuration service. */ class ConfigurationClient { /** * Creates an instance of a ConfigurationClient. * * Example usage: * ```ts * import { ConfigurationClient} from "@azure/ai-text-analytics"; * import { DefaultAzureCredential} from "@azure/identity"; * * const client = new ConfigurationClient( * "<app configuration endpoint>", * new DefaultAzureCredential() * ); * ``` * @param endpointUrl - the URL to the App Configuration endpoint * @param credential - used to authenticate requests to the service * @param options - optional configuration used to send requests to the service */ constructor(endpointUrl, credential, options = {}) { // The below code helps us set a proper User-Agent header on all requests const libInfo = `azsdk-js-template-template/${SDK_VERSION}`; if (!options.userAgentOptions) { options.userAgentOptions = {}; } if (options.userAgentOptions.userAgentPrefix) { options.userAgentOptions.userAgentPrefix = `${options.userAgentOptions.userAgentPrefix} ${libInfo}`; } else { options.userAgentOptions.userAgentPrefix = libInfo; } // The AAD scope for an API is usually the baseUri + "/.default", but it // may be different for your service. const authPolicy = coreHttp.bearerTokenAuthenticationPolicy(credential, `${endpointUrl}/.default`); const internalPipelineOptions = Object.assign(Object.assign(Object.assign({}, options), { deserializationOptions: { expectedContentTypes: { json: [ "application/vnd.microsoft.appconfig.kvset+json", "application/vnd.microsoft.appconfig.kv+json", "application/vnd.microsoft.appconfig.kvs+json", "application/vnd.microsoft.appconfig.keyset+json", "application/vnd.microsoft.appconfig.revs+json" ] } } }), { loggingOptions: { logger: logger.info, // This array contains header names we want to log that are not already // included as safe. Unknown/unsafe headers are logged as "<REDACTED>". allowedHeaderNames: ["x-ms-correlation-request-id"] } }); const pipeline = coreHttp.createPipelineFromOptions(internalPipelineOptions, authPolicy); this.client = new GeneratedClient(endpointUrl, pipeline); } async getConfigurationSetting(keyOrSetting, options = {}) { let key; let ifNoneMatch; if (typeof keyOrSetting === "string") { key = keyOrSetting; if (options.onlyIfChanged) { throw new RangeError("You must pass a ConfigurationSetting instead of a key to perform a conditional fetch."); } } else { key = keyOrSetting.key; const etag = keyOrSetting.etag; if (options.onlyIfChanged) { ifNoneMatch = quoteETag(etag); } } const { span, updatedOptions } = createSpan( // Here you set the name of the span, usually clientName-operationName "ConfigurationClient-getConfigurationSetting", options); try { const result = await this.client.getKeyValue(key, Object.assign(Object.assign({}, updatedOptions), { ifNoneMatch })); return result; } catch (e) { // There are different standard codes available for different errors: // https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/api.md#status span.setStatus({ code: coreTracing.SpanStatusCode.ERROR, message: e.message }); throw e; } finally { span.end(); } } } exports.ConfigurationClient = ConfigurationClient; //# sourceMappingURL=index.js.map