UNPKG

@azure/app-configuration

Version:

An isomorphic client library for the Azure App Configuration service.

904 lines • 28.8 kB
"use strict"; /* * 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. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.AppConfiguration = void 0; const tslib_1 = require("tslib"); const coreClient = tslib_1.__importStar(require("@azure/core-client")); const coreHttpCompat = tslib_1.__importStar(require("@azure/core-http-compat")); const core_lro_1 = require("@azure/core-lro"); const lroImpl_js_1 = require("./lroImpl.js"); const Parameters = tslib_1.__importStar(require("./models/parameters.js")); const Mappers = tslib_1.__importStar(require("./models/mappers.js")); /** @internal */ class AppConfiguration extends coreHttpCompat.ExtendedServiceClient { /** * Initializes a new instance of the AppConfiguration class. * @param endpoint The endpoint of the App Configuration instance to send requests to. * @param apiVersion Api Version * @param options The parameter options */ constructor(endpoint, apiVersion, options) { var _a, _b; if (endpoint === undefined) { throw new Error("'endpoint' cannot be null"); } if (apiVersion === undefined) { throw new Error("'apiVersion' cannot be null"); } // Initializing default values for options if (!options) { options = {}; } const defaults = { requestContentType: "application/json; charset=utf-8", }; const packageDetails = `azsdk-js-app-configuration/1.9.0`; const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` : `${packageDetails}`; const optionsWithDefaults = Object.assign(Object.assign(Object.assign({}, defaults), options), { userAgentOptions: { userAgentPrefix, }, endpoint: (_b = (_a = options.endpoint) !== null && _a !== void 0 ? _a : options.baseUri) !== null && _b !== void 0 ? _b : "{endpoint}" }); super(optionsWithDefaults); // Parameter assignments this.endpoint = endpoint; this.apiVersion = apiVersion; this.addCustomApiVersionPolicy(apiVersion); } /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */ addCustomApiVersionPolicy(apiVersion) { if (!apiVersion) { return; } const apiVersionPolicy = { name: "CustomApiVersionPolicy", async sendRequest(request, next) { const param = request.url.split("?"); if (param.length > 1) { const newParams = param[1].split("&").map((item) => { if (item.indexOf("api-version") > -1) { return "api-version=" + apiVersion; } else { return item; } }); request.url = param[0] + "?" + newParams.join("&"); } return next(request); }, }; this.pipeline.addPolicy(apiVersionPolicy); } /** * Gets a list of keys. * @param options The options parameters. */ getKeys(options) { return this.sendOperationRequest({ options }, getKeysOperationSpec); } /** * Requests the headers and status of the given resource. * @param options The options parameters. */ checkKeys(options) { return this.sendOperationRequest({ options }, checkKeysOperationSpec); } /** * Gets a list of key-values. * @param options The options parameters. */ getKeyValues(options) { return this.sendOperationRequest({ options }, getKeyValuesOperationSpec); } /** * Requests the headers and status of the given resource. * @param options The options parameters. */ checkKeyValues(options) { return this.sendOperationRequest({ options }, checkKeyValuesOperationSpec); } /** * Gets a single key-value. * @param key The key of the key-value to retrieve. * @param options The options parameters. */ getKeyValue(key, options) { return this.sendOperationRequest({ key, options }, getKeyValueOperationSpec); } /** * Creates a key-value. * @param key The key of the key-value to create. * @param options The options parameters. */ putKeyValue(key, options) { return this.sendOperationRequest({ key, options }, putKeyValueOperationSpec); } /** * Deletes a key-value. * @param key The key of the key-value to delete. * @param options The options parameters. */ deleteKeyValue(key, options) { return this.sendOperationRequest({ key, options }, 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) { return this.sendOperationRequest({ key, options }, checkKeyValueOperationSpec); } /** * Gets a list of key-value snapshots. * @param options The options parameters. */ getSnapshots(options) { return this.sendOperationRequest({ options }, getSnapshotsOperationSpec); } /** * Requests the headers and status of the given resource. * @param options The options parameters. */ checkSnapshots(options) { return this.sendOperationRequest({ options }, checkSnapshotsOperationSpec); } /** * Gets a single key-value snapshot. * @param name The name of the key-value snapshot to retrieve. * @param options The options parameters. */ getSnapshot(name, options) { return this.sendOperationRequest({ name, options }, getSnapshotOperationSpec); } /** * Creates a key-value snapshot. * @param name The name of the key-value snapshot to create. * @param entity The key-value snapshot to create. * @param options The options parameters. */ async beginCreateSnapshot(name, entity, options) { const directSendOperation = async (args, spec) => { return this.sendOperationRequest(args, spec); }; const sendOperationFn = async (args, spec) => { var _a; let currentRawResponse = undefined; const providedCallback = (_a = args.options) === null || _a === void 0 ? void 0 : _a.onResponse; const callback = (rawResponse, flatResponse) => { currentRawResponse = rawResponse; providedCallback === null || providedCallback === void 0 ? void 0 : providedCallback(rawResponse, flatResponse); }; const updatedArgs = Object.assign(Object.assign({}, args), { options: Object.assign(Object.assign({}, args.options), { onResponse: callback }) }); const flatResponse = await directSendOperation(updatedArgs, spec); return { flatResponse, rawResponse: { statusCode: currentRawResponse.status, body: currentRawResponse.parsedBody, headers: currentRawResponse.headers.toJSON(), }, }; }; const lro = (0, lroImpl_js_1.createLroSpec)({ sendOperationFn, args: { name, entity, options }, spec: createSnapshotOperationSpec, }); const poller = await (0, core_lro_1.createHttpPoller)(lro, { restoreFrom: options === null || options === void 0 ? void 0 : options.resumeFrom, intervalInMs: options === null || options === void 0 ? void 0 : options.updateIntervalInMs, }); await poller.poll(); return poller; } /** * Creates a key-value snapshot. * @param name The name of the key-value snapshot to create. * @param entity The key-value snapshot to create. * @param options The options parameters. */ async beginCreateSnapshotAndWait(name, entity, options) { const poller = await this.beginCreateSnapshot(name, entity, options); return poller.pollUntilDone(); } /** * Updates the state of a key-value snapshot. * @param name The name of the key-value snapshot to update. * @param entity The parameters used to update the snapshot. * @param options The options parameters. */ updateSnapshot(name, entity, options) { return this.sendOperationRequest({ name, entity, options }, updateSnapshotOperationSpec); } /** * Requests the headers and status of the given resource. * @param name The name of the key-value snapshot to check. * @param options The options parameters. */ checkSnapshot(name, options) { return this.sendOperationRequest({ name, options }, checkSnapshotOperationSpec); } /** * Gets a list of labels. * @param options The options parameters. */ getLabels(options) { return this.sendOperationRequest({ options }, getLabelsOperationSpec); } /** * Requests the headers and status of the given resource. * @param options The options parameters. */ checkLabels(options) { return this.sendOperationRequest({ options }, checkLabelsOperationSpec); } /** * Locks a key-value. * @param key The key of the key-value to lock. * @param options The options parameters. */ putLock(key, options) { return this.sendOperationRequest({ key, options }, putLockOperationSpec); } /** * Unlocks a key-value. * @param key The key of the key-value to unlock. * @param options The options parameters. */ deleteLock(key, options) { return this.sendOperationRequest({ key, options }, deleteLockOperationSpec); } /** * Gets a list of key-value revisions. * @param options The options parameters. */ getRevisions(options) { return this.sendOperationRequest({ options }, getRevisionsOperationSpec); } /** * Requests the headers and status of the given resource. * @param options The options parameters. */ checkRevisions(options) { return this.sendOperationRequest({ options }, checkRevisionsOperationSpec); } /** * Gets the state of a long running operation. * @param snapshot Snapshot identifier for the long running operation. * @param options The options parameters. */ getOperationDetails(snapshot, options) { return this.sendOperationRequest({ snapshot, options }, getOperationDetailsOperationSpec); } /** * GetKeysNext * @param nextLink The nextLink from the previous successful call to the GetKeys method. * @param options The options parameters. */ getKeysNext(nextLink, options) { return this.sendOperationRequest({ nextLink, options }, getKeysNextOperationSpec); } /** * GetKeyValuesNext * @param nextLink The nextLink from the previous successful call to the GetKeyValues method. * @param options The options parameters. */ getKeyValuesNext(nextLink, options) { return this.sendOperationRequest({ nextLink, options }, getKeyValuesNextOperationSpec); } /** * GetSnapshotsNext * @param nextLink The nextLink from the previous successful call to the GetSnapshots method. * @param options The options parameters. */ getSnapshotsNext(nextLink, options) { return this.sendOperationRequest({ nextLink, options }, getSnapshotsNextOperationSpec); } /** * GetLabelsNext * @param nextLink The nextLink from the previous successful call to the GetLabels method. * @param options The options parameters. */ getLabelsNext(nextLink, options) { return this.sendOperationRequest({ nextLink, options }, getLabelsNextOperationSpec); } /** * GetRevisionsNext * @param nextLink The nextLink from the previous successful call to the GetRevisions method. * @param options The options parameters. */ getRevisionsNext(nextLink, options) { return this.sendOperationRequest({ nextLink, options }, getRevisionsNextOperationSpec); } } exports.AppConfiguration = AppConfiguration; // Operation Specifications const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); const getKeysOperationSpec = { path: "/keys", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.KeyListResult, headersMapper: Mappers.AppConfigurationGetKeysHeaders, }, default: { bodyMapper: Mappers.ErrorModel, }, }, queryParameters: [Parameters.name, Parameters.apiVersion, Parameters.after], urlParameters: [Parameters.endpoint], headerParameters: [ Parameters.accept, Parameters.syncToken, Parameters.acceptDatetime, ], serializer, }; const checkKeysOperationSpec = { path: "/keys", httpMethod: "HEAD", responses: { 200: { headersMapper: Mappers.AppConfigurationCheckKeysHeaders, }, default: {}, }, queryParameters: [Parameters.name, Parameters.apiVersion, Parameters.after], urlParameters: [Parameters.endpoint], headerParameters: [Parameters.syncToken, Parameters.acceptDatetime], serializer, }; const getKeyValuesOperationSpec = { path: "/kv", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.KeyValueListResult, headersMapper: Mappers.AppConfigurationGetKeyValuesHeaders, }, default: { bodyMapper: Mappers.ErrorModel, }, }, queryParameters: [ Parameters.apiVersion, Parameters.after, Parameters.key, Parameters.label, Parameters.select, Parameters.snapshot, Parameters.tags, ], urlParameters: [Parameters.endpoint], headerParameters: [ Parameters.syncToken, Parameters.acceptDatetime, Parameters.accept1, Parameters.ifMatch, Parameters.ifNoneMatch, ], serializer, }; const checkKeyValuesOperationSpec = { path: "/kv", httpMethod: "HEAD", responses: { 200: { headersMapper: Mappers.AppConfigurationCheckKeyValuesHeaders, }, default: {}, }, queryParameters: [ Parameters.apiVersion, Parameters.after, Parameters.key, Parameters.label, Parameters.select, Parameters.snapshot, Parameters.tags, ], urlParameters: [Parameters.endpoint], headerParameters: [ Parameters.syncToken, Parameters.acceptDatetime, Parameters.ifMatch, Parameters.ifNoneMatch, ], serializer, }; const getKeyValueOperationSpec = { path: "/kv/{key}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.KeyValue, headersMapper: Mappers.AppConfigurationGetKeyValueHeaders, }, 304: { headersMapper: Mappers.AppConfigurationGetKeyValueHeaders, }, default: { bodyMapper: Mappers.ErrorModel, }, }, queryParameters: [Parameters.apiVersion, Parameters.label, Parameters.select], urlParameters: [Parameters.endpoint, Parameters.key1], headerParameters: [ Parameters.syncToken, Parameters.acceptDatetime, Parameters.ifMatch, Parameters.ifNoneMatch, Parameters.accept2, ], serializer, }; const putKeyValueOperationSpec = { path: "/kv/{key}", httpMethod: "PUT", responses: { 200: { bodyMapper: Mappers.KeyValue, headersMapper: Mappers.AppConfigurationPutKeyValueHeaders, }, default: { bodyMapper: Mappers.ErrorModel, }, }, requestBody: Parameters.entity, queryParameters: [Parameters.apiVersion, Parameters.label], urlParameters: [Parameters.endpoint, Parameters.key1], headerParameters: [ Parameters.syncToken, Parameters.ifMatch, Parameters.ifNoneMatch, Parameters.accept2, Parameters.contentType, ], mediaType: "json", serializer, }; const deleteKeyValueOperationSpec = { path: "/kv/{key}", httpMethod: "DELETE", responses: { 200: { bodyMapper: Mappers.KeyValue, headersMapper: Mappers.AppConfigurationDeleteKeyValueHeaders, }, 204: { headersMapper: Mappers.AppConfigurationDeleteKeyValueHeaders, }, default: { bodyMapper: Mappers.ErrorModel, }, }, queryParameters: [Parameters.apiVersion, Parameters.label], urlParameters: [Parameters.endpoint, Parameters.key1], headerParameters: [ Parameters.syncToken, Parameters.ifMatch, Parameters.accept2, ], serializer, }; const checkKeyValueOperationSpec = { path: "/kv/{key}", httpMethod: "HEAD", responses: { 200: { headersMapper: Mappers.AppConfigurationCheckKeyValueHeaders, }, 304: { headersMapper: Mappers.AppConfigurationCheckKeyValueHeaders, }, default: {}, }, queryParameters: [Parameters.apiVersion, Parameters.label, Parameters.select], urlParameters: [Parameters.endpoint, Parameters.key1], headerParameters: [ Parameters.syncToken, Parameters.acceptDatetime, Parameters.ifMatch, Parameters.ifNoneMatch, ], serializer, }; const getSnapshotsOperationSpec = { path: "/snapshots", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.SnapshotListResult, headersMapper: Mappers.AppConfigurationGetSnapshotsHeaders, }, default: { bodyMapper: Mappers.ErrorModel, }, }, queryParameters: [ Parameters.name, Parameters.apiVersion, Parameters.after, Parameters.select1, Parameters.status, ], urlParameters: [Parameters.endpoint], headerParameters: [Parameters.syncToken, Parameters.accept3], serializer, }; const checkSnapshotsOperationSpec = { path: "/snapshots", httpMethod: "HEAD", responses: { 200: { headersMapper: Mappers.AppConfigurationCheckSnapshotsHeaders, }, default: {}, }, queryParameters: [Parameters.apiVersion, Parameters.after], urlParameters: [Parameters.endpoint], headerParameters: [Parameters.syncToken], serializer, }; const getSnapshotOperationSpec = { path: "/snapshots/{name}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.ConfigurationSnapshot, headersMapper: Mappers.AppConfigurationGetSnapshotHeaders, }, default: { bodyMapper: Mappers.ErrorModel, }, }, queryParameters: [Parameters.apiVersion, Parameters.select1], urlParameters: [Parameters.endpoint, Parameters.name1], headerParameters: [ Parameters.syncToken, Parameters.ifMatch, Parameters.ifNoneMatch, Parameters.accept4, ], serializer, }; const createSnapshotOperationSpec = { path: "/snapshots/{name}", httpMethod: "PUT", responses: { 200: { bodyMapper: Mappers.ConfigurationSnapshot, headersMapper: Mappers.AppConfigurationCreateSnapshotHeaders, }, 201: { bodyMapper: Mappers.ConfigurationSnapshot, headersMapper: Mappers.AppConfigurationCreateSnapshotHeaders, }, 202: { bodyMapper: Mappers.ConfigurationSnapshot, headersMapper: Mappers.AppConfigurationCreateSnapshotHeaders, }, 204: { bodyMapper: Mappers.ConfigurationSnapshot, headersMapper: Mappers.AppConfigurationCreateSnapshotHeaders, }, default: { bodyMapper: Mappers.ErrorModel, }, }, requestBody: Parameters.entity1, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.endpoint, Parameters.name2], headerParameters: [ Parameters.syncToken, Parameters.accept4, Parameters.contentType1, ], mediaType: "json", serializer, }; const updateSnapshotOperationSpec = { path: "/snapshots/{name}", httpMethod: "PATCH", responses: { 200: { bodyMapper: Mappers.ConfigurationSnapshot, headersMapper: Mappers.AppConfigurationUpdateSnapshotHeaders, }, default: { bodyMapper: Mappers.ErrorModel, }, }, requestBody: Parameters.entity2, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.endpoint, Parameters.name1], headerParameters: [ Parameters.syncToken, Parameters.ifMatch, Parameters.ifNoneMatch, Parameters.accept4, Parameters.contentType2, ], mediaType: "json", serializer, }; const checkSnapshotOperationSpec = { path: "/snapshots/{name}", httpMethod: "HEAD", responses: { 200: { headersMapper: Mappers.AppConfigurationCheckSnapshotHeaders, }, default: {}, }, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.endpoint, Parameters.name1], headerParameters: [ Parameters.syncToken, Parameters.ifMatch, Parameters.ifNoneMatch, ], serializer, }; const getLabelsOperationSpec = { path: "/labels", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.LabelListResult, headersMapper: Mappers.AppConfigurationGetLabelsHeaders, }, default: { bodyMapper: Mappers.ErrorModel, }, }, queryParameters: [ Parameters.name, Parameters.apiVersion, Parameters.after, Parameters.select2, ], urlParameters: [Parameters.endpoint], headerParameters: [ Parameters.syncToken, Parameters.acceptDatetime, Parameters.accept5, ], serializer, }; const checkLabelsOperationSpec = { path: "/labels", httpMethod: "HEAD", responses: { 200: { headersMapper: Mappers.AppConfigurationCheckLabelsHeaders, }, default: {}, }, queryParameters: [ Parameters.name, Parameters.apiVersion, Parameters.after, Parameters.select2, ], urlParameters: [Parameters.endpoint], headerParameters: [Parameters.syncToken, Parameters.acceptDatetime], serializer, }; const putLockOperationSpec = { path: "/locks/{key}", httpMethod: "PUT", responses: { 200: { bodyMapper: Mappers.KeyValue, headersMapper: Mappers.AppConfigurationPutLockHeaders, }, default: { bodyMapper: Mappers.ErrorModel, }, }, queryParameters: [Parameters.apiVersion, Parameters.label], urlParameters: [Parameters.endpoint, Parameters.key1], headerParameters: [ Parameters.syncToken, Parameters.ifMatch, Parameters.ifNoneMatch, Parameters.accept2, ], serializer, }; const deleteLockOperationSpec = { path: "/locks/{key}", httpMethod: "DELETE", responses: { 200: { bodyMapper: Mappers.KeyValue, headersMapper: Mappers.AppConfigurationDeleteLockHeaders, }, default: { bodyMapper: Mappers.ErrorModel, }, }, queryParameters: [Parameters.apiVersion, Parameters.label], urlParameters: [Parameters.endpoint, Parameters.key1], headerParameters: [ Parameters.syncToken, Parameters.ifMatch, Parameters.ifNoneMatch, Parameters.accept2, ], serializer, }; const getRevisionsOperationSpec = { path: "/revisions", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.KeyValueListResult, headersMapper: Mappers.AppConfigurationGetRevisionsHeaders, }, default: { bodyMapper: Mappers.ErrorModel, }, }, queryParameters: [ Parameters.apiVersion, Parameters.after, Parameters.key, Parameters.label, Parameters.select, Parameters.tags, ], urlParameters: [Parameters.endpoint], headerParameters: [ Parameters.syncToken, Parameters.acceptDatetime, Parameters.accept1, ], serializer, }; const checkRevisionsOperationSpec = { path: "/revisions", httpMethod: "HEAD", responses: { 200: { headersMapper: Mappers.AppConfigurationCheckRevisionsHeaders, }, default: {}, }, queryParameters: [ Parameters.apiVersion, Parameters.after, Parameters.key, Parameters.label, Parameters.select, Parameters.tags, ], urlParameters: [Parameters.endpoint], headerParameters: [Parameters.syncToken, Parameters.acceptDatetime], serializer, }; const getOperationDetailsOperationSpec = { path: "/operations", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.OperationDetails, }, default: { bodyMapper: Mappers.ErrorModel, }, }, queryParameters: [Parameters.apiVersion, Parameters.snapshot1], urlParameters: [Parameters.endpoint], headerParameters: [Parameters.accept6], serializer, }; const getKeysNextOperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.KeyListResult, headersMapper: Mappers.AppConfigurationGetKeysNextHeaders, }, default: { bodyMapper: Mappers.ErrorModel, }, }, urlParameters: [Parameters.endpoint, Parameters.nextLink], headerParameters: [ Parameters.accept, Parameters.syncToken, Parameters.acceptDatetime, ], serializer, }; const getKeyValuesNextOperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.KeyValueListResult, headersMapper: Mappers.AppConfigurationGetKeyValuesNextHeaders, }, default: { bodyMapper: Mappers.ErrorModel, }, }, urlParameters: [Parameters.endpoint, Parameters.nextLink], headerParameters: [ Parameters.syncToken, Parameters.acceptDatetime, Parameters.accept1, Parameters.ifMatch, Parameters.ifNoneMatch, ], serializer, }; const getSnapshotsNextOperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.SnapshotListResult, headersMapper: Mappers.AppConfigurationGetSnapshotsNextHeaders, }, default: { bodyMapper: Mappers.ErrorModel, }, }, urlParameters: [Parameters.endpoint, Parameters.nextLink], headerParameters: [Parameters.syncToken, Parameters.accept3], serializer, }; const getLabelsNextOperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.LabelListResult, headersMapper: Mappers.AppConfigurationGetLabelsNextHeaders, }, default: { bodyMapper: Mappers.ErrorModel, }, }, urlParameters: [Parameters.endpoint, Parameters.nextLink], headerParameters: [ Parameters.syncToken, Parameters.acceptDatetime, Parameters.accept5, ], serializer, }; const getRevisionsNextOperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.KeyValueListResult, headersMapper: Mappers.AppConfigurationGetRevisionsNextHeaders, }, default: { bodyMapper: Mappers.ErrorModel, }, }, urlParameters: [Parameters.endpoint, Parameters.nextLink], headerParameters: [ Parameters.syncToken, Parameters.acceptDatetime, Parameters.accept1, ], serializer, }; //# sourceMappingURL=appConfiguration.js.map