Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 34 additions & 6 deletions cmd/lk/phone_number.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,17 @@
Flags: []cli.Flag{
&cli.IntFlag{
Name: "limit",
Usage: "Maximum number of results (default: 50)",
Usage: "Maximum number of results per page (default: 50)",
Value: 50,
},
&cli.IntFlag{
Name: "offset",
Usage: "Offset for pagination (default: 0)",
Value: 0,
},
&cli.StringSliceFlag{
Name: "status",
Usage: "Filter by status(es) (active, pending, released). Mutliple values can be specified.",
Usage: "Filter by status(es) (active, pending, released, offline). Multiple values can be specified.",
},
&cli.StringFlag{
Name: "sip-dispatch-rule-id",
Expand Down Expand Up @@ -351,10 +356,17 @@
}

req := &livekit.ListPhoneNumbersRequest{}
if val := cmd.Int("limit"); val != 0 {
limit := int32(val)
req.Limit = &limit
limit := int32(cmd.Int("limit"))
offset := int32(cmd.Int("offset"))

// Encode offset and limit into a page token for pagination
// Even if offset is 0, we encode it to include the limit in the token
pageToken, err := livekit.EncodeTokenPagination(offset, limit)
if err != nil {
return fmt.Errorf("failed to encode pagination token: %w", err)
}
req.PageToken = pageToken

if statuses := cmd.StringSlice("status"); len(statuses) > 0 {
var phoneNumberStatuses []livekit.PhoneNumberStatus
for _, status := range statuses {
Expand Down Expand Up @@ -418,7 +430,23 @@
return nil
}

fmt.Printf("Total phone numbers: %d\n", resp.TotalCount)
fmt.Printf("Total phone numbers: %d", resp.TotalCount)
if resp.OfflineCount > 0 {
fmt.Printf(" (%d offline)", resp.OfflineCount)
}
fmt.Printf("\n")

// Show pagination info
if offset > 0 {
fmt.Printf("Showing results from offset %d\n", offset)
}
if resp.NextPageToken != nil {
nextOffset, _, err := livekit.DecodeTokenPagination(resp.NextPageToken)
if err == nil {
fmt.Printf("More results available. Use --offset %d to see the next page.\n", nextOffset)
}
}

return listAndPrint(ctx, cmd, func(ctx context.Context, req *livekit.ListPhoneNumbersRequest) (*livekit.ListPhoneNumbersResponse, error) {
return client.ListPhoneNumbers(ctx, req)
}, req, []string{
Expand All @@ -428,8 +456,8 @@
dispatchRulesStr := ""
if len(rules) > 0 {
dispatchRulesStr = strings.Join(rules, ", ")
} else if item.SipDispatchRuleId != "" {

Check failure on line 459 in cmd/lk/phone_number.go

View workflow job for this annotation

GitHub Actions / build

item.SipDispatchRuleId is deprecated: Marked as deprecated in livekit_phone_number.proto. (SA1019)
dispatchRulesStr = item.SipDispatchRuleId

Check failure on line 460 in cmd/lk/phone_number.go

View workflow job for this annotation

GitHub Actions / build

item.SipDispatchRuleId is deprecated: Marked as deprecated in livekit_phone_number.proto. (SA1019)
} else {
dispatchRulesStr = "-"
}
Expand Down Expand Up @@ -524,8 +552,8 @@
dispatchRulesStr := ""
if len(rules) > 0 {
dispatchRulesStr = strings.Join(rules, ", ")
} else if item.SipDispatchRuleId != "" {

Check failure on line 555 in cmd/lk/phone_number.go

View workflow job for this annotation

GitHub Actions / build

item.SipDispatchRuleId is deprecated: Marked as deprecated in livekit_phone_number.proto. (SA1019)
dispatchRulesStr = item.SipDispatchRuleId

Check failure on line 556 in cmd/lk/phone_number.go

View workflow job for this annotation

GitHub Actions / build

item.SipDispatchRuleId is deprecated: Marked as deprecated in livekit_phone_number.proto. (SA1019)
} else {
dispatchRulesStr = "-"
}
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/go-logr/logr v1.4.3
github.com/go-task/task/v3 v3.44.1
github.com/joho/godotenv v1.5.1
github.com/livekit/protocol v1.43.1-0.20251112192040-8bdcb749c402
github.com/livekit/protocol v1.43.3-0.20251127030154-5d65f30ee664
github.com/livekit/server-sdk-go/v2 v2.12.9-0.20251112193538-ed23dded48f9
github.com/moby/patternmatcher v0.6.0
github.com/pelletier/go-toml v1.9.5
Expand Down Expand Up @@ -113,7 +113,7 @@ require (
github.com/lithammer/shortuuid/v4 v4.2.0 // indirect
github.com/livekit/mageutil v0.0.0-20250511045019-0f1ff63f7731 // indirect
github.com/livekit/mediatransportutil v0.0.0-20250922175932-f537f0880397 // indirect
github.com/livekit/psrpc v0.7.1-0.20251105165826-1016ad610a7e // indirect
github.com/livekit/psrpc v0.7.1 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/magefile/mage v1.15.0 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,10 @@ github.com/livekit/mageutil v0.0.0-20250511045019-0f1ff63f7731 h1:9x+U2HGLrSw5AT
github.com/livekit/mageutil v0.0.0-20250511045019-0f1ff63f7731/go.mod h1:Rs3MhFwutWhGwmY1VQsygw28z5bWcnEYmS1OG9OxjOQ=
github.com/livekit/mediatransportutil v0.0.0-20250922175932-f537f0880397 h1:Z7j2mY+bvG05UC80MpnJkitlJju8sSDWsr0Bb4dPceo=
github.com/livekit/mediatransportutil v0.0.0-20250922175932-f537f0880397/go.mod h1:mSNtYzSf6iY9xM3UX42VEI+STHvMgHmrYzEHPcdhB8A=
github.com/livekit/protocol v1.43.1-0.20251112192040-8bdcb749c402 h1:mMIddIE1wlvgwIDYZ48M4eptU4dzA2DqzWzeT7OTkcY=
github.com/livekit/protocol v1.43.1-0.20251112192040-8bdcb749c402/go.mod h1:TpqU2qCI1ES4Lk7PAWSgYO4RaexfVXb54ZO2hXv0Bmc=
github.com/livekit/psrpc v0.7.1-0.20251105165826-1016ad610a7e h1:K6GKMFGJW8U2RoEyi8Zar7pPwUB7RMsn3AEJXf/Mgfc=
github.com/livekit/psrpc v0.7.1-0.20251105165826-1016ad610a7e/go.mod h1:bZ4iHFQptTkbPnB0LasvRNu/OBYXEu1NA6O5BMFo9kk=
github.com/livekit/protocol v1.43.3-0.20251127030154-5d65f30ee664 h1:CfKrVfzkGDvN9XeKqjt/Ap4sEbeUiLGSo3hgMikBDXg=
github.com/livekit/protocol v1.43.3-0.20251127030154-5d65f30ee664/go.mod h1:yjkL2/HcaCRyHykP9rLgKST2099AGd8laaU8EuHMnfw=
github.com/livekit/psrpc v0.7.1 h1:ms37az0QTD3UXIWuUC5D/SkmKOlRMVRsI261eBWu/Vw=
github.com/livekit/psrpc v0.7.1/go.mod h1:bZ4iHFQptTkbPnB0LasvRNu/OBYXEu1NA6O5BMFo9kk=
github.com/livekit/server-sdk-go/v2 v2.12.9-0.20251112193538-ed23dded48f9 h1:NjL66OFpkQJMhdvi0WCGWaPUr6XE1JGQwyKpNXWj4hg=
github.com/livekit/server-sdk-go/v2 v2.12.9-0.20251112193538-ed23dded48f9/go.mod h1:YGjcmx4bSoEWGFqd1nqfVw8a+KQuOHXpr/prKtWRZaQ=
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
Expand Down
Loading