# Path: libcloudforensics/logging_utils.py
# def _GenerateColorSequences() -> List[str]:
#   def __init__(self,
#                colorize: bool = True,
#                random_color: bool = False,
#                **kwargs: str) -> None:
#   def format(self, record: logging.LogRecord) -> str:
# def SetUpLogger(name: str, no_newline: bool = False) -> None:
# def GetLogger(name: str) -> logging.Logger:
# COLOR_SEQS = _GenerateColorSequences()
# RESET_SEQ = '\u001b[0m'
# BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = COLOR_SEQS[8:16]
# BG_RED = '\u001b[41m'  # Red background
# BOLD = '\u001b[1m'  # Bold / bright modifier
# LOG_FORMAT = ('[%(asctime)s] [{0:s}{color:s}%(name)-20s{1:s}] %(levelname)-8s'
#               ' %(message)s')
# LEVEL_COLOR_MAP = {
#     'WARNING': YELLOW,
#     'INFO': WHITE,
#     'DEBUG': BLUE,
#     'CRITICAL': BOLD + BG_RED + WHITE,
#     'ERROR': RED
# }
# class Formatter(logging.Formatter):
# 
# Path: libcloudforensics/errors.py
# class LCFError(Exception):
# class CredentialsConfigurationError(LCFError):
# class InvalidFileFormatError(LCFError):
# class InvalidNameError(LCFError):
# class ResourceNotFoundError(LCFError):
# class ResourceCreationError(LCFError):
# class ResourceDeletionError(LCFError):
# class InstanceStateChangeError(LCFError):
# class ServiceAccountRemovalError(LCFError):
# class InstanceProfileCreationError(LCFError):
# class OperationFailedError(LCFError):
# class TransferCreationError(LCFError):
# class TransferExecutionError(LCFError):
# class ResourceAlreadyExistsError(LCFError):
#   def __init__(self,
#                message: str,
#                name: str) -> None:
# 
# Path: libcloudforensics/providers/azure/internal/common.py
# REGEX_DISK_NAME = re.compile('^[\\w]{1,80}$')
# REGEX_SNAPSHOT_NAME = re.compile('^(?=.{1,80}$)[a-zA-Z0-9]([\\w,-]*[\\w])?$')
# REGEX_ACCOUNT_STORAGE_NAME = re.compile('^[a-z0-9]{1,24}$')
# REGEX_COMPUTE_RESOURCE_ID = re.compile(
#     '/subscriptions/.+/resourceGroups/.+/providers/Microsoft.Compute/.+/.+')
# DEFAULT_DISK_COPY_PREFIX = 'evidence'
# UBUNTU_1804_SKU = '18.04-LTS'
# def _ParseCredentialsFile(profile_name: str) -> Dict[str, Any]:
# def _CheckAzureCliCredentials() -> Optional[str]:
# def GetCredentials(profile_name: Optional[str] = None
#                    ) -> Tuple[str, DefaultAzureCredential]:
# def ExecuteRequest(
#     client: Any,
#     func: str,
#     kwargs: Optional[Dict[str, str]] = None) -> List[Any]:
# def GenerateDiskName(snapshot: 'compute.AZComputeSnapshot',
#                      disk_name_prefix: Optional[str] = None) -> str:


from typing import TYPE_CHECKING, Optional, Tuple
from azure.mgmt import storage
from msrestazure import azure_exceptions
from libcloudforensics import logging_utils
from libcloudforensics import errors
from libcloudforensics.providers.azure.internal import common
  from libcloudforensics.providers.azure.internal import account  # pylint: disable=cyclic-import
    request = self.storage_client.storage_accounts.begin_create(
        self.az_account.default_resource_group_name,
        storage_account_name,
        creation_data
    )
    logger.info('Storage account {0:s} successfully created'.format(
        storage_account_name))
    storage_account = request.result()
    storage_account_keys = self.storage_client.storage_accounts.list_keys(
        self.az_account.default_resource_group_name, storage_account_name)
    storage_account_keys = {key.key_name: key.value
                            for key in storage_account_keys.keys}
    storage_account_id = storage_account.id  # type: str
    storage_account_key = storage_account_keys['key1']  # type: str
    return storage_account_id, storage_account_key

  def DeleteStorageAccount(self, storage_account_name: str) -> None:
    """Delete an account storage.

    Raises:
      ResourceDeletionError: if the storage account could not be deleted.
    """
    try:
      logger.info('Deleting storage account: {0:s}'.format(
          storage_account_name))
      self.storage_client.storage_accounts.delete(
          self.az_account.default_resource_group_name, storage_account_name)
      logger.info('Storage account {0:s} successfully deleted'.format(
          storage_account_name))
    except azure_exceptions.CloudError as exception:

# Path: libcloudforensics/logging_utils.py
# def _GenerateColorSequences() -> List[str]:
#   def __init__(self,
#                colorize: bool = True,
#                random_color: bool = False,
#                **kwargs: str) -> None:
#   def format(self, record: logging.LogRecord) -> str:
# def SetUpLogger(name: str, no_newline: bool = False) -> None:
# def GetLogger(name: str) -> logging.Logger:
# COLOR_SEQS = _GenerateColorSequences()
# RESET_SEQ = '\u001b[0m'
# BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = COLOR_SEQS[8:16]
# BG_RED = '\u001b[41m'  # Red background
# BOLD = '\u001b[1m'  # Bold / bright modifier
# LOG_FORMAT = ('[%(asctime)s] [{0:s}{color:s}%(name)-20s{1:s}] %(levelname)-8s'
#               ' %(message)s')
# LEVEL_COLOR_MAP = {
#     'WARNING': YELLOW,
#     'INFO': WHITE,
#     'DEBUG': BLUE,
#     'CRITICAL': BOLD + BG_RED + WHITE,
#     'ERROR': RED
# }
# class Formatter(logging.Formatter):
# 
# Path: libcloudforensics/errors.py
# class LCFError(Exception):
# class CredentialsConfigurationError(LCFError):
# class InvalidFileFormatError(LCFError):
# class InvalidNameError(LCFError):
# class ResourceNotFoundError(LCFError):
# class ResourceCreationError(LCFError):
# class ResourceDeletionError(LCFError):
# class InstanceStateChangeError(LCFError):
# class ServiceAccountRemovalError(LCFError):
# class InstanceProfileCreationError(LCFError):
# class OperationFailedError(LCFError):
# class TransferCreationError(LCFError):
# class TransferExecutionError(LCFError):
# class ResourceAlreadyExistsError(LCFError):
#   def __init__(self,
#                message: str,
#                name: str) -> None:
# 
# Path: libcloudforensics/providers/azure/internal/common.py
# REGEX_DISK_NAME = re.compile('^[\\w]{1,80}$')
# REGEX_SNAPSHOT_NAME = re.compile('^(?=.{1,80}$)[a-zA-Z0-9]([\\w,-]*[\\w])?$')
# REGEX_ACCOUNT_STORAGE_NAME = re.compile('^[a-z0-9]{1,24}$')
# REGEX_COMPUTE_RESOURCE_ID = re.compile(
#     '/subscriptions/.+/resourceGroups/.+/providers/Microsoft.Compute/.+/.+')
# DEFAULT_DISK_COPY_PREFIX = 'evidence'
# UBUNTU_1804_SKU = '18.04-LTS'
# def _ParseCredentialsFile(profile_name: str) -> Dict[str, Any]:
# def _CheckAzureCliCredentials() -> Optional[str]:
# def GetCredentials(profile_name: Optional[str] = None
#                    ) -> Tuple[str, DefaultAzureCredential]:
# def ExecuteRequest(
#     client: Any,
#     func: str,
#     kwargs: Optional[Dict[str, str]] = None) -> List[Any]:
# def GenerateDiskName(snapshot: 'compute.AZComputeSnapshot',
#                      disk_name_prefix: Optional[str] = None) -> str:


# Path: libcloudforensics/providers/azure/internal/storage.py
from typing import TYPE_CHECKING, Optional, Tuple
from azure.mgmt import storage
from msrestazure import azure_exceptions
from libcloudforensics import logging_utils
from libcloudforensics import errors
from libcloudforensics.providers.azure.internal import common
  from libcloudforensics.providers.azure.internal import account  # pylint: disable=cyclic-import

    request = self.storage_client.storage_accounts.begin_create(
        self.az_account.default_resource_group_name,
        storage_account_name,
        creation_data
    )
    logger.info('Storage account {0:s} successfully created'.format(
        storage_account_name))
    storage_account = request.result()
    storage_account_keys = self.storage_client.storage_accounts.list_keys(
        self.az_account.default_resource_group_name, storage_account_name)
    storage_account_keys = {key.key_name: key.value
                            for key in storage_account_keys.keys}
    storage_account_id = storage_account.id  # type: str
    storage_account_key = storage_account_keys['key1']  # type: str
    return storage_account_id, storage_account_key

  def DeleteStorageAccount(self, storage_account_name: str) -> None:
    """Delete an account storage.

    Raises:
      ResourceDeletionError: if the storage account could not be deleted.
    """
    try:
      logger.info('Deleting storage account: {0:s}'.format(
          storage_account_name))
      self.storage_client.storage_accounts.delete(
          self.az_account.default_resource_group_name, storage_account_name)
      logger.info('Storage account {0:s} successfully deleted'.format(
          storage_account_name))
    except azure_exceptions.CloudError as exception:

      raise errors.ResourceDeletionError(