# 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:


import binascii
import json
import os
import re
from typing import Any, List, Dict, Optional, TYPE_CHECKING, Tuple
from azure.identity import DefaultAzureCredential
from libcloudforensics import logging_utils
from libcloudforensics import errors
  from libcloudforensics.providers.azure.internal import compute  # pylint: disable=cyclic-import
        absolute path to the credentials file, then the library will look
        there instead of in ~/.azure/credentials.json.

  Returns:
    Dict[str, str]: A dict containing the required account_info fields.

  Raises:
    CredentialsConfigurationError: If there are environment variables that
        are not set or if the credentials file has missing entries/profiles.
    FileNotFoundError: If the credentials file is not found.
    InvalidFileFormatError: If the credentials file couldn't be parsed.
  """
  path = os.getenv('AZURE_CREDENTIALS_PATH')
  if not path:
    path = os.path.expanduser('~/.azure/credentials.json')

  if not os.path.exists(path):
    raise FileNotFoundError(
        'Credentials file not found. Please place it in '
        '"~/.azure/credentials.json" or specify an absolute path to it in '
        'the AZURE_CREDENTIALS_PATH environment variable.')

  with open(path, encoding='utf-8') as profiles:
    try:
      account_info: Dict[str, Any] = json.load(profiles).get(profile_name)
    except ValueError as exception:
      raise errors.InvalidFileFormatError(
          'Could not decode JSON file. Please verify the file format:'
          ' {0!s}'.format(exception), __name__) from exception
    if not account_info:

# 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
import binascii
import json
import os
import re
from typing import Any, List, Dict, Optional, TYPE_CHECKING, Tuple
from azure.identity import DefaultAzureCredential
from libcloudforensics import logging_utils
from libcloudforensics import errors
  from libcloudforensics.providers.azure.internal import compute  # pylint: disable=cyclic-import

        absolute path to the credentials file, then the library will look
        there instead of in ~/.azure/credentials.json.

  Returns:
    Dict[str, str]: A dict containing the required account_info fields.

  Raises:
    CredentialsConfigurationError: If there are environment variables that
        are not set or if the credentials file has missing entries/profiles.
    FileNotFoundError: If the credentials file is not found.
    InvalidFileFormatError: If the credentials file couldn't be parsed.
  """
  path = os.getenv('AZURE_CREDENTIALS_PATH')
  if not path:
    path = os.path.expanduser('~/.azure/credentials.json')

  if not os.path.exists(path):
    raise FileNotFoundError(
        'Credentials file not found. Please place it in '
        '"~/.azure/credentials.json" or specify an absolute path to it in '
        'the AZURE_CREDENTIALS_PATH environment variable.')

  with open(path, encoding='utf-8') as profiles:
    try:
      account_info: Dict[str, Any] = json.load(profiles).get(profile_name)
    except ValueError as exception:
      raise errors.InvalidFileFormatError(
          'Could not decode JSON file. Please verify the file format:'
          ' {0!s}'.format(exception), __name__) from exception
    if not account_info:

      raise errors.CredentialsConfigurationError(