# Path: xmanager/cloud/auth.py
# _DEFAULT_SCOPES = ('https://www.googleapis.com/auth/cloud-platform',)
# def get_project_name() -> str:
# def get_project_number() -> str:
# def get_creds(scopes: Iterable[str] = _DEFAULT_SCOPES):
# def enable_apis():
# def get_service_account() -> str:
# def _maybe_create_service_account(service_account: str) -> None:
# def _maybe_grant_service_account_permissions(service_account: str) -> None:
# def _add_member_to_iam_policy(policy: Dict[str, Any], role: str,
#                               member: str) -> bool:
# def get_bucket() -> str:


import datetime
import getpass
import tarfile
import tempfile
import time
import termcolor
from typing import Any, Dict, Optional
from absl import flags
from docker.utils import utils as docker_utils
from google.cloud import storage
from googleapiclient import discovery
from xmanager.cloud import auth
  def __init__(self,
               project: Optional[str] = None,
               bucket: Optional[str] = None,
               credentials=None,
               cloud_build_timeout_seconds: Optional[int] = None,
               use_cloud_build_cache: Optional[bool] = None,
               use_kaniko: Optional[bool] = None,
               kaniko_cache_ttl: Optional[str] = None):
    """Create the Cloud Build Client.

    Args:
      project: Name of the GCP project to use for Cloud Build calls and for
        storing the data passed to Cloud Build. If not specified the project of
        the default credentials for the current environment is used.
      bucket: Bucket used to store data passed to Cloud Build. If not specified
        uses the value from the GOOGLE_CLOUD_BUCKET_NAME environment variable.
      credentials: OAuth2 Credentials to use for Cloud Build & storage calls. If
        None gets the default credentials for the current environment.
      cloud_build_timeout_seconds: The amount of time that builds should be
        allowed to run. If None defaults to `--xm_cloud_build_timeout_seconds.
      use_cloud_build_cache: Whether to use Cloud Build cache to speed up the
        Docker build. If None defaults to `--xm_use_cloud_build_cache`. An image
        with the same name tagged as :latest should exist. More details at
          https://cloud.google.com/cloud-build/docs/speeding-up-builds#using_a_cached_docker_image
      use_kaniko: Use kaniko backend for Cloud Build and enable caching. If None
        defaults to `--xm_use_kaniko`.
      kaniko_cache_ttl: Cache ttl to use for kaniko builds. If None defaults to
        `--xm_kaniko_cache_ttl`.
    """
    self.project = project or auth.get_project_name()

# Path: xmanager/cloud/auth.py
# _DEFAULT_SCOPES = ('https://www.googleapis.com/auth/cloud-platform',)
# def get_project_name() -> str:
# def get_project_number() -> str:
# def get_creds(scopes: Iterable[str] = _DEFAULT_SCOPES):
# def enable_apis():
# def get_service_account() -> str:
# def _maybe_create_service_account(service_account: str) -> None:
# def _maybe_grant_service_account_permissions(service_account: str) -> None:
# def _add_member_to_iam_policy(policy: Dict[str, Any], role: str,
#                               member: str) -> bool:
# def get_bucket() -> str:


# Path: xmanager/cloud/cloud_build.py
import datetime
import getpass
import tarfile
import tempfile
import time
import termcolor
from typing import Any, Dict, Optional
from absl import flags
from docker.utils import utils as docker_utils
from google.cloud import storage
from googleapiclient import discovery
from xmanager.cloud import auth

  def __init__(self,
               project: Optional[str] = None,
               bucket: Optional[str] = None,
               credentials=None,
               cloud_build_timeout_seconds: Optional[int] = None,
               use_cloud_build_cache: Optional[bool] = None,
               use_kaniko: Optional[bool] = None,
               kaniko_cache_ttl: Optional[str] = None):
    """Create the Cloud Build Client.

    Args:
      project: Name of the GCP project to use for Cloud Build calls and for
        storing the data passed to Cloud Build. If not specified the project of
        the default credentials for the current environment is used.
      bucket: Bucket used to store data passed to Cloud Build. If not specified
        uses the value from the GOOGLE_CLOUD_BUCKET_NAME environment variable.
      credentials: OAuth2 Credentials to use for Cloud Build & storage calls. If
        None gets the default credentials for the current environment.
      cloud_build_timeout_seconds: The amount of time that builds should be
        allowed to run. If None defaults to `--xm_cloud_build_timeout_seconds.
      use_cloud_build_cache: Whether to use Cloud Build cache to speed up the
        Docker build. If None defaults to `--xm_use_cloud_build_cache`. An image
        with the same name tagged as :latest should exist. More details at
          https://cloud.google.com/cloud-build/docs/speeding-up-builds#using_a_cached_docker_image
      use_kaniko: Use kaniko backend for Cloud Build and enable caching. If None
        defaults to `--xm_use_kaniko`.
      kaniko_cache_ttl: Cache ttl to use for kaniko builds. If None defaults to
        `--xm_kaniko_cache_ttl`.
    """
    self.project = project or auth.get_project_name()

    self.bucket = bucket or auth.get_bucket()