
                         |    S r SSKrSSKJr  SSKJr  SSKJr  SSKJr  Sr	Sr
S	 r\R                  SS
 j5       rS rg)z/Utilities for operating on different endpoints.    N)apis)log)
properties)parsev1mlc                     [         R                  " U 5      u  p#pEpgSR                  X5      n[         R                  " X#XEXg45      $ )Nz{}-{})r   urlparseformat
urlunparse)endpointregionschemenetlocpathparamsqueryfragments           9lib/googlecloudsdk/command_lib/ml_engine/endpoint_util.pyDeriveMLRegionalEndpointr      s=    27..2J/&$>>&)&			64I	JJ    c              #   B  #    [        U 5      n[        R                  R                  R                  R                  5       n [        R                  R                  SR                  U5      5        U (       a9  U S:w  a3  [        R                  R                  R                  R                  U5        Sv   [        R                  R                  R                  R                  U5      ng! [        R                  R                  R                  R                  U5      nf = f7f)zContext manager to override the AI Platform endpoints for a while.

Args:
  region: str, region of the AI Platform stack.

Yields:
  None.
zUsing endpoint [{}]globalN)GetEffectiveMlEndpointr   VALUESapi_endpoint_overridesr   Getr   statusPrintr   Set)r   used_endpointold_endpoints      r   MlEndpointOverridesr#   #   s      )0-""99<<@@B,QJJ*11-@A&H$..1155mD	$$;;>>BB<PL:$$;;>>BB<PLs   >DA2C' 34D'5DDc                 t    [         R                  " [        [        5      nU (       a  U S:w  a  [	        X5      $ U$ )z:Returns regional ML Endpoint, or global if region not set.r   )r   GetEffectiveApiEndpointML_API_NAMEML_API_VERSIONr   )r   r   s     r   r   r   8   s.    ))+~F(("#H55	/r   )N)__doc__
contextlibgooglecloudsdk.api_lib.utilr   googlecloudsdk.corer   r   six.moves.urllibr   r'   r&   r   contextmanagerr#   r    r   r   <module>r/      sL    6  , # * "K Q Q(r   