
    p[i                     6
   d dl Z d dlZd dl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 dd
l
mZ ddl
mZ ddlmZmZ  ej.                  d      Z	 d7deeeef   ef   deeeef      deeef   fdZ	 d7deeeef   ef   deeeef      deeef   fdZ	 d7deeeef   ef   deeeef      deeef   fdZ	 d7deeeef   ef   deeeef      deeef   fdZ	 d7deeeef   ef   deeeef      deeef   fdZ 	 d7dedeeeef   ef   deeeef      deeef   fdZ!	 d7dedeeeef   ef   deeeef      deeef   fdZ"	 d7dedeeeef   ef   deeeef      deeef   fdZ#	 d7dedeeeef   ef   deeeef      deeef   fdZ$	 d7deeeef   ef   deeeef      deeef   fdZ%	 d7deeeef   ef   deeeef      deeef   fdZ&	 d7deeeef   ef   deeeef      deeef   fdZ'	 d7deeeef   ef   deeeef      deeef   fdZ(	 d7deeeef   ef   deeeef      deeef   fdZ)	 d7deeeef   ef   deeeef      deeef   fd Z*	 d7dedeeeef   ef   deeeef      deeef   fd!Z+	 d7dedeeeef   ef   deeeef      deeef   fd"Z,	 d7deeeef   ef   deeeef      deeef   fd#Z-	 d7deeeef   ef   deeeef      deeef   fd$Z.	 d7deeeef   ef   deeeef      deeef   fd%Z/	 d7deeeef   ef   deeeef      deeef   fd&Z0	 d7deeeef   ef   deeeef      deeef   fd'Z1	 d7deeeef   ef   deeeef      deeef   fd(Z2	 d7deeeef   ef   deeeef      deeef   fd)Z3	 d7deeeef   ef   deeeef      deeef   fd*Z4	 d7deeeef   ef   deeeef      deeef   fd+Z5	 d7deeeef   ef   deeeef      deeef   fd,Z6	 d7deeeef   ef   deeeef      deeef   fd-Z7	 d7deeeef   ef   deeeef      deeef   fd.Z8	 d7deeeef   ef   deeeef      deeef   fd/Z9	 d7deeeef   ef   deeeef      deeef   fd0Z:	 d7dedeeeef   ef   deeeef      deeef   fd1Z;	 d7dedeeeef   ef   deeeef      deeef   fd2Z< G d3 d4e	jz                        Z> G d5 d6e	jz                        Z?y)8    N)AnyOptionalUnion)	urlencode   )_api_module)_common)_transformers)types)BaseApiClient)get_value_by_path)set_value_by_path)
AsyncPagerPagerzgoogle_genai.cachesfrom_objectparent_objectreturnc                 v   i }t        | dg      t        |dgt        | dg             t        | dg      t        d      t        | dg      t        d      t        | dg      t        d      t        | d	g      t        d
      t        | dg      t        d      t        | dg      t        d      |S )Napi_keyapiKeyapi_key_configz8api_key_config parameter is not supported in Gemini API.	auth_typez3auth_type parameter is not supported in Gemini API.google_service_account_configzGgoogle_service_account_config parameter is not supported in Gemini API.http_basic_auth_configz@http_basic_auth_config parameter is not supported in Gemini API.oauth_configz6oauth_config parameter is not supported in Gemini API.oidc_configz5oidc_config parameter is not supported in Gemini API.getvsetv
ValueErrorr   r   	to_objects      L/mnt/data/GridWatch/venv/lib/python3.12/site-packages/google/genai/caches.py_AuthConfig_to_mldevr$   $   s     !)	+	{#/XJ[9+ >?	+()*6
O
PP	+}%1
J
KK	+789E
	 
 
+012>
J  
+'(4
M
NN	+'3
L
MM	    c                     i }t        | dg      t        |dgt        | dg             t        | dg      t        d      t        | dg      t        |dgt        | dg             |S )Ndatadisplay_name6display_name parameter is not supported in Gemini API.	mime_typemimeTyper   r!   s      r#   _Blob_to_mldevr,   F   sw     !)	+x ,VHd;9:	+'(4
M
NN	+}%1ZL${[M"BC	r%   c                     i }t        | dg      1t        |dgt        | dg      D cg c]  }t        ||       c}       t        | dg      t        |dgt        | dg             |S c c}w )Npartsrole)r   r   _Part_to_mldevr   r   r"   items       r#   _Content_to_mldevr3   W   s     !)	+y!-		 [7)4	
 4+	
 
+x ,VHd;9:		
s   A)c                 6   i }t        | dg      t        |dgt        | dg             t        | dg      t        |dgt        | dg             t        | dg      t        |dgt        | dg             t        | dg      Dt        |dgt        j                  t        | dg            D cg c]  }t	        ||       c}       t        | dg      6t        |dgt	        t        j
                  t        | dg            |             t        | d	g      1t        |d	gt        | d	g      D cg c]  }t        ||       c}       t        | d
g      #t        |dgt        t        | d
g      |             t        | dg      t        d      |S c c}w c c}w )Nttlexpire_time
expireTimer(   displayNamecontentssystem_instructionsystemInstructiontoolstool_config
toolConfigkms_key_namez6kms_key_name parameter is not supported in Gemini API.)	r   r   t
t_contentsr3   	t_content_Tool_to_mldev_ToolConfig_to_mldevr    r1   s       r#   #_CreateCachedContentConfig_to_mldevrE   l   s    !)	+w+kE7!;<	+'3[=/(JK	+'(4kN;K)LM	+
|$0	 T+
|%DE	
 dI.	
 
+,-.:	KK[+?*@ABI	
 
+y!-		 [7)4	
 4+	
 
+'3	T+?K 
+'(4
M
NN	G	
&	
s   ,F-Fc                    i }t        | dg      t        |dgt        | dg             t        | dg      t        |dgt        | dg             t        | dg      t        |dgt        | dg             t        | dg      :t        |dgt        j                  t        | dg            D cg c]  }| c}       t        | dg      ,t        |dgt        j                  t        | dg                   t        | d	g      1t        |d	gt        | d	g      D cg c]  }t        ||       c}       t        | d
g      t        |dgt        | d
g             t        | dg      t        |ddgt        | dg             |S c c}w c c}w )Nr5   r6   r7   r(   r8   r9   r:   r;   r<   r=   r>   r?   encryption_spec
kmsKeyName)r   r   r@   rA   rB   _Tool_to_vertexr1   s       r#   $_CreateCachedContentConfig_to_vertexrJ      s    !)	+w+kE7!;<	+'3[=/(JK	+'(4kN;K)LM	+
|$0	,,tK*'FGH$H 
+,-.:		D';&<=> 
+y!-		 [7)4	
 D),	
 
+'3[=/(JK	+'(4	L)[>*+ 
= 	I	
s   ,	FF
api_clientc                     i }t        |dg      -t        |dgt        j                  | t        |dg                   t        |dg      t	        t        |dg      |       |S Nmodelconfig)r   r   r@   t_caches_modelrE   rK   r   r   r"   s       r#   '_CreateCachedContentParameters_to_mldevrR      sp    
 !)	+y!-			T+y%AB 
+z".'[8*%y 
r%   c                     i }t        |dg      -t        |dgt        j                  | t        |dg                   t        |dg      t	        t        |dg      |       |S rM   )r   r   r@   rP   rJ   rQ   s       r#   (_CreateCachedContentParameters_to_vertexrT      sp    
 !)	+y!-			T+y%AB 
+z".([8*%y 
r%   c                     i }t        |dg      .t        |ddgt        j                  | t        |dg                   |S Nname_urlr   r   r@   t_cached_content_namerQ   s       r#   '_DeleteCachedContentParameters_to_mldevr[     L    
 !)	+x ,		
Dvh,GH 
r%   c                     i }t        |dg      .t        |ddgt        j                  | t        |dg                   |S rV   rY   rQ   s       r#   (_DeleteCachedContentParameters_to_vertexr^     r\   r%   c                 V    i }t        | dg      t        |dgt        | dg             |S NsdkHttpResponsesdk_http_responser   r   r!   s      r#   '_DeleteCachedContentResponse_from_mldevrd   #  @     !)	+)*+7'(${=N<O*P 
r%   c                 V    i }t        | dg      t        |dgt        | dg             |S r`   rc   r!   s      r#   (_DeleteCachedContentResponse_from_vertexrg   0  re   r%   c                     i }t        | dg      t        d      t        | dg      t        |dgt        | dg             t        | dg      t        |dgt        | dg             |S )Nr(   r)   file_urifileUrir*   r+   )r   r    r   r!   s      r#   _FileData_to_mldevrk   =  sw     !)	+'(4
M
NN	+
|$0YKkJ<!@A	+}%1ZL${[M"BC	r%   c                 N   i }t        | dg      t        |dgt        | dg             t        | dg      t        |dgt        | dg             t        | dg      t        |dgt        | dg             t        | dg      t        d      t        | dg      t        d      |S )NidargsrW   partial_argsz6partial_args parameter is not supported in Gemini API.will_continuez7will_continue parameter is not supported in Gemini API.r   r!   s      r#   _FunctionCall_to_mldevrq   N  s     !)	+v*TFDtf56	+x ,VHd;9:	+x ,VHd;9:	+'(4
M
NN	+()5
N
OO	r%   c                     i }t        | dg      t        |dgt        | dg             t        | dg      t        |dgt        | dg             t        | dg      t        d      |S )Nallowed_function_namesallowedFunctionNamesmodestream_function_call_argumentszHstream_function_call_arguments parameter is not supported in Gemini API.r   r!   s      r#   _FunctionCallingConfig_to_mldevrw   e  s     !)	+012>	 [345 
+x ,VHd;9:	+89:F
	 
 
r%   c                    i }t        | dg      t        |dgt        | dg             t        | dg      t        |dgt        | dg             t        | dg      t        |dgt        | dg             t        | dg      t        |dgt        | dg             t        | dg      t        |dgt        | dg             t        | dg      t        |dgt        | dg             t        | d	g      t        d
      |S )NdescriptionrW   
parametersparameters_json_schemaparametersJsonSchemaresponseresponse_json_schemaresponseJsonSchemabehaviorz1behavior parameter is not supported in Vertex AI.r   r!   s      r#   _FunctionDeclaration_to_vertexr   }  s&    !)	+'3]OT+%GH	+x ,VHd;9:	+~&2\ND|n$EF	+012>	 [345 
+
|$0ZL${ZL"AB	+./0<	[123 
+
|$0
H
II	r%   c                     i }t        |dg      .t        |ddgt        j                  | t        |dg                   |S rV   rY   rQ   s       r#   $_GetCachedContentParameters_to_mldevr     r\   r%   c                     i }t        |dg      .t        |ddgt        j                  | t        |dg                   |S rV   rY   rQ   s       r#   %_GetCachedContentParameters_to_vertexr     r\   r%   c           
          i }t        | dg      #t        |dgt        t        | dg      |             t        | dg      t        |dgt        | dg             |S )Nauth_config
authConfigenable_widgetenableWidget)r   r   r$   r!   s      r#   _GoogleMaps_to_mldevr     sl     !)	+'3	T+?K 
+()5^$d;8I&JK	r%   c                    i }t        | dg      t        |dgt        | dg             t        | dg      t        d      t        | dg      t        d      t        | dg      t        |dgt        | dg             |S )	Nsearch_typessearchTypesblocking_confidencez=blocking_confidence parameter is not supported in Gemini API.exclude_domainsz9exclude_domains parameter is not supported in Gemini API.time_range_filtertimeRangeFilterr   r!   s      r#   _GoogleSearch_to_mldevr     s     !)	+'(4]OT+7G%HI	+-./;
G  
+)*+7
C  
++,-9%&[;N:O(P 
r%   c                     i }t        | dg      t        |ddgt        | dg             t        | dg      t        |ddgt        | dg             |S N	page_size_querypageSize
page_token	pageTokenrc   r!   s      r#   "_ListCachedContentsConfig_to_mldevr     m     !)	+}%1*-tK+/O 
+~&2	;[<.) 
r%   c                     i }t        | dg      t        |ddgt        | dg             t        | dg      t        |ddgt        | dg             |S r   rc   r!   s      r#   #_ListCachedContentsConfig_to_vertexr     r   r%   c                 R    i }t        | dg      t        t        | dg      |       |S NrO   )r   r   r!   s      r#   &_ListCachedContentsParameters_to_mldevr     s1     !)	+z".&tK('DiP	r%   c                 R    i }t        | dg      t        t        | dg      |       |S r   )r   r   r!   s      r#   '_ListCachedContentsParameters_to_vertexr   #  s6     !)	+z".'[8*%y 
r%   c                    i }t        | dg      t        |dgt        | dg             t        | dg      t        |dgt        | dg             t        | dg      't        |dgt        | dg      D cg c]  }| c}       |S c c}w Nra   rb   nextPageTokennext_page_tokencachedContentscached_contentsrc   r1   s       r#   &_ListCachedContentsResponse_from_mldevr   0       !)	+)*+7'(${=N<O*P 
+()5&'kO;L)MN	+()*6	{-=,>?@$@ 
 	A   3	Bc                    i }t        | dg      t        |dgt        | dg             t        | dg      t        |dgt        | dg             t        | dg      't        |dgt        | dg      D cg c]  }| c}       |S c c}w r   rc   r1   s       r#   '_ListCachedContentsResponse_from_vertexr   G  r   r   c           
         i }t        | dg      t        |dgt        | dg             t        | dg      t        |dgt        | dg             t        | dg      t        |dgt        | dg             t        | dg      #t        |dgt        t        | dg      |             t        | d	g      #t        |d
gt        t        | d	g      |             t        | dg      t        |dgt        | dg             t        | dg      #t        |dgt	        t        | dg      |             t        | dg      t        |dgt        | dg             t        | dg      t        |dgt        | dg             t        | dg      t        |dgt        | dg             t        | dg      t        |dgt        | dg             |S )Nmedia_resolutionmediaResolutioncode_execution_resultcodeExecutionResultexecutable_codeexecutableCode	file_datafileDatafunction_callfunctionCallfunction_responsefunctionResponseinline_data
inlineDatatextthoughtthought_signaturethoughtSignaturevideo_metadatavideoMetadata)r   r   rk   rq   r,   r!   s      r#   r0   r0   ^  s    !)	+*+,8%&[;M:N(O 
+/01=	[234 
+)*+7%&[;L:M(NO	+}%1	4k];YG 
+()5	tK/1BCYO 
++,-9	[./0 
+'3	tK-99E 
+x ,VHd;9:	+	{#/YKkI;!?@	++,-9	[./0 
+()*6_%tK:J9K'LM	r%   c           
          i }t        | dg      t        |dgt        | dg             t        | dg      #t        |dgt        t        | dg      |             |S )Nretrieval_configretrievalConfigfunction_calling_configfunctionCallingConfig)r   r   rw   r!   s      r#   rD   rD     s|     !)	+*+,8%&[;M:N(O 
+123?	 !'89:I	
 
r%   c           
         i }t        | dg      t        d      t        | dg      t        |dgt        | dg             t        | dg      t        |dgt        | dg             t        | dg      #t        |dgt        t        | dg      |             t        | d	g      #t        |d
gt	        t        | d	g      |             t        | dg      t        |dgt        | dg             t        | dg      t        d      t        | dg      't        |dgt        | dg      D cg c]  }| c}       t        | dg      t        |dgt        | dg             t        | dg      t        d      t        | dg      t        |dgt        | dg             t        | dg      't        |dgt        | dg      D cg c]  }| c}       |S c c}w c c}w )N	retrievalz3retrieval parameter is not supported in Gemini API.computer_usecomputerUsefile_search
fileSearchgoogle_searchgoogleSearchgoogle_maps
googleMapscode_executioncodeExecutionenterprise_web_searchz?enterprise_web_search parameter is not supported in Gemini API.function_declarationsfunctionDeclarationsgoogle_search_retrievalgoogleSearchRetrievalparallel_ai_searchz<parallel_ai_search parameter is not supported in Gemini API.url_context
urlContextmcp_servers
mcpServers)r   r    r   r   r   r1   s       r#   rC   rC     s,    !)	+}%1
J
KK	+'(4]OT+7G%HI	+'3\ND}o$FG	+()5	tK/1BCYO 
+'3	T+?K 
+()*6_%tK:J9K'LM	+/01=
I  
+/01=	 {-D,EFG$G 
+123?	 ![456 
+,-.:
F  
+'3\ND}o$FG	+'3	{]O<=$= 
3 	H, 	>s   )	G	Gc                    i }t        | dg      t        |dgt        | dg             t        | dg      t        |dgt        | dg             t        | dg      t        d      t        | dg      t        |dgt        | dg             t        | dg      t        |d	gt        | dg             t        | d
g      t        |dgt        | d
g             t        | dg      t        |dgt        | dg             t        | dg      1t        |dgt        | dg      D cg c]  }t        ||       c}       t        | dg      t        |dgt        | dg             t        | dg      t        |dgt        | dg             t        | dg      t        |dgt        | dg             t        | dg      t        d      |S c c}w )Nr   r   r   r   z4file_search parameter is not supported in Vertex AI.r   r   r   r   r   r   r   enterpriseWebSearchr   r   r   r   r   parallelAiSearchr   r   r   z4mcp_servers parameter is not supported in Vertex AI.)r   r   r    r   r1   s       r#   rI   rI     s    !)	+}%1[M4k]#CD	+'(4]OT+7G%HI	+'3
K
LL	+()5^$d;8I&JK	+'3\ND}o$FG	+()*6_%tK:J9K'LM	+/01=	[234 
+/01=	  [+B*CD	
 +4;	
 
+123?	 ![456 
+,-.:	[/01 
+'3\ND}o$FG	+'3
K
LL	5	
s   #G	c                     i }t        | dg      t        |dgt        | dg             t        | dg      t        |dgt        | dg             |S Nr5   r6   r7   rc   r!   s      r#   #_UpdateCachedContentConfig_to_mldevr   :  [     !)	+w+kE7!;<	+'3[=/(JK	r%   c                     i }t        | dg      t        |dgt        | dg             t        | dg      t        |dgt        | dg             |S r   rc   r!   s      r#   $_UpdateCachedContentConfig_to_vertexr   I  r   r%   c                     i }t        |dg      .t        |ddgt        j                  | t        |dg                   t        |dg      t	        t        |dg      |       |S NrW   rX   rO   )r   r   r@   rZ   r   rQ   s       r#   '_UpdateCachedContentParameters_to_mldevr   X  ss    
 !)	+x ,		
Dvh,GH 
+z".'[8*%y 
r%   c                     i }t        |dg      .t        |ddgt        j                  | t        |dg                   t        |dg      t	        t        |dg      |       |S r   )r   r   r@   rZ   r   rQ   s       r#   (_UpdateCachedContentParameters_to_vertexr   m  ss    
 !)	+x ,		
Dvh,GH 
+z".([8*%y 
r%   c                      e Zd Zdddedeej                     dej                  fdZdddedeej                     dej                  fdZ
dddedeej                     dej                  fd	Zdddedeej                     dej                  fd
Zdddeej                      dej"                  fdZdddeej                      deej                     fdZy)CachesNrO   rN   rO   r   c                   t        j                  ||      }| j                  j                  r>t	        | j                  |      }|j                  d      }|rdj                  |      }n@d}n=t        | j                  |      }|j                  d      }|rdj                  |      }nd}|j                  d      }|r| dt        |       }|j                  dd       d}|j                  ,|j                  j                  |j                  j                  }t        j                  |      }t        j                  |      }| j                  j                  d|||      }	|	j                   si nt#        j$                  |	j                         }
t         j&                  j)                  |
|j+                         	      }| j                  j-                  |       |S )
a  Creates a cached contents resource.

    Usage:

    .. code-block:: python

      contents = ... // Initialize the content to cache.
      response = client.caches.create(
          model= ... // The publisher model id
          contents=contents,
          config={
              'display_name': 'test cache',
              'system_instruction': 'What is the sum of the two pdfs?',
              'ttl': '86400s',
          },
      )
    rN   rO   rX   r   r   ?rO   Npostr}   kwargs)r   _CreateCachedContentParameters_api_clientvertexairT   get
format_maprR   r   poprO   http_optionsr	   convert_to_dictencode_unserializable_typesrequestbodyjsonloadsCachedContent_from_response
model_dump_verify_responseselfrN   rO   parameter_modelrequest_dictrequest_url_dictpathquery_paramsr   r}   response_dictreturn_values               r#   createzCaches.create  s   0 ::O   =


Ol &))&1	**+;<<


Ol &))&1	**+;<##H-LvQy./0dXt$04L*""//;$++88l**<8L66|DL''lLH 'mmBHMM1JM&&55'A'A'C 6 L 	%%l3r%   rW   c                   t        j                  ||      }| j                  j                  r>t	        | j                  |      }|j                  d      }|rdj                  |      }n@d}n=t        | j                  |      }|j                  d      }|rdj                  |      }nd}|j                  d      }|r| dt        |       }|j                  dd       d}|j                  ,|j                  j                  |j                  j                  }t        j                  |      }t        j                  |      }| j                  j                  d|||      }	|	j                   si nt#        j$                  |	j                         }
t         j&                  j)                  |
|j+                         	      }| j                  j-                  |       |S )
zGets cached content configurations.

    .. code-block:: python

      client.caches.get(name= ... ) // The server-generated resource name.
    rW   rO   rX   {name}r   r   rO   Nr   r   )r   _GetCachedContentParametersr   r   r   r   r   r   r   r   rO   r   r	   r   r   r   r   r  r  r  r  r  r  r  rW   rO   r	  r
  r  r  r  r   r}   r  r  s               r#   r   z
Caches.get  s    77O   :


Ol &))&1	""#349


Ol &))&1	""#34##H-LvQy./0dXt$04L*""//;$++88l**<8L66|DL''t\<PH&mmBHMM1JM&&55'A'A'C 6 L 	%%l3r%   c                   t        j                  ||      }| j                  j                  r>t	        | j                  |      }|j                  d      }|rdj                  |      }n@d}n=t        | j                  |      }|j                  d      }|rdj                  |      }nd}|j                  d      }|r| dt        |       }|j                  dd       d}|j                  ,|j                  j                  |j                  j                  }t        j                  |      }t        j                  |      }| j                  j                  d|||      }	|	j                   si nt#        j$                  |	j                         }
| j                  j                  rt'        |
      }
| j                  j                  st)        |
      }
t         j*                  j-                  |
|j/                         	      }t        j0                  |	j2                  
      |_        | j                  j7                  |       |S )zDeletes cached content.

    Usage:

    .. code-block:: python

      client.caches.delete(name= ... ) // The server-generated resource name.
    r  rX   r  r   r   rO   Ndeleter   headers)r   _DeleteCachedContentParametersr   r   r^   r   r   r[   r   r   rO   r   r	   r   r   r   r   r  r  rg   rd   DeleteCachedContentResponser  r  HttpResponser  rb   r  r  s               r#   r  zCaches.delete  s    ::O   =


Ol &))&1	""#34<


Ol &))&1	""#34##H-LvQy./0dXt$04L*""//;$++88l**<8L66|DL''$lH 'mmBHMM1JM  >}Mm$$=mLm44CC'A'A'C D L &+%7%7  &L" 	%%l3r%   c                   t        j                  ||      }| j                  j                  r>t	        | j                  |      }|j                  d      }|rdj                  |      }n@d}n=t        | j                  |      }|j                  d      }|rdj                  |      }nd}|j                  d      }|r| dt        |       }|j                  dd       d}|j                  ,|j                  j                  |j                  j                  }t        j                  |      }t        j                  |      }| j                  j                  d|||      }	|	j                   si nt#        j$                  |	j                         }
t         j&                  j)                  |
|j+                         	      }| j                  j-                  |       |S )
zUpdates cached content configurations.

    .. code-block:: python

      response = client.caches.update(
          name= ... // The server-generated resource name.
          config={
              'ttl': '7600s',
          },
      )
    r  rX   r  r   r   rO   Npatchr   )r   _UpdateCachedContentParametersr   r   r   r   r   r   r   r   rO   r   r	   r   r   r   r   r  r  r  r  r  r  r  s               r#   updatezCaches.update`  s   $ ::O   =


Ol &))&1	""#34<


Ol &))&1	""#34##H-LvQy./0dXt$04L*""//;$++88l**<8L66|DL''|\H 'mmBHMM1JM&&55'A'A'C 6 L 	%%l3r%   c                R   t        j                  |      }| j                  j                  r3t	        |      }|j                  d      }|rdj                  |      }n5d}n2t        |      }|j                  d      }|rdj                  |      }nd}|j                  d      }|r| dt        |       }|j                  dd        d }|j                  ,|j                  j                  |j                  j                  }t        j                  |      }t        j                  |      }| j                  j                  d|||      }|j                   si nt#        j$                  |j                         }	| j                  j                  rt'        |	      }	| j                  j                  st)        |	      }	t         j*                  j-                  |	|j/                               }
t        j0                  |j2                  	      |
_        | j                  j7                  |
       |
S 
Nr   rX   r   r   r   rO   r   r   r  )r   _ListCachedContentsParametersr   r   r   r   r   r   r   r   rO   r   r	   r   r   r   r   r  r  r   r   ListCachedContentsResponser  r  r  r  rb   r  r  rO   r	  r
  r  r  r  r   r}   r  r  s              r#   _listzCaches._list  s    99O   <_Ml%))&1	**+;<;OLl%))&1	**+;<##H-LvQy./0dXt$04L*""//;$++88l**<8L66|DL''t\<PH&mmBHMM1JM  =mLm$$<]Km33BB'A'A'C C L &+%7%7  &L" 	%%l3r%   c                V    | j                   }t        d|| j                  |      |      S )a  Lists cached contents.

    Args:
      config (ListCachedContentsConfig): Optional configuration for the list
        request.

    Returns:
      A Pager object that contains one page of cached contents. When iterating
      over
      the pager, it automatically fetches the next page if there are more.

    Usage:

    .. code-block:: python
      for cached_content in client.caches.list():
        print(cached_content.name)
    r   r   )r&  r   r  rO   list_requests      r#   listzCaches.list  s1    * ::L

&
!	 r%   )__name__
__module____qualname__strr   r   CreateCachedContentConfigOrDictr  r  GetCachedContentConfigOrDictr   DeleteCachedContentConfigOrDictr  r  UpdateCachedContentConfigOrDictr   ListCachedContentsConfigOrDictr$  r&  r   r*   r%   r#   r   r     s]    AE	L L u<<=	L
 Ld >B	? ? u99:	?
 ?J AE	K K u<<=	K
 ((Kb AE	F F u<<=	F
 FR IM8 D DE8''8v IM D DEU  !r%   r   c                      e Zd Zdddedeej                     dej                  fdZdddedeej                     dej                  fdZ
dddedeej                     dej                  fd	Zdddedeej                     dej                  fd
Zdddeej                      dej"                  fdZdddeej                      deej                     fdZy)AsyncCachesNr   rN   rO   r   c                  K   t        j                  ||      }| j                  j                  r>t	        | j                  |      }|j                  d      }|rdj                  |      }n@d}n=t        | j                  |      }|j                  d      }|rdj                  |      }nd}|j                  d      }|r| dt        |       }|j                  dd       d}|j                  ,|j                  j                  |j                  j                  }t        j                  |      }t        j                  |      }| j                  j                  d|||       d{   }	|	j                   si nt#        j$                  |	j                         }
t         j&                  j)                  |
|j+                         	      }| j                  j-                  |       |S 7 }w)
a  Creates a cached contents resource.

    Usage:

    .. code-block:: python

      contents = ... // Initialize the content to cache.
      response = await client.aio.caches.create(
          model= ... // The publisher model id
          contents=contents,
          config={
              'display_name': 'test cache',
              'system_instruction': 'What is the sum of the two pdfs?',
              'ttl': '86400s',
          },
      )
    r   rX   r   r   r   rO   Nr   r   )r   r   r   r   rT   r   r   rR   r   r   rO   r   r	   r   r   async_requestr   r  r  r  r  r  r  r  s               r#   r  zAsyncCaches.create  s    0 ::O   =


Ol &))&1	**+;<<


Ol &))&1	**+;<##H-LvQy./0dXt$04L*""//;$++88l**<8L66|DL%%33lL H 'mmBHMM1JM&&55'A'A'C 6 L 	%%l3   E#G%%G#&A>G%rW   c                  K   t        j                  ||      }| j                  j                  r>t	        | j                  |      }|j                  d      }|rdj                  |      }n@d}n=t        | j                  |      }|j                  d      }|rdj                  |      }nd}|j                  d      }|r| dt        |       }|j                  dd       d}|j                  ,|j                  j                  |j                  j                  }t        j                  |      }t        j                  |      }| j                  j                  d|||       d{   }	|	j                   si nt#        j$                  |	j                         }
t         j&                  j)                  |
|j+                         	      }| j                  j-                  |       |S 7 }w)
zGets cached content configurations.

    .. code-block:: python

      await client.aio.caches.get(name= ... ) // The server-generated resource
      name.
    r  rX   r  r   r   rO   Nr   r   )r   r  r   r   r   r   r   r   r   r   rO   r   r	   r   r   r8  r   r  r  r  r  r  r  r  s               r#   r   zAsyncCaches.getP  s     77O   :


Ol &))&1	""#349


Ol &))&1	""#34##H-LvQy./0dXt$04L*""//;$++88l**<8L66|DL%%33t\< H 'mmBHMM1JM&&55'A'A'C 6 L 	%%l3r9  c                  K   t        j                  ||      }| j                  j                  r>t	        | j                  |      }|j                  d      }|rdj                  |      }n@d}n=t        | j                  |      }|j                  d      }|rdj                  |      }nd}|j                  d      }|r| dt        |       }|j                  dd       d}|j                  ,|j                  j                  |j                  j                  }t        j                  |      }t        j                  |      }| j                  j                  d|||       d{   }	|	j                   si nt#        j$                  |	j                         }
| j                  j                  rt'        |
      }
| j                  j                  st)        |
      }
t         j*                  j-                  |
|j/                         	      }t        j0                  |	j2                  
      |_        | j                  j7                  |       |S 7 w)zDeletes cached content.

    Usage:

    .. code-block:: python

      await client.aio.caches.delete(name= ... ) // The server-generated
      resource name.
    r  rX   r  r   r   rO   Nr  r   r  )r   r  r   r   r^   r   r   r[   r   r   rO   r   r	   r   r   r8  r   r  r  rg   rd   r  r  r  r  r  rb   r  r  s               r#   r  zAsyncCaches.delete  s      ::O   =


Ol &))&1	""#34<


Ol &))&1	""#34##H-LvQy./0dXt$04L*""//;$++88l**<8L66|DL%%33$l H 'mmBHMM1JM  >}Mm$$=mLm44CC'A'A'C D L &+%7%7  &L" 	%%l3's   E#I%I
&C%Ic                  K   t        j                  ||      }| j                  j                  r>t	        | j                  |      }|j                  d      }|rdj                  |      }n@d}n=t        | j                  |      }|j                  d      }|rdj                  |      }nd}|j                  d      }|r| dt        |       }|j                  dd       d}|j                  ,|j                  j                  |j                  j                  }t        j                  |      }t        j                  |      }| j                  j                  d|||       d{   }	|	j                   si nt#        j$                  |	j                         }
t         j&                  j)                  |
|j+                         	      }| j                  j-                  |       |S 7 }w)
zUpdates cached content configurations.

    .. code-block:: python

      response = await client.aio.caches.update(
          name= ... // The server-generated resource name.
          config={
              'ttl': '7600s',
          },
      )
    r  rX   r  r   r   rO   Nr  r   )r   r  r   r   r   r   r   r   r   r   rO   r   r	   r   r   r8  r   r  r  r  r  r  r  r  s               r#   r   zAsyncCaches.update  s    $ ::O   =


Ol &))&1	""#34<


Ol &))&1	""#34##H-LvQy./0dXt$04L*""//;$++88l**<8L66|DL%%33|\ H 'mmBHMM1JM&&55'A'A'C 6 L 	%%l3r9  c                n  K   t        j                  |      }| j                  j                  r3t	        |      }|j                  d      }|rdj                  |      }n5d}n2t        |      }|j                  d      }|rdj                  |      }nd}|j                  d      }|r| dt        |       }|j                  dd        d }|j                  ,|j                  j                  |j                  j                  }t        j                  |      }t        j                  |      }| j                  j                  d|||       d {   }|j                   si nt#        j$                  |j                         }	| j                  j                  rt'        |	      }	| j                  j                  st)        |	      }	t         j*                  j-                  |	|j/                               }
t        j0                  |j2                  	      |
_        | j                  j7                  |
       |
S 7 wr"  )r   r#  r   r   r   r   r   r   r   r   rO   r   r	   r   r   r8  r   r  r  r   r   r$  r  r  r  r  rb   r  r%  s              r#   r&  zAsyncCaches._list*  s     99O   <_Ml%))&1	**+;<;OLl%))&1	**+;<##H-LvQy./0dXt$04L*""//;$++88l**<8L66|DL%%33t\< H 'mmBHMM1JM  =mLm$$<]Km33BB'A'A'C C L &+%7%7  &L" 	%%l3's   EH5H3C%H5c                r   K   | j                   }t        d|| j                  |       d{   |      S 7 	w)a  Lists cached contents asynchronously.

    Args:
      config (ListCachedContentsConfig): Optional configuration for the list
        request.

    Returns:
      A Pager object that contains one page of cached contents. When iterating
      over
      the pager, it automatically fetches the next page if there are more.

    Usage:

    .. code-block:: python
      async for cached_content in await client.aio.caches.list():
        print(cached_content.name)
    r   r   N)r&  r   r(  s      r#   r*  zAsyncCaches.listf  s=     * ::Ljjj''	  	(s   )75
7)r+  r,  r-  r.  r   r   r/  r  r  r0  r   r1  r  r  r2  r   r3  r$  r&  r   r*  r4  r%   r#   r6  r6     sa    AE	L L u<<=	L
 Ld >B	B B u99:	B
 BP AE	L L u<<=	L
 ((Ld AE	F F u<<=	F
 FR IM: D DE:'':z IM D DE%%%&r%   r6  )N)@r  loggingtypingr   r   r   urllib.parser    r   r	   r
   r@   r   r   r   r   r   r   r   pagersr   r   	getLoggerloggerdictr.  objectr$   r,   r3   rE   rJ   rR   rT   r[   r^   rd   rg   rk   rq   rw   r   r   r   r   r   r   r   r   r   r   r   r0   rD   rC   rI   r   r   r   r   
BaseModuler   r6  r4  r%   r#   <module>rI     sv
  $   ' ' "      & . . % 
		0	1
 /3tCH~v-.DcN+ 
#s(^H /3tCH~v-.DcN+ 
#s(^& /3tCH~v-.DcN+ 
#s(^. /36tCH~v-.6DcN+6 
#s(^6v /31tCH~v-.1DcN+1 
#s(^1n /3tCH~v-. DcN+ 
#s(^	0 /3tCH~v-. DcN+ 
#s(^	0 /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(^
 /3tCH~v-.DcN+ 
#s(^& /3tCH~v-.DcN+ 
#s(^2 /3tCH~v-.DcN+ 
#s(^4 /3"tCH~v-."DcN+" 
#s(^"P /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(^8 /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(^
 /3tCH~v-.DcN+ 
#s(^2 /3tCH~v-.DcN+ 
#s(^2 /3@tCH~v-.@DcN+@ 
#s(^@J /3tCH~v-.DcN+ 
#s(^0 /3AtCH~v-.ADcN+A 
#s(^AL /3<tCH~v-.<DcN+< 
#s(^<B /3tCH~v-.DcN+ 
#s(^" /3tCH~v-.DcN+ 
#s(^$ /3tCH~v-. DcN+ 
#s(^	0 /3tCH~v-. DcN+ 
#s(^	*{[## {|A+(( Ar%   