
    ]j+                         d dl Z ddlmZmZ ddl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  e j&                  e j(                  d      Z G d d      Z G d d      Zy)    N   )AsyncClientWrapperSyncClientWrapper)RequestOptions   )AsyncRawActionsClientRawActionsClient)CreateActionsRequestFilters)CreateActionsRequestId) CreateActionsRequestOrderingItem)!CreateActionsRequestSelectedItems)ListActionsResponseItem.c                   N   e Zd ZdefdZedefd       Zdddede	j                  e   de	j                  e   fd	Zdeeedd
dedede	j                  e   de	j                  e   de	j                  e	j$                  e      de	j                  e   de	j                  e   ddfdZy)ActionsClientclient_wrapperc                &    t        |      | _        y N)r   )r	   _raw_clientselfr   s     I/root/env/lib/python3.12/site-packages/label_studio_sdk/actions/client.py__init__zActionsClient.__init__   s    +>J    returnc                     | j                   S )z
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        RawActionsClient
        r   r   s    r   with_raw_responsezActionsClient.with_raw_response        r   Nrequest_optionsprojectr!   c                T    | j                   j                  ||      }|j                  S )au  
        Retrieve all the registered actions with descriptions that data manager can use.

        Parameters
        ----------
        project : int
            Project ID

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

        Returns
        -------
        typing.List[ListActionsResponseItem]
            Actions retrieved successfully

        Examples
        --------
        from label_studio_sdk import LabelStudio

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.actions.list(
            project=1,
        )
        r"   r!   r   listdatar   r"   r!   	_responses       r   r&   zActionsClient.list!   s)    < $$))'?)[	~~r   viewfiltersorderingselected_itemsr!   idr+   r,   r-   r.   c          	      ^    | j                   j                  |||||||      }|j                  S )a]  
        Perform a Data Manager action with the selected tasks and filters. Note: More complex actions require additional parameters in the request body. Call `GET api/actions?project=<id>` to explore them. <br>Example: `GET api/actions?id=delete_tasks&project=1`

        Parameters
        ----------
        id : CreateActionsRequestId
            Action name ID, see the full list of actions in the `GET api/actions` request

        project : int
            Project ID

        view : typing.Optional[int]
            View ID (optional, it has higher priority than filters, selectedItems and ordering from the request body payload)

        filters : typing.Optional[CreateActionsRequestFilters]
            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"}]}`

        ordering : typing.Optional[typing.Sequence[CreateActionsRequestOrderingItem]]
            List of fields to order by. Fields are similar to filters but without the `filter:` prefix. To reverse the order, add a minus sign before the field name, e.g. `-tasks:created_at`.

        selected_items : typing.Optional[CreateActionsRequestSelectedItems]
            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]}`

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

        Returns
        -------
        None

        Examples
        --------
        from label_studio_sdk import LabelStudio
        from label_studio_sdk.actions import (
            CreateActionsRequestFilters,
            CreateActionsRequestFiltersItemsItem,
            CreateActionsRequestSelectedItemsExcluded,
        )

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.actions.create(
            id="delete_annotators",
            project=1,
            filters=CreateActionsRequestFilters(
                conjunction="or",
                items=[
                    CreateActionsRequestFiltersItemsItem(
                        filter="filter:tasks:id",
                        operator="greater",
                        type="Number",
                        value=123,
                    )
                ],
            ),
            ordering=["tasks:total_annotations"],
            selected_items=CreateActionsRequestSelectedItemsExcluded(
                all_=True,
                excluded=[124, 125, 126],
            ),
        )
        r/   r"   r+   r,   r-   r.   r!   r   creater'   	r   r/   r"   r+   r,   r-   r.   r!   r)   s	            r   r3   zActionsClient.createB   sA    T $$++)+ , 
	 ~~r   )__name__
__module____qualname__r   r   propertyr	   r   inttypingOptionalr   Listr   r&   OMITr   r
   Sequencer   r   r3    r   r   r   r      s   K*; K  #3     SW060O	,	-L &*@DW[MQ;?S #S 	S
 ooc"S !<=S //&//2R"STS (IJS  8S 
Sr   r   c                   N   e Zd ZdefdZedefd       Zdddede	j                  e   de	j                  e   fd	Zdeeedd
dedede	j                  e   de	j                  e   de	j                  e	j$                  e      de	j                  e   de	j                  e   ddfdZy)AsyncActionsClientr   c                &    t        |      | _        y r   )r   r   r   s     r   r   zAsyncActionsClient.__init__   s    0Or   r   c                     | j                   S )z
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        AsyncRawActionsClient
        r   r   s    r   r   z$AsyncActionsClient.with_raw_response   r   r   Nr    r"   r!   c                p   K   | j                   j                  ||       d{   }|j                  S 7 w)a  
        Retrieve all the registered actions with descriptions that data manager can use.

        Parameters
        ----------
        project : int
            Project ID

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

        Returns
        -------
        typing.List[ListActionsResponseItem]
            Actions retrieved successfully

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.actions.list(
                project=1,
            )


        asyncio.run(main())
        r$   Nr%   r(   s       r   r&   zAsyncActionsClient.list   s8     L **//Q`/aa	~~ bs   !646r*   r/   r+   r,   r-   r.   c          	      z   K   | j                   j                  |||||||       d{   }|j                  S 7 w)a  
        Perform a Data Manager action with the selected tasks and filters. Note: More complex actions require additional parameters in the request body. Call `GET api/actions?project=<id>` to explore them. <br>Example: `GET api/actions?id=delete_tasks&project=1`

        Parameters
        ----------
        id : CreateActionsRequestId
            Action name ID, see the full list of actions in the `GET api/actions` request

        project : int
            Project ID

        view : typing.Optional[int]
            View ID (optional, it has higher priority than filters, selectedItems and ordering from the request body payload)

        filters : typing.Optional[CreateActionsRequestFilters]
            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"}]}`

        ordering : typing.Optional[typing.Sequence[CreateActionsRequestOrderingItem]]
            List of fields to order by. Fields are similar to filters but without the `filter:` prefix. To reverse the order, add a minus sign before the field name, e.g. `-tasks:created_at`.

        selected_items : typing.Optional[CreateActionsRequestSelectedItems]
            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]}`

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

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio
        from label_studio_sdk.actions import (
            CreateActionsRequestFilters,
            CreateActionsRequestFiltersItemsItem,
            CreateActionsRequestSelectedItemsExcluded,
        )

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.actions.create(
                id="delete_annotators",
                project=1,
                filters=CreateActionsRequestFilters(
                    conjunction="or",
                    items=[
                        CreateActionsRequestFiltersItemsItem(
                            filter="filter:tasks:id",
                            operator="greater",
                            type="Number",
                            value=123,
                        )
                    ],
                ),
                ordering=["tasks:total_annotations"],
                selected_items=CreateActionsRequestSelectedItemsExcluded(
                    all_=True,
                    excluded=[124, 125, 126],
                ),
            )


        asyncio.run(main())
        r1   Nr2   r4   s	            r   r3   zAsyncActionsClient.create   sO     d **11)+ 2 
 
	 ~~
s   &;9;)r5   r6   r7   r   r   r8   r   r   r9   r:   r;   r   r<   r   r&   r=   r   r
   r>   r   r   r3   r?   r   r   rA   rA      s   P*< P  #8     SW''060O'	,	-'\ &*@DW[MQ;?[ #[ 	[
 ooc"[ !<=[ //&//2R"ST[ (IJ[  8[ 
[r   rA   )r:   core.client_wrapperr   r   core.request_optionsr   
raw_clientr   r	   $types.create_actions_request_filtersr
   types.create_actions_request_idr   *types.create_actions_request_ordering_itemr   +types.create_actions_request_selected_itemsr    types.list_actions_response_itemr   castAnyr=   r   rA   r?   r   r   <module>rP      sS     G 1 ? M C X Z E v{{6::s#C CLS Sr   