import * as coreClient from "@azure/core-client" ; import * as Parameters from "./models/parameters" ; import * as Mappers from "./models/mappers" ; import { ApiVersion72Preview , KeyVaultClientOptionalParams , SetSecretOptionalParams , SetSecretResponse , DeleteSecretOptionalParams , DeleteSecretResponse , UpdateSecretOptionalParams , UpdateSecretResponse , GetSecretOptionalParams , GetSecretResponse , GetSecretsOptionalParams , GetSecretsResponse , GetSecretVersionsOptionalParams , GetSecretVersionsResponse , GetDeletedSecretsOptionalParams , GetDeletedSecretsResponse , GetDeletedSecretOptionalParams , GetDeletedSecretResponse , PurgeDeletedSecretOptionalParams , RecoverDeletedSecretOptionalParams , RecoverDeletedSecretResponse , BackupSecretOptionalParams , BackupSecretResponse , RestoreSecretOptionalParams , RestoreSecretResponse , GetSecretsNextOptionalParams , GetSecretsNextResponse , GetSecretVersionsNextOptionalParams , GetSecretVersionsNextResponse , GetDeletedSecretsNextOptionalParams , GetDeletedSecretsNextResponse } from "./models" ; internal export class KeyVaultClient extends coreClient . ServiceClient { apiVersion : ApiVersion72Preview ; param apiVersion param options constructor ( apiVersion , options ? ) { if ( apiVersion === undefined ) { throw new Error ( "'apiVersion' cannot be null" ) ; } if ( ! options ) { options = { } ; } const defaults = { requestContentType : "application/json; charset=utf-8" } ; const packageDetails = `azsdk-js-keyvault-secrets/1.0.0-preview1` ; const userAgentPrefix = options . userAgentOptions && options . userAgentOptions . userAgentPrefix ? `${ options . userAgentOptions . userAgentPrefix } ${ packageDetails }` : `${ packageDetails }` ; const optionsWithDefaults = { ... defaults , ... options , userAgentOptions : { userAgentPrefix } , baseUri : options . endpoint || "{vaultBaseUrl}" } ; super ( optionsWithDefaults ) ; this . apiVersion = apiVersion ; } param vaultBaseUrl param secretName param value param options setSecret ( vaultBaseUrl , secretName , value , options ? ) { return this . sendOperationRequest ( { vaultBaseUrl , secretName , value , options } , setSecretOperationSpec ) ; } param vaultBaseUrl param secretName param options deleteSecret ( vaultBaseUrl , secretName , options ? ) { return this . sendOperationRequest ( { vaultBaseUrl , secretName , options } , deleteSecretOperationSpec ) ; } param vaultBaseUrl param secretName param secretVersion param options updateSecret ( vaultBaseUrl , secretName , secretVersion , options ? ) { return this . sendOperationRequest ( { vaultBaseUrl , secretName , secretVersion , options } , updateSecretOperationSpec ) ; } param vaultBaseUrl param secretName param secretVersion param options getSecret ( vaultBaseUrl , secretName , secretVersion , options ? ) { return this . sendOperationRequest ( { vaultBaseUrl , secretName , secretVersion , options } , getSecretOperationSpec ) ; } param vaultBaseUrl param options getSecrets ( vaultBaseUrl , options ? ) { return this . sendOperationRequest ( { vaultBaseUrl , options } , getSecretsOperationSpec ) ; } param vaultBaseUrl param secretName param options getSecretVersions ( vaultBaseUrl , secretName , options ? ) { return this . sendOperationRequest ( { vaultBaseUrl , secretName , options } , getSecretVersionsOperationSpec ) ; } param vaultBaseUrl param options getDeletedSecrets ( vaultBaseUrl , options ? ) { return this . sendOperationRequest ( { vaultBaseUrl , options } , getDeletedSecretsOperationSpec ) ; } param vaultBaseUrl param secretName param options getDeletedSecret ( vaultBaseUrl , secretName , options ? ) { return this . sendOperationRequest ( { vaultBaseUrl , secretName , options } , getDeletedSecretOperationSpec ) ; } param vaultBaseUrl param secretName param options purgeDeletedSecret ( vaultBaseUrl , secretName , options ? ) { return this . sendOperationRequest ( { vaultBaseUrl , secretName , options } , purgeDeletedSecretOperationSpec ) ; } param vaultBaseUrl param secretName param options recoverDeletedSecret ( vaultBaseUrl , secretName , options ? ) { return this . sendOperationRequest ( { vaultBaseUrl , secretName , options } , recoverDeletedSecretOperationSpec ) ; } param vaultBaseUrl param secretName param options backupSecret ( vaultBaseUrl , secretName , options ? ) { return this . sendOperationRequest ( { vaultBaseUrl , secretName , options } , backupSecretOperationSpec ) ; } param vaultBaseUrl param secretBundleBackup param options restoreSecret ( vaultBaseUrl , secretBundleBackup , options ? ) { return this . sendOperationRequest ( { vaultBaseUrl , secretBundleBackup , options } , restoreSecretOperationSpec ) ; } param vaultBaseUrl param nextLink param options getSecretsNext ( vaultBaseUrl , nextLink , options ? ) { return this . sendOperationRequest ( { vaultBaseUrl , nextLink , options } , getSecretsNextOperationSpec ) ; } param vaultBaseUrl param secretName param nextLink param options getSecretVersionsNext ( vaultBaseUrl , secretName , nextLink , options ? ) { return this . sendOperationRequest ( { vaultBaseUrl , secretName , nextLink , options } , getSecretVersionsNextOperationSpec ) ; } param vaultBaseUrl param nextLink param options getDeletedSecretsNext ( vaultBaseUrl , nextLink , options ? ) { return this . sendOperationRequest ( { vaultBaseUrl , nextLink , options } , getDeletedSecretsNextOperationSpec ) ; } } const serializer = coreClient . createSerializer ( Mappers , false ) ; const setSecretOperationSpec = { path : "/secrets/{secret-name}" , httpMethod : "PUT" , responses : { 200 : { bodyMapper : Mappers . SecretBundle } , default : { bodyMapper : Mappers . KeyVaultError } } , requestBody : { parameterPath : { value : [ "value" ] , tags : [ "options" , "tags" ] , contentType : [ "options" , "contentType" ] , secretAttributes : [ "options" , "secretAttributes" ] } , mapper : { ... Mappers . SecretSetParameters , required : true } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . vaultBaseUrl , Parameters . secretName ] , headerParameters : [ Parameters . contentType , Parameters . accept ] , mediaType : "json" , serializer } ; const deleteSecretOperationSpec = { path : "/secrets/{secret-name}" , httpMethod : "DELETE" , responses : { 200 : { bodyMapper : Mappers . DeletedSecretBundle } , default : { bodyMapper : Mappers . KeyVaultError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . vaultBaseUrl , Parameters . secretName1 ] , headerParameters : [ Parameters . accept ] , serializer } ; const updateSecretOperationSpec = { path : "/secrets/{secret-name}/{secret-version}" , httpMethod : "PATCH" , responses : { 200 : { bodyMapper : Mappers . SecretBundle } , default : { bodyMapper : Mappers . KeyVaultError } } , requestBody : { parameterPath : { contentType : [ "options" , "contentType" ] , secretAttributes : [ "options" , "secretAttributes" ] , tags : [ "options" , "tags" ] } , mapper : { ... Mappers . SecretUpdateParameters , required : true } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . vaultBaseUrl , Parameters . secretName1 , Parameters . secretVersion ] , headerParameters : [ Parameters . contentType , Parameters . accept ] , mediaType : "json" , serializer } ; const getSecretOperationSpec = { path : "/secrets/{secret-name}/{secret-version}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . SecretBundle } , default : { bodyMapper : Mappers . KeyVaultError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . vaultBaseUrl , Parameters . secretName1 , Parameters . secretVersion ] , headerParameters : [ Parameters . accept ] , serializer } ; const getSecretsOperationSpec = { path : "/secrets" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . SecretListResult } , default : { bodyMapper : Mappers . KeyVaultError } } , queryParameters : [ Parameters . apiVersion , Parameters . maxresults ] , urlParameters : [ Parameters . vaultBaseUrl ] , headerParameters : [ Parameters . accept ] , serializer } ; const getSecretVersionsOperationSpec = { path : "/secrets/{secret-name}/versions" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . SecretListResult } , default : { bodyMapper : Mappers . KeyVaultError } } , queryParameters : [ Parameters . apiVersion , Parameters . maxresults ] , urlParameters : [ Parameters . vaultBaseUrl , Parameters . secretName1 ] , headerParameters : [ Parameters . accept ] , serializer } ; const getDeletedSecretsOperationSpec = { path : "/deletedsecrets" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . DeletedSecretListResult } , default : { bodyMapper : Mappers . KeyVaultError } } , queryParameters : [ Parameters . apiVersion , Parameters . maxresults ] , urlParameters : [ Parameters . vaultBaseUrl ] , headerParameters : [ Parameters . accept ] , serializer } ; const getDeletedSecretOperationSpec = { path : "/deletedsecrets/{secret-name}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . DeletedSecretBundle } , default : { bodyMapper : Mappers . KeyVaultError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . vaultBaseUrl , Parameters . secretName1 ] , headerParameters : [ Parameters . accept ] , serializer } ; const purgeDeletedSecretOperationSpec = { path : "/deletedsecrets/{secret-name}" , httpMethod : "DELETE" , responses : { 204 : { } , default : { bodyMapper : Mappers . KeyVaultError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . vaultBaseUrl , Parameters . secretName1 ] , headerParameters : [ Parameters . accept ] , serializer } ; const recoverDeletedSecretOperationSpec = { path : "/deletedsecrets/{secret-name}/recover" , httpMethod : "POST" , responses : { 200 : { bodyMapper : Mappers . SecretBundle } , default : { bodyMapper : Mappers . KeyVaultError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . vaultBaseUrl , Parameters . secretName1 ] , headerParameters : [ Parameters . accept ] , serializer } ; const backupSecretOperationSpec = { path : "/secrets/{secret-name}/backup" , httpMethod : "POST" , responses : { 200 : { bodyMapper : Mappers . BackupSecretResult } , default : { bodyMapper : Mappers . KeyVaultError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . vaultBaseUrl , Parameters . secretName1 ] , headerParameters : [ Parameters . accept ] , serializer } ; const restoreSecretOperationSpec = { path : "/secrets/restore" , httpMethod : "POST" , responses : { 200 : { bodyMapper : Mappers . SecretBundle } , default : { bodyMapper : Mappers . KeyVaultError } } , requestBody : { parameterPath : { secretBundleBackup : [ "secretBundleBackup" ] } , mapper : { ... Mappers . SecretRestoreParameters , required : true } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . vaultBaseUrl ] , headerParameters : [ Parameters . contentType , Parameters . accept ] , mediaType : "json" , serializer } ; const getSecretsNextOperationSpec = { path : "{nextLink}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . SecretListResult } , default : { bodyMapper : Mappers . KeyVaultError } } , queryParameters : [ Parameters . apiVersion , Parameters . maxresults ] , urlParameters : [ Parameters . vaultBaseUrl , Parameters . nextLink ] , headerParameters : [ Parameters . accept ] , serializer } ; const getSecretVersionsNextOperationSpec = { path : "{nextLink}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . SecretListResult } , default : { bodyMapper : Mappers . KeyVaultError } } , queryParameters : [ Parameters . apiVersion , Parameters . maxresults ] , urlParameters : [ Parameters . vaultBaseUrl , Parameters . secretName1 , Parameters . nextLink ] , headerParameters : [ Parameters . accept ] , serializer } ; const getDeletedSecretsNextOperationSpec = { path : "{nextLink}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . DeletedSecretListResult } , default : { bodyMapper : Mappers . KeyVaultError } } , queryParameters : [ Parameters . apiVersion , Parameters . maxresults ] , urlParameters : [ Parameters . vaultBaseUrl , Parameters . nextLink ] , headerParameters : [ Parameters . accept ] , serializer } ;