
    ]j6                         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  e j.                  e j0                  d      Z G d d      Z G d d      Zy)    N)JSONDecodeError   )ApiError)AsyncClientWrapperSyncClientWrapper)AsyncHttpResponseHttpResponse)RequestOptions)'convert_and_respect_annotation_metadata)construct_type)ProjectGroupRequest)SamlSettings)SamlSettingsUpdate.c                   F   e Zd ZdefdZdddej                  e   dee	   fdZ
eeeeeeeeeeddd	ej                  e   d
ej                  e   dej                  e   dej                  e   dej                  e   dej                  e   dej                  e   dej                  ej                  e      dej                  ej                  ej                  e         dej                  ej                  ej                  e         dej                  e   dee   fdZy)RawSamlClientclient_wrapperc                    || _         y N_client_wrapperselfr   s     N/root/env/lib/python3.12/site-packages/label_studio_sdk/sso/saml/raw_client.py__init__zRawSamlClient.__init__   
    -    Nrequest_optionsr   returnc                   | j                   j                  j                  dd|      }	 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)	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 SAML2 settings for the currently active organization.

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

        Returns
        -------
        HttpResponse[SamlSettings]

        api/saml/settingsGETmethodr      ,  type_object_responsedatastatus_codeheadersbody)r   httpx_clientrequestr.   typingcastr   r   jsonr	   r   r   dictr/   textr   r   	_response_data_response_jsons        r   getzRawSamlClient.get   s    ( ((55==+ > 
	
	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s   AC C ?D domainmapping_emailmapping_first_namemapping_groupsmapping_last_namemetadata_urlmetadata_xmlprojects_groupsroles_groupsworkspaces_groupsr   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   c                p   | j                   j                  j                  dd|||||||t        |t        j
                  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                         }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>
        Update SAML2 settings for the currently active organization.

        Parameters
        ----------
        domain : typing.Optional[str]
            Organization web domain or domains; use comma separated list with no spaces for multiple. Example:<br><br>labelstud.io,humansignal.com<br><br>IMPORTANT: DO NOT PUT COMMON DOMAINS LIKE GMAIL.COM, YAHOO.COM, ETC. IN THIS FIELD

        mapping_email : typing.Optional[str]
            Mapping attributes: user email from SAML request

        mapping_first_name : typing.Optional[str]
            Mapping attributes: user first name from SAML request

        mapping_groups : typing.Optional[str]
            Mapping attributes: groups attribute for user mapping to workspaces and roles

        mapping_last_name : typing.Optional[str]
            Mapping attributes: user last name from SAML request

        metadata_url : typing.Optional[str]
            URL SAML metadata from IdP

        metadata_xml : typing.Optional[str]
            Metadata XML file

        projects_groups : typing.Optional[typing.Sequence[ProjectGroupRequest]]
            Projects to Groups Mapping. List of objects with project_id, group, role.

        roles_groups : typing.Optional[typing.Sequence[typing.Sequence[str]]]
            Organization Roles to Groups Mapping. List of [role_name, group_name] pairs.

        workspaces_groups : typing.Optional[typing.Sequence[typing.Sequence[str]]]
            Workspaces to Groups Mapping. List of [workspace_title, group_name] pairs.

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

        Returns
        -------
        HttpResponse[SamlSettingsUpdate]

        r!   POSTwriter)   
annotation	direction
r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   content-typeapplication/jsonr$   r5   r/   r   omitr%   r&   r'   r*   r-   )r   r1   r2   r   r3   Sequencer   OMITr.   r4   r   r   r5   r	   r   r   r6   r/   r7   r   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   r   r9   r:   r;   s                  r   updatezRawSamlClient.update@   s4   @ ((55== !.&8"0%6 , ,#J+H[8\ho$ !-%6  2 ,+ > 
	.	ti++1c1&"0 ) 0 $YUCC&^^-N 9#8#8$yGXGXBY`noo  	ty'<'<d9K\K\F]dmdrdrss	ts   AC6 ;C6 6?D5)__name__
__module____qualname__r   r   r3   Optionalr
   r	   r   r<   rT   strrS   r   r   rV    r   r   r   r      s   .*; . IM &pfoon&E &pQ]^jQk &pV (,.237/326-1-1QUOSTX;?dp $dp s+	dp
 #OOC0dp ,dp "??3/dp ooc*dp ooc*dp  9L)MNdp oofoofooc6J&KLdp "??6??6??3;O+PQdp  8dp 
(	)dpr   r   c                   F   e Zd ZdefdZdddej                  e   dee	   fdZ
eeeeeeeeeeddd	ej                  e   d
ej                  e   dej                  e   dej                  e   dej                  e   dej                  e   dej                  e   dej                  ej                  e      dej                  ej                  ej                  e         dej                  ej                  ej                  e         dej                  e   dee   fdZy)AsyncRawSamlClientr   c                    || _         y r   r   r   s     r   r   zAsyncRawSamlClient.__init__   r   r   Nr   r   r   c                "  K   | j                   j                  j                  dd|       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)
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 SAML2 settings for the currently active organization.

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

        Returns
        -------
        AsyncHttpResponse[SamlSettings]

        r!   r"   r#   Nr%   r&   r'   r*   r-   )r   r1   r2   r.   r3   r4   r   r   r5   r   r   r   r6   r/   r7   r8   s        r   r<   zAsyncRawSamlClient.get   s     ( ..;;CC+ D 
 
	
	ti++1c1 "* ) 0 ))%HH&^^-N 9#8#8$yGXGXBY`noo%
   	ty'<'<d9K\K\F]dmdrdrss	ts3   ,DCDAC DC  ,D?DDr=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   c                  K   | j                   j                  j                  dd|||||||t        |t        j
                  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                         }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>
        Update SAML2 settings for the currently active organization.

        Parameters
        ----------
        domain : typing.Optional[str]
            Organization web domain or domains; use comma separated list with no spaces for multiple. Example:<br><br>labelstud.io,humansignal.com<br><br>IMPORTANT: DO NOT PUT COMMON DOMAINS LIKE GMAIL.COM, YAHOO.COM, ETC. IN THIS FIELD

        mapping_email : typing.Optional[str]
            Mapping attributes: user email from SAML request

        mapping_first_name : typing.Optional[str]
            Mapping attributes: user first name from SAML request

        mapping_groups : typing.Optional[str]
            Mapping attributes: groups attribute for user mapping to workspaces and roles

        mapping_last_name : typing.Optional[str]
            Mapping attributes: user last name from SAML request

        metadata_url : typing.Optional[str]
            URL SAML metadata from IdP

        metadata_xml : typing.Optional[str]
            Metadata XML file

        projects_groups : typing.Optional[typing.Sequence[ProjectGroupRequest]]
            Projects to Groups Mapping. List of objects with project_id, group, role.

        roles_groups : typing.Optional[typing.Sequence[typing.Sequence[str]]]
            Organization Roles to Groups Mapping. List of [role_name, group_name] pairs.

        workspaces_groups : typing.Optional[typing.Sequence[typing.Sequence[str]]]
            Workspaces to Groups Mapping. List of [workspace_title, group_name] pairs.

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

        Returns
        -------
        AsyncHttpResponse[SamlSettingsUpdate]

        r!   rI   rJ   rK   rN   rO   rP   rQ   Nr%   r&   r'   r*   r-   )r   r1   r2   r   r3   rS   r   rT   r.   r4   r   r   r5   r   r   r   r6   r/   r7   rU   s                  r   rV   zAsyncRawSamlClient.update   sD    @ ..;;CC !.&8"0%6 , ,#J+H[8\ho$ !-%6  2 ,+ D 
 
	.	ti++1c1&"0 ) 0 ))%HH&^^-N 9#8#8$yGXGXBY`nooI
D  	ty'<'<d9K\K\F]dmdrdrss	ts7   A!E#D $E)AD ED ,E?EE)rW   rX   rY   r   r   r3   rZ   r
   r   r   r<   rT   r[   rS   r   r   rV   r\   r   r   r^   r^      s   .*< . OS &pFOON,K &pWhiuWv &pV (,.237/326-1-1QUOSTX;?dp $dp s+	dp
 #OOC0dp ,dp "??3/dp ooc*dp ooc*dp  9L)MNdp oofoofooc6J&KLdp "??6??6??3;O+PQdp  8dp 
-	.dpr   r^   )r3   json.decoderr   core.api_errorr   core.client_wrapperr   r   core.http_responser   r	   core.request_optionsr
   core.serializationr   core.unchecked_base_modelr   types.project_group_requestr   types.saml_settingsr   types.saml_settings_updater   r4   AnyrT   r   r^   r\   r   r   <module>rm      s]     ( & H A 2 I 7 > / < v{{6::s#Pp PpfPp Ppr   