
    +jJ              	       r   d dl Z d dlZd dlmZmZ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  ej        d
          Z	 ddeeeef         ef         deeeef                  deeef         fdZ	 ddeeeef         ef         deeeef                  deeef         fdZ	 ddeeeef         ef         deeeef                  deeef         fdZ	 ddeeeef         ef         deeeef                  deeef         fdZ G d de
j                  Z G d de
j                  ZdS )    N)AnyOptionalTypeVarUnion)	urlencode   )_api_module)_common)types)get_value_by_path)set_value_by_pathzgoogle_genai.operationsfrom_objectparent_objectreturnc                     i }t          | dg          !t          |dgt          | dg                     t          | dg          "t          |ddgt          | dg                     |S )Noperation_nameoperationNameresource_name_urlresourceNamegetvsetvr   r   	to_objects      [/home/wildlama/visual-decline/.venv/lib/python3.11/site-packages/google/genai/operations.py*_FetchPredictOperationParameters_to_vertexr       s     !)	+()**6_%tK:J9K'L'LMMM	+())5	 [?+,,   
    c                 p    i }t          | dg          "t          |ddgt          | dg                     |S Nr   r   r   r   r   s      r    _GetOperationParameters_to_mldevr!   2   S     !)	+()**6	![+,--   
r   c                 p    i }t          | dg          "t          |ddgt          | dg                     |S r    r   r   s      r   !_GetOperationParameters_to_vertexr$   A   r"   r   c                 p    i }t          | dg          "t          |ddgt          | dg                     |S )Noperation_idr   r   r   s      r   (_GetProjectOperationParameters_to_vertexr'   P   sO     !)	+'((4FN+T+?O-P-P   
r   c            	           e Zd Zdddedeej                 defdZdddededeej	                 defdZ
ddd	edeej                 dej        fd
Z edej                  Zdddedeej                 defdZdS )
OperationsNconfigr   r+   r   c                   t          j        ||          }| j        j        r?t	          |          }|                    d          }|rd                    |          }nAd}n>t          |          }|                    d          }|rd                    |          }nd}|                    d          }|r| dt          |           }|	                    dd            d }|j
        |j
        j        |j
        j        }t          j        |          }t          j        |          }| j                            d|||          }	|	j        si nt#          j        |	j                  }
|
S Nr   r+   r   z{operationName}_query?r+   get)r   _GetOperationParameters_api_clientvertexair$   r1   
format_mapr!   r   popr+   http_optionsr
   convert_to_dictencode_unserializable_typesrequestbodyjsonloadsselfr   r+   parameter_modelrequest_dictrequest_url_dictpathquery_paramsr7   responseresponse_dicts              r   _get_videos_operationz Operations._get_videos_operation_   s    3%  O   !6GGl%))&11	 ! ++,<== 5oFFl%))&11	 ! ++,<== ##H--L 100y..00dXt$$$04L*"/;$+8l*<88L6|DDL''t\<PPH&mJBBHM1J1JMr   r   c                x   t          j        |||          }| j        j        st	          d          t          |          }|                    d          }|rd                    |          }nd}|                    d          }|r| dt          |           }|	                    dd            d }	|j
        |j
        j        |j
        j        }	t          j        |          }t          j        |          }| j                            d|||	          }
|
j        si nt#          j        |
j                  }|S 	Nr   r   r+   iThis method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.r   z${resourceName}:fetchPredictOperationr/   r0   r+   post)r    _FetchPredictOperationParametersr3   r4   
ValueErrorr   r1   r5   r   r6   r+   r7   r
   r8   r9   r:   r;   r<   r=   r?   r   r   r+   r@   rA   rB   rC   rD   r7   rE   rF   s               r   _fetch_predict_videos_operationz*Operations._fetch_predict_videos_operation   sn    <%#  O $ 65  
 @PPl%))&11	 65@@
 
 6##H--L 100y..00dXt$$$04L*"/;$+8l*<88L6|DDL''lL H 'mJBBHM1J1JMr   r&   c                   t          j        ||          }| j        j        st	          d          t          |          }|                    d          }|rd                    |          }nd}|                    d          }|r| dt          |           }|	                    dd            d }|j
        |j
        j        |j
        j        }t          j        |          }t          j        |          }| j                            d|||          }	|	j        si nt#          j        |	j                  }
t           j                            |
t+          |dd           rDdt+          |j
        d	d           t+          |j
        d
d           t+          |j
        dd           dini           }| j                            |           |S N)r&   r+   rK   r   zoperations/{operation_id}r/   r0   r+   r1   response_schemaresponse_json_schemainclude_all_fields)rS   rT   rU   )rE   kwargs)r   _GetProjectOperationParametersr3   r4   rN   r'   r1   r5   r   r6   r+   r7   r
   r8   r9   r:   r;   r<   r=   ProjectOperation_from_responsegetattr_verify_responser?   r&   r+   r@   rA   rB   rC   rD   r7   rE   rF   return_values               r   _getzOperations._get   s    :!  O $ +5  
 >oNNl%))&11	 +*556FGG*##H--L 100y..00dXt$$$04L*"/;$+8l*<88L6|DDL''t\<PPH&mJBBHM1J1JM)88 ?Hd33#*#*,=t$ $ )0#*,BD) ) '.#*,@$' '
 

 
 ! 9  L& 	%%l333r   Tbound	operationc                   |j         }|st          d          | j        j        r|                    d          d         }t          j                    }t          |t                    r7|	                    dd          }|t          j        di t          |          }n=t          |t
          j
                  r#|!|j        |j        nt          j                    }t          j        |          }|                     |||          }|                    |d	          }	| j                            |	           |	S |                     ||
          }|                    |d	          }	| j                            |	           |	S )a  Gets the status of a long-running operation.

    Args:
      operation (Operation): The operation instance to get the status for.
      config (GetOperationConfig): Configuration for getting the operation.

    Returns:
      Operation: The updated operation instance with the latest status or
      result.

    Usage:

    .. code-block:: python

      import time

      operation = client.models.generate_videos(
          model="veo-2.0-generate-001",
          source=types.GenerateVideosSource(
              prompt="A neon hologram of a cat driving at top speed",
          ),
      )
      while not operation.done:
          time.sleep(10)
          operation = client.operations.get(operation)

      print(operation.result)
    Operation name is empty./operations/r   r7   Nr7   rJ   Tis_vertex_air.   F )namerN   r3   r4   
rpartitionr   HttpOptions
isinstancedictr1   GetOperationConfigr7   FetchPredictOperationConfigrP   from_api_responser[   rG   
r?   rb   r+   r   r   r7   dict_optionsfetch_operation_configrF   response_operations
             r   r1   zOperations.get
  s   H ^N 31222   & $//??Bm&((l	FD	!	! 	
zz.$77#*@@T,-?-?@@,fe677 
F<N ". "$$ 	
  %@#      ::'%' ;  m %66
d 7   ''(:;;;00' 1  m %66
e 7   ''(:;;;r   __name__
__module____qualname__strr   r   GetOperationConfigOrDictr   rG   !FetchPredictOperationConfigOrDictrP   rX   r^   r   	Operationr_   r1   ri   r   r   r)   r)   ]   st        :>	/ / / / u56	/
 / / / /l CG3 3 3 3 	3
 u>?3 3 3 3 3r :>	A A A A u56	A
 A A A AF gc)))! :>	O  O  O O  u56	O 
 	O  O  O  O  O  O r   r)   c            	           e Zd Zdddedeej                 defdZdddededeej	                 defdZ
ddd	edeej                 dej        fd
Z edej                  Zdddedeej                 defdZdS )AsyncOperationsNr*   r   r+   r   c                  K   t          j        ||          }| j        j        r?t	          |          }|                    d          }|rd                    |          }nAd}n>t          |          }|                    d          }|rd                    |          }nd}|                    d          }|r| dt          |           }|	                    dd            d }|j
        |j
        j        |j
        j        }t          j        |          }t          j        |          }| j                            d|||           d {V }	|	j        si nt#          j        |	j                  }
|
S r-   )r   r2   r3   r4   r$   r1   r5   r!   r   r6   r+   r7   r
   r8   r9   async_requestr;   r<   r=   r>   s              r   rG   z%AsyncOperations._get_videos_operation^  s      3%  O   !6GGl%))&11	 ! ++,<== 5oFFl%))&11	 ! ++,<== ##H--L 100y..00dXt$$$04L*"/;$+8l*<88L6|DDL%33t\<       H 'mJBBHM1J1JMr   r   c                  K   t          j        |||          }| j        j        st	          d          t          |          }|                    d          }|rd                    |          }nd}|                    d          }|r| dt          |           }|	                    dd            d }	|j
        |j
        j        |j
        j        }	t          j        |          }t          j        |          }| j                            d|||	           d {V }
|
j        si nt#          j        |
j                  }|S rI   )r   rM   r3   r4   rN   r   r1   r5   r   r6   r+   r7   r
   r8   r9   r   r;   r<   r=   rO   s               r   rP   z/AsyncOperations._fetch_predict_videos_operation  s      <%#  O $ 65  
 @PPl%))&11	 65@@
 
 6##H--L 100y..00dXt$$$04L*"/;$+8l*<88L6|DDL%33lL       H 'mJBBHM1J1JMr   r&   c                  K   t          j        ||          }| j        j        st	          d          t          |          }|                    d          }|rd                    |          }nd}|                    d          }|r| dt          |           }|	                    dd            d }|j
        |j
        j        |j
        j        }t          j        |          }t          j        |          }| j                            d|||           d {V }	|	j        si nt#          j        |	j                  }
t           j                            |
t+          |dd           rDdt+          |j
        d	d           t+          |j
        d
d           t+          |j
        dd           dini           }| j                            |           |S rR   )r   rW   r3   r4   rN   r'   r1   r5   r   r6   r+   r7   r
   r8   r9   r   r;   r<   r=   rX   rY   rZ   r[   r\   s               r   r^   zAsyncOperations._get  s=      :!  O $ +5  
 >oNNl%))&11	 +*556FGG*##H--L 100y..00dXt$$$04L*"/;$+8l*<88L6|DDL%33t\<       H 'mJBBHM1J1JM)88 ?Hd33#*#*,=t$ $ )0#*,BD) ) '.#*,@$' '
 

 
 ! 9  L& 	%%l333r   r_   r`   rb   c                  K   |j         }|st          d          | j        j        r|                    d          d         }t          j                    }t          |t                    r7|	                    dd          }|t          j        di t          |          }n=t          |t
          j
                  r#|!|j        |j        nt          j                    }t          j        |          }|                     |||           d{V }|                    |d	          }	|	S |                     ||
           d{V }|                    |d	          }	|	S )a  Gets the status of a long-running operation.

    Args:
      operation (Operation): The operation instance to get the status for.
      config (GetOperationConfig): Configuration for getting the operation.

    Returns:
      Operation: The updated operation instance with the latest status or
      result.

    Usage:

    .. code-block:: python

      import asyncio

      operation = await client.aio.models.generate_videos(
          model="veo-2.0-generate-001",
          source=types.GenerateVideosSource(
              prompt="A neon hologram of a cat driving at top speed",
          ),
      )
      while not operation.done:
          await asyncio.sleep(10)
          operation = await client.aio.operations.get(operation)

      print(operation.result)
    rd   re   r   r7   Nrf   rJ   Trg   r.   Fri   )rj   rN   r3   r4   rk   r   rl   rm   rn   r1   ro   r7   rp   rP   rq   rG   rr   s
             r   r1   zAsyncOperations.get  s     F ^N 31222  ! $//??Bm&((l	FD	!	! 	
zz.$77#*@@T,-?-?@@,fe677 
F<N ". "$$ 	
  %@#      !@@'%' A        m
 %66
d 7     66' 7        m %66
e 7    r   rv   ri   r   r   r   r   \  st        :>	1 1 1 1 u56	1
 1 1 1 1p CG3 3 3 3 	3
 u>?3 3 3 3 3r :>	C C C C u56	C
 C C C CJ gc)))! :>	H  H  H H  u56	H 
 	H  H  H  H  H  H r   r   )N)r<   loggingtypingr   r   r   r   urllib.parser    r	   r
   r   r   r   r   r   	getLoggerloggerrn   rz   objectr   r!   r$   r'   
BaseModuler)   r   ri   r   r   <module>r      s  $   0 0 0 0 0 0 0 0 0 0 0 0 " " " " " "                   . . . . . . . . . . . .		4	5	5
 /3 tCH~v-.DcN+ 
#s(^   ( /3 tCH~v-.DcN+ 
#s(^   " /3 tCH~v-.DcN+ 
#s(^   " /3
 
tCH~v-.
DcN+
 
#s(^
 
 
 
|  |  |  |  | ' |  |  | ~y  y  y  y  y k, y  y  y  y  y r   