
    ]jy                     J    d dl mZ d dlmZ ddlmZ ddlmZ  G d de      Zy)	    )Optional)	BaseModel   )Client)Userc                       e Zd ZU eed<   eed<   dZee   ed<   eed<   eed<   eed<   e	ed<    G d	 d
      Z
defdZdefdZd Zy)	Workspaceidtitle descriptioncoloris_personal
created_byclientc                       e Zd ZdZy)Workspace.ConfigTN)__name__
__module____qualname__arbitrary_types_allowed     M/root/env/lib/python3.12/site-packages/label_studio_sdk/_legacy/workspaces.pyConfigr      s    "&r   r   userc                     | j                   j                  dd| j                   d| j                  |j                  d      }|j                         S )zAdd user to workspace

        Parameters
        ----------
        user: label_studio_sdk.users.User
            User
        POST/api/workspaces//memberships	workspacer   json)r   make_requestr
   r$   selfr   responses      r   add_userzWorkspace.add_user   sN     ;;++twwi|4#ww8 , 

 }}r   c                     | j                   j                  dd| j                   d| j                  |j                  d      }|j                  dk7  rt	        t        |j                              y)zRemove user from workspace

        Parameters
        ----------
        user: label_studio_sdk.users.User
            User
        DELETEr   r    r!   r#      N)r   r%   r
   status_code
ValueErrorstrcontentr&   s      r   remove_userzWorkspace.remove_user$   sk     ;;++twwi|4#ww8 , 

 3&S!1!1233 'r   c                     ddl m} g }| j                  j                  dd| j                   d      }|j                         }|D ]3  }|d   }|j                  |j                  | j                  |             5 |S )zGet projects in current workspace

        Returns
        -------
        projects: list of label_studio_sdk.project.Project
            Project
        r   )ProjectGETr   z	/projectsr
   )r   
project_id)projectr3   r   r%   r
   r$   appendget_from_id)r'   r3   final_resultsr(   projectsproject_datar5   s          r   get_projectszWorkspace.get_projects4   s     	%;;++%dggYi8
 ==?$ 	L%d+J  ##;;) $ 	 r   N)r   r   r   int__annotations__r/   r   r   boolr   r   r   r)   r1   r<   r   r   r   r	   r	   	   sV    GJ!#K##JON' 'T 4 4 r   r	   N)	typingr   pydanticr   r   r   usersr   r	   r   r   r   <module>rC      s       B	 Br   