UNPKG

@azure/app-configuration

Version:
948 lines • 38.4 kB
// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import { _keyListResultDeserializer, errorDeserializer, _keyValueListResultDeserializer, keyValueSerializer, keyValueDeserializer, _snapshotListResultDeserializer, configurationSnapshotSerializer, configurationSnapshotDeserializer, operationDetailsDeserializer, snapshotUpdateParametersSerializer, _labelListResultDeserializer, } from "../models/models.js"; import { buildPagedAsyncIterator, } from "../static-helpers/pagingHelpers.js"; import { getLongRunningPoller } from "../static-helpers/pollingHelpers.js"; import { expandUrlTemplate } from "../static-helpers/urlTemplate.js"; import { createRestError, operationOptionsToRequestParameters, } from "@azure-rest/core-client"; export function _checkRevisionsSend(context, options = { requestOptions: {} }) { const path = expandUrlTemplate("/revisions{?api%2Dversion,key,label,After,%24Select,tags*}", { "api%2Dversion": context.apiVersion ?? "2026-04-01", key: options?.key, label: options?.label, After: options?.after, "%24Select": !options?.select ? options?.select : options?.select.map((p) => { return p; }), tags: !options?.tags ? options?.tags : options?.tags.map((p) => { return p; }), }, { allowReserved: options?.requestOptions?.skipUrlEncoding, }); return context .path(path) .head({ ...operationOptionsToRequestParameters(options), headers: { ...(options?.syncToken !== undefined ? { "sync-token": options?.syncToken } : {}), ...(options?.acceptDatetime !== undefined ? { "accept-datetime": options?.acceptDatetime } : {}), ...(options?.clientRequestId !== undefined ? { "x-ms-client-request-id": options?.clientRequestId } : {}), ...options.requestOptions?.headers, }, }); } export async function _checkRevisionsDeserialize(result) { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); if (result.body) { error.details = errorDeserializer(result.body); } throw error; } return; } /** Requests the headers and status of the given resource. */ export async function checkRevisions(context, options = { requestOptions: {} }) { const result = await _checkRevisionsSend(context, options); return _checkRevisionsDeserialize(result); } export function _getRevisionsSend(context, options = { requestOptions: {} }) { const path = expandUrlTemplate("/revisions{?api%2Dversion,key,label,After,%24Select,tags*}", { "api%2Dversion": context.apiVersion ?? "2026-04-01", key: options?.key, label: options?.label, After: options?.after, "%24Select": !options?.select ? options?.select : options?.select.map((p) => { return p; }), tags: !options?.tags ? options?.tags : options?.tags.map((p) => { return p; }), }, { allowReserved: options?.requestOptions?.skipUrlEncoding, }); return context .path(path) .get({ ...operationOptionsToRequestParameters(options), headers: { ...(options?.syncToken !== undefined ? { "sync-token": options?.syncToken } : {}), ...(options?.acceptDatetime !== undefined ? { "accept-datetime": options?.acceptDatetime } : {}), ...(options?.clientRequestId !== undefined ? { "x-ms-client-request-id": options?.clientRequestId } : {}), accept: "application/vnd.microsoft.appconfig.kvset+json, application/problem+json", ...options.requestOptions?.headers, }, }); } export async function _getRevisionsDeserialize(result) { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); if (result.body) { error.details = errorDeserializer(result.body); } throw error; } return _keyValueListResultDeserializer(result.body); } /** Gets a list of key-value revisions. */ export function getRevisions(context, options = { requestOptions: {} }) { return buildPagedAsyncIterator(context, () => _getRevisionsSend(context, options), _getRevisionsDeserialize, ["200"], { itemName: "items", nextLinkName: "@nextLink", apiVersion: context.apiVersion ?? "2026-04-01", }); } export function _deleteLockSend(context, key, options = { requestOptions: {} }) { const path = expandUrlTemplate("/locks/{key}{?api%2Dversion,label}", { key: key, "api%2Dversion": context.apiVersion ?? "2026-04-01", label: options?.label, }, { allowReserved: options?.requestOptions?.skipUrlEncoding, }); return context .path(path) .delete({ ...operationOptionsToRequestParameters(options), headers: { ...(options?.syncToken !== undefined ? { "sync-token": options?.syncToken } : {}), ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), ...(options?.ifNoneMatch !== undefined ? { "if-none-match": options?.ifNoneMatch } : {}), ...(options?.clientRequestId !== undefined ? { "x-ms-client-request-id": options?.clientRequestId } : {}), accept: "application/vnd.microsoft.appconfig.kv+json, application/problem+json", ...options.requestOptions?.headers, }, }); } export async function _deleteLockDeserialize(result) { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); if (result.body) { error.details = errorDeserializer(result.body); } throw error; } return keyValueDeserializer(result.body); } /** Unlocks a key-value. */ export async function deleteLock(context, key, options = { requestOptions: {} }) { const result = await _deleteLockSend(context, key, options); return _deleteLockDeserialize(result); } export function _putLockSend(context, key, options = { requestOptions: {} }) { const path = expandUrlTemplate("/locks/{key}{?api%2Dversion,label}", { key: key, "api%2Dversion": context.apiVersion ?? "2026-04-01", label: options?.label, }, { allowReserved: options?.requestOptions?.skipUrlEncoding, }); return context .path(path) .put({ ...operationOptionsToRequestParameters(options), headers: { ...(options?.syncToken !== undefined ? { "sync-token": options?.syncToken } : {}), ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), ...(options?.ifNoneMatch !== undefined ? { "if-none-match": options?.ifNoneMatch } : {}), ...(options?.clientRequestId !== undefined ? { "x-ms-client-request-id": options?.clientRequestId } : {}), accept: "application/vnd.microsoft.appconfig.kv+json, application/problem+json", ...options.requestOptions?.headers, }, }); } export async function _putLockDeserialize(result) { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); if (result.body) { error.details = errorDeserializer(result.body); } throw error; } return keyValueDeserializer(result.body); } /** Locks a key-value. */ export async function putLock(context, key, options = { requestOptions: {} }) { const result = await _putLockSend(context, key, options); return _putLockDeserialize(result); } export function _checkLabelsSend(context, options = { requestOptions: {} }) { const path = expandUrlTemplate("/labels{?api%2Dversion,name,After,%24Select}", { "api%2Dversion": context.apiVersion ?? "2026-04-01", name: options?.name, After: options?.after, "%24Select": !options?.select ? options?.select : options?.select.map((p) => { return p; }), }, { allowReserved: options?.requestOptions?.skipUrlEncoding, }); return context .path(path) .head({ ...operationOptionsToRequestParameters(options), headers: { ...(options?.syncToken !== undefined ? { "sync-token": options?.syncToken } : {}), ...(options?.acceptDatetime !== undefined ? { "accept-datetime": options?.acceptDatetime } : {}), ...(options?.clientRequestId !== undefined ? { "x-ms-client-request-id": options?.clientRequestId } : {}), ...options.requestOptions?.headers, }, }); } export async function _checkLabelsDeserialize(result) { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); if (result.body) { error.details = errorDeserializer(result.body); } throw error; } return; } /** Requests the headers and status of the given resource. */ export async function checkLabels(context, options = { requestOptions: {} }) { const result = await _checkLabelsSend(context, options); return _checkLabelsDeserialize(result); } export function _getLabelsSend(context, options = { requestOptions: {} }) { const path = expandUrlTemplate("/labels{?api%2Dversion,name,After,%24Select}", { "api%2Dversion": context.apiVersion ?? "2026-04-01", name: options?.name, After: options?.after, "%24Select": !options?.select ? options?.select : options?.select.map((p) => { return p; }), }, { allowReserved: options?.requestOptions?.skipUrlEncoding, }); return context .path(path) .get({ ...operationOptionsToRequestParameters(options), headers: { ...(options?.syncToken !== undefined ? { "sync-token": options?.syncToken } : {}), ...(options?.acceptDatetime !== undefined ? { "accept-datetime": options?.acceptDatetime } : {}), ...(options?.clientRequestId !== undefined ? { "x-ms-client-request-id": options?.clientRequestId } : {}), accept: "application/vnd.microsoft.appconfig.labelset+json, application/problem+json", ...options.requestOptions?.headers, }, }); } export async function _getLabelsDeserialize(result) { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); if (result.body) { error.details = errorDeserializer(result.body); } throw error; } return _labelListResultDeserializer(result.body); } /** Gets a list of labels. */ export function getLabels(context, options = { requestOptions: {} }) { return buildPagedAsyncIterator(context, () => _getLabelsSend(context, options), _getLabelsDeserialize, ["200"], { itemName: "items", nextLinkName: "@nextLink", apiVersion: context.apiVersion ?? "2026-04-01", }); } export function _checkSnapshotSend(context, name, options = { requestOptions: {} }) { const path = expandUrlTemplate("/snapshots/{name}{?api%2Dversion}", { name: name, "api%2Dversion": context.apiVersion ?? "2026-04-01", }, { allowReserved: options?.requestOptions?.skipUrlEncoding, }); return context .path(path) .head({ ...operationOptionsToRequestParameters(options), headers: { ...(options?.syncToken !== undefined ? { "sync-token": options?.syncToken } : {}), ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), ...(options?.ifNoneMatch !== undefined ? { "if-none-match": options?.ifNoneMatch } : {}), ...(options?.clientRequestId !== undefined ? { "x-ms-client-request-id": options?.clientRequestId } : {}), ...options.requestOptions?.headers, }, }); } export async function _checkSnapshotDeserialize(result) { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); if (result.body) { error.details = errorDeserializer(result.body); } throw error; } return; } /** Requests the headers and status of the given resource. */ export async function checkSnapshot(context, name, options = { requestOptions: {} }) { const result = await _checkSnapshotSend(context, name, options); return _checkSnapshotDeserialize(result); } export function _updateSnapshotSend(context, contentType, name, entity, options = { requestOptions: {} }) { const path = expandUrlTemplate("/snapshots/{name}{?api%2Dversion}", { name: name, "api%2Dversion": context.apiVersion ?? "2026-04-01", }, { allowReserved: options?.requestOptions?.skipUrlEncoding, }); return context .path(path) .patch({ ...operationOptionsToRequestParameters(options), contentType: contentType, headers: { ...(options?.syncToken !== undefined ? { "sync-token": options?.syncToken } : {}), ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), ...(options?.ifNoneMatch !== undefined ? { "if-none-match": options?.ifNoneMatch } : {}), ...(options?.clientRequestId !== undefined ? { "x-ms-client-request-id": options?.clientRequestId } : {}), accept: "application/vnd.microsoft.appconfig.snapshot+json, application/problem+json", ...options.requestOptions?.headers, }, body: snapshotUpdateParametersSerializer(entity), }); } export async function _updateSnapshotDeserialize(result) { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); if (result.body) { error.details = errorDeserializer(result.body); } throw error; } return configurationSnapshotDeserializer(result.body); } /** Updates the state of a key-value snapshot. */ export async function updateSnapshot(context, contentType, name, entity, options = { requestOptions: {} }) { const result = await _updateSnapshotSend(context, contentType, name, entity, options); return _updateSnapshotDeserialize(result); } export function _createSnapshotSend(context, contentType, name, entity, options = { requestOptions: {} }) { const path = expandUrlTemplate("/snapshots/{name}{?api%2Dversion}", { name: name, "api%2Dversion": context.apiVersion ?? "2026-04-01", }, { allowReserved: options?.requestOptions?.skipUrlEncoding, }); return context .path(path) .put({ ...operationOptionsToRequestParameters(options), contentType: contentType, headers: { ...(options?.syncToken !== undefined ? { "sync-token": options?.syncToken } : {}), accept: "application/vnd.microsoft.appconfig.snapshot+json, application/problem+json", ...options.requestOptions?.headers, }, body: configurationSnapshotSerializer(entity), }); } export async function _createSnapshotDeserialize(result) { const expectedStatuses = ["201", "200", "202"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); if (result.body) { error.details = errorDeserializer(result.body); } throw error; } return configurationSnapshotDeserializer(result.body); } /** Creates a key-value snapshot. */ export function createSnapshot(context, contentType, name, entity, options = { requestOptions: {} }) { return getLongRunningPoller(context, _createSnapshotDeserialize, ["201", "200", "202"], { updateIntervalInMs: options?.updateIntervalInMs, abortSignal: options?.abortSignal, getInitialResponse: () => _createSnapshotSend(context, contentType, name, entity, options), resourceLocationConfig: "original-uri", apiVersion: context.apiVersion ?? "2026-04-01", }); } export function _getOperationDetailsSend(context, snapshot, options = { requestOptions: {} }) { const path = expandUrlTemplate("/operations{?api%2Dversion,snapshot}", { "api%2Dversion": context.apiVersion ?? "2026-04-01", snapshot: snapshot, }, { allowReserved: options?.requestOptions?.skipUrlEncoding, }); return context .path(path) .get({ ...operationOptionsToRequestParameters(options), headers: { ...(options?.clientRequestId !== undefined ? { "x-ms-client-request-id": options?.clientRequestId } : {}), accept: "application/json", ...options.requestOptions?.headers, }, }); } export async function _getOperationDetailsDeserialize(result) { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); if (result.body) { error.details = errorDeserializer(result.body); } throw error; } return operationDetailsDeserializer(result.body); } /** Gets the state of a long running operation. */ export async function getOperationDetails(context, snapshot, options = { requestOptions: {} }) { const result = await _getOperationDetailsSend(context, snapshot, options); return _getOperationDetailsDeserialize(result); } export function _getSnapshotSend(context, name, options = { requestOptions: {} }) { const path = expandUrlTemplate("/snapshots/{name}{?api%2Dversion,%24Select}", { name: name, "api%2Dversion": context.apiVersion ?? "2026-04-01", "%24Select": !options?.select ? options?.select : options?.select.map((p) => { return p; }), }, { allowReserved: options?.requestOptions?.skipUrlEncoding, }); return context .path(path) .get({ ...operationOptionsToRequestParameters(options), headers: { ...(options?.syncToken !== undefined ? { "sync-token": options?.syncToken } : {}), ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), ...(options?.ifNoneMatch !== undefined ? { "if-none-match": options?.ifNoneMatch } : {}), ...(options?.clientRequestId !== undefined ? { "x-ms-client-request-id": options?.clientRequestId } : {}), accept: "application/vnd.microsoft.appconfig.snapshot+json, application/problem+json", ...options.requestOptions?.headers, }, }); } export async function _getSnapshotDeserialize(result) { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); if (result.body) { error.details = errorDeserializer(result.body); } throw error; } return configurationSnapshotDeserializer(result.body); } /** Gets a single key-value snapshot. */ export async function getSnapshot(context, name, options = { requestOptions: {} }) { const result = await _getSnapshotSend(context, name, options); return _getSnapshotDeserialize(result); } export function _checkSnapshotsSend(context, options = { requestOptions: {} }) { const path = expandUrlTemplate("/snapshots{?api%2Dversion,After}", { "api%2Dversion": context.apiVersion ?? "2026-04-01", After: options?.after, }, { allowReserved: options?.requestOptions?.skipUrlEncoding, }); return context .path(path) .head({ ...operationOptionsToRequestParameters(options), headers: { ...(options?.syncToken !== undefined ? { "sync-token": options?.syncToken } : {}), ...(options?.clientRequestId !== undefined ? { "x-ms-client-request-id": options?.clientRequestId } : {}), ...options.requestOptions?.headers, }, }); } export async function _checkSnapshotsDeserialize(result) { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); if (result.body) { error.details = errorDeserializer(result.body); } throw error; } return; } /** Requests the headers and status of the given resource. */ export async function checkSnapshots(context, options = { requestOptions: {} }) { const result = await _checkSnapshotsSend(context, options); return _checkSnapshotsDeserialize(result); } export function _getSnapshotsSend(context, options = { requestOptions: {} }) { const path = expandUrlTemplate("/snapshots{?api%2Dversion,name,After,%24Select,status}", { "api%2Dversion": context.apiVersion ?? "2026-04-01", name: options?.name, After: options?.after, "%24Select": !options?.select ? options?.select : options?.select.map((p) => { return p; }), status: !options?.status ? options?.status : options?.status.map((p) => { return p; }), }, { allowReserved: options?.requestOptions?.skipUrlEncoding, }); return context .path(path) .get({ ...operationOptionsToRequestParameters(options), headers: { ...(options?.syncToken !== undefined ? { "sync-token": options?.syncToken } : {}), accept: "application/vnd.microsoft.appconfig.snapshotset+json, application/problem+json", ...options.requestOptions?.headers, }, }); } export async function _getSnapshotsDeserialize(result) { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); if (result.body) { error.details = errorDeserializer(result.body); } throw error; } return _snapshotListResultDeserializer(result.body); } /** Gets a list of key-value snapshots. */ export function getSnapshots(context, options = { requestOptions: {} }) { return buildPagedAsyncIterator(context, () => _getSnapshotsSend(context, options), _getSnapshotsDeserialize, ["200"], { itemName: "items", nextLinkName: "@nextLink", apiVersion: context.apiVersion ?? "2026-04-01", }); } export function _checkKeyValueSend(context, key, options = { requestOptions: {} }) { const path = expandUrlTemplate("/kv/{key}{?api%2Dversion,label,%24Select,tags*}", { key: key, "api%2Dversion": context.apiVersion ?? "2026-04-01", label: options?.label, "%24Select": !options?.select ? options?.select : options?.select.map((p) => { return p; }), tags: !options?.tags ? options?.tags : options?.tags.map((p) => { return p; }), }, { allowReserved: options?.requestOptions?.skipUrlEncoding, }); return context .path(path) .head({ ...operationOptionsToRequestParameters(options), headers: { ...(options?.syncToken !== undefined ? { "sync-token": options?.syncToken } : {}), ...(options?.acceptDatetime !== undefined ? { "accept-datetime": options?.acceptDatetime } : {}), ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), ...(options?.ifNoneMatch !== undefined ? { "if-none-match": options?.ifNoneMatch } : {}), ...(options?.clientRequestId !== undefined ? { "x-ms-client-request-id": options?.clientRequestId } : {}), ...options.requestOptions?.headers, }, }); } export async function _checkKeyValueDeserialize(result) { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); if (result.body) { error.details = errorDeserializer(result.body); } throw error; } return; } /** Requests the headers and status of the given resource. */ export async function checkKeyValue(context, key, options = { requestOptions: {} }) { const result = await _checkKeyValueSend(context, key, options); return _checkKeyValueDeserialize(result); } export function _deleteKeyValueSend(context, key, options = { requestOptions: {} }) { const path = expandUrlTemplate("/kv/{key}{?api%2Dversion,label}", { key: key, "api%2Dversion": context.apiVersion ?? "2026-04-01", label: options?.label, }, { allowReserved: options?.requestOptions?.skipUrlEncoding, }); return context .path(path) .delete({ ...operationOptionsToRequestParameters(options), headers: { ...(options?.syncToken !== undefined ? { "sync-token": options?.syncToken } : {}), ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), ...(options?.clientRequestId !== undefined ? { "x-ms-client-request-id": options?.clientRequestId } : {}), accept: "application/vnd.microsoft.appconfig.kv+json, application/problem+json", ...options.requestOptions?.headers, }, }); } export async function _deleteKeyValueDeserialize(result) { const expectedStatuses = ["200", "204"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); if (result.body) { error.details = errorDeserializer(result.body); } throw error; } return result.body ? keyValueDeserializer(result.body) : undefined; } /** Deletes a key-value. */ export async function deleteKeyValue(context, key, options = { requestOptions: {} }) { const result = await _deleteKeyValueSend(context, key, options); return _deleteKeyValueDeserialize(result); } export function _putKeyValueSend(context, contentType, key, options = { requestOptions: {} }) { const path = expandUrlTemplate("/kv/{key}{?api%2Dversion,label}", { key: key, "api%2Dversion": context.apiVersion ?? "2026-04-01", label: options?.label, }, { allowReserved: options?.requestOptions?.skipUrlEncoding, }); return context .path(path) .put({ ...operationOptionsToRequestParameters(options), contentType: contentType, headers: { ...(options?.syncToken !== undefined ? { "sync-token": options?.syncToken } : {}), ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), ...(options?.ifNoneMatch !== undefined ? { "if-none-match": options?.ifNoneMatch } : {}), ...(options?.clientRequestId !== undefined ? { "x-ms-client-request-id": options?.clientRequestId } : {}), accept: "application/vnd.microsoft.appconfig.kv+json, application/problem+json", ...options.requestOptions?.headers, }, body: !options?.entity ? options?.entity : keyValueSerializer(options?.entity), }); } export async function _putKeyValueDeserialize(result) { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); if (result.body) { error.details = errorDeserializer(result.body); } throw error; } return keyValueDeserializer(result.body); } /** Creates a key-value. */ export async function putKeyValue(context, contentType, key, options = { requestOptions: {} }) { const result = await _putKeyValueSend(context, contentType, key, options); return _putKeyValueDeserialize(result); } export function _getKeyValueSend(context, key, options = { requestOptions: {} }) { const path = expandUrlTemplate("/kv/{key}{?api%2Dversion,label,%24Select,tags*}", { key: key, "api%2Dversion": context.apiVersion ?? "2026-04-01", label: options?.label, "%24Select": !options?.select ? options?.select : options?.select.map((p) => { return p; }), tags: !options?.tags ? options?.tags : options?.tags.map((p) => { return p; }), }, { allowReserved: options?.requestOptions?.skipUrlEncoding, }); return context .path(path) .get({ ...operationOptionsToRequestParameters(options), headers: { ...(options?.syncToken !== undefined ? { "sync-token": options?.syncToken } : {}), ...(options?.acceptDatetime !== undefined ? { "accept-datetime": options?.acceptDatetime } : {}), ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), ...(options?.ifNoneMatch !== undefined ? { "if-none-match": options?.ifNoneMatch } : {}), ...(options?.clientRequestId !== undefined ? { "x-ms-client-request-id": options?.clientRequestId } : {}), accept: "application/vnd.microsoft.appconfig.kv+json, application/problem+json", ...options.requestOptions?.headers, }, }); } export async function _getKeyValueDeserialize(result) { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); if (result.body) { error.details = errorDeserializer(result.body); } throw error; } return keyValueDeserializer(result.body); } /** Gets a single key-value. */ export async function getKeyValue(context, key, options = { requestOptions: {} }) { const result = await _getKeyValueSend(context, key, options); return _getKeyValueDeserialize(result); } export function _checkKeyValuesSend(context, options = { requestOptions: {} }) { const path = expandUrlTemplate("/kv{?api%2Dversion,key,label,After,%24Select,snapshot,tags*}", { "api%2Dversion": context.apiVersion ?? "2026-04-01", key: options?.key, label: options?.label, After: options?.after, "%24Select": !options?.select ? options?.select : options?.select.map((p) => { return p; }), snapshot: options?.snapshot, tags: !options?.tags ? options?.tags : options?.tags.map((p) => { return p; }), }, { allowReserved: options?.requestOptions?.skipUrlEncoding, }); return context .path(path) .head({ ...operationOptionsToRequestParameters(options), headers: { ...(options?.syncToken !== undefined ? { "sync-token": options?.syncToken } : {}), ...(options?.acceptDatetime !== undefined ? { "accept-datetime": options?.acceptDatetime } : {}), ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), ...(options?.ifNoneMatch !== undefined ? { "if-none-match": options?.ifNoneMatch } : {}), ...(options?.clientRequestId !== undefined ? { "x-ms-client-request-id": options?.clientRequestId } : {}), ...options.requestOptions?.headers, }, }); } export async function _checkKeyValuesDeserialize(result) { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); if (result.body) { error.details = errorDeserializer(result.body); } throw error; } return; } /** Requests the headers and status of the given resource. */ export async function checkKeyValues(context, options = { requestOptions: {} }) { const result = await _checkKeyValuesSend(context, options); return _checkKeyValuesDeserialize(result); } export function _getKeyValuesSend(context, options = { requestOptions: {} }) { const path = expandUrlTemplate("/kv{?api%2Dversion,key,label,After,%24Select,snapshot,tags*}", { "api%2Dversion": context.apiVersion ?? "2026-04-01", key: options?.key, label: options?.label, After: options?.after, "%24Select": !options?.select ? options?.select : options?.select.map((p) => { return p; }), snapshot: options?.snapshot, tags: !options?.tags ? options?.tags : options?.tags.map((p) => { return p; }), }, { allowReserved: options?.requestOptions?.skipUrlEncoding, }); return context .path(path) .get({ ...operationOptionsToRequestParameters(options), headers: { ...(options?.syncToken !== undefined ? { "sync-token": options?.syncToken } : {}), ...(options?.acceptDatetime !== undefined ? { "accept-datetime": options?.acceptDatetime } : {}), ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), ...(options?.ifNoneMatch !== undefined ? { "if-none-match": options?.ifNoneMatch } : {}), accept: "application/vnd.microsoft.appconfig.kvset+json, application/problem+json", ...options.requestOptions?.headers, }, }); } export async function _getKeyValuesDeserialize(result) { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); if (result.body) { error.details = errorDeserializer(result.body); } throw error; } return _keyValueListResultDeserializer(result.body); } /** Gets a list of key-values. */ export function getKeyValues(context, options = { requestOptions: {} }) { return buildPagedAsyncIterator(context, () => _getKeyValuesSend(context, options), _getKeyValuesDeserialize, ["200"], { itemName: "items", nextLinkName: "@nextLink", apiVersion: context.apiVersion ?? "2026-04-01", }); } export function _checkKeysSend(context, options = { requestOptions: {} }) { const path = expandUrlTemplate("/keys{?api%2Dversion,name,After}", { "api%2Dversion": context.apiVersion ?? "2026-04-01", name: options?.name, After: options?.after, }, { allowReserved: options?.requestOptions?.skipUrlEncoding, }); return context .path(path) .head({ ...operationOptionsToRequestParameters(options), headers: { ...(options?.syncToken !== undefined ? { "sync-token": options?.syncToken } : {}), ...(options?.acceptDatetime !== undefined ? { "accept-datetime": options?.acceptDatetime } : {}), ...(options?.clientRequestId !== undefined ? { "x-ms-client-request-id": options?.clientRequestId } : {}), ...options.requestOptions?.headers, }, }); } export async function _checkKeysDeserialize(result) { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); if (result.body) { error.details = errorDeserializer(result.body); } throw error; } return; } /** Requests the headers and status of the given resource. */ export async function checkKeys(context, options = { requestOptions: {} }) { const result = await _checkKeysSend(context, options); return _checkKeysDeserialize(result); } export function _getKeysSend(context, options = { requestOptions: {} }) { const path = expandUrlTemplate("/keys{?api%2Dversion,name,After}", { "api%2Dversion": context.apiVersion ?? "2026-04-01", name: options?.name, After: options?.after, }, { allowReserved: options?.requestOptions?.skipUrlEncoding, }); return context .path(path) .get({ ...operationOptionsToRequestParameters(options), headers: { ...(options?.syncToken !== undefined ? { "sync-token": options?.syncToken } : {}), ...(options?.acceptDatetime !== undefined ? { "accept-datetime": options?.acceptDatetime } : {}), accept: "application/vnd.microsoft.appconfig.keyset+json, application/problem+json", ...options.requestOptions?.headers, }, }); } export async function _getKeysDeserialize(result) { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); if (result.body) { error.details = errorDeserializer(result.body); } throw error; } return _keyListResultDeserializer(result.body); } /** Gets a list of keys. */ export function getKeys(context, options = { requestOptions: {} }) { return buildPagedAsyncIterator(context, () => _getKeysSend(context, options), _getKeysDeserialize, ["200"], { itemName: "items", nextLinkName: "@nextLink", apiVersion: context.apiVersion ?? "2026-04-01", }); } //# sourceMappingURL=operations.js.map