text: # coding=utf-8
  # --------------------------------------------------------------------------
  # Copyright (c) Microsoft Corporation. All rights reserved.
  # Licensed under the MIT License. See License.txt in the project root for license information.
  # Code generated by Microsoft (R) AutoRest Code Generator.
  # Changes may cause incorrect behavior and will be lost if the code is regenerated.
  # --------------------------------------------------------------------------
  import functools
  from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union
  import warnings
  
  from azure.core.async_paging import AsyncItemPaged, AsyncList
  from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
  from azure.core.pipeline import PipelineResponse
  from azure.core.pipeline.transport import AsyncHttpResponse
  from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
  from azure.core.rest import HttpRequest
  from azure.core.tracing.decorator import distributed_trace
  from azure.core.tracing.decorator_async import distributed_trace_async
  from azure.mgmt.core.exceptions import ARMErrorFormat
  from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
  
  from ... import models as _models
  from ..._vendor import _convert_request
  from ...operations._storage_accounts_operations import build_check_name_availability_request, build_create_request_initial, build_delete_request, build_failover_request_initial, build_get_properties_request, build_list_account_sas_request, build_list_by_resource_group_request, build_list_keys_request, build_list_request, build_list_service_sas_request, build_regenerate_key_request, build_restore_blob_ranges_request_initial, build_revoke_user_delegation_keys_request, build_update_request
  T = TypeVar('T')
  ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
  
  class StorageAccountsOperations:
      """StorageAccountsOperations async operations.
  
      You should not instantiate this class directly. Instead, you should create a Client instance that
      instantiates it for you and attaches it as an attribute.
  
      :ivar models: Alias to model classes used in this operation group.
      :type models: ~azure.mgmt.storage.v2021_02_01.models
      :param client: Client for service requests.
      :param config: Configuration of service client.
      :param serializer: An object model serializer.
      :param deserializer: An object model deserializer.
      """
  
      models = _models
  
      def __init__(self, client, config, serializer, deserializer) -> None:
          self._client = client
          self._serialize = serializer
          self._deserialize = deserializer
          self._config = config
  
      @distributed_trace_async
      async def check_name_availability(
          self,
          account_name: "_models.StorageAccountCheckNameAvailabilityParameters",
          **kwargs: Any
      ) -> "_models.CheckNameAvailabilityResult":
          """Checks that the storage account name is valid and is not already in use.
  
          :param account_name: The name of the storage account within the specified resource group.
           Storage account names must be between 3 and 24 characters in length and use numbers and
           lower-case letters only.
          :type account_name:
           ~azure.mgmt.storage.v2021_02_01.models.StorageAccountCheckNameAvailabilityParameters
          :keyword callable cls: A custom type or function that will be passed the direct response
          :return: CheckNameAvailabilityResult, or the result of cls(response)
          :rtype: ~azure.mgmt.storage.v2021_02_01.models.CheckNameAvailabilityResult
          :raises: ~azure.core.exceptions.HttpResponseError
          """
          cls = kwargs.pop('cls', None)  # type: ClsType["_models.CheckNameAvailabilityResult"]
          error_map = {
              401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
          }
          error_map.update(kwargs.pop('error_map', {}))
  
          content_type = kwargs.pop('content_type', "application/json")  # type: Optional[str]
  
          _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters')
  
          request = build_check_name_availability_request(
              subscription_id=self._config.subscription_id,
              content_type=content_type,
              json=_json,
              template_url=self.check_name_availability.metadata['url'],
          )
          request = _convert_request(request)
          request.url = self._client.format_url(request.url)
  
          pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
          response = pipeline_response.http_response
  
          if response.status_code not in [200]:
              map_error(status_code=response.status_code, response=response, error_map=error_map)
              raise HttpResponseError(response=response, error_format=ARMErrorFormat)
  
          deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response)
  
          if cls:
              return cls(pipeline_response, deserialized, {})
  
          return deserialized
  
      check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability'}  # type: ignore
  
  
      async def _create_initial(
          self,
          resource_group_name: str,
          account_name: str,
          parameters: "_models.StorageAccountCreateParameters",
          **kwargs: Any
      ) -> Optional["_models.StorageAccount"]:
          cls = kwargs.pop('cls', None)  # type: ClsType[Optional["_models.StorageAccount"]]
          error_map = {
              401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
          }
          error_map.update(kwargs.pop('error_map', {}))
  
          content_type = kwargs.pop('content_type', "application/json")  # type: Optional[str]
  
          _json = self._serialize.body(parameters, 'StorageAccountCreateParameters')
  
          request = build_create_request_initial(
              resource_group_name=resource_group_name,
              account_name=account_name,
              subscription_id=self._config.subscription_id,
              content_type=content_type,
              json=_json,
              template_url=self._create_initial.metadata['url'],
          )
          request = _convert_request(request)
          request.url = self._client.format_url(request.url)
  
          pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
          response = pipeline_response.http_response
  
          if response.status_code not in [200, 202]:
              map_error(status_code=response.status_code, response=response, error_map=error_map)
              raise HttpResponseError(response=response, error_format=ARMErrorFormat)
  
          deserialized = None
          if response.status_code == 200:
              deserialized = self._deserialize('StorageAccount', pipeline_response)
  
          if cls:
              return cls(pipeline_response, deserialized, {})
  
          return deserialized
  
      _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'}  # type: ignore
  
  
      @distributed_trace_async
      async def begin_create(
          self,
          resource_group_name: str,
          account_name: str,
          parameters: "_models.StorageAccountCreateParameters",
          **kwargs: Any
      ) -> AsyncLROPoller["_models.StorageAccount"]:
          """Asynchronously creates a new storage account with the specified parameters. If an account is
          already created and a subsequent create request is issued with different properties, the
          account properties will be updated. If an account is already created and a subsequent create or
          update request is issued with the exact same set of properties, the request will succeed.
  
          :param resource_group_name: The name of the resource group within the user's subscription. The
           name is case insensitive.
          :type resource_group_name: str
          :param account_name: The name of the storage account within the specified resource group.
           Storage account names must be between 3 and 24 characters in length and use numbers and
           lower-case letters only.
          :type account_name: str
          :param parameters: The parameters to provide for the created account.
          :type parameters: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountCreateParameters
          :keyword callable cls: A custom type or function that will be passed the direct response
          :keyword str continuation_token: A continuation token to restart a poller from a saved state.
          :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
           this operation to not poll, or pass in your own initialized polling object for a personal
           polling strategy.
          :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
          :keyword int polling_interval: Default waiting time between two polls for LRO operations if no
           Retry-After header is present.
          :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of
           cls(response)
          :rtype:
           ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_02_01.models.StorageAccount]
          :raises: ~azure.core.exceptions.HttpResponseError
          """
          content_type = kwargs.pop('content_type', "application/json")  # type: Optional[str]
          polling = kwargs.pop('polling', True)  # type: Union[bool, azure.core.polling.AsyncPollingMethod]
          cls = kwargs.pop('cls', None)  # type: ClsType["_models.StorageAccount"]
          lro_delay = kwargs.pop(
              'polling_interval',
              self._config.polling_interval
          )
          cont_token = kwargs.pop('continuation_token', None)  # type: Optional[str]
          if cont_token is None:
              raw_result = await self._create_initial(
                  resource_group_name=resource_group_name,
                  account_name=account_name,
                  parameters=parameters,
                  content_type=content_type,
                  cls=lambda x,y,z: x,
                  **kwargs
              )
          kwargs.pop('error_map', None)
  
          def get_long_running_output(pipeline_response):
              response = pipeline_response.http_response
              deserialized = self._deserialize('StorageAccount', pipeline_response)
              if cls:
                  return cls(pipeline_response, deserialized, {})
              return deserialized
  
  
          if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs)
          elif polling is False: polling_method = AsyncNoPolling()
          else: polling_method = polling
          if cont_token:
              return AsyncLROPoller.from_continuation_token(
                  polling_method=polling_method,
                  continuation_token=cont_token,
                  client=self._client,
                  deserialization_callback=get_long_running_output
              )
          else:
              return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method)
  
      begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'}  # type: ignore
  
      @distributed_trace_async
      async def delete(
          self,
          resource_group_name: str,
          account_name: str,
          **kwargs: Any
      ) -> None:
          """Deletes a storage account in Microsoft Azure.
  
          :param resource_group_name: The name of the resource group within the user's subscription. The
           name is case insensitive.
          :type resource_group_name: str
          :param account_name: The name of the storage account within the specified resource group.
           Storage account names must be between 3 and 24 characters in length and use numbers and
           lower-case letters only.
          :type account_name: str
          :keyword callable cls: A custom type or function that will be passed the direct response
          :return: None, or the result of cls(response)
          :rtype: None
          :raises: ~azure.core.exceptions.HttpResponseError
          """
          cls = kwargs.pop('cls', None)  # type: ClsType[None]
          error_map = {
              401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
          }
          error_map.update(kwargs.pop('error_map', {}))
  
          
          request = build_delete_request(
              resource_group_name=resource_group_name,
              account_name=account_name,
              subscription_id=self._config.subscription_id,
              template_url=self.delete.metadata['url'],
          )
          request = _convert_request(request)
          request.url = self._client.format_url(request.url)
  
          pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
          response = pipeline_response.http_response
  
          if response.status_code not in [200, 204]:
              map_error(status_code=response.status_code, response=response, error_map=error_map)
              raise HttpResponseError(response=response, error_format=ARMErrorFormat)
  
          if cls:
              return cls(pipeline_response, None, {})
  
      delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'}  # type: ignore
  
  
      @distributed_trace_async
      async def get_properties(
          self,
          resource_group_name: str,
          account_name: str,
          expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None,
          **kwargs: Any
      ) -> "_models.StorageAccount":
          """Returns the properties for the specified storage account including but not limited to name, SKU
          name, location, and account status. The ListKeys operation should be used to retrieve storage
          keys.
  
          :param resource_group_name: The name of the resource group within the user's subscription. The
           name is case insensitive.
          :type resource_group_name: str
          :param account_name: The name of the storage account within the specified resource group.
           Storage account names must be between 3 and 24 characters in length and use numbers and
           lower-case letters only.
          :type account_name: str
          :param expand: May be used to expand the properties within account's properties. By default,
           data is not included when fetching properties. Currently we only support geoReplicationStats
           and blobRestoreStatus.
          :type expand: str or ~azure.mgmt.storage.v2021_02_01.models.StorageAccountExpand
          :keyword callable cls: A custom type or function that will be passed the direct response
          :return: StorageAccount, or the result of cls(response)
          :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccount
          :raises: ~azure.core.exceptions.HttpResponseError
          """
          cls = kwargs.pop('cls', None)  # type: ClsType["_models.StorageAccount"]
          error_map = {
              401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
          }
          error_map.update(kwargs.pop('error_map', {}))
  
          
          request = build_get_properties_request(
              resource_group_name=resource_group_name,
              account_name=account_name,
              subscription_id=self._config.subscription_id,
              expand=expand,
              template_url=self.get_properties.metadata['url'],
          )
          request = _convert_request(request)
          request.url = self._client.format_url(request.url)
  
          pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
          response = pipeline_response.http_response
  
          if response.status_code not in [200]:
              map_error(status_code=response.status_code, response=response, error_map=error_map)
              raise HttpResponseError(response=response, error_format=ARMErrorFormat)
  
          deserialized = self._deserialize('StorageAccount', pipeline_response)
  
          if cls:
              return cls(pipeline_response, deserialized, {})
  
          return deserialized
  
      get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'}  # type: ignore
  
  
      @distributed_trace_async
      async def update(
          self,
          resource_group_name: str,
          account_name: str,
          parameters: "_models.StorageAccountUpdateParameters",
          **kwargs: Any
      ) -> "_models.StorageAccount":
          """The update operation can be used to update the SKU, encryption, access tier, or tags for a
          storage account. It can also be used to map the account to a custom domain. Only one custom
          domain is supported per storage account; the replacement/change of custom domain is not
          supported. In order to replace an old custom domain, the old value must be cleared/unregistered
          before a new value can be set. The update of multiple properties is supported. This call does
          not change the storage keys for the account. If you want to change the storage account keys,
          use the regenerate keys operation. The location and name of the storage account cannot be
          changed after creation.
  
          :param resource_group_name: The name of the resource group within the user's subscription. The
           name is case insensitive.
          :type resource_group_name: str
          :param account_name: The name of the storage account within the specified resource group.
           Storage account names must be between 3 and 24 characters in length and use numbers and
           lower-case letters only.
          :type account_name: str
          :param parameters: The parameters to provide for the updated account.
          :type parameters: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountUpdateParameters
          :keyword callable cls: A custom type or function that will be passed the direct response
          :return: StorageAccount, or the result of cls(response)
          :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccount
          :raises: ~azure.core.exceptions.HttpResponseError
          """
          cls = kwargs.pop('cls', None)  # type: ClsType["_models.StorageAccount"]
          error_map = {
              401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
          }
          error_map.update(kwargs.pop('error_map', {}))
  
          content_type = kwargs.pop('content_type', "application/json")  # type: Optional[str]
  
          _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters')
  
          request = build_update_request(
              resource_group_name=resource_group_name,
              account_name=account_name,
              subscription_id=self._config.subscription_id,
              content_type=content_type,
              json=_json,
              template_url=self.update.metadata['url'],
          )
          request = _convert_request(request)
          request.url = self._client.format_url(request.url)
  
          pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
          response = pipeline_response.http_response
  
          if response.status_code not in [200]:
              map_error(status_code=response.status_code, response=response, error_map=error_map)
              raise HttpResponseError(response=response, error_format=ARMErrorFormat)
  
          deserialized = self._deserialize('StorageAccount', pipeline_response)
  
          if cls:
              return cls(pipeline_response, deserialized, {})
  
          return deserialized
  
      update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'}  # type: ignore
  
  
      @distributed_trace
      def list(
          self,
          **kwargs: Any
      ) -> AsyncIterable["_models.StorageAccountListResult"]:
          """Lists all the storage accounts available under the subscription. Note that storage keys are not
          returned; use the ListKeys operation for this.
  
          :keyword callable cls: A custom type or function that will be passed the direct response
          :return: An iterator like instance of either StorageAccountListResult or the result of
           cls(response)
          :rtype:
           ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.StorageAccountListResult]
          :raises: ~azure.core.exceptions.HttpResponseError
          """
          cls = kwargs.pop('cls', None)  # type: ClsType["_models.StorageAccountListResult"]
          error_map = {
              401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
          }
          error_map.update(kwargs.pop('error_map', {}))
          def prepare_request(next_link=None):
              if not next_link:
                  
                  request = build_list_request(
                      subscription_id=self._config.subscription_id,
                      template_url=self.list.metadata['url'],
                  )
                  request = _convert_request(request)
                  request.url = self._client.format_url(request.url)
  
              else:
                  
                  request = build_list_request(
                      subscription_id=self._config.subscription_id,
                      template_url=next_link,
                  )
                  request = _convert_request(request)
                  request.url = self._client.format_url(request.url)
                  request.method = "GET"
              return request
  
          async def extract_data(pipeline_response):
              deserialized = self._deserialize("StorageAccountListResult", pipeline_response)
              list_of_elem = deserialized.value
              if cls:
                  list_of_elem = cls(list_of_elem)
              return deserialized.next_link or None, AsyncList(list_of_elem)
  
          async def get_next(next_link=None):
              request = prepare_request(next_link)
  
              pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
              response = pipeline_response.http_response
  
              if response.status_code not in [200]:
                  map_error(status_code=response.status_code, response=response, error_map=error_map)
                  raise HttpResponseError(response=response, error_format=ARMErrorFormat)
  
              return pipeline_response
  
  
          return AsyncItemPaged(
              get_next, extract_data
          )
      list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts'}  # type: ignore
  
      @distributed_trace
      def list_by_resource_group(
          self,
          resource_group_name: str,
          **kwargs: Any
      ) -> AsyncIterable["_models.StorageAccountListResult"]:
          """Lists all the storage accounts available under the given resource group. Note that storage keys
          are not returned; use the ListKeys operation for this.
  
          :param resource_group_name: The name of the resource group within the user's subscription. The
           name is case insensitive.
          :type resource_group_name: str
          :keyword callable cls: A custom type or function that will be passed the direct response
          :return: An iterator like instance of either StorageAccountListResult or the result of
           cls(response)
          :rtype:
           ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.StorageAccountListResult]
          :raises: ~azure.core.exceptions.HttpResponseError
          """
          cls = kwargs.pop('cls', None)  # type: ClsType["_models.StorageAccountListResult"]
          error_map = {
              401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
          }
          error_map.update(kwargs.pop('error_map', {}))
          def prepare_request(next_link=None):
              if not next_link:
                  
                  request = build_list_by_resource_group_request(
                      resource_group_name=resource_group_name,
                      subscription_id=self._config.subscription_id,
                      template_url=self.list_by_resource_group.metadata['url'],
                  )
                  request = _convert_request(request)
                  request.url = self._client.format_url(request.url)
  
              else:
                  
                  request = build_list_by_resource_group_request(
                      resource_group_name=resource_group_name,
                      subscription_id=self._config.subscription_id,
                      template_url=next_link,
                  )
                  request = _convert_request(request)
                  request.url = self._client.format_url(request.url)
                  request.method = "GET"
              return request
  
          async def extract_data(pipeline_response):
              deserialized = self._deserialize("StorageAccountListResult", pipeline_response)
              list_of_elem = deserialized.value
              if cls:
                  list_of_elem = cls(list_of_elem)
              return deserialized.next_link or None, AsyncList(list_of_elem)
  
          async def get_next(next_link=None):
              request = prepare_request(next_link)
  
              pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
              response = pipeline_response.http_response
  
              if response.status_code not in [200]:
                  map_error(status_code=response.status_code, response=response, error_map=error_map)
                  raise HttpResponseError(response=response, error_format=ARMErrorFormat)
  
              return pipeline_response
  
  
          return AsyncItemPaged(
              get_next, extract_data
          )
      list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts'}  # type: ignore
  
      @distributed_trace_async
      async def list_keys(
          self,
          resource_group_name: str,
          account_name: str,
          expand: Optional[str] = "kerb",
          **kwargs: Any
      ) -> "_models.StorageAccountListKeysResult":
          """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage
          account.
  
          :param resource_group_name: The name of the resource group within the user's subscription. The
           name is case insensitive.
          :type resource_group_name: str
          :param account_name: The name of the storage account within the specified resource group.
           Storage account names must be between 3 and 24 characters in length and use numbers and
           lower-case letters only.
          :type account_name: str
          :param expand: Specifies type of the key to be listed. Possible value is kerb. The default
           value is "kerb".
          :type expand: str
          :keyword callable cls: A custom type or function that will be passed the direct response
          :return: StorageAccountListKeysResult, or the result of cls(response)
          :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountListKeysResult
          :raises: ~azure.core.exceptions.HttpResponseError
          """
          cls = kwargs.pop('cls', None)  # type: ClsType["_models.StorageAccountListKeysResult"]
          error_map = {
              401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
          }
          error_map.update(kwargs.pop('error_map', {}))
  
          
          request = build_list_keys_request(
              resource_group_name=resource_group_name,
              account_name=account_name,
              subscription_id=self._config.subscription_id,
              expand=expand,
              template_url=self.list_keys.metadata['url'],
          )
          request = _convert_request(request)
          request.url = self._client.format_url(request.url)
  
          pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
          response = pipeline_response.http_response
  
          if response.status_code not in [200]:
              map_error(status_code=response.status_code, response=response, error_map=error_map)
              raise HttpResponseError(response=response, error_format=ARMErrorFormat)
  
          deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response)
  
          if cls:
              return cls(pipeline_response, deserialized, {})
  
          return deserialized
  
      list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys'}  # type: ignore
  
  
      @distributed_trace_async
      async def regenerate_key(
          self,
          resource_group_name: str,
          account_name: str,
          regenerate_key: "_models.StorageAccountRegenerateKeyParameters",
          **kwargs: Any
      ) -> "_models.StorageAccountListKeysResult":
          """Regenerates one of the access keys or Kerberos keys for the specified storage account.
  
          :param resource_group_name: The name of the resource group within the user's subscription. The
           name is case insensitive.
          :type resource_group_name: str
          :param account_name: The name of the storage account within the specified resource group.
           Storage account names must be between 3 and 24 characters in length and use numbers and
           lower-case letters only.
          :type account_name: str
          :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2,
           kerb1, kerb2.
          :type regenerate_key:
           ~azure.mgmt.storage.v2021_02_01.models.StorageAccountRegenerateKeyParameters
          :keyword callable cls: A custom type or function that will be passed the direct response
          :return: StorageAccountListKeysResult, or the result of cls(response)
          :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountListKeysResult
          :raises: ~azure.core.exceptions.HttpResponseError
          """
          cls = kwargs.pop('cls', None)  # type: ClsType["_models.StorageAccountListKeysResult"]
          error_map = {
              401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
          }
          error_map.update(kwargs.pop('error_map', {}))
  
          content_type = kwargs.pop('content_type', "application/json")  # type: Optional[str]
  
          _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters')
  
          request = build_regenerate_key_request(
              resource_group_name=resource_group_name,
              account_name=account_name,
              subscription_id=self._config.subscription_id,
              content_type=content_type,
              json=_json,
              template_url=self.regenerate_key.metadata['url'],
          )
          request = _convert_request(request)
          request.url = self._client.format_url(request.url)
  
          pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
          response = pipeline_response.http_response
  
          if response.status_code not in [200]:
              map_error(status_code=response.status_code, response=response, error_map=error_map)
              raise HttpResponseError(response=response, error_format=ARMErrorFormat)
  
          deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response)
  
          if cls:
              return cls(pipeline_response, deserialized, {})
  
          return deserialized
  
      regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey'}  # type: ignore
  
  
      @distributed_trace_async
      async def list_account_sas(
          self,
          resource_group_name: str,
          account_name: str,
          parameters: "_models.AccountSasParameters",
          **kwargs: Any
      ) -> "_models.ListAccountSasResponse":
          """List SAS credentials of a storage account.
  
          :param resource_group_name: The name of the resource group within the user's subscription. The
           name is case insensitive.
          :type resource_group_name: str
          :param account_name: The name of the storage account within the specified resource group.
           Storage account names must be between 3 and 24 characters in length and use numbers and
           lower-case letters only.
          :type account_name: str
          :param parameters: The parameters to provide to list SAS credentials for the storage account.
          :type parameters: ~azure.mgmt.storage.v2021_02_01.models.AccountSasParameters
          :keyword callable cls: A custom type or function that will be passed the direct response
          :return: ListAccountSasResponse, or the result of cls(response)
          :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListAccountSasResponse
          :raises: ~azure.core.exceptions.HttpResponseError
          """
          cls = kwargs.pop('cls', None)  # type: ClsType["_models.ListAccountSasResponse"]
          error_map = {
              401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
          }
          error_map.update(kwargs.pop('error_map', {}))
  
          content_type = kwargs.pop('content_type', "application/json")  # type: Optional[str]
  
          _json = self._serialize.body(parameters, 'AccountSasParameters')
  
          request = build_list_account_sas_request(
              resource_group_name=resource_group_name,
              account_name=account_name,
              subscription_id=self._config.subscription_id,
              content_type=content_type,
              json=_json,
              template_url=self.list_account_sas.metadata['url'],
          )
          request = _convert_request(request)
          request.url = self._client.format_url(request.url)
  
          pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
          response = pipeline_response.http_response
  
          if response.status_code not in [200]:
              map_error(status_code=response.status_code, response=response, error_map=error_map)
              raise HttpResponseError(response=response, error_format=ARMErrorFormat)
  
          deserialized = self._deserialize('ListAccountSasResponse', pipeline_response)
  
          if cls:
              return cls(pipeline_response, deserialized, {})
  
          return deserialized
  
      list_account_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas'}  # type: ignore
  
  
      @distributed_trace_async
      async def list_service_sas(
          self,
          resource_group_name: str,
          account_name: str,
          parameters: "_models.ServiceSasParameters",
          **kwargs: Any
      ) -> "_models.ListServiceSasResponse":
          """List service SAS credentials of a specific resource.
  
          :param resource_group_name: The name of the resource group within the user's subscription. The
           name is case insensitive.
          :type resource_group_name: str
          :param account_name: The name of the storage account within the specified resource group.
           Storage account names must be between 3 and 24 characters in length and use numbers and
           lower-case letters only.
          :type account_name: str
          :param parameters: The parameters to provide to list service SAS credentials.
          :type parameters: ~azure.mgmt.storage.v2021_02_01.models.ServiceSasParameters
          :keyword callable cls: A custom type or function that will be passed the direct response
          :return: ListServiceSasResponse, or the result of cls(response)
          :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListServiceSasResponse
          :raises: ~azure.core.exceptions.HttpResponseError
          """
          cls = kwargs.pop('cls', None)  # type: ClsType["_models.ListServiceSasResponse"]
          error_map = {
              401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
          }
          error_map.update(kwargs.pop('error_map', {}))
  
          content_type = kwargs.pop('content_type', "application/json")  # type: Optional[str]
  
          _json = self._serialize.body(parameters, 'ServiceSasParameters')
  
          request = build_list_service_sas_request(
              resource_group_name=resource_group_name,
              account_name=account_name,
              subscription_id=self._config.subscription_id,
              content_type=content_type,
              json=_json,
              template_url=self.list_service_sas.metadata['url'],
          )
          request = _convert_request(request)
          request.url = self._client.format_url(request.url)
  
          pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
          response = pipeline_response.http_response
  
          if response.status_code not in [200]:
              map_error(status_code=response.status_code, response=response, error_map=error_map)
              raise HttpResponseError(response=response, error_format=ARMErrorFormat)
  
          deserialized = self._deserialize('ListServiceSasResponse', pipeline_response)
  
          if cls:
              return cls(pipeline_response, deserialized, {})
  
          return deserialized
  
      list_service_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas'}  # type: ignore
  
  
      async def _failover_initial(
          self,
          resource_group_name: str,
          account_name: str,
          **kwargs: Any
      ) -> None:
          cls = kwargs.pop('cls', None)  # type: ClsType[None]
          error_map = {
              401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
          }
          error_map.update(kwargs.pop('error_map', {}))
  
          
          request = build_failover_request_initial(
              resource_group_name=resource_group_name,
              account_name=account_name,
              subscription_id=self._config.subscription_id,
              template_url=self._failover_initial.metadata['url'],
          )
          request = _convert_request(request)
          request.url = self._client.format_url(request.url)
  
          pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
          response = pipeline_response.http_response
  
          if response.status_code not in [200, 202]:
              map_error(status_code=response.status_code, response=response, error_map=error_map)
              raise HttpResponseError(response=response, error_format=ARMErrorFormat)
  
          if cls:
              return cls(pipeline_response, None, {})
  
      _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'}  # type: ignore
  
  
      @distributed_trace_async
      async def begin_failover(
          self,
          resource_group_name: str,
          account_name: str,
          **kwargs: Any
      ) -> AsyncLROPoller[None]:
          """Failover request can be triggered for a storage account in case of availability issues. The
          failover occurs from the storage account's primary cluster to secondary cluster for RA-GRS
          accounts. The secondary cluster will become primary after failover.
  
          :param resource_group_name: The name of the resource group within the user's subscription. The
           name is case insensitive.
          :type resource_group_name: str
          :param account_name: The name of the storage account within the specified resource group.
           Storage account names must be between 3 and 24 characters in length and use numbers and
           lower-case letters only.
          :type account_name: str
          :keyword callable cls: A custom type or function that will be passed the direct response
          :keyword str continuation_token: A continuation token to restart a poller from a saved state.
          :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
           this operation to not poll, or pass in your own initialized polling object for a personal
           polling strategy.
          :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
          :keyword int polling_interval: Default waiting time between two polls for LRO operations if no
           Retry-After header is present.
          :return: An instance of AsyncLROPoller that returns either None or the result of cls(response)
          :rtype: ~azure.core.polling.AsyncLROPoller[None]
          :raises: ~azure.core.exceptions.HttpResponseError
          """
          polling = kwargs.pop('polling', True)  # type: Union[bool, azure.core.polling.AsyncPollingMethod]
          cls = kwargs.pop('cls', None)  # type: ClsType[None]
          lro_delay = kwargs.pop(
              'polling_interval',
              self._config.polling_interval
          )
          cont_token = kwargs.pop('continuation_token', None)  # type: Optional[str]
          if cont_token is None:
              raw_result = await self._failover_initial(
                  resource_group_name=resource_group_name,
                  account_name=account_name,
                  cls=lambda x,y,z: x,
                  **kwargs
              )
          kwargs.pop('error_map', None)
  
          def get_long_running_output(pipeline_response):
              if cls:
                  return cls(pipeline_response, None, {})
  
  
          if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs)
          elif polling is False: polling_method = AsyncNoPolling()
          else: polling_method = polling
          if cont_token:
              return AsyncLROPoller.from_continuation_token(
                  polling_method=polling_method,
                  continuation_token=cont_token,
                  client=self._client,
                  deserialization_callback=get_long_running_output
              )
          else:
              return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method)
  
      begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'}  # type: ignore
  
      async def _restore_blob_ranges_initial(
          self,
          resource_group_name: str,
          account_name: str,
          parameters: "_models.BlobRestoreParameters",
          **kwargs: Any
      ) -> "_models.BlobRestoreStatus":
          cls = kwargs.pop('cls', None)  # type: ClsType["_models.BlobRestoreStatus"]
          error_map = {
              401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
          }
          error_map.update(kwargs.pop('error_map', {}))
  
          content_type = kwargs.pop('content_type', "application/json")  # type: Optional[str]
  
          _json = self._serialize.body(parameters, 'BlobRestoreParameters')
  
          request = build_restore_blob_ranges_request_initial(
              resource_group_name=resource_group_name,
              account_name=account_name,
              subscription_id=self._config.subscription_id,
              content_type=content_type,
              json=_json,
              template_url=self._restore_blob_ranges_initial.metadata['url'],
          )
          request = _convert_request(request)
          request.url = self._client.format_url(request.url)
  
          pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
          response = pipeline_response.http_response
  
          if response.status_code not in [200, 202]:
              map_error(status_code=response.status_code, response=response, error_map=error_map)
              raise HttpResponseError(response=response, error_format=ARMErrorFormat)
  
          if response.status_code == 200:
              deserialized = self._deserialize('BlobRestoreStatus', pipeline_response)
  
          if response.status_code == 202:
              deserialized = self._deserialize('BlobRestoreStatus', pipeline_response)
  
          if cls:
              return cls(pipeline_response, deserialized, {})
  
          return deserialized
  
      _restore_blob_ranges_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges'}  # type: ignore
  
  
      @distributed_trace_async
      async def begin_restore_blob_ranges(
          self,
          resource_group_name: str,
          account_name: str,
          parameters: "_models.BlobRestoreParameters",
          **kwargs: Any
      ) -> AsyncLROPoller["_models.BlobRestoreStatus"]:
          """Restore blobs in the specified blob ranges.
  
          :param resource_group_name: The name of the resource group within the user's subscription. The
           name is case insensitive.
          :type resource_group_name: str
          :param account_name: The name of the storage account within the specified resource group.
           Storage account names must be between 3 and 24 characters in length and use numbers and
           lower-case letters only.
          :type account_name: str
          :param parameters: The parameters to provide for restore blob ranges.
          :type parameters: ~azure.mgmt.storage.v2021_02_01.models.BlobRestoreParameters
          :keyword callable cls: A custom type or function that will be passed the direct response
          :keyword str continuation_token: A continuation token to restart a poller from a saved state.
          :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
           this operation to not poll, or pass in your own initialized polling object for a personal
           polling strategy.
          :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
          :keyword int polling_interval: Default waiting time between two polls for LRO operations if no
           Retry-After header is present.
          :return: An instance of AsyncLROPoller that returns either BlobRestoreStatus or the result of
           cls(response)
          :rtype:
           ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_02_01.models.BlobRestoreStatus]
          :raises: ~azure.core.exceptions.HttpResponseError
          """
          content_type = kwargs.pop('content_type', "application/json")  # type: Optional[str]
          polling = kwargs.pop('polling', True)  # type: Union[bool, azure.core.polling.AsyncPollingMethod]
          cls = kwargs.pop('cls', None)  # type: ClsType["_models.BlobRestoreStatus"]
          lro_delay = kwargs.pop(
              'polling_interval',
              self._config.polling_interval
          )
          cont_token = kwargs.pop('continuation_token', None)  # type: Optional[str]
          if cont_token is None:
              raw_result = await self._restore_blob_ranges_initial(
                  resource_group_name=resource_group_name,
                  account_name=account_name,
                  parameters=parameters,
                  content_type=content_type,
                  cls=lambda x,y,z: x,
                  **kwargs
              )
          kwargs.pop('error_map', None)
  
          def get_long_running_output(pipeline_response):
              response = pipeline_response.http_response
              deserialized = self._deserialize('BlobRestoreStatus', pipeline_response)
              if cls:
                  return cls(pipeline_response, deserialized, {})
              return deserialized
  
  
          if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs)
          elif polling is False: polling_method = AsyncNoPolling()
          else: polling_method = polling
          if cont_token:
              return AsyncLROPoller.from_continuation_token(
                  polling_method=polling_method,
                  continuation_token=cont_token,
                  client=self._client,
                  deserialization_callback=get_long_running_output
              )
          else:
              return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method)
  
      begin_restore_blob_ranges.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges'}  # type: ignore
  
      @distributed_trace_async
      async def revoke_user_delegation_keys(
          self,
          resource_group_name: str,
          account_name: str,
          **kwargs: Any
      ) -> None:
          """Revoke user delegation keys.
  
          :param resource_group_name: The name of the resource group within the user's subscription. The
           name is case insensitive.
          :type resource_group_name: str
          :param account_name: The name of the storage account within the specified resource group.
           Storage account names must be between 3 and 24 characters in length and use numbers and
           lower-case letters only.
          :type account_name: str
          :keyword callable cls: A custom type or function that will be passed the direct response
          :return: None, or the result of cls(response)
          :rtype: None
          :raises: ~azure.core.exceptions.HttpResponseError
          """
          cls = kwargs.pop('cls', None)  # type: ClsType[None]
          error_map = {
              401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
          }
          error_map.update(kwargs.pop('error_map', {}))
  
          
          request = build_revoke_user_delegation_keys_request(
              resource_group_name=resource_group_name,
              account_name=account_name,
              subscription_id=self._config.subscription_id,
              template_url=self.revoke_user_delegation_keys.metadata['url'],
          )
          request = _convert_request(request)
          request.url = self._client.format_url(request.url)
  
          pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
          response = pipeline_response.http_response
  
          if response.status_code not in [200]:
              map_error(status_code=response.status_code, response=response, error_map=error_map)
              raise HttpResponseError(response=response, error_format=ARMErrorFormat)
  
          if cls:
              return cls(pipeline_response, None, {})
  
      revoke_user_delegation_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys'}  # type: ignore
  
  