@@ -790,9 +790,33 @@ func listSipTrunk(ctx context.Context, cmd *cli.Command) error {
790790func listSipInboundTrunk (ctx context.Context , cmd * cli.Command ) error {
791791 cli , err := createSIPClient (ctx , cmd )
792792 if err != nil {
793- return err
793+ return fmt .Errorf ("could not create SIP client: %w" , err )
794+ }
795+
796+ // NOTE: twirp has a maximum payload size of 4MB, which some customer data may exceed.
797+ // We implement pagination here behind the scenes to split requests into manageable chunks
798+ // unlikely to exceed the limit. This should be used on all listing commands that may
799+ // return a large number of items.
800+ page := & livekit.Pagination {Limit : 500 }
801+ req := & livekit.ListSIPInboundTrunkRequest {Page : page }
802+ list := func (ctx context.Context , req * livekit.ListSIPInboundTrunkRequest ) (* livekit.ListSIPInboundTrunkResponse , error ) {
803+ res := & livekit.ListSIPInboundTrunkResponse {}
804+ if err := ExhaustivePaginatedList (
805+ ctx ,
806+ req ,
807+ cli .ListSIPInboundTrunk ,
808+ func (items []* livekit.SIPInboundTrunkInfo ) {
809+ res .Items = append (res .Items , items ... )
810+ page .AfterId = items [len (items )- 1 ].SipTrunkId
811+ },
812+ page ,
813+ ); err != nil {
814+ return nil , fmt .Errorf ("could not list SIP inbound trunks: %w" , err )
815+ }
816+ return res , nil
794817 }
795- return listAndPrint (ctx , cmd , cli .ListSIPInboundTrunk , & livekit.ListSIPInboundTrunkRequest {}, []string {
818+
819+ return listAndPrint (ctx , cmd , list , req , []string {
796820 "SipTrunkID" , "Name" , "Numbers" ,
797821 "AllowedAddresses" , "AllowedNumbers" ,
798822 "Authentication" ,
@@ -816,7 +840,31 @@ func listSipOutboundTrunk(ctx context.Context, cmd *cli.Command) error {
816840 if err != nil {
817841 return err
818842 }
819- return listAndPrint (ctx , cmd , cli .ListSIPOutboundTrunk , & livekit.ListSIPOutboundTrunkRequest {}, []string {
843+
844+ // NOTE: twirp has a maximum payload size of 4MB, which some customer data may exceed.
845+ // We implement pagination here behind the scenes to split requests into manageable chunks
846+ // unlikely to exceed the limit. This should be used on all listing commands that may
847+ // return a large number of items.
848+ page := & livekit.Pagination {Limit : 500 }
849+ req := & livekit.ListSIPOutboundTrunkRequest {Page : page }
850+ list := func (ctx context.Context , req * livekit.ListSIPOutboundTrunkRequest ) (* livekit.ListSIPOutboundTrunkResponse , error ) {
851+ res := & livekit.ListSIPOutboundTrunkResponse {}
852+ if err := ExhaustivePaginatedList (
853+ ctx ,
854+ req ,
855+ cli .ListSIPOutboundTrunk ,
856+ func (items []* livekit.SIPOutboundTrunkInfo ) {
857+ res .Items = append (res .Items , items ... )
858+ page .AfterId = items [len (items )- 1 ].SipTrunkId
859+ },
860+ page ,
861+ ); err != nil {
862+ return nil , fmt .Errorf ("could not list SIP outbound trunks: %w" , err )
863+ }
864+ return res , nil
865+ }
866+
867+ return listAndPrint (ctx , cmd , list , req , []string {
820868 "SipTrunkID" , "Name" ,
821869 "Address" , "Transport" ,
822870 "Numbers" ,
0 commit comments