Skip to content

Commit 1d8a32f

Browse files
Updated phone number api (#708)
* Updated phone number api 1. Allowing multiple status to be sent for list phone number 2. Modified optional fields * Changing helper text for statuses
1 parent 105f640 commit 1d8a32f

File tree

3 files changed

+27
-21
lines changed

3 files changed

+27
-21
lines changed

cmd/lk/phone_number.go

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ var (
7979
Usage: "Maximum number of results (default: 50)",
8080
Value: 50,
8181
},
82-
&cli.StringFlag{
82+
&cli.StringSliceFlag{
8383
Name: "status",
84-
Usage: "Filter by status (active, pending, released)",
84+
Usage: "Filter by status(es) (active, pending, released). Mutliple values can be specified.",
8585
},
8686
&cli.StringFlag{
8787
Name: "sip-dispatch-rule-id",
@@ -172,10 +172,11 @@ func searchPhoneNumbers(ctx context.Context, cmd *cli.Command) error {
172172
req.CountryCode = val
173173
}
174174
if val := cmd.String("area-code"); val != "" {
175-
req.AreaCode = val
175+
req.AreaCode = &val
176176
}
177177
if val := cmd.Int("limit"); val != 0 {
178-
req.Limit = int32(val)
178+
limit := int32(val)
179+
req.Limit = &limit
179180
}
180181

181182
resp, err := client.SearchPhoneNumbers(ctx, req)
@@ -229,7 +230,7 @@ func purchasePhoneNumbers(ctx context.Context, cmd *cli.Command) error {
229230
PhoneNumbers: phoneNumbers,
230231
}
231232
if val := cmd.String("sip-dispatch-rule-id"); val != "" {
232-
req.SipDispatchRuleId = val
233+
req.SipDispatchRuleId = &val
233234
}
234235

235236
resp, err := client.PurchasePhoneNumber(ctx, req)
@@ -258,17 +259,22 @@ func listPhoneNumbers(ctx context.Context, cmd *cli.Command) error {
258259

259260
req := &livekit.ListPhoneNumbersRequest{}
260261
if val := cmd.Int("limit"); val != 0 {
261-
req.Limit = int32(val)
262-
}
263-
if val := cmd.String("status"); val != "" {
264-
status, ok := livekit.PhoneNumberStatus_value["PHONE_NUMBER_STATUS_"+strings.ToUpper(val)]
265-
if !ok {
266-
return fmt.Errorf("invalid status: %s", val)
262+
limit := int32(val)
263+
req.Limit = &limit
264+
}
265+
if statuses := cmd.StringSlice("status"); len(statuses) > 0 {
266+
var phoneNumberStatuses []livekit.PhoneNumberStatus
267+
for _, status := range statuses {
268+
statusValue, ok := livekit.PhoneNumberStatus_value["PHONE_NUMBER_STATUS_"+strings.ToUpper(status)]
269+
if !ok {
270+
return fmt.Errorf("invalid status: %s", status)
271+
}
272+
phoneNumberStatuses = append(phoneNumberStatuses, livekit.PhoneNumberStatus(statusValue))
267273
}
268-
req.Status = livekit.PhoneNumberStatus(status)
274+
req.Statuses = phoneNumberStatuses
269275
}
270276
if val := cmd.String("sip-dispatch-rule-id"); val != "" {
271-
req.SipDispatchRuleId = val
277+
req.SipDispatchRuleId = &val
272278
}
273279

274280
resp, err := client.ListPhoneNumbers(ctx, req)
@@ -320,9 +326,9 @@ func getPhoneNumber(ctx context.Context, cmd *cli.Command) error {
320326

321327
req := &livekit.GetPhoneNumberRequest{}
322328
if id != "" {
323-
req.Id = id
329+
req.Id = &id
324330
} else {
325-
req.PhoneNumber = phoneNumber
331+
req.PhoneNumber = &phoneNumber
326332
}
327333

328334
resp, err := client.GetPhoneNumber(ctx, req)
@@ -372,12 +378,12 @@ func updatePhoneNumber(ctx context.Context, cmd *cli.Command) error {
372378

373379
req := &livekit.UpdatePhoneNumberRequest{}
374380
if id != "" {
375-
req.Id = id
381+
req.Id = &id
376382
} else {
377-
req.PhoneNumber = phoneNumber
383+
req.PhoneNumber = &phoneNumber
378384
}
379385
if val := cmd.String("sip-dispatch-rule-id"); val != "" {
380-
req.SipDispatchRuleId = val
386+
req.SipDispatchRuleId = &val
381387
}
382388

383389
resp, err := client.UpdatePhoneNumber(ctx, req)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
github.com/go-logr/logr v1.4.3
1313
github.com/go-task/task/v3 v3.44.1
1414
github.com/joho/godotenv v1.5.1
15-
github.com/livekit/protocol v1.42.2-0.20251016024155-8cf58ff15ac6
15+
github.com/livekit/protocol v1.42.3-0.20251024111301-1e3becbff5d1
1616
github.com/livekit/server-sdk-go/v2 v2.12.1
1717
github.com/moby/patternmatcher v0.6.0
1818
github.com/pelletier/go-toml v1.9.5

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,8 @@ github.com/livekit/mageutil v0.0.0-20250511045019-0f1ff63f7731 h1:9x+U2HGLrSw5AT
267267
github.com/livekit/mageutil v0.0.0-20250511045019-0f1ff63f7731/go.mod h1:Rs3MhFwutWhGwmY1VQsygw28z5bWcnEYmS1OG9OxjOQ=
268268
github.com/livekit/mediatransportutil v0.0.0-20250825135402-7bc31f107ade h1:lpxPcglwzUWNB4J0S2qZuyMehzmR7vW9whzSwV4IGoI=
269269
github.com/livekit/mediatransportutil v0.0.0-20250825135402-7bc31f107ade/go.mod h1:mSNtYzSf6iY9xM3UX42VEI+STHvMgHmrYzEHPcdhB8A=
270-
github.com/livekit/protocol v1.42.2-0.20251016024155-8cf58ff15ac6 h1:Tby1v0yn0XCXl9nBVnZI9M1cQW/0o4E/ejzRgcaMETI=
271-
github.com/livekit/protocol v1.42.2-0.20251016024155-8cf58ff15ac6/go.mod h1:vhMS30QoEyH2p34vi6X1eWkC4EMV72ZGZwQb74ajY7A=
270+
github.com/livekit/protocol v1.42.3-0.20251024111301-1e3becbff5d1 h1:MBlwsnh1Zf8cb4MiflfyIglEZKfodkcE6JUvp+8M9i0=
271+
github.com/livekit/protocol v1.42.3-0.20251024111301-1e3becbff5d1/go.mod h1:ODNQZnKVH2U93PMn/NwcpPV6zOrilBpYbyncjn/rHZI=
272272
github.com/livekit/psrpc v0.7.0 h1:rtfqfjYN06WJYloE/S0nmkJ/Y04x4pxLQLe8kQ4FVHU=
273273
github.com/livekit/psrpc v0.7.0/go.mod h1:AuDC5uOoEjQJEc69v4Li3t77Ocz0e0NdjQEuFfO+vfk=
274274
github.com/livekit/server-sdk-go/v2 v2.12.1 h1:6F4OWwWPcUjyhaWPNL5BE1XEJt9KzX4/10P5ADeL7xY=

0 commit comments

Comments
 (0)