
                             S r SSKJr  SSKJr  SSKJr  SSKrSSKJr  SSKJ	r	  SSK
Jr  S	rS
rSrSrSSSS.r\R"                  S 5       rS rS rg)z%Utilities for handling location flag.    )absolute_import)division)unicode_literalsN)apis)
properties)parsecloudresourcemanagerv3z<https://staging-cloudresourcemanager.sandbox.googleapis.com/z5stagqual-cloudresourcemanager.sandbox.googleapis.com/nane2staginganane2stagingbnane2stagingc)z northamerica-northeast2-stagingaz northamerica-northeast2-stagingbz northamerica-northeast2-stagingcc           	   #   >  #    [        [        R                  R                  [        5      nUR                  5       nU=(       a    [        U;   =(       d	    [        U:H  n U (       ap  U S:w  aj  U(       aH  [        R                  X 5      n UR                  [        S[        -   U R                  SS5      5      5        O7UR                  [        U 5      5        OU(       a  UR                  [        5        Sv   UR                  U5        g! UR                  U5        f = f7f)a  Context manager to override the current CRM endpoint.

The new endpoint will temporarily be the one corresponding to the given
location.

Args:
  location: str, location of the CRM backend (e.g. a cloud region or zone).
    Can be None to indicate global.

Yields:
  None.
globalzhttps://- N)getattrr   VALUESapi_endpoint_overridesCRM_API_NAMEGetCRM_STAGING_REGIONAL_SUFFIXCRM_STAGING_GLOBAL_APILOCATION_MAPPINGgetSet_DeriveCrmRegionalEndpointreplace_GetEffectiveCrmEndpoint)locationendpoint_propertyold_endpointis_staging_envs       Alib/googlecloudsdk/command_lib/resource_manager/endpoint_utils.pyCrmEndpointOverridesr$   +   s      j//FF*,"&&(, P%@L%P &O(>,(N (H(	 $'';&z4O'O'/'7'7R'@B	C 	6x@A	 23	,','s   ADBD 5DDDc                 V    [         R                  " [        [        5      n[	        X5      $ )zFReturns regional Tag Bindings Endpoint based on the regional location.)r   GetEffectiveApiEndpointr   CRM_API_VERSIONr   )r   endpoints     r#   r   r   R   s    )),H(	#H	77    c                     [         R                  " U 5      u  p#pEpgSR                  X5      n[         R                  " X#XEXg45      $ )Nz{}-{})r   urlparseformat
urlunparse)r(   r   schemenetlocpathparamsqueryfragments           r#   r   r   X   s=    27..2J/&$>>(+&			64I	JJr)   )__doc__
__future__r   r   r   
contextlibgooglecloudsdk.api_lib.utilr   googlecloudsdk.corer   six.moves.urllibr   r   r'   r   r   r   contextmanagerr$   r   r    r)   r#   <module>r<      st    , &  '  , * "%B  <  )8(7(7  #( #(L8Kr)   