Ë
    (täiþ%  ã                   ó4  — 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 ddlmZmZ  e ee
«      d	   «      Z ej(                  d
eD � ci c]  } | | “Œ c} e¬«      Z ee«      Z ej(                  deD �ci c]  }||“Œ c}e¬«      Zdee   dee
   fd„Z ed¬«      Zej9                  dg d¢¬«      ej:                  dfdededdfd„«       Zej9                  ddg¬«      ej:                  dfdee ej>                  d¬«      f   dededdfd„«       Z ej9                  dg d¢¬«      ddddej:                  dfdeee    ejB                  d d!¬«      f   d"eedz   ejB                  d#¬«      f   d$eedz   ejB                  d%d&¬«      f   d'eee   dz   ejB                  d(d)¬«      f   d*eedz   ejB                  d+¬«      f   dededdfd,„«       Z"ej9                  d-g d.¢¬«      ddddej:                  dfdee ej>                  d/¬«      f   d"eedz   ejB                  d0¬«      f   deee   dz   ejB                  d d1¬«      f   d'eee   dz   ejB                  d(d2¬«      f   d*eedz   ejB                  d3¬«      f   dededdfd4„«       Z#ej9                  d5d6g¬«      ej:                  dfdee ej>                  d7¬«      f   dededdfd8„«       Z$ej9                  d9d:g¬«      ej:                  dfdee ej>                  d;¬«      f   dededdfd<„«       Z%ej9                  d=d>d?g¬«      d@ej:                  dfdee ej>                  dA¬«      f   dBee& ejB                  dCdDdE¬«      f   dededdf
dF„«       Z'yc c} w c c}w )GaÚ  Contains commands to manage webhooks on the Hugging Face Hub.

Usage:
    # list all webhooks
    hf webhooks ls

    # show details of a single webhook
    hf webhooks info <webhook_id>

    # create a new webhook
    hf webhooks create --url https://example.com/hook --watch model:bert-base-uncased

    # create a webhook watching multiple items and domains
    hf webhooks create --url https://example.com/hook --watch org:HuggingFace --watch model:gpt2 --domain repo

    # update a webhook
    hf webhooks update <webhook_id> --url https://new-url.com/hook

    # enable / disable a webhook
    hf webhooks enable <webhook_id>
    hf webhooks disable <webhook_id>

    # delete a webhook
    hf webhooks delete <webhook_id>
é    N)Ú	AnnotatedÚget_argsÚget_type_hints)ÚWEBHOOK_DOMAIN_T)ÚWebhookWatchedItemé   )ÚFormatWithAutoOptÚTokenOptÚ
get_hf_apiÚtyper_factory)ÚOutputFormatWithAutoÚ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:
        typer.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ÚtyperÚBadParameterÚjoinÚsplitÚappendr   )r   ÚitemsÚvalid_typesÚvÚkindr   s         úk/Volumes/fast/ai/experiments/MLX_z-image/.venv/lib/python3.12/site-packages/huggingface_hub/cli/webhooks.pyÚ_parse_watchr$   A   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ó    zManage webhooks on the Hub.)Úhelpz	list | ls)zhf webhooks lszhf webhooks ls --format jsonzhf webhooks ls --format quiet)ÚexamplesÚformatÚ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.©r)   z(job)r   )ÚidÚurlÚdisabledÚdomainsÚwatchedN)r   Úlist_webhooksr,   r-   r.   r/   r0   r   r   r   Útable)r(   r)   ÚapiÚwÚwiÚresultss         r#   Úwebhooks_lsr7   `   s¬   € ô ˜5Ô
!€Cð ×"Ñ"Ô$ô	ñ %ˆAð —$‘$Ø—5‘5Ò#˜GØŸ
™
Ø—y‘y’ BØ:;¿)¹)º/Àr¸/ÓK¹/°2˜2Ÿ7™7˜) 1 R§W¡W IÒ.¸/ÑKó	
ð %ð ñ 	ô ‡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.r+   N)r   Úget_webhookr   Údict©r9   r(   r)   r3   Úwebhooks        r#   Úwebhooks_infor?   {   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-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                 óJ  — |�|�t        j                  d«      ‚|€|€t        j                  d«      ‚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.
    Nz+Provide either --url or --job-id, not both.z!Provide either --url or --job-id.r+   )r-   rB   r0   r/   rD   zWebhook created©r,   )	r   r   r   r$   ÚvalueÚcreate_webhookr   Úresultr,   )rA   r-   rB   rC   rD   r(   r)   r3   Úwatched_itemsÚdr/   r>   s               r#   Úwebhooks_createrL   Œ   s¡   € ðZ €˜6Ð-Ü× Ñ Ð!NÓOÐOØ
€{�v�~Ü× Ñ Ð!DÓEÐEÜ
˜5Ô
!€CÜ  Ó'€MÙ+1¡Ó'¡˜1ˆq�w‹w Ò'°t€GØ× Ñ  S°ÀÐX_ÐhnÐ Óo€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 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                 óî   — 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.r+   N)r-   r0   r/   rD   zWebhook updatedrF   )r   r$   rG   Úupdate_webhookr   rI   r,   )r9   r-   rA   rC   rD   r(   r)   r3   rJ   rK   r/   r>   s               r#   Úwebhooks_updaterP   Ä   sn   € ôN ˜5Ô
!€CÙ+0”L Ô'°d€MÙ+1¡Ó'¡˜1ˆq�w‹w Ò'°t€GØ× Ñ  °¸mÐU\ÐekÐ Ól€GÜ‡J�JÐ  W§Z¡ZÖ0ùò (s   ¢A2Ú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.r+   zWebhook enabledrF   N)r   Úenable_webhookr   rI   r,   r=   s        r#   Úwebhooks_enablerT   ò   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.r+   zWebhook disabledrF   N)r   Údisable_webhookr   rI   r,   r=   s        r#   Úwebhooks_disablerX     s1   € ô ˜5Ô
!€CØ×!Ñ! *Ó-€GÜ‡J�JÐ! g§j¡jÖ1r%   Údeletezhf webhooks delete abc123zhf webhooks delete abc123 --yesFz 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'?)rZ   r+   zWebhook deletedrF   N)r   Úconfirmr   Údelete_webhookrI   )r9   rZ   r(   r)   r3   s        r#   Úwebhooks_deleter^     sD   € ô* ‡K�KÐ;¸J¸<ÀrÐJÐPSÕTÜ
˜5Ô
!€CØ×Ñ�zÔ"Ü‡J�JÐ  ZÖ0r%   )(Ú__doc__ÚenumÚtypingr   r   r   r   Úhuggingface_hub.constantsr   Úhuggingface_hub.hf_apir   Ú
_cli_utilsr	   r
   r   r   Ú_outputr   r   r   ÚEnumÚstrr   Ú_DOMAIN_TYPESr   Úlistr$   Úwebhooks_cliÚcommandÚautor7   ÚArgumentr?   ÚOptionrL   rP   rT   rX   Úboolr^   )ÚtrK   s   00r#   Ú<module>rq      s×  ðñó4 ß 6Ñ 6ã å 6Ý 5÷ó ÷ /ñ ™.Ð);Ó<¸VÑDÓE€Ø�$—)‘)Ð-¹nÓ/M¹n¸°°1±¸nÑ/MÐTWÔX€áÐ)Ó*€Ø�—	‘	˜/¹-Ó+H¹-°Q¨A¨q©D¸-Ñ+HÈsÔS€ð˜˜c™ð  tÐ,>Ñ'?ó ñ8 Ð"?Ô@€ð ×ÑØòð ó ð !5× 9Ñ 9ØñØðàðð 
òóðð& ×ÑØ
à!ðð ó ð !5× 9Ñ 9ØñØ˜#˜~˜uŸ~™~Ð3KÔLÐLÑMðàðð ðð 
ò	óðð ×ÑØòð ó ð& 	ð 	ð 	ð 	Ø 4× 9Ñ 9Øñ?-1ØØˆS‰	Øˆ�‰ØØeô	
ð	ñð-1ð 
Øˆd‰
Øˆ�‰Ð^Ô_ð	añ
ð-1ð Øˆd‰
Øˆ�‰ØØpô	
ð	ñð-1ð& Øˆ]Ñ˜dÑ"Øˆ�‰ØØaô	
ð	ñð'-1ð4 Øˆd‰
Øˆ�‰ÐJÔKð	Mñð5-1ð< ð=-1ð> ð?-1ð@ 
òA-1óð-1ð` ×ÑØòð ó ð 	ð 	ð 	ð 	Ø 4× 9Ñ 9Øñ9#1Ø˜#˜~˜uŸ~™~Ð3UÔVÐVÑWð#1à	Øˆd‰
Øˆ�‰Ð@ÔAð	Cñ
ð#1ð ØˆS‰	�DÑØˆ�‰ØðIô	
ð	ñ	ð#1ð  Øˆ]Ñ˜dÑ"Øˆ�‰ØØUô	
ð	ñð!#1ð. Øˆd‰
Øˆ�‰ÐEÔFð	Hñð/#1ð6 ð7#1ð8 ð9#1ð: 
ò;#1óð#1ðL ×ÑØà#ðð ó ð !5× 9Ñ 9Øñ1Ø˜#˜~˜uŸ~™~Ð3UÔVÐVÑWð1àð1ð ð1ð 
ò	1óð1ð ×ÑØà$ðð ó ð !5× 9Ñ 9Øñ2Ø˜#˜~˜uŸ~™~Ð3VÔWÐWÑXð2àð2ð ð2ð 
ò	2óð2ð ×ÑØà#Ø)ðð ó ð  	Ø 4× 9Ñ 9Øñ1Ø˜#˜~˜uŸ~™~Ð3UÔVÐVÑWð1à	ØØˆ�‰ØØØ,ô	
ð	ñ
ð1ð ð1ð ð1ð 
ò1óñ1ùòA 0Nùò ,Is   Á
N
Â
N
