
    N                         d Z ddlZddlmZ ddlmZ  eg d      Z eg d      Z	dZ
dZd	Zd
 Zej                  dd       Z	 ddZy)z/Utilities for operating on different endpoints.    N)
exceptions)
properties)
euzeurope-north2zeurope-west12znorthamerica-south1uszus-west8asiazasia-southeast3zeurope-west15global))zafrica-south1z
asia-east1z
asia-east2zasia-northeast1zasia-northeast2zasia-northeast3zasia-south1zasia-south2zasia-southeast1zasia-southeast2zaustralia-southeast1zaustralia-southeast2zeurope-central2zeurope-north1zeurope-southwest1zeurope-west1zeurope-west10zeurope-west2zeurope-west3zeurope-west4zeurope-west6zeurope-west8zeurope-west9zme-central1zme-central2zme-west1znorthamerica-northeast1znorthamerica-northeast2zsouthamerica-east1zsouthamerica-west1zus-central1zus-central2zus-east1zus-east4zus-east5zus-east7z	us-south1zus-west1zus-west2zus-west3zus-west4z$https://containeranalysis.{}.rep.{}/z.{protocol}{prefix}{location}-{format}.{domain}z2{protocol}{prefix}{format}.{location}.rep.{domain}c                     t         j                  j                  j                  j	                         }t
        j                  | |      }|S N)r   VALUEScoreuniverse_domainGet!_CONTAINER_ANALYSIS_REP_STRUCTUREformat)regionr   regional_endpoints      9lib/googlecloudsdk/command_lib/artifacts/endpoint_util.py_GetRegionalEndpointr   `   s@    %%**::>>@/7>>o 
    c              #   .  K   t         j                  j                  j                  j	                         }| nl| t
        vr| t        vrt        j                         |F| t        vr>t        |       }t         j                  j                  j                  j                  |       	 d t         j                  j                  j                  j                  |       y# t         j                  j                  j                  j                  |       w xY ww)a  WithRegion overrides artifact analysis endpoint with endpoint of region.

  A call to WithRegion should be done in a with clause.
  If an existing override exists, this command does not do anything.
  If a rerouted region is passed in, this command does not do anything.
  An error is raised if an invalid location is passed in.

  Args:
    region: str, location

  Raises:
    aa_exceptions.UnsupportedLocationError if location provided is invalid.

  Yields:
    None
  N)r   r   api_endpoint_overridescontaineranalysisr   $_CONTAINER_ANALYSIS_DIRECT_LOCATIONS&_CONTAINER_ANALYSIS_REROUTED_LOCATIONSar_exceptionsUnsupportedLocationErrorr   Set)r   overrider   s      r   
WithRegionr   h   s     $ 55GGKKM(^88
>
>

0
0
226)OO,V4,,>>BBM	,,>>BB8LJ,,>>BB8Ls   B"D%C )4D5DDc                    d}t         j                  j                  j                  j	                         }|r3|dk7  r)|dk7  r$t        j                  dj                  |            |dz   }|rt        nt        }|j                  ||| ||      S )zCReturns the Artifact Registry domain endpoint for the given region.zpkg.devhttpshttpz+Invalid protocol: {}, must be https or httpz://)protocolprefixlocationr   domain)
r   r   	artifactsregistry_endpoint_prefixr   r   ArtifactRegistryErrorr   '_ARTIFACT_REGISTRY_FACADE_REP_STRUCTURE#_ARTIFACT_REGISTRY_FACADE_STRUCTURE)r%   repo_formatr#   repr&   r$   templates          r   ArtifactRegistryDomainEndpointr/      s    
 &&&??CCE&7x61//
7
>
>x
H  %H 
 .. 
 
 
 
 r   r
   ) F)__doc__
contextlib googlecloudsdk.api_lib.artifactsr   r   googlecloudsdk.corer   	frozensetr   r   r   r+   r*   r   contextmanagerr   r/    r   r   <module>r8      sy     6  H *
 *3 4 * &( (1 ,2 ,( $\ %K !&V #*^ ' #M #MN -2r   