import { PagedAsyncIterableIterator } from "@azure/core-paging" ; import { Vaults } from "../operationsInterfaces" ; import * as coreClient from "@azure/core-client" ; import * as Mappers from "../models/mappers" ; import * as Parameters from "../models/parameters" ; import { KeyVaultManagementClient } from "../keyVaultManagementClient" ; import { PollerLike , PollOperationState , LroEngine } from "@azure/core-lro" ; import { LroImpl } from "../lroImpl" ; import { Vault , VaultsListByResourceGroupNextOptionalParams , VaultsListByResourceGroupOptionalParams , VaultsListBySubscriptionNextOptionalParams , VaultsListBySubscriptionOptionalParams , DeletedVault , VaultsListDeletedNextOptionalParams , VaultsListDeletedOptionalParams , Resource , VaultsListNextOptionalParams , VaultsListOptionalParams , VaultCreateOrUpdateParameters , VaultsCreateOrUpdateOptionalParams , VaultsCreateOrUpdateResponse , VaultPatchParameters , VaultsUpdateOptionalParams , VaultsUpdateResponse , VaultsDeleteOptionalParams , VaultsGetOptionalParams , VaultsGetResponse , VaultAccessPolicyParameters , AccessPolicyUpdateKind , VaultsUpdateAccessPolicyOptionalParams , VaultsUpdateAccessPolicyResponse , VaultsListByResourceGroupResponse , VaultsListBySubscriptionResponse , VaultsListDeletedResponse , VaultsGetDeletedOptionalParams , VaultsGetDeletedResponse , VaultsPurgeDeletedOptionalParams , VaultsListResponse , VaultCheckNameAvailabilityParameters , VaultsCheckNameAvailabilityOptionalParams , VaultsCheckNameAvailabilityResponse , VaultsListByResourceGroupNextResponse , VaultsListBySubscriptionNextResponse , VaultsListDeletedNextResponse , VaultsListNextResponse } from "../models" ; /** Class containing Vaults operations. */ export class VaultsImpl implements Vaults { private readonly client : KeyVaultManagementClient ; param client constructor ( client ) { this . client = client ; } param resourceGroupName param options public listByResourceGroup ( resourceGroupName , options ? ) { const iter = this . listByResourceGroupPagingAll ( resourceGroupName , options ) ; return { next ( ) { return iter . next ( ) ; } , [ Symbol . asyncIterator ] ( ) { return this ; } , byPage : ( ) => { return this . listByResourceGroupPagingPage ( resourceGroupName , options ) ; } } ; } private async * listByResourceGroupPagingPage ( resourceGroupName , options ? ) { let result = await this . _listByResourceGroup ( resourceGroupName , options ) ; yield result . value || [ ] ; let continuationToken = result . nextLink ; while ( continuationToken ) { result = await this . _listByResourceGroupNext ( resourceGroupName , continuationToken , options ) ; continuationToken = result . nextLink ; yield result . value || [ ] ; } } private async * listByResourceGroupPagingAll ( resourceGroupName , options ? ) { for await ( const page of this . listByResourceGroupPagingPage ( resourceGroupName , options ) ) { yield * page ; } } param options public listBySubscription ( options ? ) { const iter = this . listBySubscriptionPagingAll ( options ) ; return { next ( ) { return iter . next ( ) ; } , [ Symbol . asyncIterator ] ( ) { return this ; } , byPage : ( ) => { return this . listBySubscriptionPagingPage ( options ) ; } } ; } private async * listBySubscriptionPagingPage ( options ? ) { let result = await this . _listBySubscription ( options ) ; yield result . value || [ ] ; let continuationToken = result . nextLink ; while ( continuationToken ) { result = await this . _listBySubscriptionNext ( continuationToken , options ) ; continuationToken = result . nextLink ; yield result . value || [ ] ; } } private async * listBySubscriptionPagingAll ( options ? ) { for await ( const page of this . listBySubscriptionPagingPage ( options ) ) { yield * page ; } } param options public listDeleted ( options ? ) { const iter = this . listDeletedPagingAll ( options ) ; return { next ( ) { return iter . next ( ) ; } , [ Symbol . asyncIterator ] ( ) { return this ; } , byPage : ( ) => { return this . listDeletedPagingPage ( options ) ; } } ; } private async * listDeletedPagingPage ( options ? ) { let result = await this . _listDeleted ( options ) ; yield result . value || [ ] ; let continuationToken = result . nextLink ; while ( continuationToken ) { result = await this . _listDeletedNext ( continuationToken , options ) ; continuationToken = result . nextLink ; yield result . value || [ ] ; } } private async * listDeletedPagingAll ( options ? ) { for await ( const page of this . listDeletedPagingPage ( options ) ) { yield * page ; } } param options public list ( options ? ) { const iter = this . listPagingAll ( options ) ; return { next ( ) { return iter . next ( ) ; } , [ Symbol . asyncIterator ] ( ) { return this ; } , byPage : ( ) => { return this . listPagingPage ( options ) ; } } ; } private async * listPagingPage ( options ? ) { let result = await this . _list ( options ) ; yield result . value || [ ] ; let continuationToken = result . nextLink ; while ( continuationToken ) { result = await this . _listNext ( continuationToken , options ) ; continuationToken = result . nextLink ; yield result . value || [ ] ; } } private async * listPagingAll ( options ? ) { for await ( const page of this . listPagingPage ( options ) ) { yield * page ; } } param resourceGroupName param vaultName param parameters param options async beginCreateOrUpdate ( resourceGroupName , vaultName , parameters , options ? ) { const directSendOperation = async ( args , spec ) : Promise < VaultsCreateOrUpdateResponse > => { return this . client . sendOperationRequest ( args , spec ) ; } ; const sendOperation = async ( args , spec ) => { let currentRawResponse = undefined ; const providedCallback = args . options ?. onResponse ; const callback = ( rawResponse , flatResponse ) => { currentRawResponse = rawResponse ; providedCallback ?. ( rawResponse , flatResponse ) ; } ; const updatedArgs = { ... args , options : { ... 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 = new LroImpl ( sendOperation , { resourceGroupName , vaultName , parameters , options } , createOrUpdateOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs } ) ; } param resourceGroupName param vaultName param parameters param options async beginCreateOrUpdateAndWait ( resourceGroupName , vaultName , parameters , options ? ) { const poller = await this . beginCreateOrUpdate ( resourceGroupName , vaultName , parameters , options ) ; return poller . pollUntilDone ( ) ; } param resourceGroupName param vaultName param parameters param options update ( resourceGroupName , vaultName , parameters , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , vaultName , parameters , options } , updateOperationSpec ) ; } param resourceGroupName param vaultName param options delete ( resourceGroupName , vaultName , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , vaultName , options } , deleteOperationSpec ) ; } param resourceGroupName param vaultName param options get ( resourceGroupName , vaultName , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , vaultName , options } , getOperationSpec ) ; } param resourceGroupName param vaultName param operationKind param parameters param options updateAccessPolicy ( resourceGroupName , vaultName , operationKind , parameters , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , vaultName , operationKind , parameters , options } , updateAccessPolicyOperationSpec ) ; } param resourceGroupName param options private _listByResourceGroup ( resourceGroupName , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , options } , listByResourceGroupOperationSpec ) ; } param options private _listBySubscription ( options ? ) { return this . client . sendOperationRequest ( { options } , listBySubscriptionOperationSpec ) ; } param options private _listDeleted ( options ? ) { return this . client . sendOperationRequest ( { options } , listDeletedOperationSpec ) ; } param vaultName param location param options getDeleted ( vaultName , location , options ? ) { return this . client . sendOperationRequest ( { vaultName , location , options } , getDeletedOperationSpec ) ; } param vaultName param location param options async beginPurgeDeleted ( vaultName , location , options ? ) { const directSendOperation = async ( args , spec ) : Promise < void > => { return this . client . sendOperationRequest ( args , spec ) ; } ; const sendOperation = async ( args , spec ) => { let currentRawResponse = undefined ; const providedCallback = args . options ?. onResponse ; const callback = ( rawResponse , flatResponse ) => { currentRawResponse = rawResponse ; providedCallback ?. ( rawResponse , flatResponse ) ; } ; const updatedArgs = { ... args , options : { ... 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 = new LroImpl ( sendOperation , { vaultName , location , options } , purgeDeletedOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs } ) ; } param vaultName param location param options async beginPurgeDeletedAndWait ( vaultName , location , options ? ) { const poller = await this . beginPurgeDeleted ( vaultName , location , options ) ; return poller . pollUntilDone ( ) ; } param options private _list ( options ? ) { return this . client . sendOperationRequest ( { options } , listOperationSpec ) ; } param vaultName param options checkNameAvailability ( vaultName , options ? ) { return this . client . sendOperationRequest ( { vaultName , options } , checkNameAvailabilityOperationSpec ) ; } param resourceGroupName param nextLink param options private _listByResourceGroupNext ( resourceGroupName , nextLink , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , nextLink , options } , listByResourceGroupNextOperationSpec ) ; } param nextLink param options private _listBySubscriptionNext ( nextLink , options ? ) { return this . client . sendOperationRequest ( { nextLink , options } , listBySubscriptionNextOperationSpec ) ; } param nextLink param options private _listDeletedNext ( nextLink , options ? ) { return this . client . sendOperationRequest ( { nextLink , options } , listDeletedNextOperationSpec ) ; } param nextLink param options private _listNext ( nextLink , options ? ) { return this . client . sendOperationRequest ( { nextLink , options } , listNextOperationSpec ) ; } } const serializer = coreClient . createSerializer ( Mappers , false ) ; const createOrUpdateOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}" , httpMethod : "PUT" , responses : { 200 : { bodyMapper : Mappers . Vault } , 201 : { bodyMapper : Mappers . Vault } , 202 : { bodyMapper : Mappers . Vault } , 204 : { bodyMapper : Mappers . Vault } , default : { bodyMapper : Mappers . CloudError } } , requestBody : Parameters . parameters1 , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName , Parameters . vaultName ] , headerParameters : [ Parameters . contentType , Parameters . accept ] , mediaType : "json" , serializer } ; const updateOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}" , httpMethod : "PATCH" , responses : { 200 : { bodyMapper : Mappers . Vault } , 201 : { bodyMapper : Mappers . Vault } , default : { bodyMapper : Mappers . CloudError } } , requestBody : Parameters . parameters2 , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName , Parameters . vaultName ] , headerParameters : [ Parameters . contentType , Parameters . accept ] , mediaType : "json" , serializer } ; const deleteOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}" , httpMethod : "DELETE" , responses : { 200 : { } , 204 : { } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName , Parameters . vaultName1 ] , headerParameters : [ Parameters . accept ] , serializer } ; const getOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . Vault } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName , Parameters . vaultName1 ] , headerParameters : [ Parameters . accept ] , serializer } ; const updateAccessPolicyOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/accessPolicies/{operationKind}" , httpMethod : "PUT" , responses : { 200 : { bodyMapper : Mappers . VaultAccessPolicyParameters } , 201 : { bodyMapper : Mappers . VaultAccessPolicyParameters } , default : { bodyMapper : Mappers . CloudError } } , requestBody : Parameters . parameters3 , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName , Parameters . vaultName , Parameters . operationKind ] , headerParameters : [ Parameters . contentType , Parameters . accept ] , mediaType : "json" , serializer } ; const listByResourceGroupOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . VaultListResult } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion , Parameters . top ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName ] , headerParameters : [ Parameters . accept ] , serializer } ; const listBySubscriptionOperationSpec = { path : "/subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/vaults" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . VaultListResult } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion , Parameters . top ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId ] , headerParameters : [ Parameters . accept ] , serializer } ; const listDeletedOperationSpec = { path : "/subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/deletedVaults" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . DeletedVaultListResult } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId ] , headerParameters : [ Parameters . accept ] , serializer } ; const getDeletedOperationSpec = { path : "/subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/locations/{location}/deletedVaults/{vaultName}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . DeletedVault } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . vaultName1 , Parameters . location ] , headerParameters : [ Parameters . accept ] , serializer } ; const purgeDeletedOperationSpec = { path : "/subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/locations/{location}/deletedVaults/{vaultName}/purge" , httpMethod : "POST" , responses : { 200 : { } , 201 : { } , 202 : { } , 204 : { } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . vaultName1 , Parameters . location ] , headerParameters : [ Parameters . accept ] , serializer } ; const listOperationSpec = { path : "/subscriptions/{subscriptionId}/resources" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . ResourceListResult } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . top , Parameters . filter , Parameters . apiVersion1 ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId ] , headerParameters : [ Parameters . accept ] , serializer } ; const checkNameAvailabilityOperationSpec = { path : "/subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/checkNameAvailability" , httpMethod : "POST" , responses : { 200 : { bodyMapper : Mappers . CheckNameAvailabilityResult } , default : { bodyMapper : Mappers . CloudError } } , requestBody : Parameters . vaultName2 , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId ] , headerParameters : [ Parameters . contentType , Parameters . accept ] , mediaType : "json" , serializer } ; const listByResourceGroupNextOperationSpec = { path : "{nextLink}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . VaultListResult } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion , Parameters . top ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName , Parameters . nextLink ] , headerParameters : [ Parameters . accept ] , serializer } ; const listBySubscriptionNextOperationSpec = { path : "{nextLink}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . VaultListResult } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion , Parameters . top ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . nextLink ] , headerParameters : [ Parameters . accept ] , serializer } ; const listDeletedNextOperationSpec = { path : "{nextLink}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . DeletedVaultListResult } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . nextLink ] , headerParameters : [ Parameters . accept ] , serializer } ; const listNextOperationSpec = { path : "{nextLink}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . ResourceListResult } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . top , Parameters . filter , Parameters . apiVersion1 ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . nextLink ] , headerParameters : [ Parameters . accept ] , serializer } ;