
    5pjf!                        S r SSKrSSKJrJrJr  SSKrSSKJr  SSK	J
r
  SSKJrJrJr  SSKJrJr  SS	KJr  \" \" \
5      S
   5      r\R*                  " S\ V s0 s H  o U _M     sn \S9r\" \5      r\R*                  " S\ Vs0 s H  oU_M     sn\S9rS\\   S\\
   4S jr\" SS9r\R;                  S/ SQS9 SFS\SS4S jj5       r\R;                  SS/S9 SFS\\\" SS94   S\SS4S jj5       r\R;                  S/ SQS9     SGS\\\   \" S S!S94   S"\\S-  \" S#S94   S$\\S-  \" S%S&S94   S'\\\   S-  \" S(S)S94   S*\\S-  \" S+S94   S\SS4S, jj5       r \R;                  S-/ S.QS9     SGS\\\" S/S94   S"\\S-  \" S0S94   S\\\   S-  \" S S1S94   S'\\\   S-  \" S(S2S94   S*\\S-  \" S3S94   S\SS4S4 jj5       r!\R;                  S5S6/S9 SFS\\\" S7S94   S\SS4S8 jj5       r"\R;                  S9S:/S9 SFS\\\" S;S94   S\SS4S< jj5       r#\R;                  S=S>S?/S9  SHS\\\" S@S94   SA\\$\" SBSCSDS94   S\SS4SE jj5       r%gs  sn f s  snf )Iz=Contains commands to manage webhooks on the Hugging Face Hub.    N)	Annotatedget_argsget_type_hints)WEBHOOK_DOMAIN_T)WebhookWatchedItem   )TokenOpt
get_hf_apityper_factory)ArgumentOption)outtypeWatchedItemType)r   WebhookDomainvaluesreturnc           	      X   / n[        [        5      nU  H  nSU;  a,  [        R                  " SU SSR	                  U5       S35      eUR                  SS5      u  pEXB;  a,  [        R                  " SU SSR	                  U5       S35      eUR                  [        XES95        M     U$ )	a9  Parse 'type:name' strings into WebhookWatchedItem objects.

Args:
    values: List of strings in the format 'type:name'
        (e.g., 'model:bert-base-uncased', 'org:HuggingFace').

Returns:
    List of WebhookWatchedItem objects.

Raises:
    click.BadParameter: If any value doesn't match the expected format.
:zCExpected format 'type:name' (e.g. 'model:bert-base-uncased'), got 'z'. Valid types: z, .r   zInvalid type ')r   name)tuple_WATCHED_TYPESclickBadParameterjoinsplitappendr   )r   itemsvalid_typesvkindr   s         X/var/www/html/pdf-tiff/venv/lib/python3.13/site-packages/huggingface_hub/cli/webhooks.py_parse_watchr$   )   s     E'Ka<$$UVWUX Y!!%;!7 8;  WWS!_
"$$~dV;KDIIVaLbKccd%eff'T=>  L    zManage webhooks on the Hub.)helpz	list | ls)zhf webhooks lszhf webhooks ls --format jsonzhf webhooks ls --format quiet)examplestokenc                    [        U S9nUR                  5        VVs/ s H  nUR                  UR                  =(       d    SUR                  UR
                  =(       d    / UR                  =(       d    /  Vs/ s H  o3R                   SUR                   3PM     snS.PM     nnn[        R                  " U5        gs  snf s  snnf )z'List all webhooks for the current user.r(   z(job)r   )idurldisableddomainswatchedN)r
   list_webhooksr+   r,   r-   r.   r/   r   r   r   table)r(   apiwwiresultss        r#   webhooks_lsr6   H   s     5
!C ""$	 %A $$55#G

yyB:;))/r/K/277)1RWWI./K	
 %  	 IIg	 L	s   AC8$B?	C?Cinfozhf webhooks info abc123
webhook_idzThe ID of the webhook.c                 d    [        US9nUR                  U 5      n[        R                  " U5        g)z'Show full details for a single webhook.r*   N)r
   get_webhookr   dictr8   r(   r2   webhooks       r#   webhooks_infor>   b   s(     5
!Cooj)GHHWr%   create)zQhf webhooks create --url https://example.com/hook --watch model:bert-base-uncasedzjhf webhooks create --url https://example.com/hook --watch org:HuggingFace --watch model:gpt2 --domain repozJhf webhooks create --job-id 687f911eaea852de79c4a50a --watch user:julien-cwatchz--watchzRItem to watch, in 'type:name' format (e.g. 'model:bert-base-uncased'). Repeatable.r,   zBURL to send webhook payloads to. Mutually exclusive with --job-id.job_idz--job-idz]ID of a Job to trigger (from job.id) instead of pinging a URL. Mutually exclusive with --url.domainz--domainzNDomain to watch: 'repo' or 'discussions'. Repeatable. Defaults to all domains.secretz.Optional secret used to sign webhook payloads.c                 P   Ub  Ub  [         R                  " S5      eUc  Uc  [         R                  " S5      e[        US9n[        U 5      nU(       a  U Vs/ s H  oR                  PM     snOSn	UR                  XXyUS9n
[        R                  " SU
R                  S9  gs  snf )ztCreate a new webhook.

Provide either --url (to ping a remote server) or --job-id (to trigger a Job), but not both.
Nz+Provide either --url or --job-id, not both.z!Provide either --url or --job-id.r*   )r,   rA   r/   r.   rC   zWebhook createdr+   )	r   r   r
   r$   valuecreate_webhookr   resultr+   )r@   r,   rA   rB   rC   r(   r2   watched_itemsdr.   r=   s              r#   webhooks_createrK   r   s    X 6-  !NOO
{v~  !DEE
5
!C 'M+1'1ww'tG  Shn oGJJ WZZ0 (s   B#update)z8hf webhooks update abc123 --url https://new-url.com/hookz:hf webhooks update abc123 --watch model:gpt2 --domain repoz,hf webhooks update abc123 --secret newsecretz The ID of the webhook to update.z$New URL to send webhook payloads to.ziNew list of items to watch, in 'type:name' format. Repeatable. Replaces the entire existing watched list.zBNew list of domains to watch: 'repo' or 'discussions'. Repeatable.z)New secret used to sign webhook payloads.c                     [        US9nU(       a  [        U5      OSnU(       a  U Vs/ s H  oR                  PM     snOSn	UR                  XXyUS9n
[        R
                  " SU
R                  S9  gs  snf )z>Update an existing webhook. Only provided options are changed.r*   N)r,   r/   r.   rC   zWebhook updatedrE   )r
   r$   rF   update_webhookr   rH   r+   )r8   r,   r@   rB   rC   r(   r2   rI   rJ   r.   r=   s              r#   webhooks_updaterO      sg    L 5
!C+0L'dM+1'1ww'tG  mek lGJJ WZZ0 (s   A4enablezhf webhooks enable abc123z The ID of the webhook to enable.c                 v    [        US9nUR                  U 5      n[        R                  " SUR                  S9  g)zEnable a disabled webhook.r*   zWebhook enabledrE   N)r
   enable_webhookr   rH   r+   r<   s       r#   webhooks_enablerS      s1     5
!C  ,GJJ WZZ0r%   disablezhf webhooks disable abc123z!The ID of the webhook to disable.c                 v    [        US9nUR                  U 5      n[        R                  " SUR                  S9  g)zDisable an active webhook.r*   zWebhook disabledrE   N)r
   disable_webhookr   rH   r+   r<   s       r#   webhooks_disablerW      s1     5
!C!!*-GJJ!gjj1r%   deletezhf webhooks delete abc123zhf webhooks delete abc123 --yesz The ID of the webhook to delete.yesz--yesz-yzSkip confirmation prompt.c                     [         R                  " SU  S3US9  [        US9nUR                  U 5        [         R                  " SU S9  g)zDelete a webhook permanently.z)Are you sure you want to delete webhook 'z'?)rY   r*   zWebhook deletedrE   N)r   confirmr
   delete_webhookrH   )r8   rY   r(   r2   s       r#   webhooks_deleter]      sD    ( KK;J<rJPST
5
!Cz"JJ Z0r%   )N)NNNNN)FN)&__doc__enumtypingr   r   r   r   huggingface_hub.constantsr   huggingface_hub.hf_apir   
_cli_utilsr	   r
   r   
_frameworkr   r   _outputr   r   Enumstrr   _DOMAIN_TYPESr   listr$   webhooks_clicommandr6   r>   rK   rO   rS   rW   boolr]   )trJ   s   00r#   <module>rn      s   D  6 6  6 5 
 )  .);<VDE))-n/Mn1n/MTWX)*		/-+H-QqD-+HsSc t,>'? 8 "?@    	$ 
!   #x-EFFG 
   & 	 	 	 	=,1S	e	
	,1 
d
XY	[
,1 d
p	
	,1& ]d"a	
	',14 d
DE	G5,1< =,1> 
?,1,1^    	 	 	 	7"1#x-OPPQ"1	d
:;	=
"1 S	DI	
		"1  ]d"U	
	!"1. d
?@	B/"16 7"18 
9"1"1J #   1#x-OPPQ11 
11 $   2#x-PQQR22 
22 #)    	1#x-OPPQ1	,	
	
1 1 
11u 0N ,Is   I+
I0
