diff --git a/livekit/livekit_phone_number.pb.go b/livekit/livekit_phone_number.pb.go index f8f182bbf..d5ce11742 100644 --- a/livekit/livekit_phone_number.pb.go +++ b/livekit/livekit_phone_number.pb.go @@ -30,6 +30,7 @@ const ( PhoneNumberStatus_PHONE_NUMBER_STATUS_ACTIVE PhoneNumberStatus = 1 // Number is active and ready for use PhoneNumberStatus_PHONE_NUMBER_STATUS_PENDING PhoneNumberStatus = 2 // Number is being provisioned PhoneNumberStatus_PHONE_NUMBER_STATUS_RELEASED PhoneNumberStatus = 3 // Number has been released + PhoneNumberStatus_PHONE_NUMBER_STATUS_OFFLINE PhoneNumberStatus = 4 // Number is offline (not associated with any dispatch rule) ) // Enum value maps for PhoneNumberStatus. @@ -39,12 +40,14 @@ var ( 1: "PHONE_NUMBER_STATUS_ACTIVE", 2: "PHONE_NUMBER_STATUS_PENDING", 3: "PHONE_NUMBER_STATUS_RELEASED", + 4: "PHONE_NUMBER_STATUS_OFFLINE", } PhoneNumberStatus_value = map[string]int32{ "PHONE_NUMBER_STATUS_UNSPECIFIED": 0, "PHONE_NUMBER_STATUS_ACTIVE": 1, "PHONE_NUMBER_STATUS_PENDING": 2, "PHONE_NUMBER_STATUS_RELEASED": 3, + "PHONE_NUMBER_STATUS_OFFLINE": 4, } ) @@ -423,6 +426,7 @@ type ListPhoneNumbersResponse struct { Items []*PhoneNumber `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"` // List of phone numbers NextPageToken *TokenPagination `protobuf:"bytes,2,opt,name=next_page_token,json=nextPageToken,proto3" json:"next_page_token,omitempty"` // Token for next page (empty if no more pages) TotalCount int32 `protobuf:"varint,3,opt,name=total_count,json=totalCount,proto3" json:"total_count,omitempty"` // Total number of phone numbers + OfflineCount int32 `protobuf:"varint,4,opt,name=offline_count,json=offlineCount,proto3" json:"offline_count,omitempty"` // Total number of offline phone numbers unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -478,6 +482,13 @@ func (x *ListPhoneNumbersResponse) GetTotalCount() int32 { return 0 } +func (x *ListPhoneNumbersResponse) GetOfflineCount() int32 { + if x != nil { + return x.OfflineCount + } + return 0 +} + // GetPhoneNumberRequest - Request to get a phone number type GetPhoneNumberRequest struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -774,24 +785,26 @@ func (*ReleasePhoneNumbersResponse) Descriptor() ([]byte, []int) { // PhoneNumber - Unified phone number type for inventory and purchased numbers type PhoneNumber struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // Unique identifier - E164Format string `protobuf:"bytes,2,opt,name=e164_format,json=e164Format,proto3" json:"e164_format,omitempty"` // Phone number in E.164 format (e.g., "+14155552671") - CountryCode string `protobuf:"bytes,3,opt,name=country_code,json=countryCode,proto3" json:"country_code,omitempty"` // Country code (e.g., "US") - AreaCode string `protobuf:"bytes,4,opt,name=area_code,json=areaCode,proto3" json:"area_code,omitempty"` // Area code (e.g., "415") - NumberType PhoneNumberType `protobuf:"varint,5,opt,name=number_type,json=numberType,proto3,enum=livekit.PhoneNumberType" json:"number_type,omitempty"` // Number type (mobile, local, toll-free, unknown) - Locality string `protobuf:"bytes,6,opt,name=locality,proto3" json:"locality,omitempty"` // City/locality (e.g., "San Francisco") - Region string `protobuf:"bytes,7,opt,name=region,proto3" json:"region,omitempty"` // State/region (e.g., "CA") - SpamScore float64 `protobuf:"fixed64,8,opt,name=spam_score,json=spamScore,proto3" json:"spam_score,omitempty"` // Spam score for fraud detection - CreatedAt *timestamppb.Timestamp `protobuf:"bytes,9,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` // Creation timestamp - UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,10,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"` // Last update timestamp - Capabilities []string `protobuf:"bytes,11,rep,name=capabilities,proto3" json:"capabilities,omitempty"` // Available capabilities (e.g., "voice", "sms") - Status PhoneNumberStatus `protobuf:"varint,12,opt,name=status,proto3,enum=livekit.PhoneNumberStatus" json:"status,omitempty"` // Current status - AssignedAt *timestamppb.Timestamp `protobuf:"bytes,13,opt,name=assigned_at,json=assignedAt,proto3" json:"assigned_at,omitempty"` // Assignment timestamp - ReleasedAt *timestamppb.Timestamp `protobuf:"bytes,14,opt,name=released_at,json=releasedAt,proto3" json:"released_at,omitempty"` // Release timestamp (if applicable) - SipDispatchRuleId string `protobuf:"bytes,15,opt,name=sip_dispatch_rule_id,json=sipDispatchRuleId,proto3" json:"sip_dispatch_rule_id,omitempty"` // Associated SIP dispatch rule ID - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // Unique identifier + E164Format string `protobuf:"bytes,2,opt,name=e164_format,json=e164Format,proto3" json:"e164_format,omitempty"` // Phone number in E.164 format (e.g., "+14155552671") + CountryCode string `protobuf:"bytes,3,opt,name=country_code,json=countryCode,proto3" json:"country_code,omitempty"` // Country code (e.g., "US") + AreaCode string `protobuf:"bytes,4,opt,name=area_code,json=areaCode,proto3" json:"area_code,omitempty"` // Area code (e.g., "415") + NumberType PhoneNumberType `protobuf:"varint,5,opt,name=number_type,json=numberType,proto3,enum=livekit.PhoneNumberType" json:"number_type,omitempty"` // Number type (mobile, local, toll-free, unknown) + Locality string `protobuf:"bytes,6,opt,name=locality,proto3" json:"locality,omitempty"` // City/locality (e.g., "San Francisco") + Region string `protobuf:"bytes,7,opt,name=region,proto3" json:"region,omitempty"` // State/region (e.g., "CA") + SpamScore float64 `protobuf:"fixed64,8,opt,name=spam_score,json=spamScore,proto3" json:"spam_score,omitempty"` // Spam score for fraud detection + CreatedAt *timestamppb.Timestamp `protobuf:"bytes,9,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` // Creation timestamp + UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,10,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"` // Last update timestamp + Capabilities []string `protobuf:"bytes,11,rep,name=capabilities,proto3" json:"capabilities,omitempty"` // Available capabilities (e.g., "voice", "sms") + Status PhoneNumberStatus `protobuf:"varint,12,opt,name=status,proto3,enum=livekit.PhoneNumberStatus" json:"status,omitempty"` // Current status + AssignedAt *timestamppb.Timestamp `protobuf:"bytes,13,opt,name=assigned_at,json=assignedAt,proto3" json:"assigned_at,omitempty"` // Assignment timestamp + ReleasedAt *timestamppb.Timestamp `protobuf:"bytes,14,opt,name=released_at,json=releasedAt,proto3" json:"released_at,omitempty"` // Release timestamp (if applicable) + // Deprecated: Marked as deprecated in livekit_phone_number.proto. + SipDispatchRuleId string `protobuf:"bytes,15,opt,name=sip_dispatch_rule_id,json=sipDispatchRuleId,proto3" json:"sip_dispatch_rule_id,omitempty"` // Associated SIP dispatch rule ID (deprecated: use sip_dispatch_rule_ids instead) + SipDispatchRuleIds []string `protobuf:"bytes,16,rep,name=sip_dispatch_rule_ids,json=sipDispatchRuleIds,proto3" json:"sip_dispatch_rule_ids,omitempty"` // Associated SIP dispatch rule IDs + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *PhoneNumber) Reset() { @@ -922,6 +935,7 @@ func (x *PhoneNumber) GetReleasedAt() *timestamppb.Timestamp { return nil } +// Deprecated: Marked as deprecated in livekit_phone_number.proto. func (x *PhoneNumber) GetSipDispatchRuleId() string { if x != nil { return x.SipDispatchRuleId @@ -929,6 +943,13 @@ func (x *PhoneNumber) GetSipDispatchRuleId() string { return "" } +func (x *PhoneNumber) GetSipDispatchRuleIds() []string { + if x != nil { + return x.SipDispatchRuleIds + } + return nil +} + var File_livekit_phone_number_proto protoreflect.FileDescriptor const file_livekit_phone_number_proto_rawDesc = "" + @@ -961,12 +982,13 @@ const file_livekit_phone_number_proto_rawDesc = "" + "\x14sip_dispatch_rule_id\x18\x04 \x01(\tH\x02R\x11sipDispatchRuleId\x88\x01\x01B\b\n" + "\x06_limitB\r\n" + "\v_page_tokenB\x17\n" + - "\x15_sip_dispatch_rule_id\"\xa9\x01\n" + + "\x15_sip_dispatch_rule_id\"\xce\x01\n" + "\x18ListPhoneNumbersResponse\x12*\n" + "\x05items\x18\x01 \x03(\v2\x14.livekit.PhoneNumberR\x05items\x12@\n" + "\x0fnext_page_token\x18\x02 \x01(\v2\x18.livekit.TokenPaginationR\rnextPageToken\x12\x1f\n" + "\vtotal_count\x18\x03 \x01(\x05R\n" + - "totalCount\"l\n" + + "totalCount\x12#\n" + + "\roffline_count\x18\x04 \x01(\x05R\fofflineCount\"l\n" + "\x15GetPhoneNumberRequest\x12\x13\n" + "\x02id\x18\x01 \x01(\tH\x00R\x02id\x88\x01\x01\x12&\n" + "\fphone_number\x18\x02 \x01(\tH\x01R\vphoneNumber\x88\x01\x01B\x05\n" + @@ -986,7 +1008,7 @@ const file_livekit_phone_number_proto_rawDesc = "" + "\x1aReleasePhoneNumbersRequest\x12\x10\n" + "\x03ids\x18\x01 \x03(\tR\x03ids\x12#\n" + "\rphone_numbers\x18\x02 \x03(\tR\fphoneNumbers\"\x1d\n" + - "\x1bReleasePhoneNumbersResponse\"\x85\x05\n" + + "\x1bReleasePhoneNumbersResponse\"\xbc\x05\n" + "\vPhoneNumber\x12\x0e\n" + "\x02id\x18\x01 \x01(\tR\x02id\x12\x1f\n" + "\ve164_format\x18\x02 \x01(\tR\n" + @@ -1009,13 +1031,15 @@ const file_livekit_phone_number_proto_rawDesc = "" + "\vassigned_at\x18\r \x01(\v2\x1a.google.protobuf.TimestampR\n" + "assignedAt\x12;\n" + "\vreleased_at\x18\x0e \x01(\v2\x1a.google.protobuf.TimestampR\n" + - "releasedAt\x12/\n" + - "\x14sip_dispatch_rule_id\x18\x0f \x01(\tR\x11sipDispatchRuleId*\x9b\x01\n" + + "releasedAt\x123\n" + + "\x14sip_dispatch_rule_id\x18\x0f \x01(\tB\x02\x18\x01R\x11sipDispatchRuleId\x121\n" + + "\x15sip_dispatch_rule_ids\x18\x10 \x03(\tR\x12sipDispatchRuleIds*\xbc\x01\n" + "\x11PhoneNumberStatus\x12#\n" + "\x1fPHONE_NUMBER_STATUS_UNSPECIFIED\x10\x00\x12\x1e\n" + "\x1aPHONE_NUMBER_STATUS_ACTIVE\x10\x01\x12\x1f\n" + "\x1bPHONE_NUMBER_STATUS_PENDING\x10\x02\x12 \n" + - "\x1cPHONE_NUMBER_STATUS_RELEASED\x10\x03*\x8c\x01\n" + + "\x1cPHONE_NUMBER_STATUS_RELEASED\x10\x03\x12\x1f\n" + + "\x1bPHONE_NUMBER_STATUS_OFFLINE\x10\x04*\x8c\x01\n" + "\x0fPhoneNumberType\x12\x1d\n" + "\x19PHONE_NUMBER_TYPE_UNKNOWN\x10\x00\x12\x1c\n" + "\x18PHONE_NUMBER_TYPE_MOBILE\x10\x01\x12\x1b\n" + diff --git a/livekit/livekit_phone_number.twirp.go b/livekit/livekit_phone_number.twirp.go index 3b37541eb..fc4f0c610 100644 --- a/livekit/livekit_phone_number.twirp.go +++ b/livekit/livekit_phone_number.twirp.go @@ -1919,77 +1919,80 @@ func (s *phoneNumberServiceServer) PathPrefix() string { } var twirpFileDescriptor6 = []byte{ - // 1148 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x57, 0xdd, 0x6e, 0xe3, 0x44, - 0x14, 0xce, 0x24, 0x9b, 0x6e, 0x73, 0x92, 0xb6, 0xd9, 0xd9, 0xee, 0xd6, 0x75, 0xb7, 0xdb, 0xac, - 0x0b, 0x28, 0xea, 0x45, 0x2a, 0xca, 0x6a, 0x51, 0x05, 0x17, 0x24, 0xad, 0xbb, 0x8d, 0xc8, 0xa6, - 0xc1, 0x49, 0x81, 0x45, 0x48, 0x23, 0xc7, 0x9e, 0x4d, 0x47, 0xeb, 0xd8, 0xc6, 0x9e, 0xac, 0xe8, - 0x03, 0x20, 0xad, 0x10, 0x17, 0x88, 0x5b, 0x9e, 0x80, 0x97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ee, 0xd5, 0x8b, 0x29, 0xc0, 0xc2, 0x39, 0xba, 0xe8, 0xf5, 0xc8, - 0x99, 0xa6, 0xaa, 0xf5, 0xd2, 0xd1, 0x5f, 0xf7, 0x00, 0x27, 0xc9, 0xa2, 0xde, 0x3b, 0x66, 0x50, - 0x4c, 0x00, 0xa7, 0x5f, 0x54, 0x58, 0x89, 0x85, 0x92, 0xfb, 0xa2, 0x94, 0xf7, 0x97, 0xc6, 0x44, - 0xad, 0xa2, 0x80, 0xc7, 0xf0, 0x30, 0xe3, 0x4d, 0x82, 0x6f, 0xb2, 0xf3, 0xdf, 0x50, 0xf2, 0x07, - 0xcb, 0x83, 0xe2, 0x35, 0x5e, 0x43, 0xfd, 0xf6, 0x1c, 0xc6, 0x8d, 0x38, 0x37, 0xe7, 0xdd, 0x22, - 0x3f, 0x5b, 0x12, 0x11, 0x97, 0x1e, 0xc2, 0xfa, 0xe2, 0x24, 0xc3, 0x4f, 0xe3, 0xb4, 0xcc, 0x81, - 0x2a, 0xef, 0xe5, 0xfa, 0xe3, 0xa2, 0xdf, 0xc3, 0x83, 0xd4, 0x28, 0xc0, 0x37, 0x70, 0xf2, 0xc6, - 0x9c, 0xac, 0x2c, 0x0b, 0x49, 0x32, 0x9e, 0xd1, 0xbd, 0x13, 0x8c, 0xe7, 0x0f, 0x8c, 0x04, 0xe3, - 0xcb, 0x06, 0x40, 0xa1, 0xf3, 0xe1, 0x77, 0xfb, 0x13, 0xc6, 0xaf, 0x66, 0xe3, 0x96, 0xe1, 0x4c, - 0x0f, 0xa3, 0x9c, 0xf0, 0x1f, 0x8b, 0xe1, 0x58, 0x73, 0xc3, 0x78, 0x45, 0x58, 0x3e, 0xf9, 0x27, - 0x00, 0x00, 0xff, 0xff, 0xdb, 0x0c, 0x75, 0x75, 0xf8, 0x0c, 0x00, 0x00, + // 1190 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x57, 0xdd, 0x6e, 0xe2, 0x46, + 0x14, 0x66, 0x20, 0x64, 0xc3, 0x81, 0x24, 0xec, 0xec, 0x4f, 0x1c, 0x67, 0xb3, 0x61, 0x9d, 0xb6, + 0x42, 0xb9, 0x20, 0xda, 0xec, 0x6a, 0xab, 0xa8, 0xbd, 0x28, 0x24, 0xce, 0x06, 0x95, 0x05, 0x6a, + 0x48, 0xdb, 0xad, 0x2a, 0x59, 0xc6, 0x4c, 0xc8, 0x68, 0x8d, 0xed, 0xda, 0xc3, 0xaa, 0x79, 0x83, + 0x55, 0xd5, 0x8b, 0xaa, 0xcf, 0xb3, 0xea, 0x0b, 0x54, 0xea, 0x33, 0xf4, 0x51, 0xaa, 0x19, 0x1b, + 0xc7, 0xc4, 0x36, 0xb9, 0x68, 0xa5, 0xde, 0xe1, 0x73, 0xbe, 0x73, 0xe6, 0xcc, 0x37, 0xdf, 0x9c, + 0x33, 0x80, 0x6c, 0xd1, 0xf7, 0xe4, 0x1d, 0x65, 0xba, 0x7b, 0xe5, 0xd8, 0x44, 0xb7, 0x67, 0xd3, + 0x11, 0xf1, 0x1a, 0xae, 0xe7, 0x30, 0x07, 0xdf, 0x0b, 0x7d, 0xf2, 0xde, 0xc4, 0x71, 0x26, 0x16, + 0x39, 0x14, 0xe6, 0xd1, 0xec, 0xf2, 0x90, 0xd1, 0x29, 0xf1, 0x99, 0x31, 0x75, 0x03, 0xa4, 0xfc, + 0x70, 0x9e, 0x65, 0xea, 0x8c, 0x89, 0xe5, 0x07, 0x56, 0xe5, 0x6f, 0x04, 0xdb, 0x03, 0x62, 0x78, + 0xe6, 0x55, 0x9f, 0x27, 0xef, 0x8a, 0xdc, 0xbe, 0x46, 0x7e, 0x9a, 0x11, 0x9f, 0xe1, 0x67, 0x50, + 0x31, 0x9d, 0x99, 0xcd, 0xbc, 0x6b, 0xdd, 0x74, 0xc6, 0x44, 0x42, 0x35, 0x54, 0x2f, 0x69, 0xe5, + 0xd0, 0x76, 0xe2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 0xd4, 0x03, + 0xd8, 0x58, 0x9c, 0x90, 0xf8, 0x69, 0x14, 0x96, 0x3a, 0xa8, 0xe5, 0xbd, 0x4c, 0x7f, 0x94, 0xf4, + 0x47, 0xb8, 0x9f, 0x18, 0x31, 0xf8, 0xa6, 0x9c, 0xac, 0xf1, 0x29, 0x2b, 0xcb, 0x20, 0x71, 0xc6, + 0x53, 0xa6, 0x42, 0x8c, 0xf1, 0xec, 0x41, 0x14, 0x63, 0x7c, 0xd9, 0x60, 0xc9, 0xb5, 0x3e, 0xfd, + 0x61, 0x7f, 0x42, 0xd9, 0xd5, 0x6c, 0xd4, 0x30, 0x9d, 0xe9, 0x61, 0x18, 0x13, 0xfc, 0x5d, 0x32, + 0x1d, 0x6b, 0x6e, 0x18, 0xad, 0x0a, 0xcb, 0x8b, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0xc8, 0xbb, + 0xfd, 0x42, 0x75, 0x0d, 0x00, 0x00, } diff --git a/livekit/types.go b/livekit/types.go index bdb55dce7..37e3d4c6c 100644 --- a/livekit/types.go +++ b/livekit/types.go @@ -16,6 +16,8 @@ package livekit import ( "context" + "encoding/base64" + "encoding/json" "fmt" "io" "slices" @@ -165,6 +167,50 @@ func (p *Pagination) Filter(v PageItem) bool { return true } +// TokenPaginationData represents the data encoded in a TokenPagination token +type TokenPaginationData struct { + Offset int32 `json:"offset"` + Limit int32 `json:"limit"` +} + +// EncodeTokenPagination encodes offset and limit into a TokenPagination. +// The token is a base64-encoded JSON object containing the offset and limit values. +func EncodeTokenPagination(offset, limit int32) (*TokenPagination, error) { + data := TokenPaginationData{ + Offset: offset, + Limit: limit, + } + + jsonData, err := json.Marshal(data) + if err != nil { + return nil, fmt.Errorf("failed to marshal token pagination data: %w", err) + } + + token := base64.URLEncoding.EncodeToString(jsonData) + return &TokenPagination{Token: token}, nil +} + +// DecodeTokenPagination decodes a TokenPagination into offset and limit. +// Returns an error if the token is invalid or cannot be decoded. +// If the TokenPagination is nil or has an empty token, returns zero values without error. +func DecodeTokenPagination(tp *TokenPagination) (offset, limit int32, err error) { + if tp == nil || tp.Token == "" { + return 0, 0, nil + } + + decoded, err := base64.URLEncoding.DecodeString(tp.Token) + if err != nil { + return 0, 0, fmt.Errorf("failed to decode token: %w", err) + } + + var data TokenPaginationData + if err := json.Unmarshal(decoded, &data); err != nil { + return 0, 0, fmt.Errorf("failed to unmarshal token pagination data: %w", err) + } + + return data.Offset, data.Limit, nil +} + type pageIterReq[T any] interface { GetPage() *Pagination Filter(v T) bool diff --git a/livekit/types_test.go b/livekit/types_test.go index b9bd0a81d..729d6536a 100644 --- a/livekit/types_test.go +++ b/livekit/types_test.go @@ -2,6 +2,7 @@ package livekit import ( "context" + "encoding/base64" "fmt" "slices" "testing" @@ -319,3 +320,62 @@ func TestListUpdate(t *testing.T) { }) } } + +func TestEncodeTokenPagination(t *testing.T) { + t.Run("encode and decode", func(t *testing.T) { + offset := int32(10) + limit := int32(50) + + tokenPagination, err := EncodeTokenPagination(offset, limit) + require.NoError(t, err) + require.NotNil(t, tokenPagination) + require.NotEmpty(t, tokenPagination.Token) + + decodedOffset, decodedLimit, err := DecodeTokenPagination(tokenPagination) + require.NoError(t, err) + require.Equal(t, offset, decodedOffset) + require.Equal(t, limit, decodedLimit) + }) + + t.Run("encode zero values", func(t *testing.T) { + tokenPagination, err := EncodeTokenPagination(0, 0) + require.NoError(t, err) + require.NotNil(t, tokenPagination) + require.NotEmpty(t, tokenPagination.Token) + + decodedOffset, decodedLimit, err := DecodeTokenPagination(tokenPagination) + require.NoError(t, err) + require.Equal(t, int32(0), decodedOffset) + require.Equal(t, int32(0), decodedLimit) + }) + + t.Run("decode nil token pagination", func(t *testing.T) { + offset, limit, err := DecodeTokenPagination(nil) + require.NoError(t, err) + require.Equal(t, int32(0), offset) + require.Equal(t, int32(0), limit) + }) + + t.Run("decode empty token", func(t *testing.T) { + tp := &TokenPagination{Token: ""} + offset, limit, err := DecodeTokenPagination(tp) + require.NoError(t, err) + require.Equal(t, int32(0), offset) + require.Equal(t, int32(0), limit) + }) + + t.Run("decode invalid token", func(t *testing.T) { + tp := &TokenPagination{Token: "invalid-token"} + _, _, err := DecodeTokenPagination(tp) + require.Error(t, err) + require.Contains(t, err.Error(), "failed to decode token") + }) + + t.Run("decode invalid json", func(t *testing.T) { + invalidJSON := base64.URLEncoding.EncodeToString([]byte("not json")) + tp := &TokenPagination{Token: invalidJSON} + _, _, err := DecodeTokenPagination(tp) + require.Error(t, err) + require.Contains(t, err.Error(), "failed to unmarshal") + }) +} diff --git a/protobufs/livekit_phone_number.proto b/protobufs/livekit_phone_number.proto index 1e04815fe..79177e3e0 100644 --- a/protobufs/livekit_phone_number.proto +++ b/protobufs/livekit_phone_number.proto @@ -14,6 +14,7 @@ enum PhoneNumberStatus { PHONE_NUMBER_STATUS_ACTIVE = 1; // Number is active and ready for use PHONE_NUMBER_STATUS_PENDING = 2; // Number is being provisioned PHONE_NUMBER_STATUS_RELEASED = 3; // Number has been released + PHONE_NUMBER_STATUS_OFFLINE = 4; // Number is offline (not associated with any dispatch rule) } // Phone number type enumeration @@ -89,6 +90,7 @@ message ListPhoneNumbersResponse { repeated PhoneNumber items = 1; // List of phone numbers TokenPagination next_page_token = 2; // Token for next page (empty if no more pages) int32 total_count = 3; // Total number of phone numbers + int32 offline_count = 4; // Total number of offline phone numbers } // GetPhoneNumberRequest - Request to get a phone number @@ -141,5 +143,6 @@ message PhoneNumber { PhoneNumberStatus status = 12; // Current status google.protobuf.Timestamp assigned_at = 13; // Assignment timestamp google.protobuf.Timestamp released_at = 14; // Release timestamp (if applicable) - string sip_dispatch_rule_id = 15; // Associated SIP dispatch rule ID + string sip_dispatch_rule_id = 15 [deprecated=true]; // Associated SIP dispatch rule ID (deprecated: use sip_dispatch_rule_ids instead) + repeated string sip_dispatch_rule_ids = 16; // Associated SIP dispatch rule IDs }