
    ]j+h                    N   d dl mZ d dlZd dlZd dlZddlmZ ddlmZm	Z	 ddl
mZ ej                  rddlmZmZ ddlmZmZ dd	lmZmZ dd
lmZmZ ddlmZmZ ddlmZmZ ddlm Z m!Z! ddl"m#Z#m$Z$ ddl%m&Z&m'Z' ddl(m)Z)m*Z* ddl+m,Z,m-Z- ddl.m/Z/m0Z0 ddl1m2Z2m3Z3 ddl4m5Z5m6Z6 ddl7m8Z8m9Z9 ddl:m;Z;m<Z< ddl=m>Z>m?Z? ddl@mAZAmBZB ddlCmDZDmEZE ddlFmGZGmHZH ddlImJZJmKZK ddlLmMZMmNZN ddlOmPZPmQZQ ddlRmSZSmTZT ddlUmVZVmWZW dd lXmYZYmZZZ dd!l[m\Z\m]Z]  G d" d#      Z^ G d$ d%      Z_dd&d(d'Z`y))    )annotationsN   )ApiError)AsyncClientWrapperSyncClientWrapper)LabelStudioEnvironment)ActionsClientAsyncActionsClient)ActivityLogsClientAsyncActivityLogsClient)AnnotationHistoryClientAsyncAnnotationHistoryClient)AnnotationReviewsClientAsyncAnnotationReviewsClient)AnnotationsClientAsyncAnnotationsClient)AsyncBillingClientBillingClient)AsyncCommentsClientCommentsClient)AsyncExportStorageClientExportStorageClient)AsyncFilesClientFilesClient)AsyncImportStorageClientImportStorageClient)AsyncJwtSettingsClientJwtSettingsClient)AsyncMlClientMlClient)AsyncModelProvidersClientModelProvidersClient)AsyncOrganizationsClientOrganizationsClient)AsyncPredictionsClientPredictionsClient)AsyncProjectTemplatesClientProjectTemplatesClient)AsyncProjectsClientProjectsClient)AsyncPromptsClientPromptsClient)AsyncSessionPolicyClientSessionPolicyClient)AsyncSsoClient	SsoClient)AsyncTasksClientTasksClient)AsyncTokensClientTokensClient)AsyncUsersClientUsersClient)AsyncVersionsClientVersionsClient)AsyncViewsClientViewsClient)AsyncWebhooksClientWebhooksClient)AsyncWorkspacesClientWorkspacesClientc                  (   e Zd ZdZdej
                   ej                  d      ddddd	 	 	 	 	 	 	 	 	 	 	 	 	 d"dZe	d        Z
e	d        Ze	d	        Ze	d
        Ze	d        Ze	d        Ze	d        Ze	d        Ze	d        Ze	d        Ze	d        Ze	d        Ze	d        Ze	d        Ze	d        Ze	d        Ze	d        Ze	d        Ze	d        Ze	d        Ze	d        Ze	d        Ze	d        Z e	d        Z!e	d        Z"e	d         Z#e	d!        Z$y)#LabelStudioBasea  
    Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.

    Parameters
    ----------
    base_url : typing.Optional[str]
        The base url to use for requests from the client.

    environment : LabelStudioEnvironment
        The environment to use for requests from the client. from .environment import LabelStudioEnvironment



        Defaults to LabelStudioEnvironment.DEFAULT



    api_key : typing.Optional[str]
    headers : typing.Optional[typing.Dict[str, str]]
        Additional headers to send with every request.

    timeout : typing.Optional[float]
        The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.

    follow_redirects : typing.Optional[bool]
        Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.

    httpx_client : typing.Optional[httpx.Client]
        The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.

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

    client = LabelStudio(
        api_key="YOUR_API_KEY",
    )
    NLABEL_STUDIO_API_KEYTbase_urlenvironmentapi_keyheaderstimeoutfollow_redirectshttpx_clientc          	     x   ||n|dn|j                   j                  }|t        d      t        t	        ||      ||||n.|t        j                  ||      nt        j                  |      |      | _        d | _        d | _	        d | _
        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _         d | _!        d | _"        y N<   z\The client must be instantiated be either passing in api_key or setting LABEL_STUDIO_API_KEY)bodyrC   rD   )rG   rH   )rG   )rC   rE   rF   rI   rG   )#rG   readr   r   _get_base_urlhttpxClient_client_wrapper_activity_logs_annotation_history_annotation_reviews_annotations_billing	_comments_users_actions_views_organizations_files_jwt_settings_ml_model_providers_prompts_predictions_project_templates	_projects_tasks_session_policy_import_storage_export_storage_tokens	_versions	_webhooks_workspaces_sso	selfrC   rD   rE   rF   rG   rH   rI   _defaulted_timeouts	            F/root/env/lib/python3.12/site-packages/label_studio_sdk/base_client.py__init__zLabelStudioBase.__init__S   s`    *Gl6JP\PdPdPiPi 	 ?s   1"H+N' &  + &8K[\&89&
 
 DHMQ MQ @D8<:>488<48DH48AE.2GK8<@DKO:>48EIEIEI6::>:>>B04	    c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r   client_wrapper)rT   activity_logs.clientr   rS   )rp   r   s     rr   activity_logszLabelStudioBase.activity_logs   s0    &@"4DDXDX"YD"""rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r   rv   )rU   annotation_history.clientr   rS   )rp   r   s     rr   annotation_historyz"LabelStudioBase.annotation_history   0    ##+J'>dNbNb'cD$'''rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r   rv   )rV   annotation_reviews.clientr   rS   )rp   r   s     rr   annotation_reviewsz"LabelStudioBase.annotation_reviews   r}   rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r   rv   )rW   annotations.clientr   rS   )rp   r   s     rr   r   zLabelStudioBase.annotations   0    $= 1AUAU VD   rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r   rv   )rX   billing.clientr   rS   )rp   r   s     rr   billingzLabelStudioBase.billing   +    == 5)9M9MNDM}}rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r   rv   )rY   comments.clientr   rS   )rp   r   s     rr   commentszLabelStudioBase.comments   +    >>!7+4;O;OPDN~~rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r6   rv   )rZ   users.clientr6   rS   )rp   r6   s     rr   userszLabelStudioBase.users   +    ;;1%T5I5IJDK{{rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r	   rv   )r[   actions.clientr	   rS   )rp   r	   s     rr   actionszLabelStudioBase.actions   r   rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r:   rv   )r\   views.clientr:   rS   )rp   r:   s     rr   viewszLabelStudioBase.views   r   rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r$   rv   )r]   organizations.clientr$   rS   )rp   r$   s     rr   organizationszLabelStudioBase.organizations   s0    &A"5TEYEY"ZD"""rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r   rv   )r^   files.clientr   rS   )rp   r   s     rr   fileszLabelStudioBase.files   r   rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r   rv   )r_   jwt_settings.clientr   rS   )rp   r   s     rr   jwt_settingszLabelStudioBase.jwt_settings   s0    %>!2$BVBV!WD!!!rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r    rv   )r`   	ml.clientr    rS   )rp   r    s     rr   mlzLabelStudioBase.ml   s*    88+t/C/CDDHxxrt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r"   rv   )ra   model_providers.clientr"   rS   )rp   r"   s     rr   model_providerszLabelStudioBase.model_providers   s0      (D$8H\H\$]D!$$$rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r,   rv   )rb   prompts.clientr,   rS   )rp   r,   s     rr   promptszLabelStudioBase.prompts   r   rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r&   rv   )rc   predictions.clientr&   rS   )rp   r&   s     rr   predictionszLabelStudioBase.predictions  r   rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r(   rv   )rd   project_templates.clientr(   rS   )rp   r(   s     rr   project_templatesz!LabelStudioBase.project_templates  s0    ""*H&<DL`L`&aD#&&&rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r*   rv   )re   projects.clientr*   rS   )rp   r*   s     rr   projectszLabelStudioBase.projects  r   rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r2   rv   )rf   tasks.clientr2   rS   )rp   r2   s     rr   taskszLabelStudioBase.tasks  r   rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r.   rv   )rg   session_policy.clientr.   rS   )rp   r.   s     rr   session_policyzLabelStudioBase.session_policy$  0    'B#6dFZFZ#[D ###rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r   rv   )rh   import_storage.clientr   rS   )rp   r   s     rr   import_storagezLabelStudioBase.import_storage,  r   rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r   rv   )ri   export_storage.clientr   rS   )rp   r   s     rr   export_storagezLabelStudioBase.export_storage4  r   rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r4   rv   )rj   tokens.clientr4   rS   )rp   r4   s     rr   tokenszLabelStudioBase.tokens<  s+    <<3't7K7KLDL||rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r8   rv   )rk   versions.clientr8   rS   )rp   r8   s     rr   versionszLabelStudioBase.versionsD  r   rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r<   rv   )rl   webhooks.clientr<   rS   )rp   r<   s     rr   webhookszLabelStudioBase.webhooksL  r   rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r>   rv   )rm   workspaces.clientr>   rS   )rp   r>   s     rr   
workspaceszLabelStudioBase.workspacesT  s0    #;/t?S?STDrt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r0   rv   )rn   
sso.clientr0   rS   )rp   r0   s     rr   ssozLabelStudioBase.sso\  s+    99-!1E1EFDIyyrt   )rC   typing.Optional[str]rD   r   rE   r   rF   &typing.Optional[typing.Dict[str, str]]rG   typing.Optional[float]rH   typing.Optional[bool]rI   ztyping.Optional[httpx.Client]%__name__
__module____qualname____doc__r   DEFAULTosgetenvrs   propertyry   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    rt   rr   r@   r@   +   s   %T *..D.L.L(1		2H(I:>*.266:75 '75 ,	75
 &75 875 (75 075 475r # # ( ( ( ( ! !           # #   " "   % %   ! ! ' '     $ $ $ $ $ $            rt   r@   c                  (   e Zd ZdZdej
                   ej                  d      ddddd	 	 	 	 	 	 	 	 	 	 	 	 	 d"dZe	d        Z
e	d        Ze	d	        Ze	d
        Ze	d        Ze	d        Ze	d        Ze	d        Ze	d        Ze	d        Ze	d        Ze	d        Ze	d        Ze	d        Ze	d        Ze	d        Ze	d        Ze	d        Ze	d        Ze	d        Ze	d        Ze	d        Ze	d        Z e	d        Z!e	d        Z"e	d         Z#e	d!        Z$y)#AsyncLabelStudioBasea  
    Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.

    Parameters
    ----------
    base_url : typing.Optional[str]
        The base url to use for requests from the client.

    environment : LabelStudioEnvironment
        The environment to use for requests from the client. from .environment import LabelStudioEnvironment



        Defaults to LabelStudioEnvironment.DEFAULT



    api_key : typing.Optional[str]
    headers : typing.Optional[typing.Dict[str, str]]
        Additional headers to send with every request.

    timeout : typing.Optional[float]
        The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.

    follow_redirects : typing.Optional[bool]
        Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.

    httpx_client : typing.Optional[httpx.AsyncClient]
        The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.

    Examples
    --------
    from label_studio_sdk import AsyncLabelStudio

    client = AsyncLabelStudio(
        api_key="YOUR_API_KEY",
    )
    NrA   TrB   c          	     x   ||n|dn|j                   j                  }|t        d      t        t	        ||      ||||n.|t        j                  ||      nt        j                  |      |      | _        d | _        d | _	        d | _
        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _         d | _!        d | _"        y rK   )#rG   rO   r   r   rP   rQ   AsyncClientrS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   rk   rl   rm   rn   ro   s	            rr   rs   zAsyncLabelStudioBase.__init__  sd    *Gl6JP\PdPdPiPi 	 ?s   2"H+N' &  + ""+=P`a""+=>&
 
 IMRV RV EI=A?C9==A9=IM9=FJ37LP=AEIPT?C9=JNJNJN;??C?CCG59	rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r   rv   )rT   rx   r   rS   )rp   r   s     rr   ry   z"AsyncLabelStudioBase.activity_logs  s0    &E"9I]I]"^D"""rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r   rv   )rU   r{   r   rS   )rp   r   s     rr   r|   z'AsyncLabelStudioBase.annotation_history  1    ##+O'CSWSgSg'hD$'''rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r   rv   )rV   r   r   rS   )rp   r   s     rr   r   z'AsyncLabelStudioBase.annotation_reviews  r   rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r   rv   )rW   r   r   rS   )rp   r   s     rr   r   z AsyncLabelStudioBase.annotations  0    $B 6dFZFZ [D   rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r   rv   )rX   r   r   rS   )rp   r   s     rr   r   zAsyncLabelStudioBase.billing  +    == :.d>R>RSDM}}rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r   rv   )rY   r   r   rS   )rp   r   s     rr   r   zAsyncLabelStudioBase.comments  +    >>!<0@T@TUDN~~rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r5   rv   )rZ   r   r5   rS   )rp   r5   s     rr   r   zAsyncLabelStudioBase.users  +    ;;6*$:N:NODK{{rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r
   rv   )r[   r   r
   rS   )rp   r
   s     rr   r   zAsyncLabelStudioBase.actions  r   rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r9   rv   )r\   r   r9   rS   )rp   r9   s     rr   r   zAsyncLabelStudioBase.views  r   rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r#   rv   )r]   r   r#   rS   )rp   r#   s     rr   r   z"AsyncLabelStudioBase.organizations  s0    &F":$J^J^"_D"""rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r   rv   )r^   r   r   rS   )rp   r   s     rr   r   zAsyncLabelStudioBase.files  r   rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r   rv   )r_   r   r   rS   )rp   r   s     rr   r   z!AsyncLabelStudioBase.jwt_settings  s0    %C!7tG[G[!\D!!!rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r   rv   )r`   r   r   rS   )rp   r   s     rr   r   zAsyncLabelStudioBase.ml&  s*    880$D4H4HIDHxxrt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r!   rv   )ra   r   r!   rS   )rp   r!   s     rr   r   z$AsyncLabelStudioBase.model_providers.  s0      (I$=TMaMa$bD!$$$rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r+   rv   )rb   r   r+   rS   )rp   r+   s     rr   r   zAsyncLabelStudioBase.prompts6  r   rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r%   rv   )rc   r   r%   rS   )rp   r%   s     rr   r   z AsyncLabelStudioBase.predictions>  r   rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r'   rv   )rd   r   r'   rS   )rp   r'   s     rr   r   z&AsyncLabelStudioBase.project_templatesF  s1    ""*M&AQUQeQe&fD#&&&rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r)   rv   )re   r   r)   rS   )rp   r)   s     rr   r   zAsyncLabelStudioBase.projectsN  r   rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r1   rv   )rf   r   r1   rS   )rp   r1   s     rr   r   zAsyncLabelStudioBase.tasksV  r   rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r-   rv   )rg   r   r-   rS   )rp   r-   s     rr   r   z#AsyncLabelStudioBase.session_policy^  0    'G#;4K_K_#`D ###rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r   rv   )rh   r   r   rS   )rp   r   s     rr   r   z#AsyncLabelStudioBase.import_storagef  r   rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r   rv   )ri   r   r   rS   )rp   r   s     rr   r   z#AsyncLabelStudioBase.export_storagen  r   rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r3   rv   )rj   r   r3   rS   )rp   r3   s     rr   r   zAsyncLabelStudioBase.tokensv  s+    <<8,D<P<PQDL||rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r7   rv   )rk   r   r7   rS   )rp   r7   s     rr   r   zAsyncLabelStudioBase.versions~  r   rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r;   rv   )rl   r   r;   rS   )rp   r;   s     rr   r   zAsyncLabelStudioBase.webhooks  r   rt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r=   rv   )rm   r   r=   rS   )rp   r=   s     rr   r   zAsyncLabelStudioBase.workspaces  s0    #@4DDXDXYDrt   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r/   rv   )rn   r   r/   rS   )rp   r/   s     rr   r   zAsyncLabelStudioBase.sso  s+    992&d6J6JKDIyyrt   )rC   r   rD   r   rE   r   rF   r   rG   r   rH   r   rI   z"typing.Optional[httpx.AsyncClient]r   r   rt   rr   r   r   e  s   %T *..D.L.L(1		2H(I:>*.26;?7: '7: ,	7:
 &7: 87: (7: 07: 97:r # # ( ( ( ( ! !           # #   " "   % %   ! ! ' '     $ $ $ $ $ $            rt   r   )rC   c                <    | | S ||j                   S t        d      )NzEPlease pass in either base_url or environment to construct the client)value	ExceptionrN   s     rr   rP   rP     s+    		    _``rt   )rC   r   rD   r   returnstr)a
__future__r   r   typingrQ   core.api_errorr   core.client_wrapperr   r   rD   r   TYPE_CHECKINGr   r	   r
   rx   r   r   r{   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r   r!   r"   r   r#   r$   r   r%   r&   r   r'   r(   r   r)   r*   r   r+   r,   r   r-   r.   r   r/   r0   r   r1   r2   r   r3   r4   r   r5   r6   r   r7   r8   r   r9   r:   r   r;   r<   r   r=   r>   r@   r   rP   r   rt   rr   <module>r
     s    # 	   $ F /	AQ``MADT;TN2WSM]DAT5;>;D;DJw wt	w wt	 7; art   