# 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/account.py
# class AZAccount:
#   def __init__(self,
#                default_resource_group_name: str,
#                default_region: str = 'eastus',
#                profile_name: Optional[str] = None) -> None:
#   def compute(self) -> compute_module.AZCompute:
#   def monitoring(self) -> monitoring_module.AZMonitoring:
#   def network(self) -> network_module.AZNetwork:
#   def resource(self) -> resource_module.AZResource:
#   def storage(self) -> storage_module.AZStorage:
# 
# 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, List, Dict, Tuple
from libcloudforensics import logging_utils
from libcloudforensics import errors
from libcloudforensics.providers.azure.internal import account
from libcloudforensics.providers.azure.internal import common
  from libcloudforensics.providers.azure.internal import compute
    subscription_ids = src_account.resource.ListSubscriptionIDs()
    diff_account = dst_account.subscription_id not in subscription_ids
    diff_region = dst_account.default_region != snapshot.region

    # If the destination account is different from the source account or if the
    # destination region is different from the region in which the source
    # disk is, then we need to create the disk from a storage account in
    # which we import the previously created snapshot (cross-region/account
    # sharing).
    if diff_account or diff_region:
      logger.info('Copy requested in a different destination account/region.')
      # Create a link to download the snapshot
      snapshot_uri = snapshot.GrantAccessAndGetURI()
      # Make a snapshot copy in the destination account from the link
      new_disk = dst_account.compute.CreateDiskFromSnapshotURI(
          snapshot,
          snapshot_uri,
          disk_name_prefix=common.DEFAULT_DISK_COPY_PREFIX,
          disk_type=disk_type)
      # Revoke download link and delete the initial copy
      snapshot.RevokeAccessURI()
    else:
      new_disk = dst_account.compute.CreateDiskFromSnapshot(
          snapshot,
          disk_name_prefix=common.DEFAULT_DISK_COPY_PREFIX,
          disk_type=disk_type)
    snapshot.Delete()
    logger.info('Disk {0:s} successfully copied to {1:s}'.format(
        disk_to_copy.name, new_disk.name))
  except (errors.LCFError, RuntimeError) 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/account.py
# class AZAccount:
#   def __init__(self,
#                default_resource_group_name: str,
#                default_region: str = 'eastus',
#                profile_name: Optional[str] = None) -> None:
#   def compute(self) -> compute_module.AZCompute:
#   def monitoring(self) -> monitoring_module.AZMonitoring:
#   def network(self) -> network_module.AZNetwork:
#   def resource(self) -> resource_module.AZResource:
#   def storage(self) -> storage_module.AZStorage:
# 
# 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/forensics.py
from typing import TYPE_CHECKING, Optional, List, Dict, Tuple
from libcloudforensics import logging_utils
from libcloudforensics import errors
from libcloudforensics.providers.azure.internal import account
from libcloudforensics.providers.azure.internal import common
  from libcloudforensics.providers.azure.internal import compute

    subscription_ids = src_account.resource.ListSubscriptionIDs()
    diff_account = dst_account.subscription_id not in subscription_ids
    diff_region = dst_account.default_region != snapshot.region

    # If the destination account is different from the source account or if the
    # destination region is different from the region in which the source
    # disk is, then we need to create the disk from a storage account in
    # which we import the previously created snapshot (cross-region/account
    # sharing).
    if diff_account or diff_region:
      logger.info('Copy requested in a different destination account/region.')
      # Create a link to download the snapshot
      snapshot_uri = snapshot.GrantAccessAndGetURI()
      # Make a snapshot copy in the destination account from the link
      new_disk = dst_account.compute.CreateDiskFromSnapshotURI(
          snapshot,
          snapshot_uri,
          disk_name_prefix=common.DEFAULT_DISK_COPY_PREFIX,
          disk_type=disk_type)
      # Revoke download link and delete the initial copy
      snapshot.RevokeAccessURI()
    else:
      new_disk = dst_account.compute.CreateDiskFromSnapshot(
          snapshot,
          disk_name_prefix=common.DEFAULT_DISK_COPY_PREFIX,
          disk_type=disk_type)
    snapshot.Delete()
    logger.info('Disk {0:s} successfully copied to {1:s}'.format(
        disk_to_copy.name, new_disk.name))
  except (errors.LCFError, RuntimeError) as exception:

    raise errors.ResourceCreationError('Cannot copy disk "{0:s}": {1!s}'.format(