o
     i                     @   sp   d Z ddlmZmZ dZG dd deZG dd deZdee d	ee d
efddZ	deded
e
fddZdS )zHelpers for universe domain.    )AnyOptionalzgoogleapis.comc                          e Zd Z fddZ  ZS )EmptyUniverseErrorc                    s   d}t  | d S )Nz*Universe Domain cannot be an empty string.)super__init__)selfmessage	__class__ x/var/www/snowflake_co_dev_github/snow_flake_back_end_deploy/env/lib/python3.10/site-packages/google/api_core/universe.pyr      s   zEmptyUniverseError.__init____name__
__module____qualname__r   __classcell__r   r   r
   r   r          r   c                       r   )UniverseMismatchErrorc                    s(   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
   r   r   r      s   zUniverseMismatchError.__init__r   r   r   r
   r   r      r   r   client_universe_domainuniverse_domain_envreturnc                 C   s6   t }| dur	| }n|dur|}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_domainr   r   r   determine_domain'   s   r   r   credentialsc                 C   s"   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   r   r   r   compare_domainsA   s   
r!   N)__doc__typingr   r   r   
ValueErrorr   r   strr   boolr!   r   r   r   r   <module>   s   
