Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add simple sync methods for api clients #242

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions livekit-api/livekit/api/egress_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,102 @@ async def stop_egress(
self._auth_header(VideoGrants(room_record=True)),
proto_egress.EgressInfo,
)

def sync_start_room_composite_egress(
self, start: proto_egress.RoomCompositeEgressRequest
) -> proto_egress.EgressInfo:
return self._client.sync_request(
SVC,
"StartRoomCompositeEgress",
start,
self._auth_header(VideoGrants(room_record=True)),
proto_egress.EgressInfo,
)

def sync_start_web_egress(
self, start: proto_egress.WebEgressRequest
) -> proto_egress.EgressInfo:
return self._client.sync_request(
SVC,
"StartWebEgress",
start,
self._auth_header(VideoGrants(room_record=True)),
proto_egress.EgressInfo,
)

def sync_start_participant_egress(
self, start: proto_egress.ParticipantEgressRequest
) -> proto_egress.EgressInfo:
return self._client.sync_request(
SVC,
"StartParticipantEgress",
start,
self._auth_header(VideoGrants(room_record=True)),
proto_egress.EgressInfo,
)

def sync_start_track_composite_egress(
self, start: proto_egress.TrackCompositeEgressRequest
) -> proto_egress.EgressInfo:
return self._client.sync_request(
SVC,
"StartTrackCompositeEgress",
start,
self._auth_header(VideoGrants(room_record=True)),
proto_egress.EgressInfo,
)

def sync_start_track_egress(
self, start: proto_egress.TrackEgressRequest
) -> proto_egress.EgressInfo:
return self._client.sync_request(
SVC,
"StartTrackEgress",
start,
self._auth_header(VideoGrants(room_record=True)),
proto_egress.EgressInfo,
)

def sync_update_layout(
self, update: proto_egress.UpdateLayoutRequest
) -> proto_egress.EgressInfo:
return self._client.sync_request(
SVC,
"UpdateLayout",
update,
self._auth_header(VideoGrants(room_record=True)),
proto_egress.EgressInfo,
)

def sync_update_stream(
self, update: proto_egress.UpdateStreamRequest
) -> proto_egress.EgressInfo:
return self._client.sync_request(
SVC,
"UpdateStream",
update,
self._auth_header(VideoGrants(room_record=True)),
proto_egress.EgressInfo,
)

def sync_list_egress(
self, list: proto_egress.ListEgressRequest
) -> proto_egress.ListEgressResponse:
return self._client.sync_request(
SVC,
"ListEgress",
list,
self._auth_header(VideoGrants(room_record=True)),
proto_egress.ListEgressResponse,
)

def sync_stop_egress(
self, stop: proto_egress.StopEgressRequest
) -> proto_egress.EgressInfo:
return self._client.sync_request(
SVC,
"StopEgress",
stop,
self._auth_header(VideoGrants(room_record=True)),
proto_egress.EgressInfo,
)
36 changes: 36 additions & 0 deletions livekit-api/livekit/api/ingress_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,39 @@ async def delete_ingress(
self._auth_header(VideoGrants(ingress_admin=True)),
proto_ingress.IngressInfo,
)

def sync_create_ingress(self, create: proto_ingress.CreateIngressRequest):
return self._client.sync_request(
SVC,
"CreateIngress",
create,
self._auth_header(VideoGrants(ingress_admin=True)),
proto_ingress.IngressInfo,
)

def sync_update_ingress(self, update: proto_ingress.UpdateIngressRequest):
return self._client.sync_request(
SVC,
"UpdateIngress",
update,
self._auth_header(VideoGrants(ingress_admin=True)),
proto_ingress.IngressInfo,
)

def sync_list_ingress(self, list: proto_ingress.ListIngressRequest):
return self._client.sync_request(
SVC,
"ListIngress",
list,
self._auth_header(VideoGrants(ingress_admin=True)),
proto_ingress.ListIngressResponse,
)

def sync_delete_ingress(self, delete: proto_ingress.DeleteIngressRequest):
return self._client.sync_request(
SVC,
"DeleteIngress",
delete,
self._auth_header(VideoGrants(ingress_admin=True)),
proto_ingress.IngressInfo,
)
122 changes: 122 additions & 0 deletions livekit-api/livekit/api/room_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,125 @@ async def send_data(
self._auth_header(VideoGrants(room_admin=True, room=send.room)),
proto_room.SendDataResponse,
)

def sync_create_room(
self, create: proto_room.CreateRoomRequest
) -> proto_models.Room:
return self._client.sync_request(
SVC,
"CreateRoom",
create,
self._auth_header(VideoGrants(room_create=True)),
proto_models.Room,
)

def sync_delete_room(
self, delete: proto_room.DeleteRoomRequest
) -> proto_room.DeleteRoomResponse:
return self._client.sync_request(
SVC,
"DeleteRoom",
delete,
self._auth_header(VideoGrants(room_create=True)),
proto_room.DeleteRoomResponse,
)

def sync_update_room_metadata(
self, update: proto_room.UpdateRoomMetadataRequest
) -> proto_models.Room:
return self._client.sync_request(
SVC,
"UpdateRoomMetadata",
update,
self._auth_header(VideoGrants(room_admin=True, room=update.room)),
proto_models.Room,
)

def sync_remove_participant(
self, remove: proto_room.RoomParticipantIdentity
) -> proto_room.RemoveParticipantResponse:
return self._client.sync_request(
SVC,
"RemoveParticipant",
remove,
self._auth_header(VideoGrants(room_admin=True, room=remove.room)),
proto_room.RemoveParticipantResponse,
)

def sync_mute_published_track(
self,
update: proto_room.MuteRoomTrackRequest,
) -> proto_room.MuteRoomTrackResponse:
return self._client.sync_request(
SVC,
"MutePublishedTrack",
update,
self._auth_header(VideoGrants(room_admin=True, room=update.room)),
proto_room.MuteRoomTrackResponse,
)

def sync_update_participant(
self, update: proto_room.UpdateParticipantRequest
) -> proto_models.ParticipantInfo:
return self._client.sync_request(
SVC,
"UpdateParticipant",
update,
self._auth_header(VideoGrants(room_admin=True, room=update.room)),
proto_models.ParticipantInfo,
)

def sync_update_subscriptions(
self, update: proto_room.UpdateSubscriptionsRequest
) -> proto_room.UpdateSubscriptionsResponse:
return self._client.sync_request(
SVC,
"UpdateSubscriptions",
update,
self._auth_header(VideoGrants(room_admin=True, room=update.room)),
proto_room.UpdateSubscriptionsResponse,
)

def sync_send_data(
self, send: proto_room.SendDataRequest
) -> proto_room.SendDataResponse:
return self._client.sync_request(
SVC,
"SendData",
send,
self._auth_header(VideoGrants(room_admin=True, room=send.room)),
proto_room.SendDataResponse,
)

def sync_list_participants(
self, list: proto_room.ListParticipantsRequest
) -> proto_room.ListParticipantsResponse:
return self._client.sync_request(
SVC,
"ListParticipants",
list,
self._auth_header(VideoGrants(room_admin=True, room=list.room)),
proto_room.ListParticipantsResponse,
)

def sync_get_participant(
self, get: proto_room.RoomParticipantIdentity
) -> proto_models.ParticipantInfo:
return self._client.sync_request(
SVC,
"GetParticipant",
get,
self._auth_header(VideoGrants(room_admin=True, room=get.room)),
proto_models.ParticipantInfo,
)

def sync_list_rooms(
self, list: proto_room.ListRoomsRequest
) -> proto_room.ListRoomsResponse:
return self._client.sync_request(
SVC,
"ListRooms",
list,
self._auth_header(VideoGrants(room_list=True)),
proto_room.ListRoomsResponse,
)
121 changes: 121 additions & 0 deletions livekit-api/livekit/api/sip_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,124 @@ async def create_sip_participant(
self._auth_header(VideoGrants(), sip=SIPGrants(call=True)),
proto_sip.SIPParticipantInfo,
)

def sync_create_sip_trunk(
self, create: proto_sip.CreateSIPTrunkRequest
) -> proto_sip.SIPTrunkInfo:
return self._client.sync_request(
SVC,
"CreateSIPTrunk",
create,
self._auth_header(VideoGrants(), sip=SIPGrants(admin=True)),
proto_sip.SIPTrunkInfo,
)

def sync_create_sip_inbound_trunk(
self, create: proto_sip.CreateSIPInboundTrunkRequest
) -> proto_sip.SIPInboundTrunkInfo:
return self._client.sync_request(
SVC,
"CreateSIPInboundTrunk",
create,
self._auth_header(VideoGrants(), sip=SIPGrants(admin=True)),
proto_sip.SIPInboundTrunkInfo,
)

def sync_create_sip_outbound_trunk(
self, create: proto_sip.CreateSIPOutboundTrunkRequest
) -> proto_sip.SIPOutboundTrunkInfo:
return self._client.sync_request(
SVC,
"CreateSIPOutboundTrunk",
create,
self._auth_header(VideoGrants(), sip=SIPGrants(admin=True)),
proto_sip.SIPOutboundTrunkInfo,
)

def sync_list_sip_trunk(
self, list: proto_sip.ListSIPTrunkRequest
) -> proto_sip.ListSIPTrunkResponse:
return self._client.sync_request(
SVC,
"ListSIPTrunk",
list,
self._auth_header(VideoGrants(), sip=SIPGrants(admin=True)),
proto_sip.ListSIPTrunkResponse,
)

def sync_list_sip_inbound_trunk(
self, list: proto_sip.ListSIPInboundTrunkRequest
) -> proto_sip.ListSIPInboundTrunkResponse:
return self._client.sync_request(
SVC,
"ListSIPInboundTrunk",
list,
self._auth_header(VideoGrants(), sip=SIPGrants(admin=True)),
proto_sip.ListSIPInboundTrunkResponse,
)

def sync_list_sip_outbound_trunk(
self, list: proto_sip.ListSIPOutboundTrunkRequest
) -> proto_sip.ListSIPOutboundTrunkResponse:
return self._client.sync_request(
SVC,
"ListSIPOutboundTrunk",
list,
self._auth_header(VideoGrants(), sip=SIPGrants(admin=True)),
proto_sip.ListSIPOutboundTrunkResponse,
)

def sync_delete_sip_trunk(
self, delete: proto_sip.DeleteSIPTrunkRequest
) -> proto_sip.SIPTrunkInfo:
return self._client.sync_request(
SVC,
"DeleteSIPTrunk",
delete,
self._auth_header(VideoGrants(), sip=SIPGrants(admin=True)),
proto_sip.SIPTrunkInfo,
)

def sync_create_sip_dispatch_rule(
self, create: proto_sip.CreateSIPDispatchRuleRequest
) -> proto_sip.SIPDispatchRuleInfo:
return self._client.sync_request(
SVC,
"CreateSIPDispatchRule",
create,
self._auth_header(VideoGrants(), sip=SIPGrants(admin=True)),
proto_sip.SIPDispatchRuleInfo,
)

def sync_list_sip_dispatch_rule(
self, list: proto_sip.ListSIPDispatchRuleRequest
) -> proto_sip.ListSIPDispatchRuleResponse:
return self._client.sync_request(
SVC,
"ListSIPDispatchRule",
list,
self._auth_header(VideoGrants(), sip=SIPGrants(admin=True)),
proto_sip.ListSIPDispatchRuleResponse,
)

def sync_delete_sip_dispatch_rule(
self, delete: proto_sip.DeleteSIPDispatchRuleRequest
) -> proto_sip.SIPDispatchRuleInfo:
return self._client.sync_request(
SVC,
"DeleteSIPDispatchRule",
delete,
self._auth_header(VideoGrants(), sip=SIPGrants(admin=True)),
proto_sip.SIPDispatchRuleInfo,
)

def sync_create_sip_participant(
self, create: proto_sip.CreateSIPParticipantRequest
) -> proto_sip.SIPParticipantInfo:
return self._client.sync_request(
SVC,
"CreateSIPParticipant",
create,
self._auth_header(VideoGrants(), sip=SIPGrants(call=True)),
proto_sip.SIPParticipantInfo,
)
Loading
Loading