
    j	i                         d Z ddlmZmZ dZ G d de          Z G d de          Zdee         d	ee         d
efdZ	deded
e
fdZdS )zHelpers for universe domain.    )AnyOptionalzgoogleapis.comc                        e Zd Z fdZ xZS )EmptyUniverseErrorc                 N    d}t                                          |           d S )Nz*Universe Domain cannot be an empty string.)super__init__)selfmessage	__class__s     P/srv/django_bis/venv311/lib/python3.11/site-packages/google/api_core/universe.pyr	   zEmptyUniverseError.__init__   s&    >!!!!!    __name__
__module____qualname__r	   __classcell__r   s   @r   r   r      s8        " " " " " " " " "r   r   c                        e Zd Z fdZ xZS )UniverseMismatchErrorc                 l    d| d| dt            d}t                                          |           d S )Nz The configured universe domain (z?) does not match the universe domain found in the credentials (z>). If you haven't configured the universe domain explicitly, `z` is the default.)DEFAULT_UNIVERSEr   r	   )r
   client_universecredentials_universer   r   s       r   r	   zUniverseMismatchError.__init__   sZ    4 4 4)=4 4 !4 4 4 	 	!!!!!r   r   r   s   @r   r   r      s8        " " " " " " " " "r   r   client_universe_domainuniverse_domain_envreturnc                 ~    t           }| | }n||}t          |                                          dk    rt          |S )a  Return the universe domain used by the client.

    Args:
        client_universe_domain (Optional[str]): The universe domain configured via the client options.
        universe_domain_env (Optional[str]): The universe domain configured via the
        "GOOGLE_CLOUD_UNIVERSE_DOMAIN" environment variable.

    Returns:
        str: The universe domain to be used by the client.

    Raises:
        ValueError: If the universe domain is an empty string.
    Nr   )r   lenstripr   )r   r   universe_domains      r   determine_domainr"   '   sL      'O)0		(-
?  ""##q((  r   r   credentialsc                 ^    t          |dt                    }| |k    rt          | |          dS )a  Returns True iff the universe domains used by the client and credentials match.

    Args:
        client_universe (str): The universe domain configured via the client options.
        credentials Any: The credentials being used in the client.

    Returns:
        bool: True iff client_universe matches the universe in credentials.

    Raises:
        ValueError: when client_universe does not match the universe in credentials.
    r!   T)getattrr   r   )r   r#   r   s      r   compare_domainsr&   A   s:     #;0ACSTT...#O5IJJJ4r   N)__doc__typingr   r   r   
ValueErrorr   r   strr"   boolr&    r   r   <module>r-      s    # "                # " " " " " " " "" " " " "J " " "$SM@H   4S s t      r   