§
    $ÂiË/  ã                   ó6  — d Z 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  ej        d
¦  «        Zdej        defd„Z	 ddej        deej                 dej        fd„Z G d„ dej        ¦  «        Z G d„ dej        ¦  «        ZdS )z&[Experimental] Auth Tokens API client.é    N)ÚAnyÚDictÚListÚOptional)Ú	urlencodeé   )Ú_api_module)Ú_common)Ú_tokens_converters)Útypeszgoogle_genai.tokensÚsetupÚreturnc                 ó  ‡— g }|                       ¦   «         D ]U\  Š}t          |t          ¦  «        r#|r!ˆfd„|                     ¦   «         D ¦   «         }n‰g}|                     |¦  «         ŒVd                     |¦  «        S )zReturn field_masksc                 ó   •— g | ]	}‰› d |› �‘Œ
S )ú.© )Ú.0ÚkkÚks     €ú]/var/www/html/jarvis.com/web/backend/venv/lib/python3.11/site-packages/google/genai/tokens.pyú
<listcomp>z$_get_field_masks.<locals>.<listcomp>$   s#   ø€ Ð.Ð.Ð.˜r�!ˆ{ˆ{�bˆ{ˆ{Ð.Ð.Ð.ó    ú,)ÚitemsÚ
isinstanceÚdictÚkeysÚextendÚjoin)r   ÚfieldsÚvÚfieldr   s       @r   Ú_get_field_masksr#      s�   ø€ à€&Ø�kŠk‰mŒmð ð �d€aˆå�!•TÑÔð ˜qð Ø.Ð.Ð.Ð. Q§V¢V¡X¤XÐ.Ñ.Ô.€e€eàˆc€eØ
‡M‚M�%ÑÔÐÐà	�Š�&Ñ	Ô	Ðr   Úrequest_dictÚconfigc                 ó¶  — |                       d¦  «        }|�rÌ|                      d¦  «        �r¶|                      d¦  «        | d<   t          | d         ¦  «        }t          |t          ¦  «        r*|                      d¦  «        �|                      d¦  «        r(t          |t          j        ¦  «        r|j        �|j        s|| d<   �ndt          |t          ¦  «        r|                      d¦  «        �!t          |t          j        ¦  «        r|j        €|                      dd¦  «         �n| d         r™|                       d¦  «        }t	          j        ¦   «          	                    ¦   «          
                    ¦   «         }|r&g }|D ] }||v rd|› �}|                     |¦  «         Œ!ng }|r|dz   d                     |¦  «        z   n|| d<   n`|                      dd¦  «         nI|                       dg ¦  «        }d                     |¦  «        }|r|| d<   n|                      dd¦  «         |                       d¦  «        s|                      dd¦  «         | S )z"Converts bidiGenerateContentSetup.ÚbidiGenerateContentSetupr   Úlock_additional_fieldsNÚ	fieldMaskzgenerationConfig.r   )Úgetr#   r   r   r   ÚCreateAuthTokenConfigr(   ÚpopÚGenerationConfigÚ
model_dumpr   Úappendr   )	r$   r%   Ú
bidi_setupÚ
field_maskÚadditional_fields_listÚgeneration_config_listÚfield_mask_listr"   Úfield_mask_strs	            r   Ú"_convert_bidi_setup_to_token_setupr6   ,   sµ  € ð
 ×ÒÐ :Ñ;Ô;€*Øñ 8*�J—N’N 7Ñ+Ô+ñ 8*ð 0:¯~ª~¸gÑ/FÔ/F€LÐ+Ñ,õ " ,Ð/IÔ"JÑKÔK€Jõ 	�6�4Ñ Ô ð)*à�JŠJÐ/Ñ0Ô0Ð<Ø—
’
Ð3Ñ4Ô4ð =õ 	�6�5Ô6Ñ7Ô7ð =ð Ô)Ð5ØÔ-ð 6ð #-€l�;ÑÑå�6�4Ñ Ô ð*à�JŠJÐ/Ñ0Ô0Ð8å�6�5Ô6Ñ7Ô7ð 9ð Ô)Ð1ð ×Ò�{ DÑ)Ô)Ð)Ñ)Ø	�kÔ	"ð *à4@×4DÒ4DØ
ñ5ô 5Ðõ  %Ô5Ñ7Ô7×BÒBÑDÔD×IÒIÑKÔKÐØ	ð ØˆØ+ð 	(ð 	(ˆEØÐ,Ð,Ð,Ø/¨Ð/Ð/ˆEØ
×
 Ò
  Ñ
'Ô
'Ð
'Ð
'ð	(ð
 ˆð ðˆ*�sÑ
˜SŸXšX oÑ6Ô6Ñ
6Ð
6àð �;ÑÐð ×Ò�{ DÑ)Ô)Ð)Ð)à×!Ò! +¨rÑ2Ô2€JØ—X’X˜jÑ)Ô)€NØð *Ø"0€l�;ÑÐà×Ò�{ DÑ)Ô)Ð)Ø	×	Ò	Ð4Ñ	5Ô	5ð 7Ø×ÒÐ/°Ñ6Ô6Ð6à	Ðr   c                   ót   — e Zd ZdZ ej        d¦  «        ddœdeej                 dej	        fd„¦   «         Z
dS )ÚTokenszb[Experimental] Auth Tokens API client.

  This class provides methods for creating auth tokens.
  ú[The SDK's token creation implementation is experimental, and may change in future versions.N©r%   r%   r   c                óL  — t          j        |¬¦  «        }| j        j        rt	          d¦  «        ‚t          j        | j        |¦  «        }|                     d¦  «        }|rd                     |¦  «        }nd}|                     d¦  «        }|r|› dt          |¦  «        › �}| 
                    dd¦  «         |rt          ||¦  «        }d}|�|j        �|j        j        �|j        j        }t          j        |¦  «        }t          j        |¦  «        }| j                             d	|||¦  «        }|j        si nt'          j        |j        ¦  «        }	t           j                             |	|                     ¦   «         ¬
¦  «        }
| j                             |
¦  «         |
S )aÔ  [Experimental] Creates an auth token.

    Args:
      config (CreateAuthTokenConfig): Optional configuration for the request.

    The CreateAuthTokenConfig's `live_constrained_parameters` attrubite
    Can be used to lock the parameters of the live session so they
    can't be changed client side. This behavior has two basic modes depending on
    whether `lock_additional_fields` is set:

    If you do not pass `lock_additional_fields` the entire
    `live_constrained_parameters` is locked and can't be changed
    by the token's user.

    If you set `lock_additional_fields`, then the non-null fields of
    `live_constrained_parameters` are locked, and any additional fields
    specified in `lock_additional_fields`.

    Usage:

    .. code-block:: python

      # Case 1: If LiveEphemeralParameters is unset, unlock LiveConnectConfig
      # when using the token in Live API sessions. Each session connection can
      # use a different configuration.

      config = types.CreateAuthTokenConfig(
          uses=10,
          expire_time='2025-05-01T00:00:00Z',
      )
      auth_token = client.tokens.create(config=config)

    .. code-block:: python

      # Case 2: If LiveEphemeralParameters is set, lock all fields in
      # LiveConnectConfig when using the token in Live API sessions. For
      # example, changing `output_audio_transcription` in the Live API
      # connection will be ignored by the API.

      auth_token = client.tokens.create(
          config=types.CreateAuthTokenConfig(
              uses=10,
              live_constrained_parameters=types.LiveEphemeralParameters(
                  model='gemini-live-2.5-flash-preview',
                  config=types.LiveConnectConfig(
                      system_instruction='You are an LLM called Gemini.'
                  ),
              ),
          )
      )

    .. code-block:: python

      # Case 3: If LiveEphemeralParameters is set and lockAdditionalFields is
      # empty, lock LiveConnectConfig with set fields (e.g.
      # system_instruction in this example) when using the token in Live API
      # sessions.
      auth_token = client.tokens.create(
          config=types.CreateAuthTokenConfig(
              uses=10,
              live_constrained_parameters=types.LiveEphemeralParameters(
                  config=types.LiveConnectConfig(
                      system_instruction='You are an LLM called Gemini.'
                  ),
              ),
              lock_additional_fields=[],
          )
      )

    .. code-block:: python

      # Case 4: If LiveEphemeralParameters is set and lockAdditionalFields is
      # set, lock LiveConnectConfig with set and additional fields (e.g.
      # system_instruction, temperature in this example) when using the token
      # in Live API sessions.
      auth_token = client.tokens.create(
          config=types.CreateAuthTokenConfig(
              uses=10,
              live_constrained_parameters=types.LiveEphemeralParameters(
                  model='gemini-live-2.5-flash-preview',
                  config=types.LiveConnectConfig(
                      system_instruction='You are an LLM called Gemini.'
                  ),
              ),
              lock_additional_fields=['temperature'],
          )
      )
    r:   ú=This method is only supported in the Gemini Developer client.Ú_urlÚauth_tokensÚ_queryú?r%   NÚpost©ÚresponseÚkwargs)r   ÚCreateAuthTokenParametersÚ_api_clientÚvertexaiÚ
ValueErrorÚtokens_convertersÚ#_CreateAuthTokenParameters_to_mldevr*   Ú
format_mapr   r,   r6   r%   Úhttp_optionsr
   Úconvert_to_dictÚencode_unserializable_typesÚrequestÚbodyÚjsonÚloadsÚ	AuthTokenÚ_from_responser.   Ú_verify_response©Úselfr%   Úparameter_modelr$   Úrequest_url_dictÚpathÚquery_paramsrL   rC   Úresponse_dictÚreturn_values              r   ÚcreatezTokens.createw   sØ  € õ@ Ô5Øðñ ô €Oð ÔÔ ð ÝØ
Iñô ð õ 'ÔJØ
Ô
Ø
ñô €lð &×)Ò)¨&Ñ1Ô1ÐØ	ð Ø×'Ò'Ð(8Ñ9Ô9ˆˆàˆà×#Ò# HÑ-Ô-€LØð 1ØÐ0Ð0•y Ñ.Ô.Ð0Ð0€dð ×Ò�X˜tÑ$Ô$Ð$ð ð NÝ7¸ÀfÑMÔM€là04€LàÐ#ØÔ"Ð.ØÔ"Ô/Ð;à$Ô+Ô8€låÔ*¨<Ñ8Ô8€LÝÔ6°|ÑDÔD€LàÔ×'Ò'Ø��l Lñô €Hð 'œmÐJ�B�Bµ´¸H¼MÑ1JÔ1J€Må”?×1Ò1Ø ×'AÒ'AÑ'CÔ'Cð 2ñ ô €Lð 	Ô×%Ò% lÑ3Ô3Ð3ØÐr   ©Ú__name__Ú
__module__Ú__qualname__Ú__doc__r
   Úexperimental_warningr   r   ÚCreateAuthTokenConfigOrDictrS   r^   r   r   r   r8   r8   q   sŠ   € € € € € ðð ð
  €7Ôð+ñô ð
 FJðOð Oð OØ Ô AÔBðOà„ðOð Oð Oñ	ô ðOð Oð Or   r8   c                   ót   — e Zd ZdZ ej        d¦  «        ddœdeej                 dej	        fd„¦   «         Z
dS )ÚAsyncTokenszu[Experimental] Async Auth Tokens API client.

  This class provides asynchronous methods for creating auth tokens.
  r9   Nr:   r%   r   c             ƒ   óZ  K  — t          j        |¬¦  «        }| j        j        rt	          d¦  «        ‚t          j        | j        |¦  «        }|                     d¦  «        }|rd                     |¦  «        }nd}|                     d¦  «        }|r|› dt          |¦  «        › �}| 
                    dd¦  «         t          ||¦  «        }d}|�|j        �|j        j        �|j        j        }t          j        |¦  «        }t          j        |¦  «        }| j                             d	|||¬
¦  «        ƒ d{V —†}|j        si nt'          j        |j        ¦  «        }	t           j                             |	|                     ¦   «         ¬¦  «        }
| j                             |
¦  «         |
S )aö  Creates an auth token asynchronously. Support in v1alpha only.

    Args:
      config (CreateAuthTokenConfig): Optional configuration for the request.

    Usage:

    .. code-block:: python

      client = genai.Client(
          api_key=API_KEY,
          http_options=types.HttpOptions(api_version='v1alpha'),
      )

      auth_token = await client.aio.tokens.create(
          config=types.CreateAuthTokenConfig(
              uses=10,
              live_constrained_parameters=types.LiveEphemeralParameters(
                  model='gemini-live-2.5-flash-preview',
                  config=types.LiveConnectConfig(
                      system_instruction='You are an LLM called Gemini.'
                  ),
              ),
          )
      )
    r:   r<   r=   r>   r?   r@   r%   NrA   )rL   rB   )r   rE   rF   rG   rH   rI   rJ   r*   rK   r   r,   r6   r%   rL   r
   rM   rN   Úasync_requestrP   rQ   rR   rS   rT   r.   rU   rV   s              r   r^   zAsyncTokens.create  s÷  è è € õD Ô5Øðñ ô €Oð
 ÔÔ ð ÝØ
Iñô ð õ 'ÔJØ
Ô
Ø
ñô €lð &×)Ò)¨&Ñ1Ô1ÐØ	ð Ø×'Ò'Ð(8Ñ9Ô9ˆˆàˆà×#Ò# HÑ-Ô-€LØð 1ØÐ0Ð0•y Ñ.Ô.Ð0Ð0€dà×Ò�X˜tÑ$Ô$Ð$õ 6°lÀFÑKÔK€Là04€LàÐ#ØÔ"Ð.ØÔ"Ô/Ð;à$Ô+Ô8€låÔ*¨<Ñ8Ô8€LÝÔ6°|ÑDÔD€LàÔ%×3Ò3ØØØØ!ð	 4ñ ô ð ð ð ð ð ð €Hð 'œmÐJ�B�Bµ´¸H¼MÑ1JÔ1J€Må”?×1Ò1Ø ×'AÒ'AÑ'CÔ'Cð 2ñ ô €Lð 	Ô×%Ò% lÑ3Ô3Ð3ØÐr   r_   r   r   r   rg   rg     sŠ   € € € € € ðð ð
  €7Ôð+ñô ð
 FJðSð Sð SØ Ô AÔBðSà„ðSð Sð Sñ	ô ðSð Sð Sr   rg   )N)rc   rQ   ÚloggingÚtypingr   r   r   r   Úurllib.parser   Ú r	   r
   r   rI   r   Ú	getLoggerÚloggerÚ
StringDictÚstrr#   re   r6   Ú
BaseModuler8   rg   r   r   r   ú<module>rs      s›  ðð  -Ð ,à €€€Ø €€€Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ø "Ð "Ð "Ð "Ð "Ð "Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø 5Ð 5Ð 5Ð 5Ð 5Ð 5Ø Ð Ð Ð Ð Ð à	ˆÔ	Ð0Ñ	1Ô	1€ð˜GÔ.ð °3ð ð ð ð ð  ;?ðBð BØÔ$ðBà�UÔ6Ô7ðBð ÔðBð Bð Bð BðJYð Yð Yð Yð Yˆ[Ô#ñ Yô Yð Yðx]ð ]ð ]ð ]ð ]�+Ô(ñ ]ô ]ð ]ð ]ð ]r   