
    ]js                     B   d dl Z d dlmZ ddlmZ ddlmZmZ ddl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 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 ddlm Z  ddl!m"Z" ddl#m$Z$  e jJ                  e jL                  d      Z' G d d      Z( G d d      Z)y)    N)JSONDecodeError   )ApiError)AsyncClientWrapperSyncClientWrapper)AsyncHttpResponseHttpResponse)jsonable_encoder)RequestOptions)'convert_and_respect_annotation_metadata)construct_type)BadRequestError)TaskAssignment   )AssignAssignmentsRequestType)#BulkAssignAssignmentsRequestFilters))BulkAssignAssignmentsRequestSelectedItems) BulkAssignAssignmentsRequestType)BulkAssignAssignmentsResponse)DeleteAssignmentsRequestType)UpdateAssignmentsRequestType.c                   .   e Zd ZdefdZedddededede	j                  e   d	e	j                  e   d
e	j                  e   dee   fdZdddeded
e	j                  e   dee	j"                  e      fdZdddededede	j                  e   d
e	j                  e   dee   fdZdddddedede	j                  e   de	j                  e   d
e	j                  e   ded   fdZdddededede	j                  e   d
e	j                  e   dee   fdZy)RawAssignmentsClientclient_wrapperc                    || _         y N_client_wrapperselfr   s     Z/root/env/lib/python3.12/site-packages/label_studio_sdk/projects/assignments/raw_client.py__init__zRawAssignmentsClient.__init__   
    -    Nfiltersrequest_optionsidselected_itemstypeusersr&   r'   returnc                l   | j                   j                  j                  dt        |       ddt	        |t
        d      t	        |t        d      ||dddi|t        	      }	 d
|j                  cxk  rdk  rGn nDt        j                  t        t        t        |j                                     }t        ||      S |j                  dk(  rit        t!        |j"                        t        j                  t        j$                  t        t        j$                  |j                                           |j                         }	t)        |j                  t!        |j"                        |	      # t&        $ r6 t)        |j                  t!        |j"                        |j*                        w xY w)a)  
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Assign multiple users to a collection of tasks within a specific project.

        Parameters
        ----------
        id : int

        selected_items : BulkAssignAssignmentsRequestSelectedItems
            Task selection by IDs. If filters are applied, the selection will be applied to the filtered tasks.If "all" is `false`, `"included"` must be used. If "all" is `true`, `"excluded"` must be used.<br>Examples: `{"all": false, "included": [1, 2, 3]}` or `{"all": true, "excluded": [4, 5]}`

        type : BulkAssignAssignmentsRequestType
            Assignment type. Use AN for annotate or RE for review.

        users : typing.Sequence[int]
            List of user IDs to assign

        filters : typing.Optional[BulkAssignAssignmentsRequestFilters]
            Filters to apply on tasks. You can use [the helper class `Filters` from this page](https://labelstud.io/sdk/data_manager.html) to create Data Manager Filters.<br>Example: `{"conjunction": "or", "items": [{"filter": "filter:tasks:completed_at", "operator": "greater", "type": "Datetime", "value": "2021-01-01T00:00:00.000Z"}]}`

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[BulkAssignAssignmentsResponse]
            Success
        api/projects//tasks/assigneesPOSTwriteobject_
annotation	directionr&   selectedItemsr*   r+   content-typeapplication/jsonmethodjsonheadersr'   omit   ,  type_r3   responsedata  r=   bodystatus_coder=   rH   )r   httpx_clientrequestr
   r   r   r   OMITrJ   typingcastr   r   r<   r	   r   dictr=   Anyr   r   text
r    r(   r)   r*   r+   r&   r'   	_response_data_response_jsons
             r!   bulk_assignz RawAssignmentsClient.bulk_assign   s   V ((55==,R011ABB#0S_f "I*7`ls" 	  2 ,# > 
	&	ti++1c11"; ) 0 $YUCC$$+% !2!23

&"(**$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`noo  	ty'<'<d9K\K\F]dmdrdrss	ts   %AE4 BE4 4?F3r'   task_pkc                |   | j                   j                  j                  dt        |       dt        |       dd|      }	 d|j                  cxk  rdk  rin nft        j                  t
        j                  t           t        t
        j                  t           |j                                     }t        ||	      S |j                         }t        |j                  t        |j                        |
      # t        $ r6 t        |j                  t        |j                        |j                   
      w xY w)a	  
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Retrieve a list of tasks and assignees for those tasks for a specific project.

        Parameters
        ----------
        id : int
            A unique integer value identifying this project.

        task_pk : int
            A unique integer value identifying this task.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[typing.List[TaskAssignment]]
            List of assignments for the task
        r.   /tasks/
/assigneesGETr;   r'   r?   r@   rA   rC   rI   )r   rK   rL   r
   rJ   rN   rO   Listr   r   r<   r	   r   r   rP   r=   rR   r    r(   rY   r'   rT   rU   rV   s          r!   listzRawAssignmentsClient.listw   s   8 ((55==,R019I'9R8SS]^+ > 
	
	ti++1c1KK/"$kk.9 ) 0 $YUCC&^^-N 9#8#8$yGXGXBY`noo  	ty'<'<d9K\K\F]dmdrdrss	ts   A=C< C< <?D;c                P   | j                   j                  j                  dt        |       dt        |       dd||dddi|t              }	 d	|j
                  cxk  rd
k  rGn nDt        j                  t        t        t        |j                                     }t        ||      S |j                         }t        |j
                  t        |j                        |      # t        $ r6 t        |j
                  t        |j                        |j                         w xY w)am  
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Assign a user to a task in a specific project.

        Parameters
        ----------
        id : int
            A unique integer value identifying this project.

        task_pk : int
            A unique integer value identifying this task.

        type : AssignAssignmentsRequestType
            Assignment type. Use AN for annotate or RE for review.

        users : typing.Sequence[int]
            List of user IDs to assign

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[TaskAssignment]

        r.   r[   r\   r0   r*   r+   r8   r9   r:   r?   r@   rA   rC   rI   r   rK   rL   r
   rM   rJ   rN   rO   r   r   r<   r	   r   r   rP   r=   rR   	r    r(   rY   r*   r+   r'   rT   rU   rV   s	            r!   assignzRawAssignmentsClient.assign   s!   P ((55==,R019I'9R8SS]^
  2 , > 
		ti++1c1"", ) 0 $YUCC&^^-N 9#8#8$yGXGXBY`noo  	ty'<'<d9K\K\F]dmdrdrss	t   AC& +C& &?D%r*   r+   r'   c                   | j                   j                  j                  dt        |       dt        |       dd||d|      }	 d|j                  cxk  rdk  rn nt        |d	
      S |j                         }t        |j                  t        |j                        |      # t        $ r6 t        |j                  t        |j                        |j                        w xY w)a  
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Remove assignees for a task within a specific project.

        Parameters
        ----------
        id : int
            A unique integer value identifying this project.

        task_pk : int
            A unique integer value identifying this task.

        type : typing.Optional[DeleteAssignmentsRequestType]
            Assignment type to delete (optional). If omitted, deletes all assignments for the task.

        users : typing.Optional[str]
            Comma separated list of user IDs to delete, as a string. If omitted, deletes all assignees for the given type.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[None]
        r.   r[   r\   DELETErc   r;   paramsr'   r?   r@   NrC   rI   )r   rK   rL   r
   rJ   r	   r<   r   r   rP   r=   rR   r    r(   rY   r*   r+   r'   rT   rV   s           r!   deletezRawAssignmentsClient.delete   s    N ((55==,R019I'9R8SS]^ , > 
		ti++1c1#YTBB&^^-N 9#8#8$yGXGXBY`noo  	ty'<'<d9K\K\F]dmdrdrss	ts   $B' ,B' '?C&c                P   | j                   j                  j                  dt        |       dt        |       dd||dddi|t              }	 d	|j
                  cxk  rd
k  rGn nDt        j                  t        t        t        |j                                     }t        ||      S |j                         }t        |j
                  t        |j                        |      # t        $ r6 t        |j
                  t        |j                        |j                         w xY w)at  
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Update the assignee for a task in a specific project.

        Parameters
        ----------
        id : int
            A unique integer value identifying this project.

        task_pk : int
            A unique integer value identifying this task.

        type : UpdateAssignmentsRequestType
            Assignment type. Use AN for annotate or RE for review.

        users : typing.Sequence[int]
            List of user IDs to assign

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[TaskAssignment]

        r.   r[   r\   PATCHrc   r8   r9   r:   r?   r@   rA   rC   rI   rd   re   s	            r!   updatezRawAssignmentsClient.update#  s!   P ((55==,R019I'9R8SS]^
  2 , > 
		ti++1c1"", ) 0 $YUCC&^^-N 9#8#8$yGXGXBY`noo  	ty'<'<d9K\K\F]dmdrdrss	trg   )__name__
__module____qualname__r   r"   rM   intr   r   rN   SequenceOptionalr   r   r	   r   rW   r_   r   ra   r   rf   r   strrn   r   rq    r$   r!   r   r      s(   .*; . IM;?VpVp B	Vp
 /Vp s#Vp !DEVp  8Vp 
3	4Vpr \`.p.p #.p9?9X.p	fkk.1	2.pn <@BpBp Bp
 +Bp s#Bp  8Bp 
n	%BpR ?C&*;?6p6p 6p
 oo:;6p s#6p  86p 
d	6p~ <@BpBp Bp
 +Bp s#Bp  8Bp 
n	%Bpr$   r   c                   .   e Zd ZdefdZedddededede	j                  e   d	e	j                  e   d
e	j                  e   dee   fdZdddeded
e	j                  e   dee	j"                  e      fdZdddededede	j                  e   d
e	j                  e   dee   fdZdddddedede	j                  e   de	j                  e   d
e	j                  e   ded   fdZdddededede	j                  e   d
e	j                  e   dee   fdZy)AsyncRawAssignmentsClientr   c                    || _         y r   r   r   s     r!   r"   z"AsyncRawAssignmentsClient.__init__i  r#   r$   Nr%   r(   r)   r*   r+   r&   r'   r,   c                  K   | j                   j                  j                  dt        |       ddt	        |t
        d      t	        |t        d      ||dddi|t        	       d
{   }	 d|j                  cxk  rdk  rGn nDt        j                  t        t        t        |j                                     }t        ||      S |j                  dk(  rit        t!        |j"                        t        j                  t        j$                  t        t        j$                  |j                                           |j                         }	t)        |j                  t!        |j"                        |	      7 # t&        $ r6 t)        |j                  t!        |j"                        |j*                        w xY ww)a.  
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Assign multiple users to a collection of tasks within a specific project.

        Parameters
        ----------
        id : int

        selected_items : BulkAssignAssignmentsRequestSelectedItems
            Task selection by IDs. If filters are applied, the selection will be applied to the filtered tasks.If "all" is `false`, `"included"` must be used. If "all" is `true`, `"excluded"` must be used.<br>Examples: `{"all": false, "included": [1, 2, 3]}` or `{"all": true, "excluded": [4, 5]}`

        type : BulkAssignAssignmentsRequestType
            Assignment type. Use AN for annotate or RE for review.

        users : typing.Sequence[int]
            List of user IDs to assign

        filters : typing.Optional[BulkAssignAssignmentsRequestFilters]
            Filters to apply on tasks. You can use [the helper class `Filters` from this page](https://labelstud.io/sdk/data_manager.html) to create Data Manager Filters.<br>Example: `{"conjunction": "or", "items": [{"filter": "filter:tasks:completed_at", "operator": "greater", "type": "Datetime", "value": "2021-01-01T00:00:00.000Z"}]}`

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[BulkAssignAssignmentsResponse]
            Success
        r.   r/   r0   r1   r2   r6   r8   r9   r:   Nr?   r@   rA   rC   rF   rG   rI   )r   rK   rL   r
   r   r   r   rM   rJ   rN   rO   r   r   r<   r   r   rP   r=   rQ   r   r   rR   rS   s
             r!   rW   z%AsyncRawAssignmentsClient.bulk_assignl  s    V ..;;CC,R011ABB#0S_f "I*7`ls" 	  2 ,# D 
 
	&	ti++1c11"; ) 0 ))%HH$$+% !2!23

&"(**$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`nooW
R  	ty'<'<d9K\K\F]dmdrdrss	ts8   A'G)E>*G/AF 
GBF ,G?G  GrX   rY   c                  K   | j                   j                  j                  dt        |       dt        |       dd|       d{   }	 d|j                  cxk  rdk  rin nft        j                  t
        j                  t           t        t
        j                  t           |j                         	            }t        ||
      S |j                         }t        |j                  t        |j                        |      7 # t        $ r6 t        |j                  t        |j                        |j                         w xY ww)a  
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Retrieve a list of tasks and assignees for those tasks for a specific project.

        Parameters
        ----------
        id : int
            A unique integer value identifying this project.

        task_pk : int
            A unique integer value identifying this task.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[typing.List[TaskAssignment]]
            List of assignments for the task
        r.   r[   r\   r]   r^   Nr?   r@   rA   rC   rI   )r   rK   rL   r
   rJ   rN   rO   r_   r   r   r<   r   r   r   rP   r=   rR   r`   s          r!   ra   zAsyncRawAssignmentsClient.list  s#    8 ..;;CC,R019I'9R8SS]^+ D 
 
	
	ti++1c1KK/"$kk.9 ) 0 ))%HH&^^-N 9#8#8$yGXGXBY`noo%
   	ty'<'<d9K\K\F]dmdrdrss	ts7   AE
DE
A=D 
E
D ,E
?EE
c                l  K   | j                   j                  j                  dt        |       dt        |       dd||dddi|t               d	{   }	 d
|j
                  cxk  rdk  rGn nDt        j                  t        t        t        |j                                     }t        ||      S |j                         }t        |j
                  t        |j                        |      7 # t        $ r6 t        |j
                  t        |j                        |j                         w xY ww)ar  
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Assign a user to a task in a specific project.

        Parameters
        ----------
        id : int
            A unique integer value identifying this project.

        task_pk : int
            A unique integer value identifying this task.

        type : AssignAssignmentsRequestType
            Assignment type. Use AN for annotate or RE for review.

        users : typing.Sequence[int]
            List of user IDs to assign

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[TaskAssignment]

        r.   r[   r\   r0   rc   r8   r9   r:   Nr?   r@   rA   rC   rI   r   rK   rL   r
   rM   rJ   rN   rO   r   r   r<   r   r   r   rP   r=   rR   re   s	            r!   rf   z AsyncRawAssignmentsClient.assign  s/    P ..;;CC,R019I'9R8SS]^
  2 , D 
 
		ti++1c1"", ) 0 ))%HH&^^-N 9#8#8$yGXGXBY`noo5
0  	ty'<'<d9K\K\F]dmdrdrss	t7   AD4C0D4AC2 4D45C2 ,D42?D11D4rh   c                  K   | j                   j                  j                  dt        |       dt        |       dd||d|       d{   }	 d|j                  cxk  rd	k  rn nt        |d
      S |j                         }t        |j                  t        |j                        |      7 e# t        $ r6 t        |j                  t        |j                        |j                        w xY ww)a  
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Remove assignees for a task within a specific project.

        Parameters
        ----------
        id : int
            A unique integer value identifying this project.

        task_pk : int
            A unique integer value identifying this task.

        type : typing.Optional[DeleteAssignmentsRequestType]
            Assignment type to delete (optional). If omitted, deletes all assignments for the task.

        users : typing.Optional[str]
            Comma separated list of user IDs to delete, as a string. If omitted, deletes all assignees for the given type.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[None]
        r.   r[   r\   rj   rc   rk   Nr?   r@   rC   rI   )r   rK   rL   r
   rJ   r   r<   r   r   rP   r=   rR   rm   s           r!   rn   z AsyncRawAssignmentsClient.delete8  s     N ..;;CC,R019I'9R8SS]^ , D 
 
		ti++1c1()$GG&^^-N 9#8#8$yGXGXBY`noo
  	ty'<'<d9K\K\F]dmdrdrss	ts6   A	C5B1C5$B3 5C56B3 ,C53?C22C5c                l  K   | j                   j                  j                  dt        |       dt        |       dd||dddi|t               d	{   }	 d
|j
                  cxk  rdk  rGn nDt        j                  t        t        t        |j                                     }t        ||      S |j                         }t        |j
                  t        |j                        |      7 # t        $ r6 t        |j
                  t        |j                        |j                         w xY ww)ay  
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Update the assignee for a task in a specific project.

        Parameters
        ----------
        id : int
            A unique integer value identifying this project.

        task_pk : int
            A unique integer value identifying this task.

        type : UpdateAssignmentsRequestType
            Assignment type. Use AN for annotate or RE for review.

        users : typing.Sequence[int]
            List of user IDs to assign

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[TaskAssignment]

        r.   r[   r\   rp   rc   r8   r9   r:   Nr?   r@   rA   rC   rI   r   re   s	            r!   rq   z AsyncRawAssignmentsClient.updatep  s/    P ..;;CC,R019I'9R8SS]^
  2 , D 
 
		ti++1c1"", ) 0 ))%HH&^^-N 9#8#8$yGXGXBY`noo5
0  	ty'<'<d9K\K\F]dmdrdrss	tr   )rr   rs   rt   r   r"   rM   ru   r   r   rN   rv   rw   r   r   r   r   rW   r_   r   ra   r   rf   r   rx   rn   r   rq   ry   r$   r!   r{   r{   h  s(   .*< . IM;?VpVp B	Vp
 /Vp s#Vp !DEVp  8Vp 
8	9Vpr \`.p.p #.p9?9X.p	6;;~6	7.pn <@BpBp Bp
 +Bp s#Bp  8Bp 
>	*BpR ?C&*;?6p6p 6p
 oo:;6p s#6p  86p 
4	 6p~ <@BpBp Bp
 +Bp s#Bp  8Bp 
>	*Bpr$   r{   )*rN   json.decoderr   core.api_errorr   core.client_wrapperr   r   core.http_responser   r	   core.jsonable_encoderr
   core.request_optionsr   core.serializationr   core.unchecked_base_modelr   errors.bad_request_errorr   types.task_assignmentr   %types.assign_assignments_request_typer   -types.bulk_assign_assignments_request_filtersr   4types.bulk_assign_assignments_request_selected_itemsr   *types.bulk_assign_assignments_request_typer   &types.bulk_assign_assignments_responser   %types.delete_assignments_request_typer   %types.update_assignments_request_typer   rO   rQ   rM   r   r{   ry   r$   r!   <module>r      sr     ( & H A 5 2 I 7 7 3 O ^ k X Q O O v{{6::s#Jp JpZ
Jp Jpr$   