
    rh                       U d dl mZ d dlmZ d dlmc mZ d dlm	Z	 d dlm
Z
 d dlmZ ddddd	Zd
ed<   ddZddZddZddZ	 	 	 	 d	 	 	 	 	 	 	 	 	 ddZ	 dddddd	 	 	 	 	 	 	 	 	 	 	 ddZ	 dddddd	 	 	 	 	 	 	 	 	 	 	 ddZy)    )annotations)CallableN)permission_types)retriever_types)model_typescorporatunedModels)corpusr   
tunedmodeltunedmodelszdict[str, str]_RESOURCE_TYPEc                    t        | t              r| j                         } t        j	                  | d       }|st        d|  d      |S )Nz!Unsupported resource type. Got: `
` instead.)
isinstancestrlowerr   get
ValueErrorxresource_types     q/var/www/html/ai-insurance-compliance-backend/venv/lib/python3.12/site-packages/google/generativeai/permission.py_to_resource_typer   "   sG    !SGGI"&&q$/M<QCzJKK    c                V   |dk(  rIt        j                  |       s3t        t         j                  j	                  t        |       |             y |dk(  rIt        j                  |       s3t        t        j                  j	                  t        |       |             y t        d|       )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[CCJJRUVWRX_`Jabb 5 6}oFGGr   c                    t        j                  |       s)t        t         j                  j	                  |             y )N)permission_id)r   valid_idr   INVALID_PERMISSION_ID_MSGr    )r   s    r   _validate_permission_idr)   9   s6    $$Q')CCJJYZJ[\\ (r   c                    | j                  d      }t        |      dk7  rt        d|  d      |\  }}}}t        |      }dj	                  ||g      }t        ||       t        |       dj	                  |||g      S )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4mDEMM=9M*88]M=ABBr   c           	     l   | s|r|st        d|  d| d| d      |rt        |      }nH|j                  d      }t        |      dk7  rt        d| dt        |       d	      t        |d
         }| d|v r| d} n| d| d} t	        |t
              sd|vr	| d| z  } n| |z  } t        |       } | S )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   sa    - 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M!D &d+DKr   )clientr0   r&   r   c               b    t        | |||      } t        j                  j                  | |      S )aw  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   s8    ( ###	D &&**V*DDr   c               ~   K   t        | |||      } t        j                  j                  | |       d{   S 7 w)zC
    This is the async version of `permission.get_permission`.
    r;   r<   N)r8   r   r=   	get_asyncr>   s        r   get_permission_asyncrB      sB      ###	D ",,66D6PPPPs   4=;=)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   