Ë
    rPêj„(  ã                   óä  — d Z ddlZddlmZmZmZ ddlZddlmZ ddl	m
Z
 ddlmZmZmZmZmZmZ ddlmZmZ dd	lmZ  e ee
«      d
   «      Z ej0                  deD � ci c]  } | | “Œ c} e¬«      Z ee«      Z ej0                  deD �ci c]  }||“Œ c}e¬«      Zdee   dee
   fd„Zdee   dz  dedz  dedz  deeef   dz  fd„Z  ed¬«      Z!e!jE                  dg d¢¬«      	 dJdeddfd„«       Z#e!jE                  ddg¬«      	 dJdee ed¬«      f   deddfd „«       Z$e!jE                  d!g d"¢¬«      	 	 	 	 	 	 	 dKd#eee    ed$d%¬«      f   d&eedz   ed'¬«      f   deedz   ed(d)¬«      f   d*eee   dz   ed+d,¬«      f   d-eedz   ed.¬«      f   dedededdfd/„«       Z%e!jE                  d0g d1¢¬«      	 	 	 	 	 	 	 	 dLdee ed2¬«      f   d&eedz   ed3¬«      f   deedz   ed(d4¬«      f   d#eee   dz   ed$d5¬«      f   d*eee   dz   ed+d6¬«      f   d-eedz   ed7¬«      f   dedededdfd8„«       Z&e!jE                  d9d:g¬«      	 dJdee ed;¬«      f   deddfd<„«       Z'e!jE                  d=d>g¬«      	 dJdee ed?¬«      f   deddfd@„«       Z(e!jE                  dAdBdCg¬«      	 	 dMdee edD¬«      f   dEee) edFdGdH¬«      f   deddfdI„«       Z*yc c} w c c}w )Nz=Contains commands to manage webhooks on the Hugging Face Hub.é    N)Ú	AnnotatedÚget_argsÚget_type_hints)ÚWEBHOOK_DOMAIN_T)ÚWebhookWatchedItemé   )ÚSecretsFileOptÚ
SecretsOptÚTokenOptÚ
get_hf_apiÚparse_env_mapÚtyper_factory)ÚArgumentÚOption)ÚoutÚtypeÚWatchedItemType)r   ÚWebhookDomainÚvaluesÚreturnc           	      óT  — g }t        t        «      }| D ]‘  }d|vr+t        j                  d|› ddj	                  |«      › d�«      ‚|j                  dd«      \  }}||vr+t        j                  d|› ddj	                  |«      › d�«      ‚|j                  t        ||¬«      «       Œ“ |S )	aY  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         úa/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/huggingface_hub/cli/webhooks.pyÚ_parse_watchr'   ,   sÆ   € ð €EÜœÓ'€KØò 	?ˆØ�a‰<Ü×$Ñ$ØUÐVWÐUXð Y!Ø!%§¡¨;Ó!7Ð 8¸ð;óð ð —W‘W˜S !“_‰
ˆˆdØ�{Ñ"Ü×$Ñ$ ~°d°VÐ;KÈDÏIÉIÐVaÓLbÐKcÐcdÐ%eÓfÐfØ�‰Ô'¨T¸Ô=Õ>ð	?ð €Ló    ÚsecretsÚsecrets_fileÚjob_idc                 óª   — t        | |«      }|sy|€t        j                  d«      ‚|j                  «       D ��ci c]  \  }}||xs d“Œ c}}S c c}}w )z^Parse `--secrets` / `--secrets-file` for the Job triggered by a webhook (requires `--job-id`).Nz.--secrets and --secrets-file require --job-id.Ú )r   r   r   r"   )r)   r*   r+   Úsecrets_mapÚkeyÚvalues         r&   Ú_parse_job_secretsr1   H   sW   € ô   ¨Ó6€KÙØØ€~Ü× Ñ Ð!QÓRÐRØ/:×/@Ñ/@Ó/B×C¡  eˆC�’˜"ÑÓCÐCùÓCs   ºA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                 óp  — t        | ¬«      }|j                  «       D ��cg c]o  }|j                  |j                  xs d|j                  |j
                  xs g |j                  xs g D �cg c]  }|j                  › d|j                  › �‘Œ c}dœ‘Œq }}}t        j                  |«       yc c}w c c}}w )z'List all webhooks for the current user.©r4   z(job)r   )ÚidÚurlÚdisabledÚdomainsÚwatchedN)r   Úlist_webhooksr7   r8   r9   r:   r;   r   r   r   Útable)r4   ÚapiÚwÚwiÚresultss        r&   Úwebhooks_lsrB   W   s¡   € ô ˜5Ô
!€Cð ×"Ñ"Ó$÷	ð ð —$‘$Ø—5‘5Ò#˜GØŸ
™
Ø—y‘y’ BØ:;¿)¹)º/ÀrÖK°2˜2Ÿ7™7˜) 1 R§W¡W IÒ.ÒKó	
ð	€Gñ 	ô ‡I�IˆgÕùò	 Lùó	s    AB2Á+"B-ÂB2Â-B2Úinfozhf webhooks info abc123Ú
webhook_idzThe ID of the webhook.c                 óh   — t        |¬«      }|j                  | «      }t        j                  |«       y)z'Show full details for a single webhook.r6   N)r   Úget_webhookr   Údict©rD   r4   r>   Úwebhooks       r&   Úwebhooks_inforJ   q   s(   € ô ˜5Ô
!€CØ�o‰o˜jÓ)€GÜ‡H�HˆWÕ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-czghf webhooks create --job-id 687f911eaea852de79c4a50a --watch bucket:my-org/my-bucket --secrets HF_TOKENÚwatchz--watchzRItem to watch, in 'type:name' format (e.g. 'model:bert-base-uncased'). Repeatable.r8   zBURL to send webhook payloads to. Mutually exclusive with --job-id.z--job-idz]ID of a Job to trigger (from job.id) instead of pinging a URL. Mutually exclusive with --url.Údomainz--domainzMDomain to watch: 'repo' or 'discussion'. Repeatable. Defaults to all domains.Úsecretz.Optional secret used to sign webhook payloads.c                 óf  — |�|�t        j                  d«      ‚|€|€t        j                  d«      ‚t        |||«      }t        |¬«      }	t	        | «      }
|r|D �cg c]  }|j
                  ‘Œ c}nd}|	j                  |||
|||¬«      }t        j                  d|j                  ¬«       yc c}w )zéCreate a new webhook.

    Provide either --url (to ping a remote server) or --job-id (to trigger a Job), but not both.
    The source Job's secrets are not copied to the webhook: pass them again with --secrets / --secrets-file.
    Nú+Provide either --url or --job-id, not both.z!Provide either --url or --job-id.r6   ©r8   r+   r;   r:   rN   r)   zWebhook created©r7   )
r   r   r1   r   r'   r0   Úcreate_webhookr   Úresultr7   )rL   r8   r+   rM   rN   r)   r*   r4   Újob_secretsr>   Úwatched_itemsÚdr:   rI   s                 r&   Úwebhooks_createrX   �   s·   € ð` €˜6Ð-Ü× Ñ Ð!NÓOÐOØ
€{�v�~Ü× Ñ Ð!DÓEÐEÜ$ W¨l¸FÓC€KÜ
˜5Ô
!€CÜ  Ó'€MÙ+1 Ö'˜1ˆq�w‹wÓ'°t€GØ× Ñ ØØØØØØð !ó €Gô ‡J�JÐ  W§Z¡ZÖ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 newsecretzNhf webhooks update abc123 --job-id 687f911eaea852de79c4a50a --secrets HF_TOKENz The ID of the webhook to update.z$New URL to send webhook payloads to.zcID of the source Job to trigger (can be the current one). Required with --secrets / --secrets-file.ziNew list of items to watch, in 'type:name' format. Repeatable. Replaces the entire existing watched list.zANew list of domains to watch: 'repo' or 'discussion'. Repeatable.z)New secret used to sign webhook payloads.c	           	      ó>  — |�|�t        j                  d«      ‚t        |||«      }	t        |¬«      }
|rt	        |«      nd}|r|D �cg c]  }|j
                  ‘Œ c}nd}|
j                  | ||||||	¬«      }t        j                  d|j                  ¬«       yc c}w )z¥Update an existing webhook. Only provided options are changed.

    Job secrets passed with --secrets replace stored values with the same name; others are kept.
    NrP   r6   rQ   zWebhook updatedrR   )
r   r   r1   r   r'   r0   Úupdate_webhookr   rT   r7   )rD   r8   r+   rL   rM   rN   r)   r*   r4   rU   r>   rV   rW   r:   rI   s                  r&   Úwebhooks_updater\   Ä   s£   € ðf €˜6Ð-Ü× Ñ Ð!NÓOÐOÜ$ W¨l¸FÓC€KÜ
˜5Ô
!€CÙ+0”L Ô'°d€MÙ+1 Ö'˜1ˆq�w‹wÓ'°t€GØ× Ñ ØØØØØØØð !ó €Gô ‡J�JÐ  W§Z¡ZÖ0ùò (s   ÁBÚenablezhf webhooks enable abc123z The ID of the webhook to enable.c                 ó€   — t        |¬«      }|j                  | «      }t        j                  d|j                  ¬«       y)zEnable a disabled webhook.r6   zWebhook enabledrR   N)r   Úenable_webhookr   rT   r7   rH   s       r&   Úwebhooks_enabler`   	  s1   € ô ˜5Ô
!€CØ× Ñ  Ó,€GÜ‡J�JÐ  W§Z¡ZÖ0r(   Údisablezhf webhooks disable abc123z!The ID of the webhook to disable.c                 ó€   — t        |¬«      }|j                  | «      }t        j                  d|j                  ¬«       y)zDisable an active webhook.r6   zWebhook disabledrR   N)r   Údisable_webhookr   rT   r7   rH   s       r&   Úwebhooks_disablerd     s1   € ô ˜5Ô
!€CØ×!Ñ! *Ó-€GÜ‡J�JÐ! g§j¡jÖ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                 ó¢   — t        j                  d| › d�|¬«       t        |¬«      }|j                  | «       t        j                  d| ¬«       y)zDelete a webhook permanently.z)Are you sure you want to delete webhook 'z'?)rf   r6   zWebhook deletedrR   N)r   Úconfirmr   Údelete_webhookrT   )rD   rf   r4   r>   s       r&   Úwebhooks_deleterj   )  sD   € ô( ‡K�KÐ;¸J¸<ÀrÐJÐPSÕTÜ
˜5Ô
!€CØ×Ñ�zÔ"Ü‡J�JÐ  ZÖ0r(   )N)NNNNNNN)NNNNNNNN)FN)+Ú__doc__ÚenumÚtypingr   r   r   r   Úhuggingface_hub.constantsr   Úhuggingface_hub.hf_apir   Ú
_cli_utilsr	   r
   r   r   r   r   Ú
_frameworkr   r   Ú_outputr   r   ÚEnumÚstrr   Ú_DOMAIN_TYPESr   Úlistr'   rG   r1   Úwebhooks_cliÚcommandrB   rJ   rX   r\   r`   rd   Úboolrj   )ÚtrW   s   00r&   ú<module>r{      s§  ðñ Dã ß 6Ñ 6ã å 6Ý 5÷÷ ÷ )Ý ñ ™.Ð);Ó<¸VÑDÓE€Ø�$—)‘)Ð-¸nÖ/M¸°°1±Ò/MÐTWÔX€áÐ)Ó*€Ø�—	‘	˜/¸-Ö+H°Q¨A¨q©DÒ+HÈsÔS€ð˜˜c™ð  tÐ,>Ñ'?ó ð8	DØ�#‰Y˜Ñð	DØ-0°4©Zð	DØADÀtÁð	Dà	ˆ#ˆsˆ(�^�dÑó	Dñ Ð"?Ô@€ð ×ÑØòð ó ð ñØðà	òóðð$ ×ÑØ
à!ðð ó ð ñØ˜#™xÐ-EÔFÐFÑGðàðð 
òóðð ×ÑØòð ó ð( 	ð 	ð 	ð 	ØØ#'ØñA71ØØˆS‰	ÙØØeô	
ð	ñð71ð 
Øˆd‰
ÙÐXÔYð	[ñ
ð71ð Øˆd‰
ÙØØpô	
ð	ñð71ð& Øˆ]Ñ˜dÑ"ÙØØ`ô	
ð	ñð'71ð4 Øˆd‰
ÙÐDÔEð	Gñð571ð< ð=71ð> !ð?71ð@ ðA71ðB 
òC71óð71ðt ×ÑØòð ó ð 	ð 	ð 	ð 	ð 	ØØ#'ØñI91Ø˜#™xÐ-OÔPÐPÑQð91à	Øˆd‰
ÙÐ:Ô;ð	=ñ
ð91ð Øˆd‰
ÙØØvô	
ð	ñð91ð ØˆS‰	�DÑÙØðIô	
ð	ñ	ð91ð. Øˆ]Ñ˜dÑ"ÙØØTô	
ð	ñð/91ð< Øˆd‰
ÙÐ?Ô@ð	Bñð=91ðD ðE91ðF !ðG91ðH ðI91ðJ 
òK91óð91ðx ×ÑØà#ðð ó ð ñ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óñ1ùòU 0Nùò ,Is   Á!
K(
Â
K-
