|
79 | 79 | Usage: "Maximum number of results (default: 50)", |
80 | 80 | Value: 50, |
81 | 81 | }, |
82 | | - &cli.StringFlag{ |
| 82 | + &cli.StringSliceFlag{ |
83 | 83 | Name: "status", |
84 | | - Usage: "Filter by status (active, pending, released)", |
| 84 | + Usage: "Filter by status(es) (active, pending, released). Mutliple values can be specified.", |
85 | 85 | }, |
86 | 86 | &cli.StringFlag{ |
87 | 87 | Name: "sip-dispatch-rule-id", |
@@ -172,10 +172,11 @@ func searchPhoneNumbers(ctx context.Context, cmd *cli.Command) error { |
172 | 172 | req.CountryCode = val |
173 | 173 | } |
174 | 174 | if val := cmd.String("area-code"); val != "" { |
175 | | - req.AreaCode = val |
| 175 | + req.AreaCode = &val |
176 | 176 | } |
177 | 177 | if val := cmd.Int("limit"); val != 0 { |
178 | | - req.Limit = int32(val) |
| 178 | + limit := int32(val) |
| 179 | + req.Limit = &limit |
179 | 180 | } |
180 | 181 |
|
181 | 182 | resp, err := client.SearchPhoneNumbers(ctx, req) |
@@ -229,7 +230,7 @@ func purchasePhoneNumbers(ctx context.Context, cmd *cli.Command) error { |
229 | 230 | PhoneNumbers: phoneNumbers, |
230 | 231 | } |
231 | 232 | if val := cmd.String("sip-dispatch-rule-id"); val != "" { |
232 | | - req.SipDispatchRuleId = val |
| 233 | + req.SipDispatchRuleId = &val |
233 | 234 | } |
234 | 235 |
|
235 | 236 | resp, err := client.PurchasePhoneNumber(ctx, req) |
@@ -258,17 +259,22 @@ func listPhoneNumbers(ctx context.Context, cmd *cli.Command) error { |
258 | 259 |
|
259 | 260 | req := &livekit.ListPhoneNumbersRequest{} |
260 | 261 | 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)) |
267 | 273 | } |
268 | | - req.Status = livekit.PhoneNumberStatus(status) |
| 274 | + req.Statuses = phoneNumberStatuses |
269 | 275 | } |
270 | 276 | if val := cmd.String("sip-dispatch-rule-id"); val != "" { |
271 | | - req.SipDispatchRuleId = val |
| 277 | + req.SipDispatchRuleId = &val |
272 | 278 | } |
273 | 279 |
|
274 | 280 | resp, err := client.ListPhoneNumbers(ctx, req) |
@@ -320,9 +326,9 @@ func getPhoneNumber(ctx context.Context, cmd *cli.Command) error { |
320 | 326 |
|
321 | 327 | req := &livekit.GetPhoneNumberRequest{} |
322 | 328 | if id != "" { |
323 | | - req.Id = id |
| 329 | + req.Id = &id |
324 | 330 | } else { |
325 | | - req.PhoneNumber = phoneNumber |
| 331 | + req.PhoneNumber = &phoneNumber |
326 | 332 | } |
327 | 333 |
|
328 | 334 | resp, err := client.GetPhoneNumber(ctx, req) |
@@ -372,12 +378,12 @@ func updatePhoneNumber(ctx context.Context, cmd *cli.Command) error { |
372 | 378 |
|
373 | 379 | req := &livekit.UpdatePhoneNumberRequest{} |
374 | 380 | if id != "" { |
375 | | - req.Id = id |
| 381 | + req.Id = &id |
376 | 382 | } else { |
377 | | - req.PhoneNumber = phoneNumber |
| 383 | + req.PhoneNumber = &phoneNumber |
378 | 384 | } |
379 | 385 | if val := cmd.String("sip-dispatch-rule-id"); val != "" { |
380 | | - req.SipDispatchRuleId = val |
| 386 | + req.SipDispatchRuleId = &val |
381 | 387 | } |
382 | 388 |
|
383 | 389 | resp, err := client.UpdatePhoneNumber(ctx, req) |
|
0 commit comments