
    rh                     |    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y)zHelpers for universe domain.    )AnyOptionalzgoogleapis.comc                        e Zd Z fdZ xZS )EmptyUniverseErrorc                 (    d}t         |   |       y )Nz*Universe Domain cannot be an empty string.)super__init__)selfmessage	__class__s     k/var/www/html/ai-insurance-compliance-backend/venv/lib/python3.12/site-packages/google/api_core/universe.pyr	   zEmptyUniverseError.__init__   s    >!    __name__
__module____qualname__r	   __classcell__r   s   @r   r   r      s    " "r   r   c                        e Zd Z fdZ xZS )UniverseMismatchErrorc                 D    d| d| dt          d}t        | 	  |       y )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__   s>    ..? @))=(> ? !!24 	 	!r   r   r   s   @r   r   r      s    " "r   r   client_universe_domainuniverse_domain_envreturnc                 h    t         }| | }n||}t        |j                               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.
    r   )r   lenstripr   )r   r   universe_domains      r   determine_domainr"   '   sA      'O)0		(-
?  "#q(  r   r   credentialsc                 H    t        |dt              }| |k7  rt        | |      y)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..#O5IJJr   N)__doc__typingr   r   r   
ValueErrorr   r   strr"   boolr&    r   r   <module>r-      sj    #  # " ""J "$SM@H4S s t r   