From 1243e2c2a9b63d20fadc1bbe21add7b0441b23f3 Mon Sep 17 00:00:00 2001 From: Sean DuBois Date: Sat, 28 Oct 2023 14:46:50 -0400 Subject: [PATCH] Add SIP Support --- livekit/livekit_sip.pb.go | 1622 ++++++++++++++++++ livekit/livekit_sip.twirp.go | 3087 ++++++++++++++++++++++++++++++++++ livekit_sip.proto | 191 +++ magefile.go | 1 + 4 files changed, 4901 insertions(+) create mode 100644 livekit/livekit_sip.pb.go create mode 100644 livekit/livekit_sip.twirp.go create mode 100644 livekit_sip.proto diff --git a/livekit/livekit_sip.pb.go b/livekit/livekit_sip.pb.go new file mode 100644 index 000000000..ee3126ffb --- /dev/null +++ b/livekit/livekit_sip.pb.go @@ -0,0 +1,1622 @@ +// Copyright 2023 LiveKit, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v4.23.4 +// source: livekit_sip.proto + +package livekit + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type CreateSIPTrunkRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // CIDR or IPs that traffic is accepted from + // An empty list means all inbound traffic is accepted. + Addresses []string `protobuf:"bytes,1,rep,name=addresses,proto3" json:"addresses,omitempty"` + // `To` value that will be used when making a call + To string `protobuf:"bytes,2,opt,name=to,proto3" json:"to,omitempty"` + // Accepted `To` values. This Trunk will only accept a call made to + // these numbers. This allows you to have distinct Trunks for different phone + // numbers at the same provider. + // An empty list means all dialed numbers are accepted. + AllowedDestinationsRegex []string `protobuf:"bytes,3,rep,name=allowed_destinations_regex,json=allowedDestinationsRegex,proto3" json:"allowed_destinations_regex,omitempty"` +} + +func (x *CreateSIPTrunkRequest) Reset() { + *x = CreateSIPTrunkRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_livekit_sip_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateSIPTrunkRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateSIPTrunkRequest) ProtoMessage() {} + +func (x *CreateSIPTrunkRequest) ProtoReflect() protoreflect.Message { + mi := &file_livekit_sip_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateSIPTrunkRequest.ProtoReflect.Descriptor instead. +func (*CreateSIPTrunkRequest) Descriptor() ([]byte, []int) { + return file_livekit_sip_proto_rawDescGZIP(), []int{0} +} + +func (x *CreateSIPTrunkRequest) GetAddresses() []string { + if x != nil { + return x.Addresses + } + return nil +} + +func (x *CreateSIPTrunkRequest) GetTo() string { + if x != nil { + return x.To + } + return "" +} + +func (x *CreateSIPTrunkRequest) GetAllowedDestinationsRegex() []string { + if x != nil { + return x.AllowedDestinationsRegex + } + return nil +} + +type SIPTrunkInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + SipTrunkId string `protobuf:"bytes,1,opt,name=sip_trunk_id,json=sipTrunkId,proto3" json:"sip_trunk_id,omitempty"` +} + +func (x *SIPTrunkInfo) Reset() { + *x = SIPTrunkInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_livekit_sip_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SIPTrunkInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SIPTrunkInfo) ProtoMessage() {} + +func (x *SIPTrunkInfo) ProtoReflect() protoreflect.Message { + mi := &file_livekit_sip_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SIPTrunkInfo.ProtoReflect.Descriptor instead. +func (*SIPTrunkInfo) Descriptor() ([]byte, []int) { + return file_livekit_sip_proto_rawDescGZIP(), []int{1} +} + +func (x *SIPTrunkInfo) GetSipTrunkId() string { + if x != nil { + return x.SipTrunkId + } + return "" +} + +type ListSIPTrunkRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ListSIPTrunkRequest) Reset() { + *x = ListSIPTrunkRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_livekit_sip_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListSIPTrunkRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListSIPTrunkRequest) ProtoMessage() {} + +func (x *ListSIPTrunkRequest) ProtoReflect() protoreflect.Message { + mi := &file_livekit_sip_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListSIPTrunkRequest.ProtoReflect.Descriptor instead. +func (*ListSIPTrunkRequest) Descriptor() ([]byte, []int) { + return file_livekit_sip_proto_rawDescGZIP(), []int{2} +} + +type ListSIPTrunkResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Items []*SIPTrunkInfo `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"` +} + +func (x *ListSIPTrunkResponse) Reset() { + *x = ListSIPTrunkResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_livekit_sip_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListSIPTrunkResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListSIPTrunkResponse) ProtoMessage() {} + +func (x *ListSIPTrunkResponse) ProtoReflect() protoreflect.Message { + mi := &file_livekit_sip_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListSIPTrunkResponse.ProtoReflect.Descriptor instead. +func (*ListSIPTrunkResponse) Descriptor() ([]byte, []int) { + return file_livekit_sip_proto_rawDescGZIP(), []int{3} +} + +func (x *ListSIPTrunkResponse) GetItems() []*SIPTrunkInfo { + if x != nil { + return x.Items + } + return nil +} + +type DeleteSIPTrunkRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + SipTrunkId string `protobuf:"bytes,1,opt,name=sip_trunk_id,json=sipTrunkId,proto3" json:"sip_trunk_id,omitempty"` +} + +func (x *DeleteSIPTrunkRequest) Reset() { + *x = DeleteSIPTrunkRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_livekit_sip_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeleteSIPTrunkRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteSIPTrunkRequest) ProtoMessage() {} + +func (x *DeleteSIPTrunkRequest) ProtoReflect() protoreflect.Message { + mi := &file_livekit_sip_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteSIPTrunkRequest.ProtoReflect.Descriptor instead. +func (*DeleteSIPTrunkRequest) Descriptor() ([]byte, []int) { + return file_livekit_sip_proto_rawDescGZIP(), []int{4} +} + +func (x *DeleteSIPTrunkRequest) GetSipTrunkId() string { + if x != nil { + return x.SipTrunkId + } + return "" +} + +type SIPDispatchRuleDirect struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // What room should call be directed into + RoomName string `protobuf:"bytes,1,opt,name=room_name,json=roomName,proto3" json:"room_name,omitempty"` + // Optional pin required to enter room + Pin string `protobuf:"bytes,2,opt,name=pin,proto3" json:"pin,omitempty"` +} + +func (x *SIPDispatchRuleDirect) Reset() { + *x = SIPDispatchRuleDirect{} + if protoimpl.UnsafeEnabled { + mi := &file_livekit_sip_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SIPDispatchRuleDirect) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SIPDispatchRuleDirect) ProtoMessage() {} + +func (x *SIPDispatchRuleDirect) ProtoReflect() protoreflect.Message { + mi := &file_livekit_sip_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SIPDispatchRuleDirect.ProtoReflect.Descriptor instead. +func (*SIPDispatchRuleDirect) Descriptor() ([]byte, []int) { + return file_livekit_sip_proto_rawDescGZIP(), []int{5} +} + +func (x *SIPDispatchRuleDirect) GetRoomName() string { + if x != nil { + return x.RoomName + } + return "" +} + +func (x *SIPDispatchRuleDirect) GetPin() string { + if x != nil { + return x.Pin + } + return "" +} + +type SIPDispatchRulePin struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // What room should call be directed into + RoomName string `protobuf:"bytes,1,opt,name=room_name,json=roomName,proto3" json:"room_name,omitempty"` + // Pin required to enter room + Pin string `protobuf:"bytes,2,opt,name=pin,proto3" json:"pin,omitempty"` +} + +func (x *SIPDispatchRulePin) Reset() { + *x = SIPDispatchRulePin{} + if protoimpl.UnsafeEnabled { + mi := &file_livekit_sip_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SIPDispatchRulePin) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SIPDispatchRulePin) ProtoMessage() {} + +func (x *SIPDispatchRulePin) ProtoReflect() protoreflect.Message { + mi := &file_livekit_sip_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SIPDispatchRulePin.ProtoReflect.Descriptor instead. +func (*SIPDispatchRulePin) Descriptor() ([]byte, []int) { + return file_livekit_sip_proto_rawDescGZIP(), []int{6} +} + +func (x *SIPDispatchRulePin) GetRoomName() string { + if x != nil { + return x.RoomName + } + return "" +} + +func (x *SIPDispatchRulePin) GetPin() string { + if x != nil { + return x.Pin + } + return "" +} + +type SIPDispatchRuleIndividual struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Prefix used on new room name + RoomPrefix string `protobuf:"bytes,1,opt,name=room_prefix,json=roomPrefix,proto3" json:"room_prefix,omitempty"` + // Optional pin required to enter room + Pin string `protobuf:"bytes,2,opt,name=pin,proto3" json:"pin,omitempty"` +} + +func (x *SIPDispatchRuleIndividual) Reset() { + *x = SIPDispatchRuleIndividual{} + if protoimpl.UnsafeEnabled { + mi := &file_livekit_sip_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SIPDispatchRuleIndividual) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SIPDispatchRuleIndividual) ProtoMessage() {} + +func (x *SIPDispatchRuleIndividual) ProtoReflect() protoreflect.Message { + mi := &file_livekit_sip_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SIPDispatchRuleIndividual.ProtoReflect.Descriptor instead. +func (*SIPDispatchRuleIndividual) Descriptor() ([]byte, []int) { + return file_livekit_sip_proto_rawDescGZIP(), []int{7} +} + +func (x *SIPDispatchRuleIndividual) GetRoomPrefix() string { + if x != nil { + return x.RoomPrefix + } + return "" +} + +func (x *SIPDispatchRuleIndividual) GetPin() string { + if x != nil { + return x.Pin + } + return "" +} + +type CreateSIPDispatchRuleRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Instrument: + // + // *CreateSIPDispatchRuleRequest_DispatchRuleDirect + // *CreateSIPDispatchRuleRequest_DispatchRulePin + // *CreateSIPDispatchRuleRequest_DispatchRuleIndividual + Instrument isCreateSIPDispatchRuleRequest_Instrument `protobuf_oneof:"instrument"` + // What trunks are accepted for this dispatch rul + TrunkIds []string `protobuf:"bytes,4,rep,name=trunk_ids,json=trunkIds,proto3" json:"trunk_ids,omitempty"` + // What calling numbers can this Dispatch Rule be used by. + // An empty list means all callers are accepted. + AllowedSourcesRegex []string `protobuf:"bytes,5,rep,name=allowed_sources_regex,json=allowedSourcesRegex,proto3" json:"allowed_sources_regex,omitempty"` + // By default the From value (Phone number) is used as the participant identity + // If true a random value will be used instead + HidePhoneNumber bool `protobuf:"varint,6,opt,name=hide_phone_number,json=hidePhoneNumber,proto3" json:"hide_phone_number,omitempty"` +} + +func (x *CreateSIPDispatchRuleRequest) Reset() { + *x = CreateSIPDispatchRuleRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_livekit_sip_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateSIPDispatchRuleRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateSIPDispatchRuleRequest) ProtoMessage() {} + +func (x *CreateSIPDispatchRuleRequest) ProtoReflect() protoreflect.Message { + mi := &file_livekit_sip_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateSIPDispatchRuleRequest.ProtoReflect.Descriptor instead. +func (*CreateSIPDispatchRuleRequest) Descriptor() ([]byte, []int) { + return file_livekit_sip_proto_rawDescGZIP(), []int{8} +} + +func (m *CreateSIPDispatchRuleRequest) GetInstrument() isCreateSIPDispatchRuleRequest_Instrument { + if m != nil { + return m.Instrument + } + return nil +} + +func (x *CreateSIPDispatchRuleRequest) GetDispatchRuleDirect() *SIPDispatchRuleDirect { + if x, ok := x.GetInstrument().(*CreateSIPDispatchRuleRequest_DispatchRuleDirect); ok { + return x.DispatchRuleDirect + } + return nil +} + +func (x *CreateSIPDispatchRuleRequest) GetDispatchRulePin() *SIPDispatchRulePin { + if x, ok := x.GetInstrument().(*CreateSIPDispatchRuleRequest_DispatchRulePin); ok { + return x.DispatchRulePin + } + return nil +} + +func (x *CreateSIPDispatchRuleRequest) GetDispatchRuleIndividual() *SIPDispatchRuleIndividual { + if x, ok := x.GetInstrument().(*CreateSIPDispatchRuleRequest_DispatchRuleIndividual); ok { + return x.DispatchRuleIndividual + } + return nil +} + +func (x *CreateSIPDispatchRuleRequest) GetTrunkIds() []string { + if x != nil { + return x.TrunkIds + } + return nil +} + +func (x *CreateSIPDispatchRuleRequest) GetAllowedSourcesRegex() []string { + if x != nil { + return x.AllowedSourcesRegex + } + return nil +} + +func (x *CreateSIPDispatchRuleRequest) GetHidePhoneNumber() bool { + if x != nil { + return x.HidePhoneNumber + } + return false +} + +type isCreateSIPDispatchRuleRequest_Instrument interface { + isCreateSIPDispatchRuleRequest_Instrument() +} + +type CreateSIPDispatchRuleRequest_DispatchRuleDirect struct { + DispatchRuleDirect *SIPDispatchRuleDirect `protobuf:"bytes,1,opt,name=dispatch_rule_direct,json=dispatchRuleDirect,proto3,oneof"` +} + +type CreateSIPDispatchRuleRequest_DispatchRulePin struct { + DispatchRulePin *SIPDispatchRulePin `protobuf:"bytes,2,opt,name=dispatch_rule_pin,json=dispatchRulePin,proto3,oneof"` +} + +type CreateSIPDispatchRuleRequest_DispatchRuleIndividual struct { + DispatchRuleIndividual *SIPDispatchRuleIndividual `protobuf:"bytes,3,opt,name=dispatch_rule_individual,json=dispatchRuleIndividual,proto3,oneof"` +} + +func (*CreateSIPDispatchRuleRequest_DispatchRuleDirect) isCreateSIPDispatchRuleRequest_Instrument() {} + +func (*CreateSIPDispatchRuleRequest_DispatchRulePin) isCreateSIPDispatchRuleRequest_Instrument() {} + +func (*CreateSIPDispatchRuleRequest_DispatchRuleIndividual) isCreateSIPDispatchRuleRequest_Instrument() { +} + +type SIPDispatchRuleInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + SipDispatchRuleId string `protobuf:"bytes,1,opt,name=sip_dispatch_rule_id,json=sipDispatchRuleId,proto3" json:"sip_dispatch_rule_id,omitempty"` +} + +func (x *SIPDispatchRuleInfo) Reset() { + *x = SIPDispatchRuleInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_livekit_sip_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SIPDispatchRuleInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SIPDispatchRuleInfo) ProtoMessage() {} + +func (x *SIPDispatchRuleInfo) ProtoReflect() protoreflect.Message { + mi := &file_livekit_sip_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SIPDispatchRuleInfo.ProtoReflect.Descriptor instead. +func (*SIPDispatchRuleInfo) Descriptor() ([]byte, []int) { + return file_livekit_sip_proto_rawDescGZIP(), []int{9} +} + +func (x *SIPDispatchRuleInfo) GetSipDispatchRuleId() string { + if x != nil { + return x.SipDispatchRuleId + } + return "" +} + +type ListSIPDispatchRuleRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ListSIPDispatchRuleRequest) Reset() { + *x = ListSIPDispatchRuleRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_livekit_sip_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListSIPDispatchRuleRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListSIPDispatchRuleRequest) ProtoMessage() {} + +func (x *ListSIPDispatchRuleRequest) ProtoReflect() protoreflect.Message { + mi := &file_livekit_sip_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListSIPDispatchRuleRequest.ProtoReflect.Descriptor instead. +func (*ListSIPDispatchRuleRequest) Descriptor() ([]byte, []int) { + return file_livekit_sip_proto_rawDescGZIP(), []int{10} +} + +type ListSIPDispatchRuleResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Items []*SIPDispatchRuleInfo `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"` +} + +func (x *ListSIPDispatchRuleResponse) Reset() { + *x = ListSIPDispatchRuleResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_livekit_sip_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListSIPDispatchRuleResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListSIPDispatchRuleResponse) ProtoMessage() {} + +func (x *ListSIPDispatchRuleResponse) ProtoReflect() protoreflect.Message { + mi := &file_livekit_sip_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListSIPDispatchRuleResponse.ProtoReflect.Descriptor instead. +func (*ListSIPDispatchRuleResponse) Descriptor() ([]byte, []int) { + return file_livekit_sip_proto_rawDescGZIP(), []int{11} +} + +func (x *ListSIPDispatchRuleResponse) GetItems() []*SIPDispatchRuleInfo { + if x != nil { + return x.Items + } + return nil +} + +type DeleteSIPDispatchRuleRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + SipDispatchRuleId string `protobuf:"bytes,1,opt,name=sip_dispatch_rule_id,json=sipDispatchRuleId,proto3" json:"sip_dispatch_rule_id,omitempty"` +} + +func (x *DeleteSIPDispatchRuleRequest) Reset() { + *x = DeleteSIPDispatchRuleRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_livekit_sip_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeleteSIPDispatchRuleRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteSIPDispatchRuleRequest) ProtoMessage() {} + +func (x *DeleteSIPDispatchRuleRequest) ProtoReflect() protoreflect.Message { + mi := &file_livekit_sip_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteSIPDispatchRuleRequest.ProtoReflect.Descriptor instead. +func (*DeleteSIPDispatchRuleRequest) Descriptor() ([]byte, []int) { + return file_livekit_sip_proto_rawDescGZIP(), []int{12} +} + +func (x *DeleteSIPDispatchRuleRequest) GetSipDispatchRuleId() string { + if x != nil { + return x.SipDispatchRuleId + } + return "" +} + +// A SIP Participant is a singular SIP session connected to a LiveKit room via +// a SIP Trunk into a SIP DispatchRule +type CreateSIPParticipantRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // What LiveKit room should this participant be connected too + RoomName string `protobuf:"bytes,1,opt,name=room_name,json=roomName,proto3" json:"room_name,omitempty"` + // What SIP Trunk should be used to dial the user + SipTrunkId string `protobuf:"bytes,2,opt,name=sip_trunk_id,json=sipTrunkId,proto3" json:"sip_trunk_id,omitempty"` +} + +func (x *CreateSIPParticipantRequest) Reset() { + *x = CreateSIPParticipantRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_livekit_sip_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateSIPParticipantRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateSIPParticipantRequest) ProtoMessage() {} + +func (x *CreateSIPParticipantRequest) ProtoReflect() protoreflect.Message { + mi := &file_livekit_sip_proto_msgTypes[13] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateSIPParticipantRequest.ProtoReflect.Descriptor instead. +func (*CreateSIPParticipantRequest) Descriptor() ([]byte, []int) { + return file_livekit_sip_proto_rawDescGZIP(), []int{13} +} + +func (x *CreateSIPParticipantRequest) GetRoomName() string { + if x != nil { + return x.RoomName + } + return "" +} + +func (x *CreateSIPParticipantRequest) GetSipTrunkId() string { + if x != nil { + return x.SipTrunkId + } + return "" +} + +type SIPParticipantInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + SipParticipantId string `protobuf:"bytes,1,opt,name=sip_participant_id,json=sipParticipantId,proto3" json:"sip_participant_id,omitempty"` +} + +func (x *SIPParticipantInfo) Reset() { + *x = SIPParticipantInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_livekit_sip_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SIPParticipantInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SIPParticipantInfo) ProtoMessage() {} + +func (x *SIPParticipantInfo) ProtoReflect() protoreflect.Message { + mi := &file_livekit_sip_proto_msgTypes[14] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SIPParticipantInfo.ProtoReflect.Descriptor instead. +func (*SIPParticipantInfo) Descriptor() ([]byte, []int) { + return file_livekit_sip_proto_rawDescGZIP(), []int{14} +} + +func (x *SIPParticipantInfo) GetSipParticipantId() string { + if x != nil { + return x.SipParticipantId + } + return "" +} + +// DTMF Request lets you send a DTMF message for a SIP Participant +type SendSIPParticipantDTMFRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // What SIP Participant to send this DTMF for + SipParticipantId string `protobuf:"bytes,1,opt,name=sip_participant_id,json=sipParticipantId,proto3" json:"sip_participant_id,omitempty"` + // Digits that will be sent via DTMF + Digits string `protobuf:"bytes,2,opt,name=digits,proto3" json:"digits,omitempty"` +} + +func (x *SendSIPParticipantDTMFRequest) Reset() { + *x = SendSIPParticipantDTMFRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_livekit_sip_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SendSIPParticipantDTMFRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SendSIPParticipantDTMFRequest) ProtoMessage() {} + +func (x *SendSIPParticipantDTMFRequest) ProtoReflect() protoreflect.Message { + mi := &file_livekit_sip_proto_msgTypes[15] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SendSIPParticipantDTMFRequest.ProtoReflect.Descriptor instead. +func (*SendSIPParticipantDTMFRequest) Descriptor() ([]byte, []int) { + return file_livekit_sip_proto_rawDescGZIP(), []int{15} +} + +func (x *SendSIPParticipantDTMFRequest) GetSipParticipantId() string { + if x != nil { + return x.SipParticipantId + } + return "" +} + +func (x *SendSIPParticipantDTMFRequest) GetDigits() string { + if x != nil { + return x.Digits + } + return "" +} + +type SIPParticipantDTMFInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + SipParticipantId string `protobuf:"bytes,1,opt,name=sip_participant_id,json=sipParticipantId,proto3" json:"sip_participant_id,omitempty"` +} + +func (x *SIPParticipantDTMFInfo) Reset() { + *x = SIPParticipantDTMFInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_livekit_sip_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SIPParticipantDTMFInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SIPParticipantDTMFInfo) ProtoMessage() {} + +func (x *SIPParticipantDTMFInfo) ProtoReflect() protoreflect.Message { + mi := &file_livekit_sip_proto_msgTypes[16] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SIPParticipantDTMFInfo.ProtoReflect.Descriptor instead. +func (*SIPParticipantDTMFInfo) Descriptor() ([]byte, []int) { + return file_livekit_sip_proto_rawDescGZIP(), []int{16} +} + +func (x *SIPParticipantDTMFInfo) GetSipParticipantId() string { + if x != nil { + return x.SipParticipantId + } + return "" +} + +type ListSIPParticipantRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ListSIPParticipantRequest) Reset() { + *x = ListSIPParticipantRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_livekit_sip_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListSIPParticipantRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListSIPParticipantRequest) ProtoMessage() {} + +func (x *ListSIPParticipantRequest) ProtoReflect() protoreflect.Message { + mi := &file_livekit_sip_proto_msgTypes[17] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListSIPParticipantRequest.ProtoReflect.Descriptor instead. +func (*ListSIPParticipantRequest) Descriptor() ([]byte, []int) { + return file_livekit_sip_proto_rawDescGZIP(), []int{17} +} + +type ListSIPParticipantResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Items []*SIPParticipantInfo `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"` +} + +func (x *ListSIPParticipantResponse) Reset() { + *x = ListSIPParticipantResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_livekit_sip_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListSIPParticipantResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListSIPParticipantResponse) ProtoMessage() {} + +func (x *ListSIPParticipantResponse) ProtoReflect() protoreflect.Message { + mi := &file_livekit_sip_proto_msgTypes[18] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListSIPParticipantResponse.ProtoReflect.Descriptor instead. +func (*ListSIPParticipantResponse) Descriptor() ([]byte, []int) { + return file_livekit_sip_proto_rawDescGZIP(), []int{18} +} + +func (x *ListSIPParticipantResponse) GetItems() []*SIPParticipantInfo { + if x != nil { + return x.Items + } + return nil +} + +type DeleteSIPParticipantRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + SipParticipantId string `protobuf:"bytes,1,opt,name=sip_participant_id,json=sipParticipantId,proto3" json:"sip_participant_id,omitempty"` +} + +func (x *DeleteSIPParticipantRequest) Reset() { + *x = DeleteSIPParticipantRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_livekit_sip_proto_msgTypes[19] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeleteSIPParticipantRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteSIPParticipantRequest) ProtoMessage() {} + +func (x *DeleteSIPParticipantRequest) ProtoReflect() protoreflect.Message { + mi := &file_livekit_sip_proto_msgTypes[19] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteSIPParticipantRequest.ProtoReflect.Descriptor instead. +func (*DeleteSIPParticipantRequest) Descriptor() ([]byte, []int) { + return file_livekit_sip_proto_rawDescGZIP(), []int{19} +} + +func (x *DeleteSIPParticipantRequest) GetSipParticipantId() string { + if x != nil { + return x.SipParticipantId + } + return "" +} + +var File_livekit_sip_proto protoreflect.FileDescriptor + +var file_livekit_sip_proto_rawDesc = []byte{ + 0x0a, 0x11, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x5f, 0x73, 0x69, 0x70, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x22, 0x83, 0x01, 0x0a, + 0x15, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x49, 0x50, 0x54, 0x72, 0x75, 0x6e, 0x6b, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, + 0x73, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x61, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x65, 0x73, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x02, 0x74, 0x6f, 0x12, 0x3c, 0x0a, 0x1a, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x5f, + 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x5f, 0x72, 0x65, 0x67, + 0x65, 0x78, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x18, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, + 0x64, 0x44, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x67, + 0x65, 0x78, 0x22, 0x30, 0x0a, 0x0c, 0x53, 0x49, 0x50, 0x54, 0x72, 0x75, 0x6e, 0x6b, 0x49, 0x6e, + 0x66, 0x6f, 0x12, 0x20, 0x0a, 0x0c, 0x73, 0x69, 0x70, 0x5f, 0x74, 0x72, 0x75, 0x6e, 0x6b, 0x5f, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x69, 0x70, 0x54, 0x72, 0x75, + 0x6e, 0x6b, 0x49, 0x64, 0x22, 0x15, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x49, 0x50, 0x54, + 0x72, 0x75, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x43, 0x0a, 0x14, 0x4c, + 0x69, 0x73, 0x74, 0x53, 0x49, 0x50, 0x54, 0x72, 0x75, 0x6e, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x2b, 0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x53, 0x49, 0x50, + 0x54, 0x72, 0x75, 0x6e, 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, + 0x22, 0x39, 0x0a, 0x15, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x49, 0x50, 0x54, 0x72, 0x75, + 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x20, 0x0a, 0x0c, 0x73, 0x69, 0x70, + 0x5f, 0x74, 0x72, 0x75, 0x6e, 0x6b, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0a, 0x73, 0x69, 0x70, 0x54, 0x72, 0x75, 0x6e, 0x6b, 0x49, 0x64, 0x22, 0x46, 0x0a, 0x15, 0x53, + 0x49, 0x50, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x52, 0x75, 0x6c, 0x65, 0x44, 0x69, + 0x72, 0x65, 0x63, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x72, 0x6f, 0x6f, 0x6d, 0x5f, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x6f, 0x6f, 0x6d, 0x4e, 0x61, 0x6d, + 0x65, 0x12, 0x10, 0x0a, 0x03, 0x70, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, + 0x70, 0x69, 0x6e, 0x22, 0x43, 0x0a, 0x12, 0x53, 0x49, 0x50, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, + 0x63, 0x68, 0x52, 0x75, 0x6c, 0x65, 0x50, 0x69, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x72, 0x6f, 0x6f, + 0x6d, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x6f, + 0x6f, 0x6d, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x70, 0x69, 0x6e, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x03, 0x70, 0x69, 0x6e, 0x22, 0x4e, 0x0a, 0x19, 0x53, 0x49, 0x50, 0x44, + 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x52, 0x75, 0x6c, 0x65, 0x49, 0x6e, 0x64, 0x69, 0x76, + 0x69, 0x64, 0x75, 0x61, 0x6c, 0x12, 0x1f, 0x0a, 0x0b, 0x72, 0x6f, 0x6f, 0x6d, 0x5f, 0x70, 0x72, + 0x65, 0x66, 0x69, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x72, 0x6f, 0x6f, 0x6d, + 0x50, 0x72, 0x65, 0x66, 0x69, 0x78, 0x12, 0x10, 0x0a, 0x03, 0x70, 0x69, 0x6e, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x03, 0x70, 0x69, 0x6e, 0x22, 0xa8, 0x03, 0x0a, 0x1c, 0x43, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x53, 0x49, 0x50, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x52, 0x75, + 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x52, 0x0a, 0x14, 0x64, 0x69, 0x73, + 0x70, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x72, 0x75, 0x6c, 0x65, 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63, + 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, + 0x74, 0x2e, 0x53, 0x49, 0x50, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x52, 0x75, 0x6c, + 0x65, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x48, 0x00, 0x52, 0x12, 0x64, 0x69, 0x73, 0x70, 0x61, + 0x74, 0x63, 0x68, 0x52, 0x75, 0x6c, 0x65, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x12, 0x49, 0x0a, + 0x11, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x72, 0x75, 0x6c, 0x65, 0x5f, 0x70, + 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, + 0x69, 0x74, 0x2e, 0x53, 0x49, 0x50, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x52, 0x75, + 0x6c, 0x65, 0x50, 0x69, 0x6e, 0x48, 0x00, 0x52, 0x0f, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, + 0x68, 0x52, 0x75, 0x6c, 0x65, 0x50, 0x69, 0x6e, 0x12, 0x5e, 0x0a, 0x18, 0x64, 0x69, 0x73, 0x70, + 0x61, 0x74, 0x63, 0x68, 0x5f, 0x72, 0x75, 0x6c, 0x65, 0x5f, 0x69, 0x6e, 0x64, 0x69, 0x76, 0x69, + 0x64, 0x75, 0x61, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x6c, 0x69, 0x76, + 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x53, 0x49, 0x50, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, + 0x52, 0x75, 0x6c, 0x65, 0x49, 0x6e, 0x64, 0x69, 0x76, 0x69, 0x64, 0x75, 0x61, 0x6c, 0x48, 0x00, + 0x52, 0x16, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x52, 0x75, 0x6c, 0x65, 0x49, 0x6e, + 0x64, 0x69, 0x76, 0x69, 0x64, 0x75, 0x61, 0x6c, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x72, 0x75, 0x6e, + 0x6b, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x74, 0x72, 0x75, + 0x6e, 0x6b, 0x49, 0x64, 0x73, 0x12, 0x32, 0x0a, 0x15, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, + 0x5f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x5f, 0x72, 0x65, 0x67, 0x65, 0x78, 0x18, 0x05, + 0x20, 0x03, 0x28, 0x09, 0x52, 0x13, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x53, 0x6f, 0x75, + 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, 0x67, 0x65, 0x78, 0x12, 0x2a, 0x0a, 0x11, 0x68, 0x69, 0x64, + 0x65, 0x5f, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x06, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x68, 0x69, 0x64, 0x65, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x4e, + 0x75, 0x6d, 0x62, 0x65, 0x72, 0x42, 0x0c, 0x0a, 0x0a, 0x69, 0x6e, 0x73, 0x74, 0x72, 0x75, 0x6d, + 0x65, 0x6e, 0x74, 0x22, 0x46, 0x0a, 0x13, 0x53, 0x49, 0x50, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, + 0x63, 0x68, 0x52, 0x75, 0x6c, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x2f, 0x0a, 0x14, 0x73, 0x69, + 0x70, 0x5f, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x72, 0x75, 0x6c, 0x65, 0x5f, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x73, 0x69, 0x70, 0x44, 0x69, 0x73, + 0x70, 0x61, 0x74, 0x63, 0x68, 0x52, 0x75, 0x6c, 0x65, 0x49, 0x64, 0x22, 0x1c, 0x0a, 0x1a, 0x4c, + 0x69, 0x73, 0x74, 0x53, 0x49, 0x50, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x52, 0x75, + 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x51, 0x0a, 0x1b, 0x4c, 0x69, 0x73, + 0x74, 0x53, 0x49, 0x50, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x52, 0x75, 0x6c, 0x65, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x32, 0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, + 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, + 0x74, 0x2e, 0x53, 0x49, 0x50, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x52, 0x75, 0x6c, + 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x22, 0x4f, 0x0a, 0x1c, + 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x49, 0x50, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, + 0x68, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2f, 0x0a, 0x14, + 0x73, 0x69, 0x70, 0x5f, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x72, 0x75, 0x6c, + 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x73, 0x69, 0x70, 0x44, + 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x52, 0x75, 0x6c, 0x65, 0x49, 0x64, 0x22, 0x5c, 0x0a, + 0x1b, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x49, 0x50, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, + 0x69, 0x70, 0x61, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, + 0x72, 0x6f, 0x6f, 0x6d, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x08, 0x72, 0x6f, 0x6f, 0x6d, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0c, 0x73, 0x69, 0x70, + 0x5f, 0x74, 0x72, 0x75, 0x6e, 0x6b, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0a, 0x73, 0x69, 0x70, 0x54, 0x72, 0x75, 0x6e, 0x6b, 0x49, 0x64, 0x22, 0x42, 0x0a, 0x12, 0x53, + 0x49, 0x50, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, 0x6e, 0x66, + 0x6f, 0x12, 0x2c, 0x0a, 0x12, 0x73, 0x69, 0x70, 0x5f, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, + 0x70, 0x61, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x73, + 0x69, 0x70, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x22, + 0x65, 0x0a, 0x1d, 0x53, 0x65, 0x6e, 0x64, 0x53, 0x49, 0x50, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, + 0x69, 0x70, 0x61, 0x6e, 0x74, 0x44, 0x54, 0x4d, 0x46, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x2c, 0x0a, 0x12, 0x73, 0x69, 0x70, 0x5f, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, + 0x61, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x73, 0x69, + 0x70, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x16, + 0x0a, 0x06, 0x64, 0x69, 0x67, 0x69, 0x74, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x64, 0x69, 0x67, 0x69, 0x74, 0x73, 0x22, 0x46, 0x0a, 0x16, 0x53, 0x49, 0x50, 0x50, 0x61, 0x72, + 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x44, 0x54, 0x4d, 0x46, 0x49, 0x6e, 0x66, 0x6f, + 0x12, 0x2c, 0x0a, 0x12, 0x73, 0x69, 0x70, 0x5f, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, + 0x61, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x73, 0x69, + 0x70, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x22, 0x1b, + 0x0a, 0x19, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x49, 0x50, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, + 0x70, 0x61, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x4f, 0x0a, 0x1a, 0x4c, + 0x69, 0x73, 0x74, 0x53, 0x49, 0x50, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, + 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x31, 0x0a, 0x05, 0x69, 0x74, 0x65, + 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, + 0x69, 0x74, 0x2e, 0x53, 0x49, 0x50, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, + 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x22, 0x4b, 0x0a, 0x1b, + 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x49, 0x50, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, + 0x70, 0x61, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2c, 0x0a, 0x12, 0x73, + 0x69, 0x70, 0x5f, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x5f, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x73, 0x69, 0x70, 0x50, 0x61, 0x72, 0x74, + 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x32, 0xfa, 0x06, 0x0a, 0x03, 0x53, 0x49, + 0x50, 0x12, 0x47, 0x0a, 0x0e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x49, 0x50, 0x54, 0x72, + 0x75, 0x6e, 0x6b, 0x12, 0x1e, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x43, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x53, 0x49, 0x50, 0x54, 0x72, 0x75, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x53, 0x49, + 0x50, 0x54, 0x72, 0x75, 0x6e, 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x4b, 0x0a, 0x0c, 0x4c, 0x69, + 0x73, 0x74, 0x53, 0x49, 0x50, 0x54, 0x72, 0x75, 0x6e, 0x6b, 0x12, 0x1c, 0x2e, 0x6c, 0x69, 0x76, + 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x49, 0x50, 0x54, 0x72, 0x75, 0x6e, + 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, + 0x69, 0x74, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x49, 0x50, 0x54, 0x72, 0x75, 0x6e, 0x6b, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x47, 0x0a, 0x0e, 0x44, 0x65, 0x6c, 0x65, 0x74, + 0x65, 0x53, 0x49, 0x50, 0x54, 0x72, 0x75, 0x6e, 0x6b, 0x12, 0x1e, 0x2e, 0x6c, 0x69, 0x76, 0x65, + 0x6b, 0x69, 0x74, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x49, 0x50, 0x54, 0x72, 0x75, + 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x6c, 0x69, 0x76, 0x65, + 0x6b, 0x69, 0x74, 0x2e, 0x53, 0x49, 0x50, 0x54, 0x72, 0x75, 0x6e, 0x6b, 0x49, 0x6e, 0x66, 0x6f, + 0x12, 0x5c, 0x0a, 0x15, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x49, 0x50, 0x44, 0x69, 0x73, + 0x70, 0x61, 0x74, 0x63, 0x68, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x25, 0x2e, 0x6c, 0x69, 0x76, 0x65, + 0x6b, 0x69, 0x74, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x49, 0x50, 0x44, 0x69, 0x73, + 0x70, 0x61, 0x74, 0x63, 0x68, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x1c, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x53, 0x49, 0x50, 0x44, 0x69, + 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x52, 0x75, 0x6c, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x60, + 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x49, 0x50, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, + 0x68, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x23, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, + 0x4c, 0x69, 0x73, 0x74, 0x53, 0x49, 0x50, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x52, + 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x6c, 0x69, 0x76, + 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x49, 0x50, 0x44, 0x69, 0x73, 0x70, + 0x61, 0x74, 0x63, 0x68, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x5c, 0x0a, 0x15, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x49, 0x50, 0x44, 0x69, 0x73, + 0x70, 0x61, 0x74, 0x63, 0x68, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x25, 0x2e, 0x6c, 0x69, 0x76, 0x65, + 0x6b, 0x69, 0x74, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x49, 0x50, 0x44, 0x69, 0x73, + 0x70, 0x61, 0x74, 0x63, 0x68, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x1c, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x53, 0x49, 0x50, 0x44, 0x69, + 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x52, 0x75, 0x6c, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x59, + 0x0a, 0x14, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x49, 0x50, 0x50, 0x61, 0x72, 0x74, 0x69, + 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x12, 0x24, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, + 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x49, 0x50, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, + 0x69, 0x70, 0x61, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x6c, + 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x53, 0x49, 0x50, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, + 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x61, 0x0a, 0x16, 0x53, 0x65, 0x6e, + 0x64, 0x53, 0x49, 0x50, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x44, + 0x54, 0x4d, 0x46, 0x12, 0x26, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x53, 0x65, + 0x6e, 0x64, 0x53, 0x49, 0x50, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, + 0x44, 0x54, 0x4d, 0x46, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x6c, 0x69, + 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x53, 0x49, 0x50, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, + 0x70, 0x61, 0x6e, 0x74, 0x44, 0x54, 0x4d, 0x46, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x5d, 0x0a, 0x12, + 0x4c, 0x69, 0x73, 0x74, 0x53, 0x49, 0x50, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, + 0x6e, 0x74, 0x12, 0x22, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x4c, 0x69, 0x73, + 0x74, 0x53, 0x49, 0x50, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, + 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x49, 0x50, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, + 0x61, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x59, 0x0a, 0x14, 0x44, + 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x49, 0x50, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, + 0x61, 0x6e, 0x74, 0x12, 0x24, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x44, 0x65, + 0x6c, 0x65, 0x74, 0x65, 0x53, 0x49, 0x50, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, + 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x6c, 0x69, 0x76, 0x65, + 0x6b, 0x69, 0x74, 0x2e, 0x53, 0x49, 0x50, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, + 0x6e, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x42, 0x46, 0x5a, 0x23, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2f, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0xaa, 0x02, 0x0d, + 0x4c, 0x69, 0x76, 0x65, 0x4b, 0x69, 0x74, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0xea, 0x02, 0x0e, + 0x4c, 0x69, 0x76, 0x65, 0x4b, 0x69, 0x74, 0x3a, 0x3a, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_livekit_sip_proto_rawDescOnce sync.Once + file_livekit_sip_proto_rawDescData = file_livekit_sip_proto_rawDesc +) + +func file_livekit_sip_proto_rawDescGZIP() []byte { + file_livekit_sip_proto_rawDescOnce.Do(func() { + file_livekit_sip_proto_rawDescData = protoimpl.X.CompressGZIP(file_livekit_sip_proto_rawDescData) + }) + return file_livekit_sip_proto_rawDescData +} + +var file_livekit_sip_proto_msgTypes = make([]protoimpl.MessageInfo, 20) +var file_livekit_sip_proto_goTypes = []interface{}{ + (*CreateSIPTrunkRequest)(nil), // 0: livekit.CreateSIPTrunkRequest + (*SIPTrunkInfo)(nil), // 1: livekit.SIPTrunkInfo + (*ListSIPTrunkRequest)(nil), // 2: livekit.ListSIPTrunkRequest + (*ListSIPTrunkResponse)(nil), // 3: livekit.ListSIPTrunkResponse + (*DeleteSIPTrunkRequest)(nil), // 4: livekit.DeleteSIPTrunkRequest + (*SIPDispatchRuleDirect)(nil), // 5: livekit.SIPDispatchRuleDirect + (*SIPDispatchRulePin)(nil), // 6: livekit.SIPDispatchRulePin + (*SIPDispatchRuleIndividual)(nil), // 7: livekit.SIPDispatchRuleIndividual + (*CreateSIPDispatchRuleRequest)(nil), // 8: livekit.CreateSIPDispatchRuleRequest + (*SIPDispatchRuleInfo)(nil), // 9: livekit.SIPDispatchRuleInfo + (*ListSIPDispatchRuleRequest)(nil), // 10: livekit.ListSIPDispatchRuleRequest + (*ListSIPDispatchRuleResponse)(nil), // 11: livekit.ListSIPDispatchRuleResponse + (*DeleteSIPDispatchRuleRequest)(nil), // 12: livekit.DeleteSIPDispatchRuleRequest + (*CreateSIPParticipantRequest)(nil), // 13: livekit.CreateSIPParticipantRequest + (*SIPParticipantInfo)(nil), // 14: livekit.SIPParticipantInfo + (*SendSIPParticipantDTMFRequest)(nil), // 15: livekit.SendSIPParticipantDTMFRequest + (*SIPParticipantDTMFInfo)(nil), // 16: livekit.SIPParticipantDTMFInfo + (*ListSIPParticipantRequest)(nil), // 17: livekit.ListSIPParticipantRequest + (*ListSIPParticipantResponse)(nil), // 18: livekit.ListSIPParticipantResponse + (*DeleteSIPParticipantRequest)(nil), // 19: livekit.DeleteSIPParticipantRequest +} +var file_livekit_sip_proto_depIdxs = []int32{ + 1, // 0: livekit.ListSIPTrunkResponse.items:type_name -> livekit.SIPTrunkInfo + 5, // 1: livekit.CreateSIPDispatchRuleRequest.dispatch_rule_direct:type_name -> livekit.SIPDispatchRuleDirect + 6, // 2: livekit.CreateSIPDispatchRuleRequest.dispatch_rule_pin:type_name -> livekit.SIPDispatchRulePin + 7, // 3: livekit.CreateSIPDispatchRuleRequest.dispatch_rule_individual:type_name -> livekit.SIPDispatchRuleIndividual + 9, // 4: livekit.ListSIPDispatchRuleResponse.items:type_name -> livekit.SIPDispatchRuleInfo + 14, // 5: livekit.ListSIPParticipantResponse.items:type_name -> livekit.SIPParticipantInfo + 0, // 6: livekit.SIP.CreateSIPTrunk:input_type -> livekit.CreateSIPTrunkRequest + 2, // 7: livekit.SIP.ListSIPTrunk:input_type -> livekit.ListSIPTrunkRequest + 4, // 8: livekit.SIP.DeleteSIPTrunk:input_type -> livekit.DeleteSIPTrunkRequest + 8, // 9: livekit.SIP.CreateSIPDispatchRule:input_type -> livekit.CreateSIPDispatchRuleRequest + 10, // 10: livekit.SIP.ListSIPDispatchRule:input_type -> livekit.ListSIPDispatchRuleRequest + 12, // 11: livekit.SIP.DeleteSIPDispatchRule:input_type -> livekit.DeleteSIPDispatchRuleRequest + 13, // 12: livekit.SIP.CreateSIPParticipant:input_type -> livekit.CreateSIPParticipantRequest + 15, // 13: livekit.SIP.SendSIPParticipantDTMF:input_type -> livekit.SendSIPParticipantDTMFRequest + 17, // 14: livekit.SIP.ListSIPParticipant:input_type -> livekit.ListSIPParticipantRequest + 19, // 15: livekit.SIP.DeleteSIPParticipant:input_type -> livekit.DeleteSIPParticipantRequest + 1, // 16: livekit.SIP.CreateSIPTrunk:output_type -> livekit.SIPTrunkInfo + 3, // 17: livekit.SIP.ListSIPTrunk:output_type -> livekit.ListSIPTrunkResponse + 1, // 18: livekit.SIP.DeleteSIPTrunk:output_type -> livekit.SIPTrunkInfo + 9, // 19: livekit.SIP.CreateSIPDispatchRule:output_type -> livekit.SIPDispatchRuleInfo + 11, // 20: livekit.SIP.ListSIPDispatchRule:output_type -> livekit.ListSIPDispatchRuleResponse + 9, // 21: livekit.SIP.DeleteSIPDispatchRule:output_type -> livekit.SIPDispatchRuleInfo + 14, // 22: livekit.SIP.CreateSIPParticipant:output_type -> livekit.SIPParticipantInfo + 16, // 23: livekit.SIP.SendSIPParticipantDTMF:output_type -> livekit.SIPParticipantDTMFInfo + 18, // 24: livekit.SIP.ListSIPParticipant:output_type -> livekit.ListSIPParticipantResponse + 14, // 25: livekit.SIP.DeleteSIPParticipant:output_type -> livekit.SIPParticipantInfo + 16, // [16:26] is the sub-list for method output_type + 6, // [6:16] is the sub-list for method input_type + 6, // [6:6] is the sub-list for extension type_name + 6, // [6:6] is the sub-list for extension extendee + 0, // [0:6] is the sub-list for field type_name +} + +func init() { file_livekit_sip_proto_init() } +func file_livekit_sip_proto_init() { + if File_livekit_sip_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_livekit_sip_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateSIPTrunkRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_livekit_sip_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SIPTrunkInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_livekit_sip_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListSIPTrunkRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_livekit_sip_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListSIPTrunkResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_livekit_sip_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeleteSIPTrunkRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_livekit_sip_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SIPDispatchRuleDirect); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_livekit_sip_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SIPDispatchRulePin); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_livekit_sip_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SIPDispatchRuleIndividual); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_livekit_sip_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateSIPDispatchRuleRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_livekit_sip_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SIPDispatchRuleInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_livekit_sip_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListSIPDispatchRuleRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_livekit_sip_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListSIPDispatchRuleResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_livekit_sip_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeleteSIPDispatchRuleRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_livekit_sip_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateSIPParticipantRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_livekit_sip_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SIPParticipantInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_livekit_sip_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SendSIPParticipantDTMFRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_livekit_sip_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SIPParticipantDTMFInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_livekit_sip_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListSIPParticipantRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_livekit_sip_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListSIPParticipantResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_livekit_sip_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeleteSIPParticipantRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_livekit_sip_proto_msgTypes[8].OneofWrappers = []interface{}{ + (*CreateSIPDispatchRuleRequest_DispatchRuleDirect)(nil), + (*CreateSIPDispatchRuleRequest_DispatchRulePin)(nil), + (*CreateSIPDispatchRuleRequest_DispatchRuleIndividual)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_livekit_sip_proto_rawDesc, + NumEnums: 0, + NumMessages: 20, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_livekit_sip_proto_goTypes, + DependencyIndexes: file_livekit_sip_proto_depIdxs, + MessageInfos: file_livekit_sip_proto_msgTypes, + }.Build() + File_livekit_sip_proto = out.File + file_livekit_sip_proto_rawDesc = nil + file_livekit_sip_proto_goTypes = nil + file_livekit_sip_proto_depIdxs = nil +} diff --git a/livekit/livekit_sip.twirp.go b/livekit/livekit_sip.twirp.go new file mode 100644 index 000000000..41c4c6614 --- /dev/null +++ b/livekit/livekit_sip.twirp.go @@ -0,0 +1,3087 @@ +// Code generated by protoc-gen-twirp v8.1.3, DO NOT EDIT. +// source: livekit_sip.proto + +package livekit + +import context "context" +import fmt "fmt" +import http "net/http" +import io "io" +import json "encoding/json" +import strconv "strconv" +import strings "strings" + +import protojson "google.golang.org/protobuf/encoding/protojson" +import proto "google.golang.org/protobuf/proto" +import twirp "github.com/twitchtv/twirp" +import ctxsetters "github.com/twitchtv/twirp/ctxsetters" + +// Version compatibility assertion. +// If the constant is not defined in the package, that likely means +// the package needs to be updated to work with this generated code. +// See https://twitchtv.github.io/twirp/docs/version_matrix.html +const _ = twirp.TwirpPackageMinVersion_8_1_0 + +// ============= +// SIP Interface +// ============= + +type SIP interface { + CreateSIPTrunk(context.Context, *CreateSIPTrunkRequest) (*SIPTrunkInfo, error) + + ListSIPTrunk(context.Context, *ListSIPTrunkRequest) (*ListSIPTrunkResponse, error) + + DeleteSIPTrunk(context.Context, *DeleteSIPTrunkRequest) (*SIPTrunkInfo, error) + + CreateSIPDispatchRule(context.Context, *CreateSIPDispatchRuleRequest) (*SIPDispatchRuleInfo, error) + + ListSIPDispatchRule(context.Context, *ListSIPDispatchRuleRequest) (*ListSIPDispatchRuleResponse, error) + + DeleteSIPDispatchRule(context.Context, *DeleteSIPDispatchRuleRequest) (*SIPDispatchRuleInfo, error) + + CreateSIPParticipant(context.Context, *CreateSIPParticipantRequest) (*SIPParticipantInfo, error) + + SendSIPParticipantDTMF(context.Context, *SendSIPParticipantDTMFRequest) (*SIPParticipantDTMFInfo, error) + + ListSIPParticipant(context.Context, *ListSIPParticipantRequest) (*ListSIPParticipantResponse, error) + + DeleteSIPParticipant(context.Context, *DeleteSIPParticipantRequest) (*SIPParticipantInfo, error) +} + +// =================== +// SIP Protobuf Client +// =================== + +type sIPProtobufClient struct { + client HTTPClient + urls [10]string + interceptor twirp.Interceptor + opts twirp.ClientOptions +} + +// NewSIPProtobufClient creates a Protobuf client that implements the SIP interface. +// It communicates using Protobuf and can be configured with a custom HTTPClient. +func NewSIPProtobufClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) SIP { + if c, ok := client.(*http.Client); ok { + client = withoutRedirects(c) + } + + clientOpts := twirp.ClientOptions{} + for _, o := range opts { + o(&clientOpts) + } + + // Using ReadOpt allows backwards and forwards compatibility with new options in the future + literalURLs := false + _ = clientOpts.ReadOpt("literalURLs", &literalURLs) + var pathPrefix string + if ok := clientOpts.ReadOpt("pathPrefix", &pathPrefix); !ok { + pathPrefix = "/twirp" // default prefix + } + + // Build method URLs: []/./ + serviceURL := sanitizeBaseURL(baseURL) + serviceURL += baseServicePath(pathPrefix, "livekit", "SIP") + urls := [10]string{ + serviceURL + "CreateSIPTrunk", + serviceURL + "ListSIPTrunk", + serviceURL + "DeleteSIPTrunk", + serviceURL + "CreateSIPDispatchRule", + serviceURL + "ListSIPDispatchRule", + serviceURL + "DeleteSIPDispatchRule", + serviceURL + "CreateSIPParticipant", + serviceURL + "SendSIPParticipantDTMF", + serviceURL + "ListSIPParticipant", + serviceURL + "DeleteSIPParticipant", + } + + return &sIPProtobufClient{ + client: client, + urls: urls, + interceptor: twirp.ChainInterceptors(clientOpts.Interceptors...), + opts: clientOpts, + } +} + +func (c *sIPProtobufClient) CreateSIPTrunk(ctx context.Context, in *CreateSIPTrunkRequest) (*SIPTrunkInfo, error) { + ctx = ctxsetters.WithPackageName(ctx, "livekit") + ctx = ctxsetters.WithServiceName(ctx, "SIP") + ctx = ctxsetters.WithMethodName(ctx, "CreateSIPTrunk") + caller := c.callCreateSIPTrunk + if c.interceptor != nil { + caller = func(ctx context.Context, req *CreateSIPTrunkRequest) (*SIPTrunkInfo, error) { + resp, err := c.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*CreateSIPTrunkRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*CreateSIPTrunkRequest) when calling interceptor") + } + return c.callCreateSIPTrunk(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*SIPTrunkInfo) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*SIPTrunkInfo) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + return caller(ctx, in) +} + +func (c *sIPProtobufClient) callCreateSIPTrunk(ctx context.Context, in *CreateSIPTrunkRequest) (*SIPTrunkInfo, error) { + out := new(SIPTrunkInfo) + ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[0], in, out) + if err != nil { + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + callClientError(ctx, c.opts.Hooks, twerr) + return nil, err + } + + callClientResponseReceived(ctx, c.opts.Hooks) + + return out, nil +} + +func (c *sIPProtobufClient) ListSIPTrunk(ctx context.Context, in *ListSIPTrunkRequest) (*ListSIPTrunkResponse, error) { + ctx = ctxsetters.WithPackageName(ctx, "livekit") + ctx = ctxsetters.WithServiceName(ctx, "SIP") + ctx = ctxsetters.WithMethodName(ctx, "ListSIPTrunk") + caller := c.callListSIPTrunk + if c.interceptor != nil { + caller = func(ctx context.Context, req *ListSIPTrunkRequest) (*ListSIPTrunkResponse, error) { + resp, err := c.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*ListSIPTrunkRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*ListSIPTrunkRequest) when calling interceptor") + } + return c.callListSIPTrunk(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*ListSIPTrunkResponse) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*ListSIPTrunkResponse) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + return caller(ctx, in) +} + +func (c *sIPProtobufClient) callListSIPTrunk(ctx context.Context, in *ListSIPTrunkRequest) (*ListSIPTrunkResponse, error) { + out := new(ListSIPTrunkResponse) + ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[1], in, out) + if err != nil { + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + callClientError(ctx, c.opts.Hooks, twerr) + return nil, err + } + + callClientResponseReceived(ctx, c.opts.Hooks) + + return out, nil +} + +func (c *sIPProtobufClient) DeleteSIPTrunk(ctx context.Context, in *DeleteSIPTrunkRequest) (*SIPTrunkInfo, error) { + ctx = ctxsetters.WithPackageName(ctx, "livekit") + ctx = ctxsetters.WithServiceName(ctx, "SIP") + ctx = ctxsetters.WithMethodName(ctx, "DeleteSIPTrunk") + caller := c.callDeleteSIPTrunk + if c.interceptor != nil { + caller = func(ctx context.Context, req *DeleteSIPTrunkRequest) (*SIPTrunkInfo, error) { + resp, err := c.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*DeleteSIPTrunkRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*DeleteSIPTrunkRequest) when calling interceptor") + } + return c.callDeleteSIPTrunk(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*SIPTrunkInfo) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*SIPTrunkInfo) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + return caller(ctx, in) +} + +func (c *sIPProtobufClient) callDeleteSIPTrunk(ctx context.Context, in *DeleteSIPTrunkRequest) (*SIPTrunkInfo, error) { + out := new(SIPTrunkInfo) + ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[2], in, out) + if err != nil { + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + callClientError(ctx, c.opts.Hooks, twerr) + return nil, err + } + + callClientResponseReceived(ctx, c.opts.Hooks) + + return out, nil +} + +func (c *sIPProtobufClient) CreateSIPDispatchRule(ctx context.Context, in *CreateSIPDispatchRuleRequest) (*SIPDispatchRuleInfo, error) { + ctx = ctxsetters.WithPackageName(ctx, "livekit") + ctx = ctxsetters.WithServiceName(ctx, "SIP") + ctx = ctxsetters.WithMethodName(ctx, "CreateSIPDispatchRule") + caller := c.callCreateSIPDispatchRule + if c.interceptor != nil { + caller = func(ctx context.Context, req *CreateSIPDispatchRuleRequest) (*SIPDispatchRuleInfo, error) { + resp, err := c.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*CreateSIPDispatchRuleRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*CreateSIPDispatchRuleRequest) when calling interceptor") + } + return c.callCreateSIPDispatchRule(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*SIPDispatchRuleInfo) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*SIPDispatchRuleInfo) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + return caller(ctx, in) +} + +func (c *sIPProtobufClient) callCreateSIPDispatchRule(ctx context.Context, in *CreateSIPDispatchRuleRequest) (*SIPDispatchRuleInfo, error) { + out := new(SIPDispatchRuleInfo) + ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[3], in, out) + if err != nil { + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + callClientError(ctx, c.opts.Hooks, twerr) + return nil, err + } + + callClientResponseReceived(ctx, c.opts.Hooks) + + return out, nil +} + +func (c *sIPProtobufClient) ListSIPDispatchRule(ctx context.Context, in *ListSIPDispatchRuleRequest) (*ListSIPDispatchRuleResponse, error) { + ctx = ctxsetters.WithPackageName(ctx, "livekit") + ctx = ctxsetters.WithServiceName(ctx, "SIP") + ctx = ctxsetters.WithMethodName(ctx, "ListSIPDispatchRule") + caller := c.callListSIPDispatchRule + if c.interceptor != nil { + caller = func(ctx context.Context, req *ListSIPDispatchRuleRequest) (*ListSIPDispatchRuleResponse, error) { + resp, err := c.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*ListSIPDispatchRuleRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*ListSIPDispatchRuleRequest) when calling interceptor") + } + return c.callListSIPDispatchRule(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*ListSIPDispatchRuleResponse) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*ListSIPDispatchRuleResponse) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + return caller(ctx, in) +} + +func (c *sIPProtobufClient) callListSIPDispatchRule(ctx context.Context, in *ListSIPDispatchRuleRequest) (*ListSIPDispatchRuleResponse, error) { + out := new(ListSIPDispatchRuleResponse) + ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[4], in, out) + if err != nil { + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + callClientError(ctx, c.opts.Hooks, twerr) + return nil, err + } + + callClientResponseReceived(ctx, c.opts.Hooks) + + return out, nil +} + +func (c *sIPProtobufClient) DeleteSIPDispatchRule(ctx context.Context, in *DeleteSIPDispatchRuleRequest) (*SIPDispatchRuleInfo, error) { + ctx = ctxsetters.WithPackageName(ctx, "livekit") + ctx = ctxsetters.WithServiceName(ctx, "SIP") + ctx = ctxsetters.WithMethodName(ctx, "DeleteSIPDispatchRule") + caller := c.callDeleteSIPDispatchRule + if c.interceptor != nil { + caller = func(ctx context.Context, req *DeleteSIPDispatchRuleRequest) (*SIPDispatchRuleInfo, error) { + resp, err := c.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*DeleteSIPDispatchRuleRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*DeleteSIPDispatchRuleRequest) when calling interceptor") + } + return c.callDeleteSIPDispatchRule(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*SIPDispatchRuleInfo) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*SIPDispatchRuleInfo) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + return caller(ctx, in) +} + +func (c *sIPProtobufClient) callDeleteSIPDispatchRule(ctx context.Context, in *DeleteSIPDispatchRuleRequest) (*SIPDispatchRuleInfo, error) { + out := new(SIPDispatchRuleInfo) + ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[5], in, out) + if err != nil { + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + callClientError(ctx, c.opts.Hooks, twerr) + return nil, err + } + + callClientResponseReceived(ctx, c.opts.Hooks) + + return out, nil +} + +func (c *sIPProtobufClient) CreateSIPParticipant(ctx context.Context, in *CreateSIPParticipantRequest) (*SIPParticipantInfo, error) { + ctx = ctxsetters.WithPackageName(ctx, "livekit") + ctx = ctxsetters.WithServiceName(ctx, "SIP") + ctx = ctxsetters.WithMethodName(ctx, "CreateSIPParticipant") + caller := c.callCreateSIPParticipant + if c.interceptor != nil { + caller = func(ctx context.Context, req *CreateSIPParticipantRequest) (*SIPParticipantInfo, error) { + resp, err := c.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*CreateSIPParticipantRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*CreateSIPParticipantRequest) when calling interceptor") + } + return c.callCreateSIPParticipant(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*SIPParticipantInfo) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*SIPParticipantInfo) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + return caller(ctx, in) +} + +func (c *sIPProtobufClient) callCreateSIPParticipant(ctx context.Context, in *CreateSIPParticipantRequest) (*SIPParticipantInfo, error) { + out := new(SIPParticipantInfo) + ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[6], in, out) + if err != nil { + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + callClientError(ctx, c.opts.Hooks, twerr) + return nil, err + } + + callClientResponseReceived(ctx, c.opts.Hooks) + + return out, nil +} + +func (c *sIPProtobufClient) SendSIPParticipantDTMF(ctx context.Context, in *SendSIPParticipantDTMFRequest) (*SIPParticipantDTMFInfo, error) { + ctx = ctxsetters.WithPackageName(ctx, "livekit") + ctx = ctxsetters.WithServiceName(ctx, "SIP") + ctx = ctxsetters.WithMethodName(ctx, "SendSIPParticipantDTMF") + caller := c.callSendSIPParticipantDTMF + if c.interceptor != nil { + caller = func(ctx context.Context, req *SendSIPParticipantDTMFRequest) (*SIPParticipantDTMFInfo, error) { + resp, err := c.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*SendSIPParticipantDTMFRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*SendSIPParticipantDTMFRequest) when calling interceptor") + } + return c.callSendSIPParticipantDTMF(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*SIPParticipantDTMFInfo) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*SIPParticipantDTMFInfo) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + return caller(ctx, in) +} + +func (c *sIPProtobufClient) callSendSIPParticipantDTMF(ctx context.Context, in *SendSIPParticipantDTMFRequest) (*SIPParticipantDTMFInfo, error) { + out := new(SIPParticipantDTMFInfo) + ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[7], in, out) + if err != nil { + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + callClientError(ctx, c.opts.Hooks, twerr) + return nil, err + } + + callClientResponseReceived(ctx, c.opts.Hooks) + + return out, nil +} + +func (c *sIPProtobufClient) ListSIPParticipant(ctx context.Context, in *ListSIPParticipantRequest) (*ListSIPParticipantResponse, error) { + ctx = ctxsetters.WithPackageName(ctx, "livekit") + ctx = ctxsetters.WithServiceName(ctx, "SIP") + ctx = ctxsetters.WithMethodName(ctx, "ListSIPParticipant") + caller := c.callListSIPParticipant + if c.interceptor != nil { + caller = func(ctx context.Context, req *ListSIPParticipantRequest) (*ListSIPParticipantResponse, error) { + resp, err := c.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*ListSIPParticipantRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*ListSIPParticipantRequest) when calling interceptor") + } + return c.callListSIPParticipant(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*ListSIPParticipantResponse) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*ListSIPParticipantResponse) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + return caller(ctx, in) +} + +func (c *sIPProtobufClient) callListSIPParticipant(ctx context.Context, in *ListSIPParticipantRequest) (*ListSIPParticipantResponse, error) { + out := new(ListSIPParticipantResponse) + ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[8], in, out) + if err != nil { + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + callClientError(ctx, c.opts.Hooks, twerr) + return nil, err + } + + callClientResponseReceived(ctx, c.opts.Hooks) + + return out, nil +} + +func (c *sIPProtobufClient) DeleteSIPParticipant(ctx context.Context, in *DeleteSIPParticipantRequest) (*SIPParticipantInfo, error) { + ctx = ctxsetters.WithPackageName(ctx, "livekit") + ctx = ctxsetters.WithServiceName(ctx, "SIP") + ctx = ctxsetters.WithMethodName(ctx, "DeleteSIPParticipant") + caller := c.callDeleteSIPParticipant + if c.interceptor != nil { + caller = func(ctx context.Context, req *DeleteSIPParticipantRequest) (*SIPParticipantInfo, error) { + resp, err := c.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*DeleteSIPParticipantRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*DeleteSIPParticipantRequest) when calling interceptor") + } + return c.callDeleteSIPParticipant(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*SIPParticipantInfo) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*SIPParticipantInfo) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + return caller(ctx, in) +} + +func (c *sIPProtobufClient) callDeleteSIPParticipant(ctx context.Context, in *DeleteSIPParticipantRequest) (*SIPParticipantInfo, error) { + out := new(SIPParticipantInfo) + ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[9], in, out) + if err != nil { + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + callClientError(ctx, c.opts.Hooks, twerr) + return nil, err + } + + callClientResponseReceived(ctx, c.opts.Hooks) + + return out, nil +} + +// =============== +// SIP JSON Client +// =============== + +type sIPJSONClient struct { + client HTTPClient + urls [10]string + interceptor twirp.Interceptor + opts twirp.ClientOptions +} + +// NewSIPJSONClient creates a JSON client that implements the SIP interface. +// It communicates using JSON and can be configured with a custom HTTPClient. +func NewSIPJSONClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) SIP { + if c, ok := client.(*http.Client); ok { + client = withoutRedirects(c) + } + + clientOpts := twirp.ClientOptions{} + for _, o := range opts { + o(&clientOpts) + } + + // Using ReadOpt allows backwards and forwards compatibility with new options in the future + literalURLs := false + _ = clientOpts.ReadOpt("literalURLs", &literalURLs) + var pathPrefix string + if ok := clientOpts.ReadOpt("pathPrefix", &pathPrefix); !ok { + pathPrefix = "/twirp" // default prefix + } + + // Build method URLs: []/./ + serviceURL := sanitizeBaseURL(baseURL) + serviceURL += baseServicePath(pathPrefix, "livekit", "SIP") + urls := [10]string{ + serviceURL + "CreateSIPTrunk", + serviceURL + "ListSIPTrunk", + serviceURL + "DeleteSIPTrunk", + serviceURL + "CreateSIPDispatchRule", + serviceURL + "ListSIPDispatchRule", + serviceURL + "DeleteSIPDispatchRule", + serviceURL + "CreateSIPParticipant", + serviceURL + "SendSIPParticipantDTMF", + serviceURL + "ListSIPParticipant", + serviceURL + "DeleteSIPParticipant", + } + + return &sIPJSONClient{ + client: client, + urls: urls, + interceptor: twirp.ChainInterceptors(clientOpts.Interceptors...), + opts: clientOpts, + } +} + +func (c *sIPJSONClient) CreateSIPTrunk(ctx context.Context, in *CreateSIPTrunkRequest) (*SIPTrunkInfo, error) { + ctx = ctxsetters.WithPackageName(ctx, "livekit") + ctx = ctxsetters.WithServiceName(ctx, "SIP") + ctx = ctxsetters.WithMethodName(ctx, "CreateSIPTrunk") + caller := c.callCreateSIPTrunk + if c.interceptor != nil { + caller = func(ctx context.Context, req *CreateSIPTrunkRequest) (*SIPTrunkInfo, error) { + resp, err := c.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*CreateSIPTrunkRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*CreateSIPTrunkRequest) when calling interceptor") + } + return c.callCreateSIPTrunk(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*SIPTrunkInfo) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*SIPTrunkInfo) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + return caller(ctx, in) +} + +func (c *sIPJSONClient) callCreateSIPTrunk(ctx context.Context, in *CreateSIPTrunkRequest) (*SIPTrunkInfo, error) { + out := new(SIPTrunkInfo) + ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[0], in, out) + if err != nil { + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + callClientError(ctx, c.opts.Hooks, twerr) + return nil, err + } + + callClientResponseReceived(ctx, c.opts.Hooks) + + return out, nil +} + +func (c *sIPJSONClient) ListSIPTrunk(ctx context.Context, in *ListSIPTrunkRequest) (*ListSIPTrunkResponse, error) { + ctx = ctxsetters.WithPackageName(ctx, "livekit") + ctx = ctxsetters.WithServiceName(ctx, "SIP") + ctx = ctxsetters.WithMethodName(ctx, "ListSIPTrunk") + caller := c.callListSIPTrunk + if c.interceptor != nil { + caller = func(ctx context.Context, req *ListSIPTrunkRequest) (*ListSIPTrunkResponse, error) { + resp, err := c.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*ListSIPTrunkRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*ListSIPTrunkRequest) when calling interceptor") + } + return c.callListSIPTrunk(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*ListSIPTrunkResponse) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*ListSIPTrunkResponse) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + return caller(ctx, in) +} + +func (c *sIPJSONClient) callListSIPTrunk(ctx context.Context, in *ListSIPTrunkRequest) (*ListSIPTrunkResponse, error) { + out := new(ListSIPTrunkResponse) + ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[1], in, out) + if err != nil { + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + callClientError(ctx, c.opts.Hooks, twerr) + return nil, err + } + + callClientResponseReceived(ctx, c.opts.Hooks) + + return out, nil +} + +func (c *sIPJSONClient) DeleteSIPTrunk(ctx context.Context, in *DeleteSIPTrunkRequest) (*SIPTrunkInfo, error) { + ctx = ctxsetters.WithPackageName(ctx, "livekit") + ctx = ctxsetters.WithServiceName(ctx, "SIP") + ctx = ctxsetters.WithMethodName(ctx, "DeleteSIPTrunk") + caller := c.callDeleteSIPTrunk + if c.interceptor != nil { + caller = func(ctx context.Context, req *DeleteSIPTrunkRequest) (*SIPTrunkInfo, error) { + resp, err := c.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*DeleteSIPTrunkRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*DeleteSIPTrunkRequest) when calling interceptor") + } + return c.callDeleteSIPTrunk(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*SIPTrunkInfo) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*SIPTrunkInfo) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + return caller(ctx, in) +} + +func (c *sIPJSONClient) callDeleteSIPTrunk(ctx context.Context, in *DeleteSIPTrunkRequest) (*SIPTrunkInfo, error) { + out := new(SIPTrunkInfo) + ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[2], in, out) + if err != nil { + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + callClientError(ctx, c.opts.Hooks, twerr) + return nil, err + } + + callClientResponseReceived(ctx, c.opts.Hooks) + + return out, nil +} + +func (c *sIPJSONClient) CreateSIPDispatchRule(ctx context.Context, in *CreateSIPDispatchRuleRequest) (*SIPDispatchRuleInfo, error) { + ctx = ctxsetters.WithPackageName(ctx, "livekit") + ctx = ctxsetters.WithServiceName(ctx, "SIP") + ctx = ctxsetters.WithMethodName(ctx, "CreateSIPDispatchRule") + caller := c.callCreateSIPDispatchRule + if c.interceptor != nil { + caller = func(ctx context.Context, req *CreateSIPDispatchRuleRequest) (*SIPDispatchRuleInfo, error) { + resp, err := c.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*CreateSIPDispatchRuleRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*CreateSIPDispatchRuleRequest) when calling interceptor") + } + return c.callCreateSIPDispatchRule(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*SIPDispatchRuleInfo) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*SIPDispatchRuleInfo) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + return caller(ctx, in) +} + +func (c *sIPJSONClient) callCreateSIPDispatchRule(ctx context.Context, in *CreateSIPDispatchRuleRequest) (*SIPDispatchRuleInfo, error) { + out := new(SIPDispatchRuleInfo) + ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[3], in, out) + if err != nil { + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + callClientError(ctx, c.opts.Hooks, twerr) + return nil, err + } + + callClientResponseReceived(ctx, c.opts.Hooks) + + return out, nil +} + +func (c *sIPJSONClient) ListSIPDispatchRule(ctx context.Context, in *ListSIPDispatchRuleRequest) (*ListSIPDispatchRuleResponse, error) { + ctx = ctxsetters.WithPackageName(ctx, "livekit") + ctx = ctxsetters.WithServiceName(ctx, "SIP") + ctx = ctxsetters.WithMethodName(ctx, "ListSIPDispatchRule") + caller := c.callListSIPDispatchRule + if c.interceptor != nil { + caller = func(ctx context.Context, req *ListSIPDispatchRuleRequest) (*ListSIPDispatchRuleResponse, error) { + resp, err := c.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*ListSIPDispatchRuleRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*ListSIPDispatchRuleRequest) when calling interceptor") + } + return c.callListSIPDispatchRule(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*ListSIPDispatchRuleResponse) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*ListSIPDispatchRuleResponse) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + return caller(ctx, in) +} + +func (c *sIPJSONClient) callListSIPDispatchRule(ctx context.Context, in *ListSIPDispatchRuleRequest) (*ListSIPDispatchRuleResponse, error) { + out := new(ListSIPDispatchRuleResponse) + ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[4], in, out) + if err != nil { + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + callClientError(ctx, c.opts.Hooks, twerr) + return nil, err + } + + callClientResponseReceived(ctx, c.opts.Hooks) + + return out, nil +} + +func (c *sIPJSONClient) DeleteSIPDispatchRule(ctx context.Context, in *DeleteSIPDispatchRuleRequest) (*SIPDispatchRuleInfo, error) { + ctx = ctxsetters.WithPackageName(ctx, "livekit") + ctx = ctxsetters.WithServiceName(ctx, "SIP") + ctx = ctxsetters.WithMethodName(ctx, "DeleteSIPDispatchRule") + caller := c.callDeleteSIPDispatchRule + if c.interceptor != nil { + caller = func(ctx context.Context, req *DeleteSIPDispatchRuleRequest) (*SIPDispatchRuleInfo, error) { + resp, err := c.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*DeleteSIPDispatchRuleRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*DeleteSIPDispatchRuleRequest) when calling interceptor") + } + return c.callDeleteSIPDispatchRule(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*SIPDispatchRuleInfo) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*SIPDispatchRuleInfo) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + return caller(ctx, in) +} + +func (c *sIPJSONClient) callDeleteSIPDispatchRule(ctx context.Context, in *DeleteSIPDispatchRuleRequest) (*SIPDispatchRuleInfo, error) { + out := new(SIPDispatchRuleInfo) + ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[5], in, out) + if err != nil { + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + callClientError(ctx, c.opts.Hooks, twerr) + return nil, err + } + + callClientResponseReceived(ctx, c.opts.Hooks) + + return out, nil +} + +func (c *sIPJSONClient) CreateSIPParticipant(ctx context.Context, in *CreateSIPParticipantRequest) (*SIPParticipantInfo, error) { + ctx = ctxsetters.WithPackageName(ctx, "livekit") + ctx = ctxsetters.WithServiceName(ctx, "SIP") + ctx = ctxsetters.WithMethodName(ctx, "CreateSIPParticipant") + caller := c.callCreateSIPParticipant + if c.interceptor != nil { + caller = func(ctx context.Context, req *CreateSIPParticipantRequest) (*SIPParticipantInfo, error) { + resp, err := c.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*CreateSIPParticipantRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*CreateSIPParticipantRequest) when calling interceptor") + } + return c.callCreateSIPParticipant(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*SIPParticipantInfo) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*SIPParticipantInfo) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + return caller(ctx, in) +} + +func (c *sIPJSONClient) callCreateSIPParticipant(ctx context.Context, in *CreateSIPParticipantRequest) (*SIPParticipantInfo, error) { + out := new(SIPParticipantInfo) + ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[6], in, out) + if err != nil { + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + callClientError(ctx, c.opts.Hooks, twerr) + return nil, err + } + + callClientResponseReceived(ctx, c.opts.Hooks) + + return out, nil +} + +func (c *sIPJSONClient) SendSIPParticipantDTMF(ctx context.Context, in *SendSIPParticipantDTMFRequest) (*SIPParticipantDTMFInfo, error) { + ctx = ctxsetters.WithPackageName(ctx, "livekit") + ctx = ctxsetters.WithServiceName(ctx, "SIP") + ctx = ctxsetters.WithMethodName(ctx, "SendSIPParticipantDTMF") + caller := c.callSendSIPParticipantDTMF + if c.interceptor != nil { + caller = func(ctx context.Context, req *SendSIPParticipantDTMFRequest) (*SIPParticipantDTMFInfo, error) { + resp, err := c.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*SendSIPParticipantDTMFRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*SendSIPParticipantDTMFRequest) when calling interceptor") + } + return c.callSendSIPParticipantDTMF(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*SIPParticipantDTMFInfo) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*SIPParticipantDTMFInfo) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + return caller(ctx, in) +} + +func (c *sIPJSONClient) callSendSIPParticipantDTMF(ctx context.Context, in *SendSIPParticipantDTMFRequest) (*SIPParticipantDTMFInfo, error) { + out := new(SIPParticipantDTMFInfo) + ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[7], in, out) + if err != nil { + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + callClientError(ctx, c.opts.Hooks, twerr) + return nil, err + } + + callClientResponseReceived(ctx, c.opts.Hooks) + + return out, nil +} + +func (c *sIPJSONClient) ListSIPParticipant(ctx context.Context, in *ListSIPParticipantRequest) (*ListSIPParticipantResponse, error) { + ctx = ctxsetters.WithPackageName(ctx, "livekit") + ctx = ctxsetters.WithServiceName(ctx, "SIP") + ctx = ctxsetters.WithMethodName(ctx, "ListSIPParticipant") + caller := c.callListSIPParticipant + if c.interceptor != nil { + caller = func(ctx context.Context, req *ListSIPParticipantRequest) (*ListSIPParticipantResponse, error) { + resp, err := c.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*ListSIPParticipantRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*ListSIPParticipantRequest) when calling interceptor") + } + return c.callListSIPParticipant(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*ListSIPParticipantResponse) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*ListSIPParticipantResponse) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + return caller(ctx, in) +} + +func (c *sIPJSONClient) callListSIPParticipant(ctx context.Context, in *ListSIPParticipantRequest) (*ListSIPParticipantResponse, error) { + out := new(ListSIPParticipantResponse) + ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[8], in, out) + if err != nil { + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + callClientError(ctx, c.opts.Hooks, twerr) + return nil, err + } + + callClientResponseReceived(ctx, c.opts.Hooks) + + return out, nil +} + +func (c *sIPJSONClient) DeleteSIPParticipant(ctx context.Context, in *DeleteSIPParticipantRequest) (*SIPParticipantInfo, error) { + ctx = ctxsetters.WithPackageName(ctx, "livekit") + ctx = ctxsetters.WithServiceName(ctx, "SIP") + ctx = ctxsetters.WithMethodName(ctx, "DeleteSIPParticipant") + caller := c.callDeleteSIPParticipant + if c.interceptor != nil { + caller = func(ctx context.Context, req *DeleteSIPParticipantRequest) (*SIPParticipantInfo, error) { + resp, err := c.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*DeleteSIPParticipantRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*DeleteSIPParticipantRequest) when calling interceptor") + } + return c.callDeleteSIPParticipant(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*SIPParticipantInfo) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*SIPParticipantInfo) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + return caller(ctx, in) +} + +func (c *sIPJSONClient) callDeleteSIPParticipant(ctx context.Context, in *DeleteSIPParticipantRequest) (*SIPParticipantInfo, error) { + out := new(SIPParticipantInfo) + ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[9], in, out) + if err != nil { + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + callClientError(ctx, c.opts.Hooks, twerr) + return nil, err + } + + callClientResponseReceived(ctx, c.opts.Hooks) + + return out, nil +} + +// ================== +// SIP Server Handler +// ================== + +type sIPServer struct { + SIP + interceptor twirp.Interceptor + hooks *twirp.ServerHooks + pathPrefix string // prefix for routing + jsonSkipDefaults bool // do not include unpopulated fields (default values) in the response + jsonCamelCase bool // JSON fields are serialized as lowerCamelCase rather than keeping the original proto names +} + +// NewSIPServer builds a TwirpServer that can be used as an http.Handler to handle +// HTTP requests that are routed to the right method in the provided svc implementation. +// The opts are twirp.ServerOption modifiers, for example twirp.WithServerHooks(hooks). +func NewSIPServer(svc SIP, opts ...interface{}) TwirpServer { + serverOpts := newServerOpts(opts) + + // Using ReadOpt allows backwards and forwards compatibility with new options in the future + jsonSkipDefaults := false + _ = serverOpts.ReadOpt("jsonSkipDefaults", &jsonSkipDefaults) + jsonCamelCase := false + _ = serverOpts.ReadOpt("jsonCamelCase", &jsonCamelCase) + var pathPrefix string + if ok := serverOpts.ReadOpt("pathPrefix", &pathPrefix); !ok { + pathPrefix = "/twirp" // default prefix + } + + return &sIPServer{ + SIP: svc, + hooks: serverOpts.Hooks, + interceptor: twirp.ChainInterceptors(serverOpts.Interceptors...), + pathPrefix: pathPrefix, + jsonSkipDefaults: jsonSkipDefaults, + jsonCamelCase: jsonCamelCase, + } +} + +// writeError writes an HTTP response with a valid Twirp error format, and triggers hooks. +// If err is not a twirp.Error, it will get wrapped with twirp.InternalErrorWith(err) +func (s *sIPServer) writeError(ctx context.Context, resp http.ResponseWriter, err error) { + writeError(ctx, resp, err, s.hooks) +} + +// handleRequestBodyError is used to handle error when the twirp server cannot read request +func (s *sIPServer) handleRequestBodyError(ctx context.Context, resp http.ResponseWriter, msg string, err error) { + if context.Canceled == ctx.Err() { + s.writeError(ctx, resp, twirp.NewError(twirp.Canceled, "failed to read request: context canceled")) + return + } + if context.DeadlineExceeded == ctx.Err() { + s.writeError(ctx, resp, twirp.NewError(twirp.DeadlineExceeded, "failed to read request: deadline exceeded")) + return + } + s.writeError(ctx, resp, twirp.WrapError(malformedRequestError(msg), err)) +} + +// SIPPathPrefix is a convenience constant that may identify URL paths. +// Should be used with caution, it only matches routes generated by Twirp Go clients, +// with the default "/twirp" prefix and default CamelCase service and method names. +// More info: https://twitchtv.github.io/twirp/docs/routing.html +const SIPPathPrefix = "/twirp/livekit.SIP/" + +func (s *sIPServer) ServeHTTP(resp http.ResponseWriter, req *http.Request) { + ctx := req.Context() + ctx = ctxsetters.WithPackageName(ctx, "livekit") + ctx = ctxsetters.WithServiceName(ctx, "SIP") + ctx = ctxsetters.WithResponseWriter(ctx, resp) + + var err error + ctx, err = callRequestReceived(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + if req.Method != "POST" { + msg := fmt.Sprintf("unsupported method %q (only POST is allowed)", req.Method) + s.writeError(ctx, resp, badRouteError(msg, req.Method, req.URL.Path)) + return + } + + // Verify path format: []/./ + prefix, pkgService, method := parseTwirpPath(req.URL.Path) + if pkgService != "livekit.SIP" { + msg := fmt.Sprintf("no handler for path %q", req.URL.Path) + s.writeError(ctx, resp, badRouteError(msg, req.Method, req.URL.Path)) + return + } + if prefix != s.pathPrefix { + msg := fmt.Sprintf("invalid path prefix %q, expected %q, on path %q", prefix, s.pathPrefix, req.URL.Path) + s.writeError(ctx, resp, badRouteError(msg, req.Method, req.URL.Path)) + return + } + + switch method { + case "CreateSIPTrunk": + s.serveCreateSIPTrunk(ctx, resp, req) + return + case "ListSIPTrunk": + s.serveListSIPTrunk(ctx, resp, req) + return + case "DeleteSIPTrunk": + s.serveDeleteSIPTrunk(ctx, resp, req) + return + case "CreateSIPDispatchRule": + s.serveCreateSIPDispatchRule(ctx, resp, req) + return + case "ListSIPDispatchRule": + s.serveListSIPDispatchRule(ctx, resp, req) + return + case "DeleteSIPDispatchRule": + s.serveDeleteSIPDispatchRule(ctx, resp, req) + return + case "CreateSIPParticipant": + s.serveCreateSIPParticipant(ctx, resp, req) + return + case "SendSIPParticipantDTMF": + s.serveSendSIPParticipantDTMF(ctx, resp, req) + return + case "ListSIPParticipant": + s.serveListSIPParticipant(ctx, resp, req) + return + case "DeleteSIPParticipant": + s.serveDeleteSIPParticipant(ctx, resp, req) + return + default: + msg := fmt.Sprintf("no handler for path %q", req.URL.Path) + s.writeError(ctx, resp, badRouteError(msg, req.Method, req.URL.Path)) + return + } +} + +func (s *sIPServer) serveCreateSIPTrunk(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + header := req.Header.Get("Content-Type") + i := strings.Index(header, ";") + if i == -1 { + i = len(header) + } + switch strings.TrimSpace(strings.ToLower(header[:i])) { + case "application/json": + s.serveCreateSIPTrunkJSON(ctx, resp, req) + case "application/protobuf": + s.serveCreateSIPTrunkProtobuf(ctx, resp, req) + default: + msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type")) + twerr := badRouteError(msg, req.Method, req.URL.Path) + s.writeError(ctx, resp, twerr) + } +} + +func (s *sIPServer) serveCreateSIPTrunkJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + var err error + ctx = ctxsetters.WithMethodName(ctx, "CreateSIPTrunk") + ctx, err = callRequestRouted(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + d := json.NewDecoder(req.Body) + rawReqBody := json.RawMessage{} + if err := d.Decode(&rawReqBody); err != nil { + s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err) + return + } + reqContent := new(CreateSIPTrunkRequest) + unmarshaler := protojson.UnmarshalOptions{DiscardUnknown: true} + if err = unmarshaler.Unmarshal(rawReqBody, reqContent); err != nil { + s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err) + return + } + + handler := s.SIP.CreateSIPTrunk + if s.interceptor != nil { + handler = func(ctx context.Context, req *CreateSIPTrunkRequest) (*SIPTrunkInfo, error) { + resp, err := s.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*CreateSIPTrunkRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*CreateSIPTrunkRequest) when calling interceptor") + } + return s.SIP.CreateSIPTrunk(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*SIPTrunkInfo) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*SIPTrunkInfo) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + + // Call service method + var respContent *SIPTrunkInfo + func() { + defer ensurePanicResponses(ctx, resp, s.hooks) + respContent, err = handler(ctx, reqContent) + }() + + if err != nil { + s.writeError(ctx, resp, err) + return + } + if respContent == nil { + s.writeError(ctx, resp, twirp.InternalError("received a nil *SIPTrunkInfo and nil error while calling CreateSIPTrunk. nil responses are not supported")) + return + } + + ctx = callResponsePrepared(ctx, s.hooks) + + marshaler := &protojson.MarshalOptions{UseProtoNames: !s.jsonCamelCase, EmitUnpopulated: !s.jsonSkipDefaults} + respBytes, err := marshaler.Marshal(respContent) + if err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response")) + return + } + + ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) + resp.Header().Set("Content-Type", "application/json") + resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) + resp.WriteHeader(http.StatusOK) + + if n, err := resp.Write(respBytes); err != nil { + msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) + twerr := twirp.NewError(twirp.Unknown, msg) + ctx = callError(ctx, s.hooks, twerr) + } + callResponseSent(ctx, s.hooks) +} + +func (s *sIPServer) serveCreateSIPTrunkProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + var err error + ctx = ctxsetters.WithMethodName(ctx, "CreateSIPTrunk") + ctx, err = callRequestRouted(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + buf, err := io.ReadAll(req.Body) + if err != nil { + s.handleRequestBodyError(ctx, resp, "failed to read request body", err) + return + } + reqContent := new(CreateSIPTrunkRequest) + if err = proto.Unmarshal(buf, reqContent); err != nil { + s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded")) + return + } + + handler := s.SIP.CreateSIPTrunk + if s.interceptor != nil { + handler = func(ctx context.Context, req *CreateSIPTrunkRequest) (*SIPTrunkInfo, error) { + resp, err := s.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*CreateSIPTrunkRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*CreateSIPTrunkRequest) when calling interceptor") + } + return s.SIP.CreateSIPTrunk(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*SIPTrunkInfo) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*SIPTrunkInfo) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + + // Call service method + var respContent *SIPTrunkInfo + func() { + defer ensurePanicResponses(ctx, resp, s.hooks) + respContent, err = handler(ctx, reqContent) + }() + + if err != nil { + s.writeError(ctx, resp, err) + return + } + if respContent == nil { + s.writeError(ctx, resp, twirp.InternalError("received a nil *SIPTrunkInfo and nil error while calling CreateSIPTrunk. nil responses are not supported")) + return + } + + ctx = callResponsePrepared(ctx, s.hooks) + + respBytes, err := proto.Marshal(respContent) + if err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response")) + return + } + + ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) + resp.Header().Set("Content-Type", "application/protobuf") + resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) + resp.WriteHeader(http.StatusOK) + if n, err := resp.Write(respBytes); err != nil { + msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) + twerr := twirp.NewError(twirp.Unknown, msg) + ctx = callError(ctx, s.hooks, twerr) + } + callResponseSent(ctx, s.hooks) +} + +func (s *sIPServer) serveListSIPTrunk(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + header := req.Header.Get("Content-Type") + i := strings.Index(header, ";") + if i == -1 { + i = len(header) + } + switch strings.TrimSpace(strings.ToLower(header[:i])) { + case "application/json": + s.serveListSIPTrunkJSON(ctx, resp, req) + case "application/protobuf": + s.serveListSIPTrunkProtobuf(ctx, resp, req) + default: + msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type")) + twerr := badRouteError(msg, req.Method, req.URL.Path) + s.writeError(ctx, resp, twerr) + } +} + +func (s *sIPServer) serveListSIPTrunkJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + var err error + ctx = ctxsetters.WithMethodName(ctx, "ListSIPTrunk") + ctx, err = callRequestRouted(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + d := json.NewDecoder(req.Body) + rawReqBody := json.RawMessage{} + if err := d.Decode(&rawReqBody); err != nil { + s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err) + return + } + reqContent := new(ListSIPTrunkRequest) + unmarshaler := protojson.UnmarshalOptions{DiscardUnknown: true} + if err = unmarshaler.Unmarshal(rawReqBody, reqContent); err != nil { + s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err) + return + } + + handler := s.SIP.ListSIPTrunk + if s.interceptor != nil { + handler = func(ctx context.Context, req *ListSIPTrunkRequest) (*ListSIPTrunkResponse, error) { + resp, err := s.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*ListSIPTrunkRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*ListSIPTrunkRequest) when calling interceptor") + } + return s.SIP.ListSIPTrunk(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*ListSIPTrunkResponse) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*ListSIPTrunkResponse) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + + // Call service method + var respContent *ListSIPTrunkResponse + func() { + defer ensurePanicResponses(ctx, resp, s.hooks) + respContent, err = handler(ctx, reqContent) + }() + + if err != nil { + s.writeError(ctx, resp, err) + return + } + if respContent == nil { + s.writeError(ctx, resp, twirp.InternalError("received a nil *ListSIPTrunkResponse and nil error while calling ListSIPTrunk. nil responses are not supported")) + return + } + + ctx = callResponsePrepared(ctx, s.hooks) + + marshaler := &protojson.MarshalOptions{UseProtoNames: !s.jsonCamelCase, EmitUnpopulated: !s.jsonSkipDefaults} + respBytes, err := marshaler.Marshal(respContent) + if err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response")) + return + } + + ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) + resp.Header().Set("Content-Type", "application/json") + resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) + resp.WriteHeader(http.StatusOK) + + if n, err := resp.Write(respBytes); err != nil { + msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) + twerr := twirp.NewError(twirp.Unknown, msg) + ctx = callError(ctx, s.hooks, twerr) + } + callResponseSent(ctx, s.hooks) +} + +func (s *sIPServer) serveListSIPTrunkProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + var err error + ctx = ctxsetters.WithMethodName(ctx, "ListSIPTrunk") + ctx, err = callRequestRouted(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + buf, err := io.ReadAll(req.Body) + if err != nil { + s.handleRequestBodyError(ctx, resp, "failed to read request body", err) + return + } + reqContent := new(ListSIPTrunkRequest) + if err = proto.Unmarshal(buf, reqContent); err != nil { + s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded")) + return + } + + handler := s.SIP.ListSIPTrunk + if s.interceptor != nil { + handler = func(ctx context.Context, req *ListSIPTrunkRequest) (*ListSIPTrunkResponse, error) { + resp, err := s.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*ListSIPTrunkRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*ListSIPTrunkRequest) when calling interceptor") + } + return s.SIP.ListSIPTrunk(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*ListSIPTrunkResponse) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*ListSIPTrunkResponse) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + + // Call service method + var respContent *ListSIPTrunkResponse + func() { + defer ensurePanicResponses(ctx, resp, s.hooks) + respContent, err = handler(ctx, reqContent) + }() + + if err != nil { + s.writeError(ctx, resp, err) + return + } + if respContent == nil { + s.writeError(ctx, resp, twirp.InternalError("received a nil *ListSIPTrunkResponse and nil error while calling ListSIPTrunk. nil responses are not supported")) + return + } + + ctx = callResponsePrepared(ctx, s.hooks) + + respBytes, err := proto.Marshal(respContent) + if err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response")) + return + } + + ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) + resp.Header().Set("Content-Type", "application/protobuf") + resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) + resp.WriteHeader(http.StatusOK) + if n, err := resp.Write(respBytes); err != nil { + msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) + twerr := twirp.NewError(twirp.Unknown, msg) + ctx = callError(ctx, s.hooks, twerr) + } + callResponseSent(ctx, s.hooks) +} + +func (s *sIPServer) serveDeleteSIPTrunk(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + header := req.Header.Get("Content-Type") + i := strings.Index(header, ";") + if i == -1 { + i = len(header) + } + switch strings.TrimSpace(strings.ToLower(header[:i])) { + case "application/json": + s.serveDeleteSIPTrunkJSON(ctx, resp, req) + case "application/protobuf": + s.serveDeleteSIPTrunkProtobuf(ctx, resp, req) + default: + msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type")) + twerr := badRouteError(msg, req.Method, req.URL.Path) + s.writeError(ctx, resp, twerr) + } +} + +func (s *sIPServer) serveDeleteSIPTrunkJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + var err error + ctx = ctxsetters.WithMethodName(ctx, "DeleteSIPTrunk") + ctx, err = callRequestRouted(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + d := json.NewDecoder(req.Body) + rawReqBody := json.RawMessage{} + if err := d.Decode(&rawReqBody); err != nil { + s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err) + return + } + reqContent := new(DeleteSIPTrunkRequest) + unmarshaler := protojson.UnmarshalOptions{DiscardUnknown: true} + if err = unmarshaler.Unmarshal(rawReqBody, reqContent); err != nil { + s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err) + return + } + + handler := s.SIP.DeleteSIPTrunk + if s.interceptor != nil { + handler = func(ctx context.Context, req *DeleteSIPTrunkRequest) (*SIPTrunkInfo, error) { + resp, err := s.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*DeleteSIPTrunkRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*DeleteSIPTrunkRequest) when calling interceptor") + } + return s.SIP.DeleteSIPTrunk(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*SIPTrunkInfo) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*SIPTrunkInfo) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + + // Call service method + var respContent *SIPTrunkInfo + func() { + defer ensurePanicResponses(ctx, resp, s.hooks) + respContent, err = handler(ctx, reqContent) + }() + + if err != nil { + s.writeError(ctx, resp, err) + return + } + if respContent == nil { + s.writeError(ctx, resp, twirp.InternalError("received a nil *SIPTrunkInfo and nil error while calling DeleteSIPTrunk. nil responses are not supported")) + return + } + + ctx = callResponsePrepared(ctx, s.hooks) + + marshaler := &protojson.MarshalOptions{UseProtoNames: !s.jsonCamelCase, EmitUnpopulated: !s.jsonSkipDefaults} + respBytes, err := marshaler.Marshal(respContent) + if err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response")) + return + } + + ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) + resp.Header().Set("Content-Type", "application/json") + resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) + resp.WriteHeader(http.StatusOK) + + if n, err := resp.Write(respBytes); err != nil { + msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) + twerr := twirp.NewError(twirp.Unknown, msg) + ctx = callError(ctx, s.hooks, twerr) + } + callResponseSent(ctx, s.hooks) +} + +func (s *sIPServer) serveDeleteSIPTrunkProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + var err error + ctx = ctxsetters.WithMethodName(ctx, "DeleteSIPTrunk") + ctx, err = callRequestRouted(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + buf, err := io.ReadAll(req.Body) + if err != nil { + s.handleRequestBodyError(ctx, resp, "failed to read request body", err) + return + } + reqContent := new(DeleteSIPTrunkRequest) + if err = proto.Unmarshal(buf, reqContent); err != nil { + s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded")) + return + } + + handler := s.SIP.DeleteSIPTrunk + if s.interceptor != nil { + handler = func(ctx context.Context, req *DeleteSIPTrunkRequest) (*SIPTrunkInfo, error) { + resp, err := s.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*DeleteSIPTrunkRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*DeleteSIPTrunkRequest) when calling interceptor") + } + return s.SIP.DeleteSIPTrunk(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*SIPTrunkInfo) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*SIPTrunkInfo) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + + // Call service method + var respContent *SIPTrunkInfo + func() { + defer ensurePanicResponses(ctx, resp, s.hooks) + respContent, err = handler(ctx, reqContent) + }() + + if err != nil { + s.writeError(ctx, resp, err) + return + } + if respContent == nil { + s.writeError(ctx, resp, twirp.InternalError("received a nil *SIPTrunkInfo and nil error while calling DeleteSIPTrunk. nil responses are not supported")) + return + } + + ctx = callResponsePrepared(ctx, s.hooks) + + respBytes, err := proto.Marshal(respContent) + if err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response")) + return + } + + ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) + resp.Header().Set("Content-Type", "application/protobuf") + resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) + resp.WriteHeader(http.StatusOK) + if n, err := resp.Write(respBytes); err != nil { + msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) + twerr := twirp.NewError(twirp.Unknown, msg) + ctx = callError(ctx, s.hooks, twerr) + } + callResponseSent(ctx, s.hooks) +} + +func (s *sIPServer) serveCreateSIPDispatchRule(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + header := req.Header.Get("Content-Type") + i := strings.Index(header, ";") + if i == -1 { + i = len(header) + } + switch strings.TrimSpace(strings.ToLower(header[:i])) { + case "application/json": + s.serveCreateSIPDispatchRuleJSON(ctx, resp, req) + case "application/protobuf": + s.serveCreateSIPDispatchRuleProtobuf(ctx, resp, req) + default: + msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type")) + twerr := badRouteError(msg, req.Method, req.URL.Path) + s.writeError(ctx, resp, twerr) + } +} + +func (s *sIPServer) serveCreateSIPDispatchRuleJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + var err error + ctx = ctxsetters.WithMethodName(ctx, "CreateSIPDispatchRule") + ctx, err = callRequestRouted(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + d := json.NewDecoder(req.Body) + rawReqBody := json.RawMessage{} + if err := d.Decode(&rawReqBody); err != nil { + s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err) + return + } + reqContent := new(CreateSIPDispatchRuleRequest) + unmarshaler := protojson.UnmarshalOptions{DiscardUnknown: true} + if err = unmarshaler.Unmarshal(rawReqBody, reqContent); err != nil { + s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err) + return + } + + handler := s.SIP.CreateSIPDispatchRule + if s.interceptor != nil { + handler = func(ctx context.Context, req *CreateSIPDispatchRuleRequest) (*SIPDispatchRuleInfo, error) { + resp, err := s.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*CreateSIPDispatchRuleRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*CreateSIPDispatchRuleRequest) when calling interceptor") + } + return s.SIP.CreateSIPDispatchRule(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*SIPDispatchRuleInfo) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*SIPDispatchRuleInfo) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + + // Call service method + var respContent *SIPDispatchRuleInfo + func() { + defer ensurePanicResponses(ctx, resp, s.hooks) + respContent, err = handler(ctx, reqContent) + }() + + if err != nil { + s.writeError(ctx, resp, err) + return + } + if respContent == nil { + s.writeError(ctx, resp, twirp.InternalError("received a nil *SIPDispatchRuleInfo and nil error while calling CreateSIPDispatchRule. nil responses are not supported")) + return + } + + ctx = callResponsePrepared(ctx, s.hooks) + + marshaler := &protojson.MarshalOptions{UseProtoNames: !s.jsonCamelCase, EmitUnpopulated: !s.jsonSkipDefaults} + respBytes, err := marshaler.Marshal(respContent) + if err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response")) + return + } + + ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) + resp.Header().Set("Content-Type", "application/json") + resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) + resp.WriteHeader(http.StatusOK) + + if n, err := resp.Write(respBytes); err != nil { + msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) + twerr := twirp.NewError(twirp.Unknown, msg) + ctx = callError(ctx, s.hooks, twerr) + } + callResponseSent(ctx, s.hooks) +} + +func (s *sIPServer) serveCreateSIPDispatchRuleProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + var err error + ctx = ctxsetters.WithMethodName(ctx, "CreateSIPDispatchRule") + ctx, err = callRequestRouted(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + buf, err := io.ReadAll(req.Body) + if err != nil { + s.handleRequestBodyError(ctx, resp, "failed to read request body", err) + return + } + reqContent := new(CreateSIPDispatchRuleRequest) + if err = proto.Unmarshal(buf, reqContent); err != nil { + s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded")) + return + } + + handler := s.SIP.CreateSIPDispatchRule + if s.interceptor != nil { + handler = func(ctx context.Context, req *CreateSIPDispatchRuleRequest) (*SIPDispatchRuleInfo, error) { + resp, err := s.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*CreateSIPDispatchRuleRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*CreateSIPDispatchRuleRequest) when calling interceptor") + } + return s.SIP.CreateSIPDispatchRule(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*SIPDispatchRuleInfo) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*SIPDispatchRuleInfo) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + + // Call service method + var respContent *SIPDispatchRuleInfo + func() { + defer ensurePanicResponses(ctx, resp, s.hooks) + respContent, err = handler(ctx, reqContent) + }() + + if err != nil { + s.writeError(ctx, resp, err) + return + } + if respContent == nil { + s.writeError(ctx, resp, twirp.InternalError("received a nil *SIPDispatchRuleInfo and nil error while calling CreateSIPDispatchRule. nil responses are not supported")) + return + } + + ctx = callResponsePrepared(ctx, s.hooks) + + respBytes, err := proto.Marshal(respContent) + if err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response")) + return + } + + ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) + resp.Header().Set("Content-Type", "application/protobuf") + resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) + resp.WriteHeader(http.StatusOK) + if n, err := resp.Write(respBytes); err != nil { + msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) + twerr := twirp.NewError(twirp.Unknown, msg) + ctx = callError(ctx, s.hooks, twerr) + } + callResponseSent(ctx, s.hooks) +} + +func (s *sIPServer) serveListSIPDispatchRule(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + header := req.Header.Get("Content-Type") + i := strings.Index(header, ";") + if i == -1 { + i = len(header) + } + switch strings.TrimSpace(strings.ToLower(header[:i])) { + case "application/json": + s.serveListSIPDispatchRuleJSON(ctx, resp, req) + case "application/protobuf": + s.serveListSIPDispatchRuleProtobuf(ctx, resp, req) + default: + msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type")) + twerr := badRouteError(msg, req.Method, req.URL.Path) + s.writeError(ctx, resp, twerr) + } +} + +func (s *sIPServer) serveListSIPDispatchRuleJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + var err error + ctx = ctxsetters.WithMethodName(ctx, "ListSIPDispatchRule") + ctx, err = callRequestRouted(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + d := json.NewDecoder(req.Body) + rawReqBody := json.RawMessage{} + if err := d.Decode(&rawReqBody); err != nil { + s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err) + return + } + reqContent := new(ListSIPDispatchRuleRequest) + unmarshaler := protojson.UnmarshalOptions{DiscardUnknown: true} + if err = unmarshaler.Unmarshal(rawReqBody, reqContent); err != nil { + s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err) + return + } + + handler := s.SIP.ListSIPDispatchRule + if s.interceptor != nil { + handler = func(ctx context.Context, req *ListSIPDispatchRuleRequest) (*ListSIPDispatchRuleResponse, error) { + resp, err := s.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*ListSIPDispatchRuleRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*ListSIPDispatchRuleRequest) when calling interceptor") + } + return s.SIP.ListSIPDispatchRule(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*ListSIPDispatchRuleResponse) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*ListSIPDispatchRuleResponse) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + + // Call service method + var respContent *ListSIPDispatchRuleResponse + func() { + defer ensurePanicResponses(ctx, resp, s.hooks) + respContent, err = handler(ctx, reqContent) + }() + + if err != nil { + s.writeError(ctx, resp, err) + return + } + if respContent == nil { + s.writeError(ctx, resp, twirp.InternalError("received a nil *ListSIPDispatchRuleResponse and nil error while calling ListSIPDispatchRule. nil responses are not supported")) + return + } + + ctx = callResponsePrepared(ctx, s.hooks) + + marshaler := &protojson.MarshalOptions{UseProtoNames: !s.jsonCamelCase, EmitUnpopulated: !s.jsonSkipDefaults} + respBytes, err := marshaler.Marshal(respContent) + if err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response")) + return + } + + ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) + resp.Header().Set("Content-Type", "application/json") + resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) + resp.WriteHeader(http.StatusOK) + + if n, err := resp.Write(respBytes); err != nil { + msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) + twerr := twirp.NewError(twirp.Unknown, msg) + ctx = callError(ctx, s.hooks, twerr) + } + callResponseSent(ctx, s.hooks) +} + +func (s *sIPServer) serveListSIPDispatchRuleProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + var err error + ctx = ctxsetters.WithMethodName(ctx, "ListSIPDispatchRule") + ctx, err = callRequestRouted(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + buf, err := io.ReadAll(req.Body) + if err != nil { + s.handleRequestBodyError(ctx, resp, "failed to read request body", err) + return + } + reqContent := new(ListSIPDispatchRuleRequest) + if err = proto.Unmarshal(buf, reqContent); err != nil { + s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded")) + return + } + + handler := s.SIP.ListSIPDispatchRule + if s.interceptor != nil { + handler = func(ctx context.Context, req *ListSIPDispatchRuleRequest) (*ListSIPDispatchRuleResponse, error) { + resp, err := s.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*ListSIPDispatchRuleRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*ListSIPDispatchRuleRequest) when calling interceptor") + } + return s.SIP.ListSIPDispatchRule(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*ListSIPDispatchRuleResponse) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*ListSIPDispatchRuleResponse) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + + // Call service method + var respContent *ListSIPDispatchRuleResponse + func() { + defer ensurePanicResponses(ctx, resp, s.hooks) + respContent, err = handler(ctx, reqContent) + }() + + if err != nil { + s.writeError(ctx, resp, err) + return + } + if respContent == nil { + s.writeError(ctx, resp, twirp.InternalError("received a nil *ListSIPDispatchRuleResponse and nil error while calling ListSIPDispatchRule. nil responses are not supported")) + return + } + + ctx = callResponsePrepared(ctx, s.hooks) + + respBytes, err := proto.Marshal(respContent) + if err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response")) + return + } + + ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) + resp.Header().Set("Content-Type", "application/protobuf") + resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) + resp.WriteHeader(http.StatusOK) + if n, err := resp.Write(respBytes); err != nil { + msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) + twerr := twirp.NewError(twirp.Unknown, msg) + ctx = callError(ctx, s.hooks, twerr) + } + callResponseSent(ctx, s.hooks) +} + +func (s *sIPServer) serveDeleteSIPDispatchRule(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + header := req.Header.Get("Content-Type") + i := strings.Index(header, ";") + if i == -1 { + i = len(header) + } + switch strings.TrimSpace(strings.ToLower(header[:i])) { + case "application/json": + s.serveDeleteSIPDispatchRuleJSON(ctx, resp, req) + case "application/protobuf": + s.serveDeleteSIPDispatchRuleProtobuf(ctx, resp, req) + default: + msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type")) + twerr := badRouteError(msg, req.Method, req.URL.Path) + s.writeError(ctx, resp, twerr) + } +} + +func (s *sIPServer) serveDeleteSIPDispatchRuleJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + var err error + ctx = ctxsetters.WithMethodName(ctx, "DeleteSIPDispatchRule") + ctx, err = callRequestRouted(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + d := json.NewDecoder(req.Body) + rawReqBody := json.RawMessage{} + if err := d.Decode(&rawReqBody); err != nil { + s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err) + return + } + reqContent := new(DeleteSIPDispatchRuleRequest) + unmarshaler := protojson.UnmarshalOptions{DiscardUnknown: true} + if err = unmarshaler.Unmarshal(rawReqBody, reqContent); err != nil { + s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err) + return + } + + handler := s.SIP.DeleteSIPDispatchRule + if s.interceptor != nil { + handler = func(ctx context.Context, req *DeleteSIPDispatchRuleRequest) (*SIPDispatchRuleInfo, error) { + resp, err := s.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*DeleteSIPDispatchRuleRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*DeleteSIPDispatchRuleRequest) when calling interceptor") + } + return s.SIP.DeleteSIPDispatchRule(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*SIPDispatchRuleInfo) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*SIPDispatchRuleInfo) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + + // Call service method + var respContent *SIPDispatchRuleInfo + func() { + defer ensurePanicResponses(ctx, resp, s.hooks) + respContent, err = handler(ctx, reqContent) + }() + + if err != nil { + s.writeError(ctx, resp, err) + return + } + if respContent == nil { + s.writeError(ctx, resp, twirp.InternalError("received a nil *SIPDispatchRuleInfo and nil error while calling DeleteSIPDispatchRule. nil responses are not supported")) + return + } + + ctx = callResponsePrepared(ctx, s.hooks) + + marshaler := &protojson.MarshalOptions{UseProtoNames: !s.jsonCamelCase, EmitUnpopulated: !s.jsonSkipDefaults} + respBytes, err := marshaler.Marshal(respContent) + if err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response")) + return + } + + ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) + resp.Header().Set("Content-Type", "application/json") + resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) + resp.WriteHeader(http.StatusOK) + + if n, err := resp.Write(respBytes); err != nil { + msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) + twerr := twirp.NewError(twirp.Unknown, msg) + ctx = callError(ctx, s.hooks, twerr) + } + callResponseSent(ctx, s.hooks) +} + +func (s *sIPServer) serveDeleteSIPDispatchRuleProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + var err error + ctx = ctxsetters.WithMethodName(ctx, "DeleteSIPDispatchRule") + ctx, err = callRequestRouted(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + buf, err := io.ReadAll(req.Body) + if err != nil { + s.handleRequestBodyError(ctx, resp, "failed to read request body", err) + return + } + reqContent := new(DeleteSIPDispatchRuleRequest) + if err = proto.Unmarshal(buf, reqContent); err != nil { + s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded")) + return + } + + handler := s.SIP.DeleteSIPDispatchRule + if s.interceptor != nil { + handler = func(ctx context.Context, req *DeleteSIPDispatchRuleRequest) (*SIPDispatchRuleInfo, error) { + resp, err := s.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*DeleteSIPDispatchRuleRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*DeleteSIPDispatchRuleRequest) when calling interceptor") + } + return s.SIP.DeleteSIPDispatchRule(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*SIPDispatchRuleInfo) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*SIPDispatchRuleInfo) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + + // Call service method + var respContent *SIPDispatchRuleInfo + func() { + defer ensurePanicResponses(ctx, resp, s.hooks) + respContent, err = handler(ctx, reqContent) + }() + + if err != nil { + s.writeError(ctx, resp, err) + return + } + if respContent == nil { + s.writeError(ctx, resp, twirp.InternalError("received a nil *SIPDispatchRuleInfo and nil error while calling DeleteSIPDispatchRule. nil responses are not supported")) + return + } + + ctx = callResponsePrepared(ctx, s.hooks) + + respBytes, err := proto.Marshal(respContent) + if err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response")) + return + } + + ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) + resp.Header().Set("Content-Type", "application/protobuf") + resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) + resp.WriteHeader(http.StatusOK) + if n, err := resp.Write(respBytes); err != nil { + msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) + twerr := twirp.NewError(twirp.Unknown, msg) + ctx = callError(ctx, s.hooks, twerr) + } + callResponseSent(ctx, s.hooks) +} + +func (s *sIPServer) serveCreateSIPParticipant(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + header := req.Header.Get("Content-Type") + i := strings.Index(header, ";") + if i == -1 { + i = len(header) + } + switch strings.TrimSpace(strings.ToLower(header[:i])) { + case "application/json": + s.serveCreateSIPParticipantJSON(ctx, resp, req) + case "application/protobuf": + s.serveCreateSIPParticipantProtobuf(ctx, resp, req) + default: + msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type")) + twerr := badRouteError(msg, req.Method, req.URL.Path) + s.writeError(ctx, resp, twerr) + } +} + +func (s *sIPServer) serveCreateSIPParticipantJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + var err error + ctx = ctxsetters.WithMethodName(ctx, "CreateSIPParticipant") + ctx, err = callRequestRouted(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + d := json.NewDecoder(req.Body) + rawReqBody := json.RawMessage{} + if err := d.Decode(&rawReqBody); err != nil { + s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err) + return + } + reqContent := new(CreateSIPParticipantRequest) + unmarshaler := protojson.UnmarshalOptions{DiscardUnknown: true} + if err = unmarshaler.Unmarshal(rawReqBody, reqContent); err != nil { + s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err) + return + } + + handler := s.SIP.CreateSIPParticipant + if s.interceptor != nil { + handler = func(ctx context.Context, req *CreateSIPParticipantRequest) (*SIPParticipantInfo, error) { + resp, err := s.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*CreateSIPParticipantRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*CreateSIPParticipantRequest) when calling interceptor") + } + return s.SIP.CreateSIPParticipant(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*SIPParticipantInfo) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*SIPParticipantInfo) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + + // Call service method + var respContent *SIPParticipantInfo + func() { + defer ensurePanicResponses(ctx, resp, s.hooks) + respContent, err = handler(ctx, reqContent) + }() + + if err != nil { + s.writeError(ctx, resp, err) + return + } + if respContent == nil { + s.writeError(ctx, resp, twirp.InternalError("received a nil *SIPParticipantInfo and nil error while calling CreateSIPParticipant. nil responses are not supported")) + return + } + + ctx = callResponsePrepared(ctx, s.hooks) + + marshaler := &protojson.MarshalOptions{UseProtoNames: !s.jsonCamelCase, EmitUnpopulated: !s.jsonSkipDefaults} + respBytes, err := marshaler.Marshal(respContent) + if err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response")) + return + } + + ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) + resp.Header().Set("Content-Type", "application/json") + resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) + resp.WriteHeader(http.StatusOK) + + if n, err := resp.Write(respBytes); err != nil { + msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) + twerr := twirp.NewError(twirp.Unknown, msg) + ctx = callError(ctx, s.hooks, twerr) + } + callResponseSent(ctx, s.hooks) +} + +func (s *sIPServer) serveCreateSIPParticipantProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + var err error + ctx = ctxsetters.WithMethodName(ctx, "CreateSIPParticipant") + ctx, err = callRequestRouted(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + buf, err := io.ReadAll(req.Body) + if err != nil { + s.handleRequestBodyError(ctx, resp, "failed to read request body", err) + return + } + reqContent := new(CreateSIPParticipantRequest) + if err = proto.Unmarshal(buf, reqContent); err != nil { + s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded")) + return + } + + handler := s.SIP.CreateSIPParticipant + if s.interceptor != nil { + handler = func(ctx context.Context, req *CreateSIPParticipantRequest) (*SIPParticipantInfo, error) { + resp, err := s.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*CreateSIPParticipantRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*CreateSIPParticipantRequest) when calling interceptor") + } + return s.SIP.CreateSIPParticipant(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*SIPParticipantInfo) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*SIPParticipantInfo) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + + // Call service method + var respContent *SIPParticipantInfo + func() { + defer ensurePanicResponses(ctx, resp, s.hooks) + respContent, err = handler(ctx, reqContent) + }() + + if err != nil { + s.writeError(ctx, resp, err) + return + } + if respContent == nil { + s.writeError(ctx, resp, twirp.InternalError("received a nil *SIPParticipantInfo and nil error while calling CreateSIPParticipant. nil responses are not supported")) + return + } + + ctx = callResponsePrepared(ctx, s.hooks) + + respBytes, err := proto.Marshal(respContent) + if err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response")) + return + } + + ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) + resp.Header().Set("Content-Type", "application/protobuf") + resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) + resp.WriteHeader(http.StatusOK) + if n, err := resp.Write(respBytes); err != nil { + msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) + twerr := twirp.NewError(twirp.Unknown, msg) + ctx = callError(ctx, s.hooks, twerr) + } + callResponseSent(ctx, s.hooks) +} + +func (s *sIPServer) serveSendSIPParticipantDTMF(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + header := req.Header.Get("Content-Type") + i := strings.Index(header, ";") + if i == -1 { + i = len(header) + } + switch strings.TrimSpace(strings.ToLower(header[:i])) { + case "application/json": + s.serveSendSIPParticipantDTMFJSON(ctx, resp, req) + case "application/protobuf": + s.serveSendSIPParticipantDTMFProtobuf(ctx, resp, req) + default: + msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type")) + twerr := badRouteError(msg, req.Method, req.URL.Path) + s.writeError(ctx, resp, twerr) + } +} + +func (s *sIPServer) serveSendSIPParticipantDTMFJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + var err error + ctx = ctxsetters.WithMethodName(ctx, "SendSIPParticipantDTMF") + ctx, err = callRequestRouted(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + d := json.NewDecoder(req.Body) + rawReqBody := json.RawMessage{} + if err := d.Decode(&rawReqBody); err != nil { + s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err) + return + } + reqContent := new(SendSIPParticipantDTMFRequest) + unmarshaler := protojson.UnmarshalOptions{DiscardUnknown: true} + if err = unmarshaler.Unmarshal(rawReqBody, reqContent); err != nil { + s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err) + return + } + + handler := s.SIP.SendSIPParticipantDTMF + if s.interceptor != nil { + handler = func(ctx context.Context, req *SendSIPParticipantDTMFRequest) (*SIPParticipantDTMFInfo, error) { + resp, err := s.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*SendSIPParticipantDTMFRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*SendSIPParticipantDTMFRequest) when calling interceptor") + } + return s.SIP.SendSIPParticipantDTMF(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*SIPParticipantDTMFInfo) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*SIPParticipantDTMFInfo) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + + // Call service method + var respContent *SIPParticipantDTMFInfo + func() { + defer ensurePanicResponses(ctx, resp, s.hooks) + respContent, err = handler(ctx, reqContent) + }() + + if err != nil { + s.writeError(ctx, resp, err) + return + } + if respContent == nil { + s.writeError(ctx, resp, twirp.InternalError("received a nil *SIPParticipantDTMFInfo and nil error while calling SendSIPParticipantDTMF. nil responses are not supported")) + return + } + + ctx = callResponsePrepared(ctx, s.hooks) + + marshaler := &protojson.MarshalOptions{UseProtoNames: !s.jsonCamelCase, EmitUnpopulated: !s.jsonSkipDefaults} + respBytes, err := marshaler.Marshal(respContent) + if err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response")) + return + } + + ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) + resp.Header().Set("Content-Type", "application/json") + resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) + resp.WriteHeader(http.StatusOK) + + if n, err := resp.Write(respBytes); err != nil { + msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) + twerr := twirp.NewError(twirp.Unknown, msg) + ctx = callError(ctx, s.hooks, twerr) + } + callResponseSent(ctx, s.hooks) +} + +func (s *sIPServer) serveSendSIPParticipantDTMFProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + var err error + ctx = ctxsetters.WithMethodName(ctx, "SendSIPParticipantDTMF") + ctx, err = callRequestRouted(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + buf, err := io.ReadAll(req.Body) + if err != nil { + s.handleRequestBodyError(ctx, resp, "failed to read request body", err) + return + } + reqContent := new(SendSIPParticipantDTMFRequest) + if err = proto.Unmarshal(buf, reqContent); err != nil { + s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded")) + return + } + + handler := s.SIP.SendSIPParticipantDTMF + if s.interceptor != nil { + handler = func(ctx context.Context, req *SendSIPParticipantDTMFRequest) (*SIPParticipantDTMFInfo, error) { + resp, err := s.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*SendSIPParticipantDTMFRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*SendSIPParticipantDTMFRequest) when calling interceptor") + } + return s.SIP.SendSIPParticipantDTMF(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*SIPParticipantDTMFInfo) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*SIPParticipantDTMFInfo) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + + // Call service method + var respContent *SIPParticipantDTMFInfo + func() { + defer ensurePanicResponses(ctx, resp, s.hooks) + respContent, err = handler(ctx, reqContent) + }() + + if err != nil { + s.writeError(ctx, resp, err) + return + } + if respContent == nil { + s.writeError(ctx, resp, twirp.InternalError("received a nil *SIPParticipantDTMFInfo and nil error while calling SendSIPParticipantDTMF. nil responses are not supported")) + return + } + + ctx = callResponsePrepared(ctx, s.hooks) + + respBytes, err := proto.Marshal(respContent) + if err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response")) + return + } + + ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) + resp.Header().Set("Content-Type", "application/protobuf") + resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) + resp.WriteHeader(http.StatusOK) + if n, err := resp.Write(respBytes); err != nil { + msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) + twerr := twirp.NewError(twirp.Unknown, msg) + ctx = callError(ctx, s.hooks, twerr) + } + callResponseSent(ctx, s.hooks) +} + +func (s *sIPServer) serveListSIPParticipant(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + header := req.Header.Get("Content-Type") + i := strings.Index(header, ";") + if i == -1 { + i = len(header) + } + switch strings.TrimSpace(strings.ToLower(header[:i])) { + case "application/json": + s.serveListSIPParticipantJSON(ctx, resp, req) + case "application/protobuf": + s.serveListSIPParticipantProtobuf(ctx, resp, req) + default: + msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type")) + twerr := badRouteError(msg, req.Method, req.URL.Path) + s.writeError(ctx, resp, twerr) + } +} + +func (s *sIPServer) serveListSIPParticipantJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + var err error + ctx = ctxsetters.WithMethodName(ctx, "ListSIPParticipant") + ctx, err = callRequestRouted(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + d := json.NewDecoder(req.Body) + rawReqBody := json.RawMessage{} + if err := d.Decode(&rawReqBody); err != nil { + s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err) + return + } + reqContent := new(ListSIPParticipantRequest) + unmarshaler := protojson.UnmarshalOptions{DiscardUnknown: true} + if err = unmarshaler.Unmarshal(rawReqBody, reqContent); err != nil { + s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err) + return + } + + handler := s.SIP.ListSIPParticipant + if s.interceptor != nil { + handler = func(ctx context.Context, req *ListSIPParticipantRequest) (*ListSIPParticipantResponse, error) { + resp, err := s.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*ListSIPParticipantRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*ListSIPParticipantRequest) when calling interceptor") + } + return s.SIP.ListSIPParticipant(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*ListSIPParticipantResponse) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*ListSIPParticipantResponse) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + + // Call service method + var respContent *ListSIPParticipantResponse + func() { + defer ensurePanicResponses(ctx, resp, s.hooks) + respContent, err = handler(ctx, reqContent) + }() + + if err != nil { + s.writeError(ctx, resp, err) + return + } + if respContent == nil { + s.writeError(ctx, resp, twirp.InternalError("received a nil *ListSIPParticipantResponse and nil error while calling ListSIPParticipant. nil responses are not supported")) + return + } + + ctx = callResponsePrepared(ctx, s.hooks) + + marshaler := &protojson.MarshalOptions{UseProtoNames: !s.jsonCamelCase, EmitUnpopulated: !s.jsonSkipDefaults} + respBytes, err := marshaler.Marshal(respContent) + if err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response")) + return + } + + ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) + resp.Header().Set("Content-Type", "application/json") + resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) + resp.WriteHeader(http.StatusOK) + + if n, err := resp.Write(respBytes); err != nil { + msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) + twerr := twirp.NewError(twirp.Unknown, msg) + ctx = callError(ctx, s.hooks, twerr) + } + callResponseSent(ctx, s.hooks) +} + +func (s *sIPServer) serveListSIPParticipantProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + var err error + ctx = ctxsetters.WithMethodName(ctx, "ListSIPParticipant") + ctx, err = callRequestRouted(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + buf, err := io.ReadAll(req.Body) + if err != nil { + s.handleRequestBodyError(ctx, resp, "failed to read request body", err) + return + } + reqContent := new(ListSIPParticipantRequest) + if err = proto.Unmarshal(buf, reqContent); err != nil { + s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded")) + return + } + + handler := s.SIP.ListSIPParticipant + if s.interceptor != nil { + handler = func(ctx context.Context, req *ListSIPParticipantRequest) (*ListSIPParticipantResponse, error) { + resp, err := s.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*ListSIPParticipantRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*ListSIPParticipantRequest) when calling interceptor") + } + return s.SIP.ListSIPParticipant(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*ListSIPParticipantResponse) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*ListSIPParticipantResponse) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + + // Call service method + var respContent *ListSIPParticipantResponse + func() { + defer ensurePanicResponses(ctx, resp, s.hooks) + respContent, err = handler(ctx, reqContent) + }() + + if err != nil { + s.writeError(ctx, resp, err) + return + } + if respContent == nil { + s.writeError(ctx, resp, twirp.InternalError("received a nil *ListSIPParticipantResponse and nil error while calling ListSIPParticipant. nil responses are not supported")) + return + } + + ctx = callResponsePrepared(ctx, s.hooks) + + respBytes, err := proto.Marshal(respContent) + if err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response")) + return + } + + ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) + resp.Header().Set("Content-Type", "application/protobuf") + resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) + resp.WriteHeader(http.StatusOK) + if n, err := resp.Write(respBytes); err != nil { + msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) + twerr := twirp.NewError(twirp.Unknown, msg) + ctx = callError(ctx, s.hooks, twerr) + } + callResponseSent(ctx, s.hooks) +} + +func (s *sIPServer) serveDeleteSIPParticipant(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + header := req.Header.Get("Content-Type") + i := strings.Index(header, ";") + if i == -1 { + i = len(header) + } + switch strings.TrimSpace(strings.ToLower(header[:i])) { + case "application/json": + s.serveDeleteSIPParticipantJSON(ctx, resp, req) + case "application/protobuf": + s.serveDeleteSIPParticipantProtobuf(ctx, resp, req) + default: + msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type")) + twerr := badRouteError(msg, req.Method, req.URL.Path) + s.writeError(ctx, resp, twerr) + } +} + +func (s *sIPServer) serveDeleteSIPParticipantJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + var err error + ctx = ctxsetters.WithMethodName(ctx, "DeleteSIPParticipant") + ctx, err = callRequestRouted(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + d := json.NewDecoder(req.Body) + rawReqBody := json.RawMessage{} + if err := d.Decode(&rawReqBody); err != nil { + s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err) + return + } + reqContent := new(DeleteSIPParticipantRequest) + unmarshaler := protojson.UnmarshalOptions{DiscardUnknown: true} + if err = unmarshaler.Unmarshal(rawReqBody, reqContent); err != nil { + s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err) + return + } + + handler := s.SIP.DeleteSIPParticipant + if s.interceptor != nil { + handler = func(ctx context.Context, req *DeleteSIPParticipantRequest) (*SIPParticipantInfo, error) { + resp, err := s.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*DeleteSIPParticipantRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*DeleteSIPParticipantRequest) when calling interceptor") + } + return s.SIP.DeleteSIPParticipant(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*SIPParticipantInfo) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*SIPParticipantInfo) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + + // Call service method + var respContent *SIPParticipantInfo + func() { + defer ensurePanicResponses(ctx, resp, s.hooks) + respContent, err = handler(ctx, reqContent) + }() + + if err != nil { + s.writeError(ctx, resp, err) + return + } + if respContent == nil { + s.writeError(ctx, resp, twirp.InternalError("received a nil *SIPParticipantInfo and nil error while calling DeleteSIPParticipant. nil responses are not supported")) + return + } + + ctx = callResponsePrepared(ctx, s.hooks) + + marshaler := &protojson.MarshalOptions{UseProtoNames: !s.jsonCamelCase, EmitUnpopulated: !s.jsonSkipDefaults} + respBytes, err := marshaler.Marshal(respContent) + if err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response")) + return + } + + ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) + resp.Header().Set("Content-Type", "application/json") + resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) + resp.WriteHeader(http.StatusOK) + + if n, err := resp.Write(respBytes); err != nil { + msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) + twerr := twirp.NewError(twirp.Unknown, msg) + ctx = callError(ctx, s.hooks, twerr) + } + callResponseSent(ctx, s.hooks) +} + +func (s *sIPServer) serveDeleteSIPParticipantProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + var err error + ctx = ctxsetters.WithMethodName(ctx, "DeleteSIPParticipant") + ctx, err = callRequestRouted(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + buf, err := io.ReadAll(req.Body) + if err != nil { + s.handleRequestBodyError(ctx, resp, "failed to read request body", err) + return + } + reqContent := new(DeleteSIPParticipantRequest) + if err = proto.Unmarshal(buf, reqContent); err != nil { + s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded")) + return + } + + handler := s.SIP.DeleteSIPParticipant + if s.interceptor != nil { + handler = func(ctx context.Context, req *DeleteSIPParticipantRequest) (*SIPParticipantInfo, error) { + resp, err := s.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*DeleteSIPParticipantRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*DeleteSIPParticipantRequest) when calling interceptor") + } + return s.SIP.DeleteSIPParticipant(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*SIPParticipantInfo) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*SIPParticipantInfo) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + + // Call service method + var respContent *SIPParticipantInfo + func() { + defer ensurePanicResponses(ctx, resp, s.hooks) + respContent, err = handler(ctx, reqContent) + }() + + if err != nil { + s.writeError(ctx, resp, err) + return + } + if respContent == nil { + s.writeError(ctx, resp, twirp.InternalError("received a nil *SIPParticipantInfo and nil error while calling DeleteSIPParticipant. nil responses are not supported")) + return + } + + ctx = callResponsePrepared(ctx, s.hooks) + + respBytes, err := proto.Marshal(respContent) + if err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response")) + return + } + + ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) + resp.Header().Set("Content-Type", "application/protobuf") + resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) + resp.WriteHeader(http.StatusOK) + if n, err := resp.Write(respBytes); err != nil { + msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) + twerr := twirp.NewError(twirp.Unknown, msg) + ctx = callError(ctx, s.hooks, twerr) + } + callResponseSent(ctx, s.hooks) +} + +func (s *sIPServer) ServiceDescriptor() ([]byte, int) { + return twirpFileDescriptor3, 0 +} + +func (s *sIPServer) ProtocGenTwirpVersion() string { + return "v8.1.3" +} + +// PathPrefix returns the base service path, in the form: "//./" +// that is everything in a Twirp route except for the . This can be used for routing, +// for example to identify the requests that are targeted to this service in a mux. +func (s *sIPServer) PathPrefix() string { + return baseServicePath(s.pathPrefix, "livekit", "SIP") +} + +var twirpFileDescriptor3 = []byte{ + // 876 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0x5d, 0x73, 0xdb, 0x44, + 0x14, 0x8d, 0x6d, 0x1a, 0xe2, 0x9b, 0x90, 0x36, 0x1b, 0x3b, 0xa3, 0xda, 0x2e, 0xcd, 0x28, 0x85, + 0xc9, 0x00, 0xe3, 0x80, 0x79, 0xa2, 0xc3, 0x53, 0xe2, 0x71, 0xe3, 0x49, 0x49, 0x85, 0xdc, 0x97, + 0x32, 0x01, 0xa1, 0x78, 0x37, 0xc9, 0x4e, 0xe5, 0x95, 0xd0, 0xae, 0x42, 0xdf, 0xf9, 0x33, 0x0c, + 0x3f, 0x8d, 0x9f, 0xc0, 0x13, 0xa3, 0xf5, 0xea, 0x7b, 0xad, 0x8c, 0xfb, 0x66, 0xdd, 0x7b, 0xf7, + 0xec, 0xbd, 0x47, 0xe7, 0xe8, 0x1a, 0xf6, 0x3c, 0x7a, 0x4f, 0xde, 0x53, 0xe1, 0x70, 0x1a, 0x0c, + 0x83, 0xd0, 0x17, 0x3e, 0xfa, 0x54, 0x85, 0xcc, 0xbf, 0x1a, 0xd0, 0x3d, 0x0b, 0x89, 0x2b, 0xc8, + 0x6c, 0x6a, 0xbd, 0x0d, 0x23, 0xf6, 0xde, 0x26, 0x7f, 0x44, 0x84, 0x0b, 0x34, 0x80, 0xb6, 0x8b, + 0x71, 0x48, 0x38, 0x27, 0xdc, 0x68, 0x1c, 0xb6, 0x8e, 0xdb, 0x76, 0x16, 0x40, 0xbb, 0xd0, 0x14, + 0xbe, 0xd1, 0x3c, 0x6c, 0x1c, 0xb7, 0xed, 0xa6, 0xf0, 0xd1, 0x8f, 0xd0, 0x73, 0x3d, 0xcf, 0xff, + 0x93, 0x60, 0x07, 0x13, 0x2e, 0x28, 0x73, 0x05, 0xf5, 0x19, 0x77, 0x42, 0x72, 0x4b, 0x3e, 0x18, + 0x2d, 0x79, 0xdc, 0x50, 0x15, 0xe3, 0x5c, 0x81, 0x1d, 0xe7, 0xcd, 0x6f, 0x61, 0x27, 0xb9, 0x7e, + 0xca, 0x6e, 0x7c, 0x74, 0x08, 0x3b, 0x9c, 0x06, 0x8e, 0x88, 0x03, 0x0e, 0xc5, 0x46, 0x43, 0xde, + 0x03, 0x9c, 0x06, 0xcb, 0x1a, 0x6c, 0x76, 0x61, 0xff, 0x35, 0xe5, 0xa2, 0xd4, 0xb4, 0x79, 0x06, + 0x9d, 0x62, 0x98, 0x07, 0x3e, 0xe3, 0x04, 0x7d, 0x0d, 0x8f, 0xa8, 0x20, 0x8b, 0xe5, 0x20, 0xdb, + 0xa3, 0xee, 0x50, 0xcd, 0x3f, 0xcc, 0x5f, 0x6b, 0x2f, 0x6b, 0xcc, 0x1f, 0xa0, 0x3b, 0x26, 0x1e, + 0xa9, 0x52, 0xf2, 0x70, 0x5b, 0x13, 0xe8, 0xce, 0xa6, 0xd6, 0x98, 0xf2, 0xc0, 0x15, 0xf3, 0x3b, + 0x3b, 0xf2, 0xc8, 0x98, 0x86, 0x64, 0x2e, 0x50, 0x1f, 0xda, 0xa1, 0xef, 0x2f, 0x1c, 0xe6, 0x2e, + 0x88, 0x3a, 0xb7, 0x15, 0x07, 0x2e, 0xdd, 0x05, 0x41, 0x4f, 0xa0, 0x15, 0x50, 0xa6, 0xd8, 0x8c, + 0x7f, 0x9a, 0x67, 0x80, 0x4a, 0x38, 0x16, 0x65, 0xeb, 0x82, 0x5c, 0xc2, 0xd3, 0x12, 0xc8, 0x94, + 0x61, 0x7a, 0x4f, 0x71, 0xe4, 0x7a, 0xe8, 0x39, 0x6c, 0x4b, 0xac, 0x20, 0x24, 0x37, 0xf4, 0x43, + 0x32, 0x4a, 0x1c, 0xb2, 0x64, 0x44, 0x83, 0xf7, 0x77, 0x0b, 0x06, 0xa9, 0x56, 0xf2, 0xb0, 0x09, + 0x3f, 0x36, 0x74, 0xb0, 0x0a, 0x3b, 0x61, 0xe4, 0x11, 0x07, 0xcb, 0xe1, 0x25, 0xf8, 0xf6, 0xe8, + 0xf3, 0x3c, 0xe9, 0x55, 0x8a, 0xce, 0x37, 0x6c, 0x84, 0xab, 0xc4, 0x4d, 0x61, 0xaf, 0x88, 0x99, + 0x34, 0xb5, 0x3d, 0xea, 0xaf, 0x02, 0xb4, 0x28, 0x3b, 0xdf, 0xb0, 0x1f, 0xe3, 0x12, 0x7d, 0xbf, + 0x81, 0x51, 0x84, 0xa2, 0x29, 0x1d, 0x46, 0x4b, 0x22, 0x9a, 0xab, 0x10, 0x33, 0xe2, 0xce, 0x37, + 0xec, 0x03, 0xac, 0xa7, 0xb4, 0x0f, 0xed, 0x44, 0x1a, 0xdc, 0xf8, 0x44, 0x4a, 0x7e, 0x4b, 0x2c, + 0x85, 0xc1, 0xd1, 0x08, 0xba, 0x89, 0x41, 0xb8, 0x1f, 0x85, 0x73, 0x92, 0x78, 0xe3, 0x91, 0x2c, + 0xdc, 0x57, 0xc9, 0xd9, 0x32, 0x27, 0x6d, 0x81, 0xbe, 0x82, 0xbd, 0x3b, 0x8a, 0x89, 0x13, 0xdc, + 0xf9, 0x8c, 0x38, 0x2c, 0x5a, 0x5c, 0x93, 0xd0, 0xd8, 0x3c, 0x6c, 0x1c, 0x6f, 0xd9, 0x8f, 0xe3, + 0x84, 0x15, 0xc7, 0x2f, 0x65, 0xf8, 0x74, 0x07, 0x80, 0x32, 0x2e, 0xc2, 0x68, 0x41, 0x98, 0x30, + 0x27, 0xb0, 0x5f, 0x99, 0xe0, 0xc6, 0x47, 0x27, 0xd0, 0x89, 0x05, 0x5c, 0x62, 0x21, 0x11, 0xf2, + 0x1e, 0xa7, 0x41, 0xe1, 0x08, 0x36, 0x07, 0xd0, 0x53, 0x7e, 0xd2, 0xbc, 0x6f, 0xf3, 0x67, 0xe8, + 0x6b, 0xb3, 0xca, 0x74, 0xa3, 0xa2, 0xe9, 0x06, 0xab, 0xc9, 0xcd, 0xbc, 0xf7, 0x06, 0x06, 0xa9, + 0xf7, 0x74, 0x12, 0x5b, 0x7b, 0x82, 0x2b, 0xe8, 0xa7, 0x9a, 0xb5, 0xdc, 0x50, 0xd0, 0x39, 0x0d, + 0x5c, 0x26, 0x12, 0xbc, 0x5a, 0x4b, 0x95, 0xfd, 0xde, 0xac, 0xf8, 0xfd, 0x54, 0xfa, 0x34, 0x87, + 0x2b, 0x69, 0xfe, 0x06, 0x50, 0x7c, 0x2e, 0xc8, 0xc2, 0x59, 0x8b, 0x4f, 0x38, 0x0d, 0xf2, 0xf5, + 0xd8, 0x24, 0xf0, 0x6c, 0x46, 0x18, 0x2e, 0xe2, 0x8c, 0xdf, 0xfe, 0x34, 0x49, 0x7a, 0x5c, 0x0b, + 0x0e, 0x1d, 0xc0, 0x26, 0xa6, 0xb7, 0x54, 0x70, 0xd5, 0xae, 0x7a, 0x32, 0x27, 0x70, 0x50, 0xbd, + 0xe2, 0x23, 0xda, 0xed, 0xc3, 0x53, 0xf5, 0xd2, 0xab, 0x74, 0x9a, 0x6f, 0x52, 0xbd, 0x14, 0x92, + 0x4a, 0x10, 0xdf, 0x15, 0x05, 0x51, 0xf0, 0x6f, 0x89, 0xc3, 0x44, 0x0f, 0x17, 0xd0, 0x4f, 0xf5, + 0xa0, 0x79, 0x7d, 0x6b, 0xb5, 0x3e, 0xfa, 0x6f, 0x13, 0x5a, 0xb3, 0xa9, 0x85, 0x5e, 0xc1, 0x6e, + 0x71, 0xe7, 0xa1, 0xec, 0xdb, 0xa4, 0x5d, 0x86, 0x3d, 0xfd, 0xc2, 0x40, 0x17, 0xb0, 0x93, 0x5f, + 0x37, 0x28, 0x93, 0xb8, 0x66, 0x39, 0xf5, 0x9e, 0xad, 0xc8, 0x2a, 0x76, 0x5e, 0xc1, 0x6e, 0x71, + 0xed, 0xe4, 0xba, 0xd2, 0xee, 0xa3, 0x55, 0x5d, 0x5d, 0xe5, 0x56, 0x7a, 0xde, 0x0d, 0xe8, 0x8b, + 0xea, 0x94, 0x1a, 0x8f, 0xf5, 0x6a, 0x8d, 0x8a, 0x7e, 0x4f, 0x37, 0x6f, 0x01, 0xfb, 0xa8, 0x3c, + 0x9c, 0x0e, 0xf9, 0x45, 0x7d, 0x91, 0x22, 0xe2, 0x2a, 0xb7, 0x7f, 0x57, 0xf4, 0x5f, 0xf7, 0x8d, + 0x78, 0xa0, 0xff, 0x77, 0xd0, 0xd1, 0x7d, 0x10, 0xd0, 0x8b, 0x2a, 0x39, 0x55, 0xc1, 0xf5, 0xea, + 0x34, 0x8b, 0x5c, 0x38, 0xd0, 0x3b, 0x19, 0x7d, 0x99, 0x1d, 0xab, 0xb3, 0x7a, 0xef, 0xf9, 0x0a, + 0xf8, 0xd4, 0xab, 0xbf, 0x02, 0xaa, 0x1a, 0x0c, 0x99, 0x65, 0x5e, 0x35, 0x9d, 0x1f, 0xd5, 0xd6, + 0x28, 0xea, 0xdf, 0x41, 0x47, 0x67, 0xb7, 0x1c, 0x39, 0x35, 0x6e, 0xac, 0x25, 0xe7, 0x74, 0xf2, + 0xcb, 0xd1, 0x2d, 0x15, 0x77, 0xd1, 0xf5, 0x70, 0xee, 0x2f, 0x4e, 0x54, 0xe1, 0x89, 0xfc, 0x3b, + 0x3a, 0xf7, 0xbd, 0x24, 0xf0, 0x4f, 0xf3, 0xb3, 0xd7, 0xf4, 0x9e, 0x5c, 0x50, 0x31, 0xb4, 0xe2, + 0xd4, 0xbf, 0xcd, 0x5d, 0xf5, 0xfc, 0xf2, 0xa5, 0x0c, 0x5c, 0x6f, 0xca, 0x23, 0xdf, 0xff, 0x1f, + 0x00, 0x00, 0xff, 0xff, 0x31, 0xcc, 0x31, 0xfc, 0xd6, 0x0a, 0x00, 0x00, +} diff --git a/livekit_sip.proto b/livekit_sip.proto new file mode 100644 index 000000000..5725c2199 --- /dev/null +++ b/livekit_sip.proto @@ -0,0 +1,191 @@ +// Copyright 2023 LiveKit, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package livekit; + +option go_package = "github.com/livekit/protocol/livekit"; +option csharp_namespace = "LiveKit.Proto"; +option ruby_package = "LiveKit::Proto"; + +/* + LiveKit's SIP API is built with 3 high level primitives + - SIP Trunk + - SIP Dispatch Rule + - SIP Participant + + + The `SIP Trunk` is used to accept and make calls. A `SIP Trunk` is configured with + the IPs/Ports and Authentication details of your SIP Provider. When a call is accepted from + the `SIP Trunk` it is then handled by the `SIP Dispatch Rules`. When a `SIP Participant` is created + for a outbound call a `SIP Trunk` is chosen to make the call with. + + + The `SIP Dispatch Rule` is a list of rules that dictate how a incoming SIP call should be handled. + LiveKit currently supports 3 types, but may support more in the future. + + - `Direct Dispatch` puts a caller into a existing room + - `Pin Dispatch` allows a caller to choose between multiple rooms with a pin + - `Individual Dispatch` puts a caller into a new room created for the call + + + The `SIP Participant` represents an active SIP Session. These SIP Sessions are created by an + inbound call or can be created by a developer making an outbound call. DTMF can be emitted for + these participants via an API. +*/ + + +service SIP { + rpc CreateSIPTrunk(CreateSIPTrunkRequest) returns (SIPTrunkInfo); + rpc ListSIPTrunk(ListSIPTrunkRequest) returns (ListSIPTrunkResponse); + rpc DeleteSIPTrunk(DeleteSIPTrunkRequest) returns (SIPTrunkInfo); + + rpc CreateSIPDispatchRule(CreateSIPDispatchRuleRequest) returns (SIPDispatchRuleInfo); + rpc ListSIPDispatchRule(ListSIPDispatchRuleRequest) returns (ListSIPDispatchRuleResponse); + rpc DeleteSIPDispatchRule(DeleteSIPDispatchRuleRequest) returns (SIPDispatchRuleInfo); + + rpc CreateSIPParticipant(CreateSIPParticipantRequest) returns (SIPParticipantInfo); + rpc SendSIPParticipantDTMF(SendSIPParticipantDTMFRequest) returns (SIPParticipantDTMFInfo); + rpc ListSIPParticipant(ListSIPParticipantRequest) returns (ListSIPParticipantResponse); + rpc DeleteSIPParticipant(DeleteSIPParticipantRequest) returns (SIPParticipantInfo); +} + + +message CreateSIPTrunkRequest { + // CIDR or IPs that traffic is accepted from + // An empty list means all inbound traffic is accepted. + repeated string addresses = 1; + + // `To` value that will be used when making a call + string to = 2; + + // Accepted `To` values. This Trunk will only accept a call made to + // these numbers. This allows you to have distinct Trunks for different phone + // numbers at the same provider. + // An empty list means all dialed numbers are accepted. + repeated string allowed_destinations_regex = 3; +} + +message SIPTrunkInfo { + string sip_trunk_id = 1; +} + +message ListSIPTrunkRequest { +} + +message ListSIPTrunkResponse { + repeated SIPTrunkInfo items = 1; +} + +message DeleteSIPTrunkRequest { + string sip_trunk_id = 1; +} + + +message SIPDispatchRuleDirect { + // What room should call be directed into + string room_name = 1; + + // Optional pin required to enter room + string pin = 2; +} + +message SIPDispatchRulePin { + // What room should call be directed into + string room_name = 1; + + // Pin required to enter room + string pin = 2; +} + +message SIPDispatchRuleIndividual { + // Prefix used on new room name + string room_prefix = 1; + + // Optional pin required to enter room + string pin = 2; +} + +message CreateSIPDispatchRuleRequest { + oneof instrument { + SIPDispatchRuleDirect dispatch_rule_direct = 1; + SIPDispatchRulePin dispatch_rule_pin = 2; + SIPDispatchRuleIndividual dispatch_rule_individual = 3; + } + + // What trunks are accepted for this dispatch rul + repeated string trunk_ids = 4; + + // What calling numbers can this Dispatch Rule be used by. + // An empty list means all callers are accepted. + repeated string allowed_sources_regex = 5; + + // By default the From value (Phone number) is used as the participant identity + // If true a random value will be used instead + bool hide_phone_number = 6; +} + +message SIPDispatchRuleInfo { + string sip_dispatch_rule_id = 1; +} + +message ListSIPDispatchRuleRequest { +} + +message ListSIPDispatchRuleResponse { + repeated SIPDispatchRuleInfo items = 1; +} + +message DeleteSIPDispatchRuleRequest { + string sip_dispatch_rule_id = 1; +} + +// A SIP Participant is a singular SIP session connected to a LiveKit room via +// a SIP Trunk into a SIP DispatchRule +message CreateSIPParticipantRequest { + // What LiveKit room should this participant be connected too + string room_name = 1; + + // What SIP Trunk should be used to dial the user + string sip_trunk_id = 2; +} + +message SIPParticipantInfo { + string sip_participant_id = 1; +} + +// DTMF Request lets you send a DTMF message for a SIP Participant +message SendSIPParticipantDTMFRequest { + // What SIP Participant to send this DTMF for + string sip_participant_id = 1; + + // Digits that will be sent via DTMF + string digits = 2; +} + +message SIPParticipantDTMFInfo { + string sip_participant_id = 1; +} + +message ListSIPParticipantRequest { +} + +message ListSIPParticipantResponse { + repeated SIPParticipantInfo items = 1; +} + +message DeleteSIPParticipantRequest { + string sip_participant_id = 1; +} diff --git a/magefile.go b/magefile.go index 467b49ccd..fbe821850 100644 --- a/magefile.go +++ b/magefile.go @@ -46,6 +46,7 @@ func Proto() error { "livekit_egress.proto", "livekit_ingress.proto", "livekit_room.proto", + "livekit_sip.proto", } grpcProtoFiles := []string{ "livekit_analytics.proto",