import { PagedAsyncIterableIterator } from "@azure/core-paging" ; import { StorageAccounts } from "../operationsInterfaces" ; import * as coreClient from "@azure/core-client" ; import * as Mappers from "../models/mappers" ; import * as Parameters from "../models/parameters" ; import { StorageManagementClient } from "../storageManagementClient" ; import { PollerLike , PollOperationState , LroEngine } from "@azure/core-lro" ; import { LroImpl } from "../lroImpl" ; import { StorageAccount , StorageAccountsListNextOptionalParams , StorageAccountsListOptionalParams , StorageAccountsListByResourceGroupNextOptionalParams , StorageAccountsListByResourceGroupOptionalParams , StorageAccountCheckNameAvailabilityParameters , StorageAccountsCheckNameAvailabilityOptionalParams , StorageAccountsCheckNameAvailabilityResponse , StorageAccountCreateParameters , StorageAccountsCreateOptionalParams , StorageAccountsCreateResponse , StorageAccountsDeleteOptionalParams , StorageAccountsGetPropertiesOptionalParams , StorageAccountsGetPropertiesResponse , StorageAccountUpdateParameters , StorageAccountsUpdateOptionalParams , StorageAccountsUpdateResponse , StorageAccountsListResponse , StorageAccountsListByResourceGroupResponse , StorageAccountsListKeysOptionalParams , StorageAccountsListKeysResponse , StorageAccountRegenerateKeyParameters , StorageAccountsRegenerateKeyOptionalParams , StorageAccountsRegenerateKeyResponse , AccountSasParameters , StorageAccountsListAccountSASOptionalParams , StorageAccountsListAccountSASResponse , ServiceSasParameters , StorageAccountsListServiceSASOptionalParams , StorageAccountsListServiceSASResponse , StorageAccountsFailoverOptionalParams , StorageAccountsHierarchicalNamespaceMigrationOptionalParams , StorageAccountsAbortHierarchicalNamespaceMigrationOptionalParams , BlobRestoreParameters , StorageAccountsRestoreBlobRangesOptionalParams , StorageAccountsRestoreBlobRangesResponse , StorageAccountsRevokeUserDelegationKeysOptionalParams , StorageAccountsListNextResponse , StorageAccountsListByResourceGroupNextResponse } from "../models" ; /** Class containing StorageAccounts operations. */ export class StorageAccountsImpl implements StorageAccounts { private readonly client : StorageManagementClient ; param client constructor ( client ) { this . client = client ; } 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 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 accountName param options checkNameAvailability ( accountName , options ? ) { return this . client . sendOperationRequest ( { accountName , options } , checkNameAvailabilityOperationSpec ) ; } param resourceGroupName param accountName param parameters param options async beginCreate ( resourceGroupName , accountName , parameters , options ? ) { const directSendOperation = async ( args , spec ) : Promise < StorageAccountsCreateResponse > => { 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 , accountName , parameters , options } , createOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs } ) ; } param resourceGroupName param accountName param parameters param options async beginCreateAndWait ( resourceGroupName , accountName , parameters , options ? ) { const poller = await this . beginCreate ( resourceGroupName , accountName , parameters , options ) ; return poller . pollUntilDone ( ) ; } param resourceGroupName param accountName param options delete ( resourceGroupName , accountName , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , accountName , options } , deleteOperationSpec ) ; } param resourceGroupName param accountName param options getProperties ( resourceGroupName , accountName , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , accountName , options } , getPropertiesOperationSpec ) ; } param resourceGroupName param accountName param parameters param options update ( resourceGroupName , accountName , parameters , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , accountName , parameters , options } , updateOperationSpec ) ; } param options private _list ( options ? ) { return this . client . sendOperationRequest ( { options } , listOperationSpec ) ; } param resourceGroupName param options private _listByResourceGroup ( resourceGroupName , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , options } , listByResourceGroupOperationSpec ) ; } param resourceGroupName param accountName param options listKeys ( resourceGroupName , accountName , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , accountName , options } , listKeysOperationSpec ) ; } param resourceGroupName param accountName param regenerateKey param options regenerateKey ( resourceGroupName , accountName , regenerateKey , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , accountName , regenerateKey , options } , regenerateKeyOperationSpec ) ; } param resourceGroupName param accountName param parameters param options listAccountSAS ( resourceGroupName , accountName , parameters , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , accountName , parameters , options } , listAccountSASOperationSpec ) ; } param resourceGroupName param accountName param parameters param options listServiceSAS ( resourceGroupName , accountName , parameters , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , accountName , parameters , options } , listServiceSASOperationSpec ) ; } param resourceGroupName param accountName param options async beginFailover ( resourceGroupName , accountName , 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 , { resourceGroupName , accountName , options } , failoverOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs , lroResourceLocationConfig : "location" } ) ; } param resourceGroupName param accountName param options async beginFailoverAndWait ( resourceGroupName , accountName , options ? ) { const poller = await this . beginFailover ( resourceGroupName , accountName , options ) ; return poller . pollUntilDone ( ) ; } param resourceGroupName param accountName param requestType param options async beginHierarchicalNamespaceMigration ( resourceGroupName , accountName , requestType , 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 , { resourceGroupName , accountName , requestType , options } , hierarchicalNamespaceMigrationOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs , lroResourceLocationConfig : "location" } ) ; } param resourceGroupName param accountName param requestType param options async beginHierarchicalNamespaceMigrationAndWait ( resourceGroupName , accountName , requestType , options ? ) { const poller = await this . beginHierarchicalNamespaceMigration ( resourceGroupName , accountName , requestType , options ) ; return poller . pollUntilDone ( ) ; } param resourceGroupName param accountName param options async beginAbortHierarchicalNamespaceMigration ( resourceGroupName , accountName , 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 , { resourceGroupName , accountName , options } , abortHierarchicalNamespaceMigrationOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs , lroResourceLocationConfig : "location" } ) ; } param resourceGroupName param accountName param options async beginAbortHierarchicalNamespaceMigrationAndWait ( resourceGroupName , accountName , options ? ) { const poller = await this . beginAbortHierarchicalNamespaceMigration ( resourceGroupName , accountName , options ) ; return poller . pollUntilDone ( ) ; } param resourceGroupName param accountName param parameters param options async beginRestoreBlobRanges ( resourceGroupName , accountName , parameters , options ? ) { const directSendOperation = async ( args , spec ) : Promise < StorageAccountsRestoreBlobRangesResponse > => { 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 , accountName , parameters , options } , restoreBlobRangesOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs , lroResourceLocationConfig : "location" } ) ; } param resourceGroupName param accountName param parameters param options async beginRestoreBlobRangesAndWait ( resourceGroupName , accountName , parameters , options ? ) { const poller = await this . beginRestoreBlobRanges ( resourceGroupName , accountName , parameters , options ) ; return poller . pollUntilDone ( ) ; } param resourceGroupName param accountName param options revokeUserDelegationKeys ( resourceGroupName , accountName , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , accountName , options } , revokeUserDelegationKeysOperationSpec ) ; } param nextLink param options private _listNext ( nextLink , options ? ) { return this . client . sendOperationRequest ( { nextLink , options } , listNextOperationSpec ) ; } param resourceGroupName param nextLink param options private _listByResourceGroupNext ( resourceGroupName , nextLink , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , nextLink , options } , listByResourceGroupNextOperationSpec ) ; } } const serializer = coreClient . createSerializer ( Mappers , false ) ; const checkNameAvailabilityOperationSpec = { path : "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" , httpMethod : "POST" , responses : { 200 : { bodyMapper : Mappers . CheckNameAvailabilityResult } } , requestBody : Parameters . accountName , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId ] , headerParameters : [ Parameters . accept , Parameters . contentType ] , mediaType : "json" , serializer } ; const createOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" , httpMethod : "PUT" , responses : { 200 : { bodyMapper : Mappers . StorageAccount } , 201 : { bodyMapper : Mappers . StorageAccount } , 202 : { bodyMapper : Mappers . StorageAccount } , 204 : { bodyMapper : Mappers . StorageAccount } } , requestBody : Parameters . parameters , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName , Parameters . accountName1 ] , headerParameters : [ Parameters . accept , Parameters . contentType ] , mediaType : "json" , serializer } ; const deleteOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" , httpMethod : "DELETE" , responses : { 200 : { } , 204 : { } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName , Parameters . accountName1 ] , serializer } ; const getPropertiesOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . StorageAccount } } , queryParameters : [ Parameters . apiVersion , Parameters . expand ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName , Parameters . accountName1 ] , headerParameters : [ Parameters . accept ] , serializer } ; const updateOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" , httpMethod : "PATCH" , responses : { 200 : { bodyMapper : Mappers . StorageAccount } } , requestBody : Parameters . parameters1 , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName , Parameters . accountName1 ] , headerParameters : [ Parameters . accept , Parameters . contentType ] , mediaType : "json" , serializer } ; const listOperationSpec = { path : "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . StorageAccountListResult } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId ] , headerParameters : [ Parameters . accept ] , serializer } ; const listByResourceGroupOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . StorageAccountListResult } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName ] , headerParameters : [ Parameters . accept ] , serializer } ; const listKeysOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" , httpMethod : "POST" , responses : { 200 : { bodyMapper : Mappers . StorageAccountListKeysResult } } , queryParameters : [ Parameters . apiVersion , Parameters . expand1 ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName , Parameters . accountName1 ] , headerParameters : [ Parameters . accept ] , serializer } ; const regenerateKeyOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" , httpMethod : "POST" , responses : { 200 : { bodyMapper : Mappers . StorageAccountListKeysResult } } , requestBody : Parameters . regenerateKey , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName , Parameters . accountName1 ] , headerParameters : [ Parameters . accept , Parameters . contentType ] , mediaType : "json" , serializer } ; const listAccountSASOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" , httpMethod : "POST" , responses : { 200 : { bodyMapper : Mappers . ListAccountSasResponse } } , requestBody : Parameters . parameters2 , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName , Parameters . accountName1 ] , headerParameters : [ Parameters . accept , Parameters . contentType ] , mediaType : "json" , serializer } ; const listServiceSASOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" , httpMethod : "POST" , responses : { 200 : { bodyMapper : Mappers . ListServiceSasResponse } } , requestBody : Parameters . parameters3 , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName , Parameters . accountName1 ] , headerParameters : [ Parameters . accept , Parameters . contentType ] , mediaType : "json" , serializer } ; const failoverOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" , httpMethod : "POST" , responses : { 200 : { } , 201 : { } , 202 : { } , 204 : { } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName , Parameters . accountName1 ] , serializer } ; const hierarchicalNamespaceMigrationOperationSpec = { path : "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration" , httpMethod : "POST" , responses : { 200 : { } , 201 : { } , 202 : { } , 204 : { } , default : { bodyMapper : Mappers . ErrorResponse } } , queryParameters : [ Parameters . apiVersion , Parameters . requestType ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName , Parameters . accountName1 ] , headerParameters : [ Parameters . accept ] , serializer } ; const abortHierarchicalNamespaceMigrationOperationSpec = { path : "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration" , httpMethod : "POST" , responses : { 200 : { } , 201 : { } , 202 : { } , 204 : { } , default : { bodyMapper : Mappers . ErrorResponse } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName , Parameters . accountName1 ] , headerParameters : [ Parameters . accept ] , serializer } ; const restoreBlobRangesOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" , httpMethod : "POST" , responses : { 200 : { bodyMapper : Mappers . BlobRestoreStatus } , 201 : { bodyMapper : Mappers . BlobRestoreStatus } , 202 : { bodyMapper : Mappers . BlobRestoreStatus } , 204 : { bodyMapper : Mappers . BlobRestoreStatus } } , requestBody : Parameters . parameters4 , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName , Parameters . accountName1 ] , headerParameters : [ Parameters . accept , Parameters . contentType ] , mediaType : "json" , serializer } ; const revokeUserDelegationKeysOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys" , httpMethod : "POST" , responses : { 200 : { } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName , Parameters . accountName1 ] , serializer } ; const listNextOperationSpec = { path : "{nextLink}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . StorageAccountListResult } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . nextLink ] , headerParameters : [ Parameters . accept ] , serializer } ; const listByResourceGroupNextOperationSpec = { path : "{nextLink}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . StorageAccountListResult } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName , Parameters . nextLink ] , headerParameters : [ Parameters . accept ] , serializer } ;