
    /jd                        S SK Jr  S SK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"J#r#  SSK$J%r%  SSK&J'r'J(r(  S	r)  " S
 S\%5      r*g)    )annotationsN)Optional)
ListUpdate)SIPOutboundConfig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                  p  ^  \ rS rSrSrS)U 4S j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	.                 S,S
 j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SSSSSS.                 S0S jjrSSSSSSSS.                 S1S jjr    S2S jr    S2S jr    S3S jr    S3S jrS4S jrS4S jr    S5S jr    S5S jr      S6S jr      S6S jrSSSSSS.             S7S jjrSSSSSS.             S8S jjr    S9S  jr    S9S! jr    S:S" jr     S:S# jr!SS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        H/app/agent/.venv/lib/python3.13/site-packages/livekit/api/sip_service.pyr+   SipService.__init__8   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     r2   create_inbound_trunkSipService.create_inbound_trunk;   @      \\))#!
 
 	
 
   9AA Ac                t   #    [         R                  " S[        SS9  U R                  U5      I Sh  vN $  N7f)zCreate a new SIP inbound trunk.

.. deprecated::
   Use :meth:`create_inbound_trunk` instead.

Args:
    create: Request containing trunk details

Returns:
    Created SIP inbound trunk
zHcreate_sip_inbound_trunk is deprecated, use create_inbound_trunk instead   
stacklevelN)warningswarnDeprecationWarningr=   r;   s     r2   create_sip_inbound_trunk#SipService.create_sip_inbound_trunkN   5      	V	

 ..v6666   /868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)r7   r8   r9   r	   r:   r
   r,   trunk_idtrunks      r2   update_inbound_trunkSipService.update_inbound_trunkc   sM      \\))#(% !	
 	
 		
 	
   AA
AA
c                t   #    [         R                  " S[        SS9  U R                  X5      I Sh  vN $  N7f)a  Updates an existing SIP inbound trunk by replacing it entirely.

.. deprecated::
   Use :meth:`update_inbound_trunk` instead.

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

Returns:
    Updated SIP inbound trunk
zHupdate_sip_inbound_trunk is deprecated, use update_inbound_trunk insteadrB   rC   N)rE   rF   rG   rT   rQ   s      r2   update_sip_inbound_trunk#SipService.update_sip_inbound_trunk|   s5     " 	V	

 ..x????rK   Nnumbersallowed_addressesallowed_numbersauth_usernameauth_passwordnamemetadatac          	     r  #    [        UUUUS9n	Ub  [        U[        5      (       a  U	R                  R                  R                  UR                  5        U	R                  R                  R                  UR                  5        U	R                  R                  R                  UR                  5        O%U	R                  R                  R                  U5        Ub  [        U[        5      (       a  U	R                  R                  R                  UR                  5        U	R                  R                  R                  UR                  5        U	R                  R                  R                  UR                  5        O%U	R                  R                  R                  U5        Ub  [        U[        5      (       a  U	R                  R                  R                  UR                  5        U	R                  R                  R                  UR                  5        U	R                  R                  R                  UR                  5        O%U	R                  R                  R                  U5        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.
)r^   r_   r`   ra   NrM   rO   update)r   
isinstancer   r[   setextendaddremover\   r]   r7   r8   r9   r	   r:   r
   )
r,   rR   r[   r\   r]   r^   r_   r`   ra   rd   s
             r2   update_inbound_trunk_fields&SipService.update_inbound_trunk_fields   s      '''	
 ':..""))'++6""))'++6%%,,W^^<""))'2(+Z88((,,334E4I4IJ((,,334E4I4IJ((//667H7O7OP((,,334EF&/:66&&**11/2E2EF&&**11/2E2EF&&--44_5K5KL&&**11/B\\))#(% !	
 	
 		
 	
s   J.J70J51J7c               ~   #    [         R                  " S[        SS9  U R                  UUUUUUUUS9I Sh  vN $  N7f)zUpdates specific fields of an existing SIP inbound trunk.

.. deprecated::
   Use :meth:`update_inbound_trunk_fields` instead.

Only provided fields will be updated.
zVupdate_sip_inbound_trunk_fields is deprecated, use update_inbound_trunk_fields insteadrB   rC   rZ   N)rE   rF   rG   rj   )	r,   rR   r[   r\   r]   r^   r_   r`   ra   s	            r2   update_sip_inbound_trunk_fields*SipService.update_sip_inbound_trunk_fields   sX     & 	d	

 55/+'' 6 	
 	
 		
 	
   4=;=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)r7   r8   r9   r:   r   r;   s     r2   create_outbound_trunk SipService.create_outbound_trunk   s@      \\))$! 
 
 	
 
r@   c                t   #    [         R                  " S[        SS9  U R                  U5      I Sh  vN $  N7f)zCreate a new SIP outbound trunk.

.. deprecated::
   Use :meth:`create_outbound_trunk` instead.

Args:
    create: Request containing trunk details

Returns:
    Created SIP outbound trunk
zJcreate_sip_outbound_trunk is deprecated, use create_outbound_trunk insteadrB   rC   N)rE   rF   rG   rr   r;   s     r2   create_sip_outbound_trunk$SipService.create_sip_outbound_trunk  s5      	X	

 //7777rK   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
UpdateSIPOutboundTrunkrN   N)r7   r8   r9   r   r:   r   rQ   s      r2   update_outbound_trunk SipService.update_outbound_trunk  sM      \\))$)% ! 	
 	
 		
 	
rV   c                t   #    [         R                  " S[        SS9  U R                  X5      I Sh  vN $  N7f)a  Updates an existing SIP outbound trunk by replacing it entirely.

.. deprecated::
   Use :meth:`update_outbound_trunk` instead.

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

Returns:
    Updated SIP outbound trunk
zJupdate_sip_outbound_trunk is deprecated, use update_outbound_trunk insteadrB   rC   N)rE   rF   rG   ry   rQ   s      r2   update_sip_outbound_trunk$SipService.update_sip_outbound_trunk/  s5     " 	X	

 //@@@@rK   address	transportr[   r^   r_   r`   ra   c          	     J  #    [        UUUUUUS9n	Ub  [        U[        5      (       a  U	R                  R                  R                  UR                  5        U	R                  R                  R                  UR                  5        U	R                  R                  R                  UR                  5        O%U	R                  R                  R                  U5        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.
)r   r   r^   r_   r`   ra   Nrx   rc   )r   re   r   r[   rf   rg   rh   ri   r7   r8   r9   r   r:   r   )
r,   rR   r   r   r[   r^   r_   r`   ra   rd   s
             r2   update_outbound_trunk_fields'SipService.update_outbound_trunk_fieldsG  s       (''
 ':..""))'++6""))'++6%%,,W^^<""))'2\\))$)% ! 	
 	
 		
 	
s   DD#D!D#c               ~   #    [         R                  " S[        SS9  U R                  UUUUUUUUS9I Sh  vN $  N7f)zUpdates specific fields of an existing SIP outbound trunk.

.. deprecated::
   Use :meth:`update_outbound_trunk_fields` instead.

Only provided fields will be updated.
zXupdate_sip_outbound_trunk_fields is deprecated, use update_outbound_trunk_fields insteadrB   rC   r~   N)rE   rF   rG   r   )	r,   rR   r   r   r[   r^   r_   r`   ra   s	            r2    update_sip_outbound_trunk_fields+SipService.update_sip_outbound_trunk_fieldsr  sX     & 	f	

 66'' 7 	
 	
 		
 	
ro   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)r7   r8   r9   r:   r   r,   lists     r2   list_inbound_trunkSipService.list_inbound_trunk  @      \\))!!'
 
 	
 
r@   c                t   #    [         R                  " S[        SS9  U R                  U5      I Sh  vN $  N7f)zList SIP inbound trunks with optional filtering.

.. deprecated::
   Use :meth:`list_inbound_trunk` instead.

Args:
    list: Request with optional filtering parameters

Returns:
    Response containing list of SIP inbound trunks
zDlist_sip_inbound_trunk is deprecated, use list_inbound_trunk insteadrB   rC   N)rE   rF   rG   r   r   s     r2   list_sip_inbound_trunk!SipService.list_sip_inbound_trunk  5      	R	

 ,,T2222rK   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)r7   r8   r9   r:   r   r   s     r2   list_outbound_trunkSipService.list_outbound_trunk  s@      \\))"!(
 
 	
 
r@   c                t   #    [         R                  " S[        SS9  U R                  U5      I Sh  vN $  N7f)zList SIP outbound trunks with optional filtering.

.. deprecated::
   Use :meth:`list_outbound_trunk` instead.

Args:
    list: Request with optional filtering parameters

Returns:
    Response containing list of SIP outbound trunks
zFlist_sip_outbound_trunk is deprecated, use list_outbound_trunk insteadrB   rC   N)rE   rF   rG   r   r   s     r2   list_sip_outbound_trunk"SipService.list_sip_outbound_trunk  s5      	T	

 --d3333rK   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)r7   r8   r9   r:   r   r,   deletes     r2   delete_trunkSipService.delete_trunk  s@      \\))!
 
 	
 
r@   c                t   #    [         R                  " S[        SS9  U R                  U5      I Sh  vN $  N7f)zDelete a SIP trunk.

.. deprecated::
   Use :meth:`delete_trunk` instead.

Args:
    delete: Request containing trunk ID to delete

Returns:
    Deleted trunk information
z8delete_sip_trunk is deprecated, use delete_trunk insteadrB   rC   N)rE   rF   rG   r   r   s     r2   delete_sip_trunkSipService.delete_sip_trunk  s5      	F	

 &&v....rK   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r7   r8   r9   r:   r   r;   s     r2   create_dispatch_ruleSipService.create_dispatch_rule	  r?   r@   c                t   #    [         R                  " S[        SS9  U R                  U5      I Sh  vN $  N7f)zCreate a new SIP dispatch rule.

.. deprecated::
   Use :meth:`create_dispatch_rule` instead.

Args:
    create: Request containing rule details

Returns:
    Created SIP dispatch rule
zHcreate_sip_dispatch_rule is deprecated, use create_dispatch_rule insteadrB   rC   N)rE   rF   rG   r   r;   s     r2   create_sip_dispatch_rule#SipService.create_sip_dispatch_rule  rJ   rK   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_idrP   N)r7   r8   r9   r   r:   r   r,   rule_idrules      r2   update_dispatch_ruleSipService.update_dispatch_rule1  sE      \\))#(gT!
 
 	
 
s   A A	AA	c                t   #    [         R                  " S[        SS9  U R                  X5      I Sh  vN $  N7f)a  Updates an existing SIP dispatch rule by replacing it entirely.

.. deprecated::
   Use :meth:`update_dispatch_rule` instead.

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

Returns:
    Updated SIP dispatch rule
zHupdate_sip_dispatch_rule is deprecated, use update_dispatch_rule insteadrB   rC   N)rE   rF   rG   r   r   s      r2   update_sip_dispatch_rule#SipService.update_sip_dispatch_ruleG  s5     " 	V	

 ..w====rK   	trunk_idsr   r`   ra   
attributesc          	     D  #    [        UUUUS9nUb  [        U[        5      (       a  UR                  R                  R                  UR                  5        UR                  R                  R                  UR                  5        UR                  R                  R                  UR                  5        O%UR                  R                  R                  U5        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.
)r`   ra   r   r   Nr   )r   rd   )r   re   r   r   rf   rg   rh   ri   r7   r8   r9   r   r:   r   )r,   r   r   r   r`   ra   r   rd   s           r2   update_dispatch_rule_fields&SipService.update_dispatch_rule_fields_  s      '!	
  )Z00  $$++IMM:  $$++IMM:  ''..y/?/?@  $$++I6\\))#(gU!
 
 	
 
s   DD DD c          	     z   #    [         R                  " S[        SS9  U R                  UUUUUUS9I Sh  vN $  N7f)zUpdates specific fields of an existing SIP dispatch rule.

.. deprecated::
   Use :meth:`update_dispatch_rule_fields` instead.

Only provided fields will be updated.
zVupdate_sip_dispatch_rule_fields is deprecated, use update_dispatch_rule_fields insteadrB   rC   r   N)rE   rF   rG   r   )r,   r   r   r   r`   ra   r   s          r2   update_sip_dispatch_rule_fields*SipService.update_sip_dispatch_rule_fields  sR     " 	d	

 55! 6 
 
 	
 
s   2;9;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)r7   r8   r9   r:   r   r   s     r2   list_dispatch_ruleSipService.list_dispatch_rule  r   r@   c                t   #    [         R                  " S[        SS9  U R                  U5      I Sh  vN $  N7f)zList SIP dispatch rules with optional filtering.

.. deprecated::
   Use :meth:`list_dispatch_rule` instead.

Args:
    list: Request with optional filtering parameters

Returns:
    Response containing list of SIP dispatch rules
zDlist_sip_dispatch_rule is deprecated, use list_dispatch_rule insteadrB   rC   N)rE   rF   rG   r   r   s     r2   list_sip_dispatch_rule!SipService.list_sip_dispatch_rule  r   rK   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
DeleteSIPDispatchRuleNr   r   s     r2   delete_dispatch_ruleSipService.delete_dispatch_rule  r?   r@   c                t   #    [         R                  " S[        SS9  U R                  U5      I Sh  vN $  N7f)zDelete a SIP dispatch rule.

.. deprecated::
   Use :meth:`delete_dispatch_rule` instead.

Args:
    delete: Request containing rule ID to delete

Returns:
    Deleted rule information
zHdelete_sip_dispatch_rule is deprecated, use delete_dispatch_rule insteadrB   rC   N)rE   rF   rG   r   r   s     r2   delete_sip_dispatch_rule#SipService.delete_sip_dispatch_rule  rJ   rK   )timeoutrR   outbound_trunk_configc               b  #    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(       a  X1l        U(       a  XAl        U R                  R                  [        SUU R                  [        5       [        SS9S9[        US9I Sh  vN $  N7f)	au  Create a new SIP participant.

Args:
    create: Request containing participant details
    timeout: Optional request timeout in seconds
    trunk_id: Optional SIP trunk ID to use for the participant
    outbound_trunk_config: Optional outbound trunk configuration for the participant

Returns:
    Created SIP participant

Raises:
    SIPError: If the SIP operation fails
N)total   CreateSIPParticipantTcallsip)r   )aiohttpClientTimeoutwait_until_answeredr7   _sessionr   r   rO   rS   r8   r9   _auth_headerr#   r$   r   )r,   r<   r   rR   r   client_timeouts         r2   create_sip_participant!SipService.create_sip_participant  s     , ;?$22AN'' %%--LL))1177LL))1177"<!(!6!6R!@"* 0L\\))"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)r7   r8   r9   r   r#   	room_namer$   r   )r,   transfers     r2   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    r2   r:   SipService._admin_headers=  s      ID4I JJr4    )r-   zaiohttp.ClientSessionr.   strr/   r   r0   r   )r<   r   returnr
   )rR   r   rS   r
   r   r
   )rR   r   r[    Optional[ListUpdate | list[str]]r\   r   r]   r   r^   Optional[str]r_   r   r`   r   ra   r   r   r
   )rR   r   r[   Optional[list[str]]r\   r   r]   r   r^   r   r_   r   r`   r   ra   r   r   r
   )r<   r   r   r   )rR   r   rS   r   r   r   )rR   r   r   
str | Noner   SIPTransport | Noner[   r   r^   r   r_   r   r`   r   ra   r   r   r   )rR   r   r   r   r   r   r[   zlist[str] | Noner^   r   r_   r   r`   r   ra   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   Optional[SIPDispatchRule]r`   r   ra   r   r   Optional[dict[str, str]]r   r   )r   r   r   r   r   r   r`   r   ra   r   r   r   r   r   )r   r   r   r   )r   r   r   r   )
r<   r   r   zOptional[float]rR   r   r   zOptional[SIPOutboundConfig]r   r   )r   r   r   r   )r   zdict[str, str])'__name__
__module____qualname____firstlineno____doc__r+   r=   rH   rT   rX   rj   rm   rr   ru   ry   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r:   __static_attributes____classcell__)r1   s   @r2   r'   r'   ,   s   	<
2
	
&727	7*

 #
 
	
2@@ #@ 
	@8 59>B<@'+'+""&5
5
 2	5

 <5
 :5
 %5
 %5
 5
  5
 
5
v (,15/3'+'+""&!
!
 %	!

 /!
 -!
 %!
 %!
 !
  !
 
!
F
3
	
&838	8*

 $
 
	
2AA $A 
	A8 #)-48$($(#)
)
 	)

 ')
 2)
 ")
 ")
 )
 )
 
)
^ #)-$($($(#!
!
 	!

 '!
 "!
 "!
 "!
 !
 !
 
!
F
.
	$
&3.3	$3*
/
	%
&4/4	%4*
"/&
2
	
&727	7*

 "
 
	
,>> "> 
	>8 7;*.""&/3"
"
 4	"

 ("
 "
  "
 -"
 
"
P *.*.""&/3

 '	

 (
 
  
 -
 

>
.
	$
&3.3	$3*
2
	
&727	72 $("&=A0
+0
 !	0

  0
  ;0
 
0
d
5
	
2K Kr4   r'   )+
__future__r   r   rE   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   r    _servicer"   access_tokenr#   r$   r9   r'   r   r4   r2   <module>r      s\    "    .       :  0 RK RKr4   