o
    -wit                     @  s   d dl mZ d dlmZmZmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZ d dlmZ erJd dlmZ d d	lmZmZmZ d d
lmZmZmZ G dd ded ZG dd ded ZG dd ded ZdS )    )annotations)TYPE_CHECKINGAnyIterable)ValidationError)override)gql)Document)	Paginator)_Client)IntegrationSlackIntegrationWebhookIntegration))GenericWebhookIntegrationConnectionFieldsIntegrationConnectionFields SlackIntegrationConnectionFieldsc                      f   e Zd ZU ded< ded< dd fddZedddZedddZedddZ	d ddZ
  ZS )!Integrationsz"IntegrationConnectionFields | Nonelast_responser	   _query2   clientr   	variablesdict[str, Any]per_pageintc                   ,   ddl m} t j|||d t|| _d S )Nr   )INTEGRATIONS_BY_ENTITY_GQLr   )wandb.automations._generatedr   super__init__r   r   )selfr   r   r   r   	__class__ [/home/ubuntu/sommelier/.venv/lib/python3.10/site-packages/wandb/apis/public/integrations.pyr!         zIntegrations.__init__returnboolc                 C     | j du rdS | j jjS )z-Whether there are more Integrations to fetch.NTr   	page_infohas_next_pager"   r%   r%   r&   more!      

zIntegrations.more
str | Nonec                 C     | j du rdS | j jjS z*The start cursor to use for the next page.Nr   r,   
end_cursorr.   r%   r%   r&   cursor(   r0   zIntegrations.cursorNonec              
   C  h   ddl m} | jj| j| jd}z|d d }||| _W dS  tt	t
fy3 } ztd|d}~ww )7Fetch and parse the response data for the current page.r   )r   variable_valuesentityintegrationsUnexpected response dataN)r   r   r   executer   r   model_validater   LookupErrorAttributeErrorr   
ValueError)r"   r   data	page_dataer%   r%   r&   _update_response/   s   
zIntegrations._update_responseIterable[Integration]c                   s&   ddl m  | j} fdd|jD S )z0Parse the page data into a list of integrations.r   _IntegrationEdgec                   s   g | ]}  |jqS r%   )r@   node.0edgerI   r%   r&   
<listcomp>B   s    z0Integrations.convert_objects.<locals>.<listcomp>)wandb.automations.integrationsrJ   r   edges)r"   pager%   rI   r&   convert_objects=   s   zIntegrations.convert_objectsr   r   r   r   r   r   r   r(   r)   r(   r1   r(   r7   )r(   rH   __name__
__module____qualname____annotations__r!   propertyr/   r6   r   rG   rS   __classcell__r%   r%   r#   r&   r      s   
 r   r   c                      r   )!WebhookIntegrationsz0GenericWebhookIntegrationConnectionFields | Noner   r	   r   r   r   r   r   r   r   r   c                   r   )Nr   )*GENERIC_WEBHOOK_INTEGRATIONS_BY_ENTITY_GQLr   )r   ra   r    r!   r   r   )r"   r   r   r   ra   r#   r%   r&   r!   I   s   zWebhookIntegrations.__init__r(   r)   c                 C  r*   )z5Whether there are more webhook integrations to fetch.NTr+   r.   r%   r%   r&   r/   R   r0   zWebhookIntegrations.morer1   c                 C  r2   r3   r4   r.   r%   r%   r&   r6   Y   r0   zWebhookIntegrations.cursorr7   c              
   C  r8   )r9   r   )r   r:   r<   r=   r>   N)r   r   r   r?   r   r   r@   r   rA   rB   r   rC   )r"   r   rD   rE   rF   r%   r%   r&   rG   `   s   

z$WebhookIntegrations._update_responseIterable[WebhookIntegration]c                   *   ddl m  d fdd| jjD S )z8Parse the page data into a list of webhook integrations.r   )r   GenericWebhookIntegrationc                   *   g | ]}|j  rjkr qS r%   rK   
typename__r@   rL   r   rK   typenamer%   r&   rO   w       
z7WebhookIntegrations.convert_objects.<locals>.<listcomp>)wandb.automationsr   r   rQ   r.   r%   rh   r&   rS   r   
   z#WebhookIntegrations.convert_objectsrT   rU   rV   rW   rX   )r(   rb   rY   r%   r%   r#   r&   r`   E   s   
 	r`   r   c                      r   )!SlackIntegrationsz'SlackIntegrationConnectionFields | Noner   r	   r   r   r   r   r   r   r   r   c                   r   )Nr   ) SLACK_INTEGRATIONS_BY_ENTITY_GQLr   )r   rn   r    r!   r   r   )r"   r   r   r   rn   r#   r%   r&   r!      r'   zSlackIntegrations.__init__r(   r)   c                 C  r*   )z3Whether there are more Slack integrations to fetch.NTr+   r.   r%   r%   r&   r/      r0   zSlackIntegrations.morer1   c                 C  r2   r3   r4   r.   r%   r%   r&   r6      r0   zSlackIntegrations.cursorr7   c              
   C  r8   )r9   r   )r   r:   r<   r=   r>   N)r   r   r   r?   r   r   r@   r   rA   rB   r   rC   )r"   r   rD   rE   rF   r%   r%   r&   rG      s   
z"SlackIntegrations._update_responseIterable[SlackIntegration]c                   rc   )z6Parse the page data into a list of Slack integrations.r   )r   r   c                   re   r%   rf   rL   r   rK   ri   r%   r&   rO      rj   z5SlackIntegrations.convert_objects.<locals>.<listcomp>)rk   r   r   rQ   r.   r%   rp   r&   rS      rl   z!SlackIntegrations.convert_objectsrT   rU   rV   rW   rX   )r(   ro   rY   r%   r%   r#   r&   rm      s   
 rm   r   N)
__future__r   typingr   r   r   pydanticr   typing_extensionsr   	wandb_gqlr   wandb_graphql.language.astr	   wandb.apis.paginatorr
   r   rk   r   r   r   r   r   r   r   r   r`   rm   r%   r%   r%   r&   <module>   s    /;