
    h3                        S SK Jr  S SKrS SKJr  S SKJr  S SKJrJ	r	J
r
JrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJ r J!r!  SSK"J#r#  SSK$J%r%J&r&  S	r'  " S
 S\#5      r(g)    )annotationsN)Optional)
ListUpdate)SIPTrunkInfoCreateSIPInboundTrunkRequestUpdateSIPInboundTrunkRequestSIPInboundTrunkInfoSIPInboundTrunkUpdateCreateSIPOutboundTrunkRequestUpdateSIPOutboundTrunkRequestSIPOutboundTrunkInfoSIPOutboundTrunkUpdateListSIPInboundTrunkRequestListSIPInboundTrunkResponseListSIPOutboundTrunkRequestListSIPOutboundTrunkResponseDeleteSIPTrunkRequestSIPDispatchRuleSIPDispatchRuleInfoSIPDispatchRuleUpdateCreateSIPDispatchRuleRequestUpdateSIPDispatchRuleRequestListSIPDispatchRuleRequestListSIPDispatchRuleResponseDeleteSIPDispatchRuleRequestCreateSIPParticipantRequestTransferSIPParticipantRequestSIPParticipantInfoSIPTransport   )Service)VideoGrants	SIPGrantsSIPc                    ^  \ rS rSrSrSU 4S jjr    SS jr      SS jrSSSSSSSS.                 SS jjr    SS	 jr	      S S
 jr
SSSSSSSS.                 S!S jjr    S"S jr    S#S jrS$S jr    S%S jr      S&S jrSSSSSS.             S'S jjr    S(S jr    S)S jrSS.     S*S jjr    S+S jrS,S jrSrU =r$ )-
SipService*   zClient for LiveKit SIP Service API

Recommended way to use this service is via `livekit.api.LiveKitAPI`:

```python
from livekit import api
lkapi = api.LiveKitAPI()
sip_service = lkapi.sip
```
c                &   > [         TU ]  XX45        g )N)super__init__)selfsessionurlapi_key
api_secret	__class__s        I/var/www/html/env/lib/python3.13/site-packages/livekit/api/sip_service.pyr*   SipService.__init__6   s    w;    c                   #    U R                   R                  [        SUU R                  5       [        5      I Sh  vN $  N7f)z|Create a new SIP inbound trunk.

Args:
    create: Request containing trunk details

Returns:
    Created SIP inbound trunk
CreateSIPInboundTrunkN)_clientrequestSVC_admin_headersr	   r+   creates     r1   create_sip_inbound_trunk#SipService.create_sip_inbound_trunk9   @      \\))#!
 
 	
 
   9AA Ac           	        #    U R                   R                  [        S[        UUS9U R	                  5       [
        5      I Sh  vN $  N7f)zUpdates an existing SIP inbound trunk by replacing it entirely.

Args:
    trunk_id: ID of the SIP inbound trunk to update
    trunk: SIP inbound trunk to update with

Returns:
    Updated SIP inbound trunk
UpdateSIPInboundTrunksip_trunk_idreplaceN)r6   r7   r8   r   r9   r	   r+   trunk_idtrunks      r1   update_sip_inbound_trunk#SipService.update_sip_inbound_trunkL   sM      \\))#(% !	
 	
 		
 	
   AA
AA
N)numbersallowed_addressesallowed_numbersauth_usernameauth_passwordnamemetadatac          	       #    [        UUUUS9n	Ub  [        US9U	l        Ub  [        US9U	l        Ub  [        US9U	l        U R
                  R                  [        S[        UU	S9U R                  5       [        5      I Sh  vN $  N7f)zaUpdates specific fields of an existing SIP inbound trunk.

Only provided fields will be updated.
)rN   rO   rP   rQ   NsetrA   rC   update)r
   r   rK   rL   rM   r6   r7   r8   r   r9   r	   )
r+   rF   rK   rL   rM   rN   rO   rP   rQ   rV   s
             r1   update_sip_inbound_trunk_fields*SipService.update_sip_inbound_trunk_fieldse   s       '''	
 'G4FN('16G'HF$&%/O%DF"\\))#(% !	
 	
 		
 	
s   B B	BB	c                   #    U R                   R                  [        SUU R                  5       [        5      I Sh  vN $  N7f)z~Create a new SIP outbound trunk.

Args:
    create: Request containing trunk details

Returns:
    Created SIP outbound trunk
CreateSIPOutboundTrunkN)r6   r7   r8   r9   r   r:   s     r1   create_sip_outbound_trunk$SipService.create_sip_outbound_trunk   s@      \\))$! 
 
 	
 
r?   c           	        #    U R                   R                  [        S[        UUS9U R	                  5       [
        5      I Sh  vN $  N7f)zUpdates an existing SIP outbound trunk by replacing it entirely.

Args:
    trunk_id: ID of the SIP outbound trunk to update
    trunk: SIP outbound trunk to update with

Returns:
    Updated SIP outbound trunk
UpdateSIPOutboundTrunkrB   N)r6   r7   r8   r   r9   r   rE   s      r1   update_sip_outbound_trunk$SipService.update_sip_outbound_trunk   sM      \\))$)% ! 	
 	
 		
 	
rJ   )address	transportrK   rN   rO   rP   rQ   c          	        #    [        UUUUUUS9n	Ub  [        US9U	l        U R                  R	                  [
        S[        UU	S9U R                  5       [        5      I Sh  vN $  N7f)zbUpdates specific fields of an existing SIP outbound trunk.

Only provided fields will be updated.
)ra   rb   rN   rO   rP   rQ   NrS   r^   rU   )	r   r   rK   r6   r7   r8   r   r9   r   )
r+   rF   ra   rb   rK   rN   rO   rP   rQ   rV   s
             r1    update_sip_outbound_trunk_fields+SipService.update_sip_outbound_trunk_fields   s}       (''
 'G4FN\\))$)% ! 	
 	
 		
 	
s   A A)"A'#A)c                   #    U R                   R                  [        SUU R                  5       [        5      I Sh  vN $  N7f)zList SIP inbound trunks with optional filtering.

Args:
    list: Request with optional filtering parameters

Returns:
    Response containing list of SIP inbound trunks
ListSIPInboundTrunkN)r6   r7   r8   r9   r   r+   lists     r1   list_sip_inbound_trunk!SipService.list_sip_inbound_trunk   @      \\))!!'
 
 	
 
r?   c                   #    U R                   R                  [        SUU R                  5       [        5      I Sh  vN $  N7f)zList SIP outbound trunks with optional filtering.

Args:
    list: Request with optional filtering parameters

Returns:
    Response containing list of SIP outbound trunks
ListSIPOutboundTrunkN)r6   r7   r8   r9   r   rh   s     r1   list_sip_outbound_trunk"SipService.list_sip_outbound_trunk   s@      \\))"!(
 
 	
 
r?   c                   #    U R                   R                  [        SUU R                  5       [        5      I Sh  vN $  N7f)zuDelete a SIP trunk.

Args:
    delete: Request containing trunk ID to delete

Returns:
    Deleted trunk information
DeleteSIPTrunkN)r6   r7   r8   r9   r   r+   deletes     r1   delete_sip_trunkSipService.delete_sip_trunk  s@      \\))!
 
 	
 
r?   c                   #    U R                   R                  [        SUU R                  5       [        5      I Sh  vN $  N7f)z{Create a new SIP dispatch rule.

Args:
    create: Request containing rule details

Returns:
    Created SIP dispatch rule
CreateSIPDispatchRuleNr6   r7   r8   r9   r   r:   s     r1   create_sip_dispatch_rule#SipService.create_sip_dispatch_rule  r>   r?   c           	        #    U R                   R                  [        S[        XS9U R	                  5       [
        5      I Sh  vN $  N7f)zUpdates an existing SIP dispatch rule by replacing it entirely.

Args:
    rule_id: ID of the SIP dispatch rule to update
    rule: SIP dispatch rule to update with

Returns:
    Updated SIP dispatch rule
UpdateSIPDispatchRule)sip_dispatch_rule_idrD   N)r6   r7   r8   r   r9   r   )r+   rule_idrules      r1   update_sip_dispatch_rule#SipService.update_sip_dispatch_rule(  sE      \\))#(gT!
 
 	
 
s   A A	AA	)	trunk_idsr   rP   rQ   
attributesc          	        #    [        XEX6S9nUb  [        US9Ul        U R                  R	                  [
        S[        XS9U R                  5       [        5      I Sh  vN $  N7f)zaUpdates specific fields of an existing SIP dispatch rule.

Only provided fields will be updated.
)rP   rQ   r   r   NrS   r}   )r~   rV   )	r   r   r   r6   r7   r8   r   r9   r   )r+   r   r   r   rP   rQ   r   rV   s           r1   update_sip_dispatch_rule_fields*SipService.update_sip_dispatch_rule_fields>  si      't
  )i8F\\))#(gU!
 
 	
 
s   AA$A"A$c                   #    U R                   R                  [        SUU R                  5       [        5      I Sh  vN $  N7f)zList SIP dispatch rules with optional filtering.

Args:
    list: Request with optional filtering parameters

Returns:
    Response containing list of SIP dispatch rules
ListSIPDispatchRuleN)r6   r7   r8   r9   r   rh   s     r1   list_sip_dispatch_rule!SipService.list_sip_dispatch_ruleY  rl   r?   c                   #    U R                   R                  [        SUU R                  5       [        5      I Sh  vN $  N7f)z{Delete a SIP dispatch rule.

Args:
    delete: Request containing rule ID to delete

Returns:
    Deleted rule information
DeleteSIPDispatchRuleNry   rs   s     r1   delete_sip_dispatch_rule#SipService.delete_sip_dispatch_rulel  r>   r?   timeoutc               .  #    SnU(       a  [         R                  " US9nOUR                  (       a  U R                  R                  R
                  (       aq  U R                  R                  R
                  R                  (       aB  U R                  R                  R
                  R                  S:  a  [         R                  " SS9nU R                  R                  [        SUU R                  [        5       [        SS9S9[        US9I Sh  vN $  N7f)	zCreate a new SIP participant.

Args:
    create: Request containing participant details
    timeout: Optional request timeout in seconds

Returns:
    Created SIP participant

Raises:
    SIPError: If the SIP operation fails
N)total   CreateSIPParticipantTcallsipr   )aiohttpClientTimeoutwait_until_answeredr6   _sessionr   r   r7   r8   _auth_headerr"   r#   r   )r+   r;   r   client_timeouts       r1   create_sip_participant!SipService.create_sip_participant  s     $ ;?$22AN'' %%--LL))1177LL))1177"<!(!6!6R!@\\))"km1EF" * 
 
 	
 
s   DDDDc                   #    U R                   R                  [        SUU R                  [	        SUR
                  S9[        SS9S9[        5      I Sh  vN $  N7f)zTransfer a SIP participant to a different room.

Args:
    transfer: Request containing transfer details

Returns:
    Updated SIP participant information
TransferSIPParticipantT)
room_adminroomr   r   N)r6   r7   r8   r   r"   	room_namer#   r   )r+   transfers     r1   transfer_sip_participant#SipService.transfer_sip_participant  sg      \\))$#!++ 4(   
 
 	
 
s   AAAAc                @    U R                  [        5       [        SS9S9$ )NT)adminr   )r   r"   r#   )r+   s    r1   r9   SipService._admin_headers  s      ID4I JJr3    )r,   zaiohttp.ClientSessionr-   strr.   r   r/   r   )r;   r   returnr	   )rF   r   rG   r	   r   r	   )rF   r   rK   Optional[list[str]]rL   r   rM   r   rN   Optional[str]rO   r   rP   r   rQ   r   r   r	   )r;   r   r   r   )rF   r   rG   r   r   r   )rF   r   ra   
str | Nonerb   zSIPTransport | NonerK   zlist[str] | NonerN   r   rO   r   rP   r   rQ   r   r   r   )ri   r   r   r   )ri   r   r   r   )rt   r   r   r   )r;   r   r   r   )r   r   r   r   r   r   )r   r   r   r   r   zOptional[SIPDispatchRule]rP   r   rQ   r   r   zOptional[dict[str, str]]r   r   )ri   r   r   r   )rt   r   r   r   )r;   r   r   zOptional[float]r   r   )r   r   r   r   )r   zdict[str, str])__name__
__module____qualname____firstlineno____doc__r*   r<   rH   rW   r[   r_   rd   rj   ro   ru   rz   r   r   r   r   r   r   r9   __static_attributes____classcell__)r0   s   @r1   r&   r&   *   s   	<
2
	
&

 #
 
	
: (,15/3'+'+""&&
&
 %	&

 /&
 -&
 %&
 %&
 &
  &
 
&
P
3
	
&

 $
 
	
: #)-$($($(##
#
 	#

 '#
 "#
 "#
 "#
 #
 #
 
#
J
.
	$
&
/
	%
&
"
2
	
&

 "
 
	
4 *.*.""&/3

 '	

 (
 
  
 -
 

6
.
	$
&
2
	
. $(	&
+&
 !	&

 
&
P
5
	
2K Kr3   r&   ))
__future__r   r   typingr   livekit.protocol.modelsr   livekit.protocol.sipr   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   _servicer!   access_tokenr"   r#   r8   r&   r   r3   r1   <module>r      sT    "   .      8  0 WK WKr3   