o
    0Xxi,                  	   @   sp  d dl mZmZ d dlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ dd	lmZ 	
dde
deeef dedefddZ	
dde
deeef dedefddZ	
dde
deeef dedefddZ	
dde
deeef dedefddZ	
dde
deeef dedefddZ	
dde
deeef dedefddZG dd dejZG dd dejZd
S )     )OptionalUnion)	urlencode   )_api_module)_common)types)	ApiClient)get_value_by_path)set_value_by_pathN
api_clientfrom_objectparent_objectreturnc                 C   V   i }t |dgd urt|ddgt |dg t |dgd ur)t|dgt |dg |S Noperation_name_urloperationNameconfiggetvsetvr   r   r   	to_object r   W/home/air/biblejyuku/back/venv/lib/python3.10/site-packages/google/genai/_operations.py _GetOperationParameters_to_mldev      
r   c                 C   r   r   r   r   r   r   r   !_GetOperationParameters_to_vertex/   r   r   c                 C   sP   i }t |dgd urtdt |dgd urtdt |dgd ur&td|S )Nr   z8operation_name parameter is not supported in Gemini API.resource_namez7resource_name parameter is not supported in Gemini API.r   z0config parameter is not supported in Gemini API.)r   
ValueErrorr   r   r   r   )_FetchPredictOperationParameters_to_mldevB   s   r"   c                 C   s|   i }t |dgd urt|dgt |dg t |dgd ur)t|ddgt |dg t |dgd ur<t|dgt |dg |S )Nr   r   r    r   resourceNamer   r   r   r   r   r   *_FetchPredictOperationParameters_to_vertexT   s   
r$   c                 C      i }t |dgd urt|dgt |dg t |dgd ur(t|dgt |dg t |dgd ur;t|dgt |dg t |dgd urNt|dgt |dg t |dgd urat|dgt |dg |S Nnamemetadatadoneerrorresponser   r   r   r   r   _Operation_from_mldevj      r,   c                 C   r%   r&   r   r   r   r   r   _Operation_from_vertex   r-   r.   c                	   @   X   e Zd Zdddedeej dejfddZdddededeej	 dejfd	d
Z
dS )_operationsNr   r   r   r   c          
      C   s  t j||d}| jjrt| j|}d|d}nt| j|}d|d}|d}|r8| dt| }|	dd  d }t
|trL|dd }nt|drT|j}t|}t|}| jd|||}| jjrrt| j|}nt| j|}t jj||d	}	| j|	 |	S 
N)r   r   z{operationName}r   _query?r   http_optionsgetr+   kwargs)r   _GetOperationParameters_api_clientvertexair   
format_mapr6   r   r   pop
isinstancedicthasattrr5   r   convert_to_dictencode_unserializable_typesrequestr.   r,   	Operation_from_response_verify_response
selfr   r   parameter_modelrequest_dictpathquery_paramsr5   response_dictreturn_valuer   r   r   _get_operation   sF   




z_operations._get_operationr    c                C   s   t j|||d}| jjstdt| j|}d|d}|d}|r.| dt| }|	dd  d }t
|trB|dd }nt|drJ|j}t|}t|}| jd	|||}	| jjrht| j|	}	nt| j|	}	t jj|	|d
}
| j|
 |
S N)r   r    r   z6This method is only supported in the Vertex AI client.z${resourceName}:fetchPredictOperationr   r3   r4   r   r5   postr7   )r    _FetchPredictOperationParametersr:   r;   r!   r$   r<   r6   r   r=   r>   r?   r@   r5   r   rA   rB   rC   r.   r,   rD   rE   rF   rH   r   r    r   rI   rJ   rK   rL   r5   rM   rN   r   r   r   _fetch_predict_operation   sF   




z$_operations._fetch_predict_operation__name__
__module____qualname__strr   r   GetOperationConfigOrDictrD   rO   !FetchPredictOperationConfigOrDictrT   r   r   r   r   r0      &    
8r0   c                	   @   r/   )Async_operationsNr1   r   r   r   c          
         s  t j||d}| jjrt| j|}d|d}nt| j|}d|d}|d}|r9| dt| }|	dd  d }t
|trM|dd }nt|drU|j}t|}t|}| jd|||I d H }| jjrvt| j|}nt| j|}t jj||d	}	| j|	 |	S r2   )r   r9   r:   r;   r   r<   r6   r   r   r=   r>   r?   r@   r5   r   rA   rB   async_requestr.   r,   rD   rE   rF   rG   r   r   r   rO     sH   





zAsync_operations._get_operationr    c                   s  t j|||d}| jjstdt| j|}d|d}|d}|r/| dt| }|	dd  d }t
|trC|dd }nt|drK|j}t|}t|}| jd	|||I d H }	| jjrlt| j|	}	nt| j|	}	t jj|	|d
}
| j|
 |
S rP   )r   rR   r:   r;   r!   r$   r<   r6   r   r=   r>   r?   r@   r5   r   rA   rB   r^   r.   r,   rD   rE   rF   rS   r   r   r   rT   :  sH   





z)Async_operations._fetch_predict_operationrU   r   r   r   r   r]     r\   r]   )N)typingr   r   urllib.parser    r   r   r   r:   r	   r
   r   r   r   r?   objectr   r   r"   r$   r,   r.   
BaseModuler0   r]   r   r   r   r   <module>   s   











k