diff --git a/go.mod b/go.mod index 06f7030..f8a4c3c 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/gorilla/websocket v1.5.3 github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1 github.com/livekit/mediatransportutil v0.0.0-20241128072814-c363618d4c98 - github.com/livekit/protocol v1.29.3 + github.com/livekit/protocol v1.29.5-0.20241209183753-f6b5078b2244 github.com/magefile/mage v1.15.0 github.com/pion/dtls/v3 v3.0.4 github.com/pion/interceptor v0.1.37 diff --git a/go.sum b/go.sum index 100874a..74d9fca 100644 --- a/go.sum +++ b/go.sum @@ -64,8 +64,8 @@ github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1 h1:jm09419p0lqTkD github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1/go.mod h1:Rs3MhFwutWhGwmY1VQsygw28z5bWcnEYmS1OG9OxjOQ= github.com/livekit/mediatransportutil v0.0.0-20241128072814-c363618d4c98 h1:QA7DqIC/ZSsMj8HC0+zNfMMwssHbA0alZALK68r30LQ= github.com/livekit/mediatransportutil v0.0.0-20241128072814-c363618d4c98/go.mod h1:WIVFAGzVZ7VMjPC5+nbSfwdFjWcbuLgx97KeNSUDTEo= -github.com/livekit/protocol v1.29.3 h1:aAKhnc/E8H8uTB3sGmsp4OOtXV9vab2PqA57+SnDHEU= -github.com/livekit/protocol v1.29.3/go.mod h1:NDg1btMpKCzr/w6QR5kDuXw/e4Y7yOBE+RUAHsc+Y/M= +github.com/livekit/protocol v1.29.5-0.20241209183753-f6b5078b2244 h1:Eg9HK+5bMCDRKhh5g5g16oyNaMbCqMrJvxFBaBuP7Vo= +github.com/livekit/protocol v1.29.5-0.20241209183753-f6b5078b2244/go.mod h1:NDg1btMpKCzr/w6QR5kDuXw/e4Y7yOBE+RUAHsc+Y/M= github.com/livekit/psrpc v0.6.1-0.20241018124827-1efff3d113a8 h1:Ibh0LoFl5NW5a1KFJEE0eLxxz7dqqKmYTj/BfCb0PbY= github.com/livekit/psrpc v0.6.1-0.20241018124827-1efff3d113a8/go.mod h1:CQUBSPfYYAaevg1TNCc6/aYsa8DJH4jSRFdCeSZk5u0= github.com/magefile/mage v1.15.0 h1:BvGheCMAsG3bWUDbZ8AyXXpCNwU9u5CB6sM+HNb9HYg= diff --git a/sipclient.go b/sipclient.go index 15a31d5..36725cc 100644 --- a/sipclient.go +++ b/sipclient.go @@ -68,6 +68,50 @@ func (s *SIPClient) CreateSIPOutboundTrunk(ctx context.Context, in *livekit.Crea return s.sipClient.CreateSIPOutboundTrunk(ctx, in) } +// GetSIPInboundTrunksByIDs gets SIP Inbound Trunks by ID. +// Returned slice is in the same order as the IDs. Missing IDs will have nil in the corresponding position. +func (s *SIPClient) GetSIPInboundTrunksByIDs(ctx context.Context, ids []string) ([]*livekit.SIPInboundTrunkInfo, error) { + if len(ids) == 0 { + return nil, ErrInvalidParameter + } + + ctx, err := s.withAuth(ctx, withSIPGrant{Admin: true}) + if err != nil { + return nil, err + } + req := &livekit.ListSIPInboundTrunkRequest{ + TrunkIds: ids, + } + resp, err := s.ListSIPInboundTrunk(ctx, req) + if err != nil { + return nil, err + } + // Client-side filtering, in case SDK is newer than the server. + return req.FilterSlice(resp.Items), nil +} + +// GetSIPOutboundTrunksByIDs gets SIP Outbound Trunks by ID. +// Returned slice is in the same order as the IDs. Missing IDs will have nil in the corresponding position. +func (s *SIPClient) GetSIPOutboundTrunksByIDs(ctx context.Context, ids []string) ([]*livekit.SIPOutboundTrunkInfo, error) { + if len(ids) == 0 { + return nil, ErrInvalidParameter + } + + ctx, err := s.withAuth(ctx, withSIPGrant{Admin: true}) + if err != nil { + return nil, err + } + req := &livekit.ListSIPOutboundTrunkRequest{ + TrunkIds: ids, + } + resp, err := s.ListSIPOutboundTrunk(ctx, req) + if err != nil { + return nil, err + } + // Client-side filtering, in case SDK is newer than the server. + return req.FilterSlice(resp.Items), nil +} + // ListSIPTrunk lists SIP Trunks. // // Deprecated: Use ListSIPInboundTrunk or ListSIPOutboundTrunk @@ -135,6 +179,28 @@ func (s *SIPClient) CreateSIPDispatchRule(ctx context.Context, in *livekit.Creat return s.sipClient.CreateSIPDispatchRule(ctx, in) } +// GetSIPDispatchRulesByIDs gets SIP Dispatch Rules by ID. +// Returned slice is in the same order as the IDs. Missing IDs will have nil in the corresponding position. +func (s *SIPClient) GetSIPDispatchRulesByIDs(ctx context.Context, ids []string) ([]*livekit.SIPDispatchRuleInfo, error) { + if len(ids) == 0 { + return nil, ErrInvalidParameter + } + + ctx, err := s.withAuth(ctx, withSIPGrant{Admin: true}) + if err != nil { + return nil, err + } + req := &livekit.ListSIPDispatchRuleRequest{ + DispatchRuleIds: ids, + } + resp, err := s.ListSIPDispatchRule(ctx, req) + if err != nil { + return nil, err + } + // Client-side filtering, in case SDK is newer than the server. + return req.FilterSlice(resp.Items), nil +} + // ListSIPDispatchRule lists SIP Dispatch Rules. func (s *SIPClient) ListSIPDispatchRule(ctx context.Context, in *livekit.ListSIPDispatchRuleRequest) (*livekit.ListSIPDispatchRuleResponse, error) { if in == nil {