
    Ng                     V   d dl Z d dlZd dlZd dlmZmZmZ d dlZd dlmZ d dl	m
Z
 d dlmZ  ej        e          Z G d d e j        dd	          ej                  Z G d
 de          Z G d dej                  Z G d de          Zdej        dee         dej        fdZdS )    N)CallableOptionalType)_common)cygrpc)MetadataTypec                       e Zd ZdS )_AuthMetadataContextN)__name__
__module____qualname__     Q/var/www/html/ai-engine/env/lib/python3.11/site-packages/grpc/_plugin_wrapping.pyr
   r
      s         	Dr   r
   AuthMetadataContext)service_urlmethod_namec                       e Zd Zd ZdS )_CallbackStatec                 R    t          j                    | _        d| _        d | _        d S )NF)	threadingLocklockcalled	exception)selfs    r   __init__z_CallbackState.__init__*   s#    N$$	r   N)r   r   r   r   r   r   r   r   r   )   s#            r   r   c                   \    e Zd ZU eed<   eed<   dedefdZdedee	e
                  fdZd	S )
_AuthMetadataPluginCallback_state	_callbackstatecallbackc                 "    || _         || _        d S N)r    r!   )r   r"   r#   s      r   r   z$_AuthMetadataPluginCallback.__init__4   s    !r   metadataerrorc           	         | j         j        5  | j         j        (| j         j        rt	          d          d| j         _        n,t	          d                    | j         j                            	 d d d            n# 1 swxY w Y   |(|                     |t          j        j	        d            d S |                     d t          j        j
        t          j        t          |                               d S )Nz2AuthMetadataPluginCallback invoked more than once!Tz1AuthMetadataPluginCallback raised exception "{}"!)r    r   r   r   RuntimeErrorformatr!   r   
StatusCodeokinternalr   encodestr)r   r&   r'   s      r   __call__z$_AuthMetadataPluginCallback.__call__8   s8    [ 	 	{$,;% .&L   *.DK&&"GNN-    '	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 =NN8V%6%94@@@@@NNf'0'.U2L2L    s   A!A;;A?A?N)r   r   r   r   __annotations__r   r   r   r   r   BaseExceptionr0   r   r   r   r   r   0   s~         "n " " " " "$-5d=6I-J     r   r   c                   N    e Zd ZU ej        ed<   dej        fdZdededefdZ	dS )	_Plugin_metadata_pluginmetadata_pluginc                     || _         d | _        	 dd l}|                                | _        d S # t          $ r Y d S w xY w)Nr   )r5   _stored_ctxcontextvarscopy_contextImportError)r   r6   r9   s      r   r   z_Plugin.__init__T   sa     /		
  +7799D 	 	 	DD	s   / 
==r   r   r#   c           
      :   t          t          j        |          t          j        |                    }t                      }	 |                     |t          ||                     d S # t          $ r}t                              d| j                   |j	        5  ||_        |j
        r	 d d d            Y d }~d S 	 d d d            n# 1 swxY w Y    |d t          j        j        t          j        t          |                               Y d }~d S d }~ww xY w)Nz1AuthMetadataPluginCallback "%s" raised exception!)r
   r   decoder   r5   r   	Exception_LOGGERr   r   r   r   r+   r-   r.   r/   )r   r   r   r#   contextcallback_stater   s          r   r0   z_Plugin.__call__c   s   &N;'')D)D
 
 ())	!!4^XNN      	 	 	C%    $  +4(!(                           Hf'0'.Y2P2P        	sB   $A* *
D4'DC	+D=D	C	DC	>DDN)
r   r   r   grpcAuthMetadataPluginr1   r   r/   r   r0   r   r   r   r4   r4   Q   sl         ----(?    C c X      r   r4   r6   namereturnc                     |%	 | j         }n# t          $ r | j        j         }Y nw xY w|}t          j        t          j        t          |           t          j	        |                              S r%   )
r   AttributeError	__class__rB   CallCredentialsr   MetadataPluginCallCredentialsr4   r   r.   )r6   rD   effective_names      r    metadata_plugin_call_credentialsrL   z   s     |	@,5NN 	@ 	@ 	@,6?NNN	@ ,O$$gn^&D&D	
 	
  s    %%)collectionsloggingr   typingr   r   r   rB   r   grpc._cythonr   grpc._typingr   	getLoggerr   r?   
namedtupler   r
   objectr   AuthMetadataPluginCallbackr   r4   rC   r/   rI   rL   r   r   r   <module>rV      s            + + + + + + + + + +              % % % % % %
'
H
%
%
	 
	 
	 
	 
	K	
  	
	 
	 
	    V       $"A   B& & & & &f & & &R,4<SM	     r   