|
| 1 | +import aiohttp |
| 2 | +from livekit.protocol import sip as proto_sip |
| 3 | +from ._service import Service |
| 4 | +from .access_token import VideoGrants |
| 5 | + |
| 6 | +SVC = "SIP" |
| 7 | + |
| 8 | + |
| 9 | +class SipService(Service): |
| 10 | + def __init__( |
| 11 | + self, session: aiohttp.ClientSession, url: str, api_key: str, api_secret: str |
| 12 | + ): |
| 13 | + super().__init__(session, url, api_key, api_secret) |
| 14 | + |
| 15 | + async def create_sip_trunk( |
| 16 | + self, create: proto_sip.CreateSIPTrunkRequest |
| 17 | + ) -> proto_sip.SIPTrunkInfo: |
| 18 | + return await self._client.request( |
| 19 | + SVC, |
| 20 | + "CreateSIPTrunk", |
| 21 | + create, |
| 22 | + self._auth_header(VideoGrants()), |
| 23 | + proto_sip.SIPTrunkInfo, |
| 24 | + ) |
| 25 | + |
| 26 | + async def list_sip_trunk( |
| 27 | + self, list: proto_sip.ListSIPTrunkRequest |
| 28 | + ) -> proto_sip.ListSIPTrunkResponse: |
| 29 | + return await self._client.request( |
| 30 | + SVC, |
| 31 | + "ListSIPTrunk", |
| 32 | + list, |
| 33 | + self._auth_header(VideoGrants()), |
| 34 | + proto_sip.ListSIPTrunkResponse, |
| 35 | + ) |
| 36 | + |
| 37 | + async def delete_sip_trunk( |
| 38 | + self, delete: proto_sip.DeleteSIPTrunkRequest |
| 39 | + ) -> proto_sip.SIPTrunkInfo: |
| 40 | + return await self._client.request( |
| 41 | + SVC, |
| 42 | + "DeleteSIPTrunk", |
| 43 | + delete, |
| 44 | + self._auth_header(VideoGrants()), |
| 45 | + proto_sip.SIPTrunkInfo, |
| 46 | + ) |
| 47 | + |
| 48 | + async def create_sip_dispatch_rule( |
| 49 | + self, create: proto_sip.CreateSIPDispatchRuleRequest |
| 50 | + ) -> proto_sip.SIPDispatchRuleInfo: |
| 51 | + return await self._client.request( |
| 52 | + SVC, |
| 53 | + "CreateSIPDispatchRule", |
| 54 | + create, |
| 55 | + self._auth_header(VideoGrants()), |
| 56 | + proto_sip.SIPDispatchRuleInfo, |
| 57 | + ) |
| 58 | + |
| 59 | + async def list_sip_dispatch_rule( |
| 60 | + self, list: proto_sip.ListSIPDispatchRuleRequest |
| 61 | + ) -> proto_sip.ListSIPDispatchRuleResponse: |
| 62 | + return await self._client.request( |
| 63 | + SVC, |
| 64 | + "ListSIPDispatchRule", |
| 65 | + list, |
| 66 | + self._auth_header(VideoGrants()), |
| 67 | + proto_sip.ListSIPDispatchRuleResponse, |
| 68 | + ) |
| 69 | + |
| 70 | + async def delete_sip_dispatch_rule( |
| 71 | + self, delete: proto_sip.DeleteSIPDispatchRuleRequest |
| 72 | + ) -> proto_sip.SIPDispatchRuleInfo: |
| 73 | + return await self._client.request( |
| 74 | + SVC, |
| 75 | + "DeleteSIPDispatchRule", |
| 76 | + delete, |
| 77 | + self._auth_header(VideoGrants()), |
| 78 | + proto_sip.SIPDispatchRuleInfo, |
| 79 | + ) |
| 80 | + |
| 81 | + async def create_sip_participant( |
| 82 | + self, create: proto_sip.CreateSIPParticipantRequest |
| 83 | + ) -> proto_sip.SIPParticipantInfo: |
| 84 | + return await self._client.request( |
| 85 | + SVC, |
| 86 | + "CreateSIPParticipant", |
| 87 | + create, |
| 88 | + self._auth_header(VideoGrants()), |
| 89 | + proto_sip.SIPParticipantInfo, |
| 90 | + ) |
0 commit comments