
    
!i                    $   % S SK Jr  S SKJr  S SKJs  Jr  S SKJ	r	  S SKJ
r
  S SKJr  SSSSS	.rS
\S'   SS jrSS jrSS jrSS jr    S         SS jjr SSSSSS.           SS jjjr SSSSSS.           SS jjjrg)    )annotations)CallableN)permission_types)retriever_types)model_typescorporatunedModels)corpusr   
tunedmodeltunedmodelszdict[str, str]_RESOURCE_TYPEc                    [        U [        5      (       a  U R                  5       n [        R	                  U S 5      nU(       d  [        SU  S35      eU$ )Nz!Unsupported resource type. Got: `
` instead.)
isinstancestrlowerr   get
ValueErrorxresource_types     X/home/james-whalen/.local/lib/python3.13/site-packages/google/generativeai/permission.py_to_resource_typer   "   sJ    !SGGI"&&q$/M<QCzJKK    c                f   US:X  aL  [         R                  " U 5      (       d0  [        [         R                  R	                  [        U 5      U S95      eg US:X  aL  [        R                  " U 5      (       d0  [        [        R                  R	                  [        U 5      U S95      eg [        SU 35      e)Nr   )lengthnamer	   zUnsupported resource type: )	r   
valid_namer   NAME_ERROR_MSGformatlenr   valid_tuned_model_nameTUNED_MODEL_NAME_ERROR_MSGr   s     r   _validate_resource_namer$   ,   s    	!))!,,_;;BB#a&WXBYZZ - 
-	'11!44[CCJJRUVWRX_`Jabb 5 6}oFGGr   c                    [         R                  " U 5      (       d&  [        [         R                  R	                  U S95      eg )N)permission_id)r   valid_idr   INVALID_PERMISSION_ID_MSGr    )r   s    r   _validate_permission_idr)   9   s9    $$Q'')CCJJYZJ[\\ (r   c                    U R                  S5      n[        U5      S:w  a  [        SU  S35      eUu  p#pE[        U5      nSR	                  XE/5      n[        X25        [        U5        SR	                  X#U/5      $ )N/   zyInvalid name format. Expected format:                 `resource_type/<resource_name>/permissions/<permission_id>`. Got: `r   )splitr!   r   r   joinr$   r)   )r   name_path_componentsr   resource_namepermission_placeholderr&   s         r   _get_valid_name_componentsr2   >   s    ::c?
 A%TTXSYYce
 	

 K_GM"8%m4MHH4DEMM9M*88]=ABBr   c           	        U (       d  U(       a  U(       d  [        SU  SU SU S35      eU(       a  [        U5      nOIUR                  S5      n[        U5      S:w  a  [        SU S[        U5       S	35      e[        US
   5      nU S3U;   a  U S3n OU SU S3n [	        U[
        5      (       d  SU;  a	  U SU 3-  n OX-  n [        U 5      n U $ )NznInvalid arguments: Either `name` or both `resource_name` and `permission_id` must be provided. Received name: z, resource_name: z, permission_id: .r+      zlInvalid `resource_name` format: Expected format is `resource_type/resource_name` (2 components). Received: `z` with z components.r   zpermissions/)r   r   r-   r!   r   intr2   )r   r0   r&   r   resource_path_componentss        r   _construct_namer8   R   sb    - A  BF  AG  GX  Yf  Xg  gx  yF  xG  GH  I  -m<M (5':':3'?$+,1  C  DQ  CR  RY  Z]  ^v  Zw  Yx  xD  E  ..Fq.IJM_A-/#_A&D#_Am_A6DmS))^=-Pl=/22D!D &d+DKr   )clientr0   r&   r   c               T    [        U UUUS9n [        R                  R                  XS9$ )aS  Calls the API to retrieve detailed information about a specific permission based on resource type and permission identifiers

Args:
    name: The name of the permission.
    resource_name: The name of the supported resource for which the permission details are needed.
    permission_id: The name of the permission.
    resource_type: The type of the resource (corpus or tunedModel as of now) for which the permission details are needed.
                    If not provided, it will be inferred from `resource_name`.

Returns:
    The permission as an instance of `permission_types.Permission`.
r   r0   r&   r   r   r9   )r8   r   
Permissionr   r   r9   r0   r&   r   s        r   get_permissionr?   y   s6    ( ###	D &&***DDr   c               p   #    [        U UUUS9n [        R                  R                  XS9I Sh  vN $  N7f)z;
This is the async version of `permission.get_permission`.
r;   r<   N)r8   r   r=   	get_asyncr>   s        r   get_permission_asyncrB      s?      ###	D ",,66D6PPPPs   -646)r   r   returnr   )r   r   r   r   rC   None)r   r   rC   rD   )r   r   rC   r   )NNNN)
r   
str | Noner0   rE   r&   str | int | Noner   rE   rC   r   )N)r   rE   r9   z"glm.PermissionServiceClient | Noner0   rE   r&   rF   r   rE   rC   permission_types.Permission)r   rE   r9   z'glm.PermissionServiceAsyncClient | Noner0   rE   r&   rF   r   rE   rC   rG   )
__future__r   typingr   google.ai.generativelanguageaigenerativelanguageglmgoogle.generativeai.typesr   r   r   r   __annotations__r   r$   r)   r2   r8   r?   rB    r   r   <module>rQ      sO   #  * * 6 5 1  	" 
H]
C*  $&* $	$
$$ $$ 	$
 	$P E 26 $&* $E
E /E 	E
 $E E !E< Q 7; $&* $Q
Q 4Q 	Q
 $Q Q !Qr   