o
    ϖiX                     @   s   d dl mZmZmZmZ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mZ G dd deZG dd	 d	eZd
eeef defddZdS )    )AnyDictIteratorListOptionalUnionoverload)
deprecated)Model)Page)	NamespaceResourcec                   @   s   e Zd ZU dZeed< 	 eed< 	 eed< 	 dZeee	  ed< 	 e
eddefd	d
Zdee	 fddZededee	 fddZededeee	  fddZdeeef deee	 eee	  f fddZdefddZdS )
Collectionz.
    A collection of models on Replicate.
    slugnamedescriptionNmodelszUse `slug` instead of `id`returnc                 C   s   | j S )z1
        DEPRECATED: Use `slug` instead.
        )r   self r   H/home/ubuntu/.local/lib/python3.10/site-packages/replicate/collection.pyid   s   zCollection.idc                 C   s   | j d ur
t| j S tg S N)r   iterr   r   r   r   __iter__#   s   

zCollection.__iter__indexc                 C      d S r   r   r   r   r   r   r   __getitem__(      zCollection.__getitem__c                 C   r   r   r   r   r   r   r   r   +   r    c                 C   s   | j d ur
| j | S d S r   )r   r   r   r   r   r   .   s   

c                 C   s   | j d ur
t| j S dS )Nr   )r   lenr   r   r   r   __len__5   s   

zCollection.__len__)__name__
__module____qualname____doc__str__annotations__r   r   r   r
   propertyr	   r   r   r   r   intr   slicer   r"   r   r   r   r   r   
   s0   
 

r   c                   @   s|   e Zd ZdZ	ddeeddf dee fddZ	ddeeddf dee fd	d
Z	dedefddZ
dedefddZdS )CollectionszF
    A namespace for operations related to collections of models.
    .cursorellipsisNr   c                 C   sZ   |du rt d| jd|du rdn|}| }dd |d D |d< tt d	i |S )
7  
        List collections of models.

        Parameters:
            cursor: The cursor to use for pagination. Use the value of `Page.next` or `Page.previous`.
        Returns:
            Page[Collection]: A page of of model collections.
        Raises:
            ValueError: If `cursor` is `None`.
        Ncursor cannot be NoneGET./v1/collectionsc                 S      g | ]}t |qS r   _json_to_collection.0resultr   r   r   
<listcomp>X       z$Collections.list.<locals>.<listcomp>resultsr   )
ValueError_client_requestjsonr   r   r   r-   respobjr   r   r   listA   s   zCollections.listc                    sb   |du r	t d| jd|du rdn|I dH }| }dd |d D |d< tt d	i |S )
r/   Nr0   r1   .r2   c                 S   r3   r   r4   r6   r   r   r   r9   s   r:   z*Collections.async_list.<locals>.<listcomp>r;   r   )r<   r=   _async_requestr?   r   r   r@   r   r   r   
async_list\   s   
zCollections.async_listr   c                 C   s    | j dd| }t| S )Get a model by name.

        Args:
            name: The name of the model, in the format `owner/model-name`.
        Returns:
            The model.
        r1   /v1/collections/)r=   r>   r5   r?   r   r   rA   r   r   r   getw   s   	zCollections.getc                    s(   | j dd| I dH }t| S )rF   r1   rG   N)r=   rD   r5   r?   rH   r   r   r   	async_get   s   	zCollections.async_get).)r#   r$   r%   r&   r   r'   r   r   rC   rE   rI   rJ   r   r   r   r   r,   <   s     

r,   r?   r   c                 C   s   t di | S )Nr   )r   )r?   r   r   r   r5      s   r5   N)typingr   r   r   r   r   r   r   typing_extensionsr	   replicate.modelr
   replicate.paginationr   replicate.resourcer   r   r   r,   r'   r5   r   r   r   r   <module>   s   $ 2V