Skip to content

Commit 88a30ed

Browse files
committed
feat(tiers): made tiers global rather than isolated polykey
1 parent 55e376f commit 88a30ed

File tree

6 files changed

+134
-126
lines changed

6 files changed

+134
-126
lines changed

gen/go/common/v2/common.pb.go

Lines changed: 73 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,58 @@ const (
2222
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
2323
)
2424

25+
type ClientTier int32
26+
27+
const (
28+
ClientTier_CLIENT_TIER_UNSPECIFIED ClientTier = 0
29+
ClientTier_CLIENT_TIER_FREE ClientTier = 1
30+
ClientTier_CLIENT_TIER_PRO ClientTier = 2
31+
ClientTier_CLIENT_TIER_ENTERPRISE ClientTier = 3
32+
)
33+
34+
// Enum value maps for ClientTier.
35+
var (
36+
ClientTier_name = map[int32]string{
37+
0: "CLIENT_TIER_UNSPECIFIED",
38+
1: "CLIENT_TIER_FREE",
39+
2: "CLIENT_TIER_PRO",
40+
3: "CLIENT_TIER_ENTERPRISE",
41+
}
42+
ClientTier_value = map[string]int32{
43+
"CLIENT_TIER_UNSPECIFIED": 0,
44+
"CLIENT_TIER_FREE": 1,
45+
"CLIENT_TIER_PRO": 2,
46+
"CLIENT_TIER_ENTERPRISE": 3,
47+
}
48+
)
49+
50+
func (x ClientTier) Enum() *ClientTier {
51+
p := new(ClientTier)
52+
*p = x
53+
return p
54+
}
55+
56+
func (x ClientTier) String() string {
57+
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
58+
}
59+
60+
func (ClientTier) Descriptor() protoreflect.EnumDescriptor {
61+
return file_common_v2_common_proto_enumTypes[0].Descriptor()
62+
}
63+
64+
func (ClientTier) Type() protoreflect.EnumType {
65+
return &file_common_v2_common_proto_enumTypes[0]
66+
}
67+
68+
func (x ClientTier) Number() protoreflect.EnumNumber {
69+
return protoreflect.EnumNumber(x)
70+
}
71+
72+
// Deprecated: Use ClientTier.Descriptor instead.
73+
func (ClientTier) EnumDescriptor() ([]byte, []int) {
74+
return file_common_v2_common_proto_rawDescGZIP(), []int{0}
75+
}
76+
2577
type Status struct {
2678
state protoimpl.MessageState `protogen:"open.v1"`
2779
Code int32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"`
@@ -379,7 +431,13 @@ const file_common_v2_common_proto_rawDesc = "" +
379431
"\x06fields\x18\x01 \x03(\v2\x1f.common.v2.Metadata.FieldsEntryR\x06fields\x1a9\n" +
380432
"\vFieldsEntry\x12\x10\n" +
381433
"\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" +
382-
"\x05value\x18\x02 \x01(\tR\x05value:\x028\x01B\xa0\x01\n" +
434+
"\x05value\x18\x02 \x01(\tR\x05value:\x028\x01*p\n" +
435+
"\n" +
436+
"ClientTier\x12\x1b\n" +
437+
"\x17CLIENT_TIER_UNSPECIFIED\x10\x00\x12\x14\n" +
438+
"\x10CLIENT_TIER_FREE\x10\x01\x12\x13\n" +
439+
"\x0fCLIENT_TIER_PRO\x10\x02\x12\x1a\n" +
440+
"\x16CLIENT_TIER_ENTERPRISE\x10\x03B\xa0\x01\n" +
383441
"\rcom.common.v2B\vCommonProtoP\x01Z=github.com/spounge-ai/spounge-proto/gen/go/common/v2;commonv2\xa2\x02\x03CXX\xaa\x02\tCommon.V2\xca\x02\tCommon\\V2\xe2\x02\x15Common\\V2\\GPBMetadata\xea\x02\n" +
384442
"Common::V2b\x06proto3"
385443

@@ -395,20 +453,22 @@ func file_common_v2_common_proto_rawDescGZIP() []byte {
395453
return file_common_v2_common_proto_rawDescData
396454
}
397455

456+
var file_common_v2_common_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
398457
var file_common_v2_common_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
399458
var file_common_v2_common_proto_goTypes = []any{
400-
(*Status)(nil), // 0: common.v2.Status
401-
(*File)(nil), // 1: common.v2.File
402-
(*PaginationParams)(nil), // 2: common.v2.PaginationParams
403-
(*PaginationResult)(nil), // 3: common.v2.PaginationResult
404-
(*EntityId)(nil), // 4: common.v2.EntityId
405-
(*Metadata)(nil), // 5: common.v2.Metadata
406-
nil, // 6: common.v2.Metadata.FieldsEntry
407-
(*structpb.Struct)(nil), // 7: google.protobuf.Struct
459+
(ClientTier)(0), // 0: common.v2.ClientTier
460+
(*Status)(nil), // 1: common.v2.Status
461+
(*File)(nil), // 2: common.v2.File
462+
(*PaginationParams)(nil), // 3: common.v2.PaginationParams
463+
(*PaginationResult)(nil), // 4: common.v2.PaginationResult
464+
(*EntityId)(nil), // 5: common.v2.EntityId
465+
(*Metadata)(nil), // 6: common.v2.Metadata
466+
nil, // 7: common.v2.Metadata.FieldsEntry
467+
(*structpb.Struct)(nil), // 8: google.protobuf.Struct
408468
}
409469
var file_common_v2_common_proto_depIdxs = []int32{
410-
7, // 0: common.v2.Status.details:type_name -> google.protobuf.Struct
411-
6, // 1: common.v2.Metadata.fields:type_name -> common.v2.Metadata.FieldsEntry
470+
8, // 0: common.v2.Status.details:type_name -> google.protobuf.Struct
471+
7, // 1: common.v2.Metadata.fields:type_name -> common.v2.Metadata.FieldsEntry
412472
2, // [2:2] is the sub-list for method output_type
413473
2, // [2:2] is the sub-list for method input_type
414474
2, // [2:2] is the sub-list for extension type_name
@@ -426,13 +486,14 @@ func file_common_v2_common_proto_init() {
426486
File: protoimpl.DescBuilder{
427487
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
428488
RawDescriptor: unsafe.Slice(unsafe.StringData(file_common_v2_common_proto_rawDesc), len(file_common_v2_common_proto_rawDesc)),
429-
NumEnums: 0,
489+
NumEnums: 1,
430490
NumMessages: 7,
431491
NumExtensions: 0,
432492
NumServices: 0,
433493
},
434494
GoTypes: file_common_v2_common_proto_goTypes,
435495
DependencyIndexes: file_common_v2_common_proto_depIdxs,
496+
EnumInfos: file_common_v2_common_proto_enumTypes,
436497
MessageInfos: file_common_v2_common_proto_msgTypes,
437498
}.Build()
438499
File_common_v2_common_proto = out.File

gen/go/polykey/v2/auth.pb.go

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
package polykeyv2
88

99
import (
10+
v2 "github.com/spounge-ai/spounge-proto/gen/go/common/v2"
1011
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
1112
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
1213
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
@@ -89,7 +90,7 @@ type AuthenticateResponse struct {
8990
ExpiresIn int64 `protobuf:"varint,3,opt,name=expires_in,json=expiresIn,proto3" json:"expires_in,omitempty"` // Token TTL in seconds
9091
Permissions []string `protobuf:"bytes,4,rep,name=permissions,proto3" json:"permissions,omitempty"` // ["secrets:read", "secrets:write"]
9192
IssuedAt *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=issued_at,json=issuedAt,proto3" json:"issued_at,omitempty"`
92-
ServiceTier ClientTier `protobuf:"varint,6,opt,name=service_tier,json=serviceTier,proto3,enum=polykey.v2.ClientTier" json:"service_tier,omitempty"`
93+
ClientTier v2.ClientTier `protobuf:"varint,6,opt,name=client_tier,json=clientTier,proto3,enum=common.v2.ClientTier" json:"client_tier,omitempty"`
9394
unknownFields protoimpl.UnknownFields
9495
sizeCache protoimpl.SizeCache
9596
}
@@ -159,11 +160,11 @@ func (x *AuthenticateResponse) GetIssuedAt() *timestamppb.Timestamp {
159160
return nil
160161
}
161162

162-
func (x *AuthenticateResponse) GetServiceTier() ClientTier {
163+
func (x *AuthenticateResponse) GetClientTier() v2.ClientTier {
163164
if x != nil {
164-
return x.ServiceTier
165+
return x.ClientTier
165166
}
166-
return ClientTier_CLIENT_TIER_UNSPECIFIED
167+
return v2.ClientTier(0)
167168
}
168169

169170
type RefreshTokenRequest struct {
@@ -391,7 +392,7 @@ type ClientInfo struct {
391392
Environment string `protobuf:"bytes,4,opt,name=environment,proto3" json:"environment,omitempty"` // "dev", "staging", "prod"
392393
CreatedAt *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
393394
LastUsedAt *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=last_used_at,json=lastUsedAt,proto3" json:"last_used_at,omitempty"`
394-
ServiceTier ClientTier `protobuf:"varint,7,opt,name=service_tier,json=serviceTier,proto3,enum=polykey.v2.ClientTier" json:"service_tier,omitempty"`
395+
ClientTier v2.ClientTier `protobuf:"varint,7,opt,name=client_tier,json=clientTier,proto3,enum=common.v2.ClientTier" json:"client_tier,omitempty"`
395396
unknownFields protoimpl.UnknownFields
396397
sizeCache protoimpl.SizeCache
397398
}
@@ -468,33 +469,34 @@ func (x *ClientInfo) GetLastUsedAt() *timestamppb.Timestamp {
468469
return nil
469470
}
470471

471-
func (x *ClientInfo) GetServiceTier() ClientTier {
472+
func (x *ClientInfo) GetClientTier() v2.ClientTier {
472473
if x != nil {
473-
return x.ServiceTier
474+
return x.ClientTier
474475
}
475-
return ClientTier_CLIENT_TIER_UNSPECIFIED
476+
return v2.ClientTier(0)
476477
}
477478

478479
var File_polykey_v2_auth_proto protoreflect.FileDescriptor
479480

480481
const file_polykey_v2_auth_proto_rawDesc = "" +
481482
"\n" +
482483
"\x15polykey/v2/auth.proto\x12\n" +
483-
"polykey.v2\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x17polykey/v2/common.proto\"j\n" +
484+
"polykey.v2\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x16common/v2/common.proto\"j\n" +
484485
"\x13AuthenticateRequest\x12\x1b\n" +
485486
"\tclient_id\x18\x01 \x01(\tR\bclientId\x12\x17\n" +
486487
"\aapi_key\x18\x02 \x01(\tR\x06apiKey\x12\x1d\n" +
487488
"\n" +
488-
"grant_type\x18\x03 \x01(\tR\tgrantType\"\x8d\x02\n" +
489+
"grant_type\x18\x03 \x01(\tR\tgrantType\"\x8a\x02\n" +
489490
"\x14AuthenticateResponse\x12!\n" +
490491
"\faccess_token\x18\x01 \x01(\tR\vaccessToken\x12\x1d\n" +
491492
"\n" +
492493
"token_type\x18\x02 \x01(\tR\ttokenType\x12\x1d\n" +
493494
"\n" +
494495
"expires_in\x18\x03 \x01(\x03R\texpiresIn\x12 \n" +
495496
"\vpermissions\x18\x04 \x03(\tR\vpermissions\x127\n" +
496-
"\tissued_at\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampR\bissuedAt\x129\n" +
497-
"\fservice_tier\x18\x06 \x01(\x0e2\x16.polykey.v2.ClientTierR\vserviceTier\":\n" +
497+
"\tissued_at\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampR\bissuedAt\x126\n" +
498+
"\vclient_tier\x18\x06 \x01(\x0e2\x15.common.v2.ClientTierR\n" +
499+
"clientTier\":\n" +
498500
"\x13RefreshTokenRequest\x12#\n" +
499501
"\rrefresh_token\x18\x01 \x01(\tR\frefreshToken\"\xb0\x01\n" +
500502
"\x14RefreshTokenResponse\x12!\n" +
@@ -510,7 +512,7 @@ const file_polykey_v2_auth_proto_rawDesc = "" +
510512
"\x13RevokeTokenResponse\x12\x18\n" +
511513
"\arevoked\x18\x01 \x01(\bR\arevoked\x129\n" +
512514
"\n" +
513-
"revoked_at\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\trevokedAt\"\xc2\x02\n" +
515+
"revoked_at\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\trevokedAt\"\xbf\x02\n" +
514516
"\n" +
515517
"ClientInfo\x12\x1b\n" +
516518
"\tclient_id\x18\x01 \x01(\tR\bclientId\x12\x1f\n" +
@@ -521,8 +523,9 @@ const file_polykey_v2_auth_proto_rawDesc = "" +
521523
"\n" +
522524
"created_at\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampR\tcreatedAt\x12<\n" +
523525
"\flast_used_at\x18\x06 \x01(\v2\x1a.google.protobuf.TimestampR\n" +
524-
"lastUsedAt\x129\n" +
525-
"\fservice_tier\x18\a \x01(\x0e2\x16.polykey.v2.ClientTierR\vserviceTierB\xa5\x01\n" +
526+
"lastUsedAt\x126\n" +
527+
"\vclient_tier\x18\a \x01(\x0e2\x15.common.v2.ClientTierR\n" +
528+
"clientTierB\xa5\x01\n" +
526529
"\x0ecom.polykey.v2B\tAuthProtoP\x01Z?github.com/spounge-ai/spounge-proto/gen/go/polykey/v2;polykeyv2\xa2\x02\x03PXX\xaa\x02\n" +
527530
"Polykey.V2\xca\x02\n" +
528531
"Polykey\\V2\xe2\x02\x16Polykey\\V2\\GPBMetadata\xea\x02\vPolykey::V2b\x06proto3"
@@ -549,16 +552,16 @@ var file_polykey_v2_auth_proto_goTypes = []any{
549552
(*RevokeTokenResponse)(nil), // 5: polykey.v2.RevokeTokenResponse
550553
(*ClientInfo)(nil), // 6: polykey.v2.ClientInfo
551554
(*timestamppb.Timestamp)(nil), // 7: google.protobuf.Timestamp
552-
(ClientTier)(0), // 8: polykey.v2.ClientTier
555+
(v2.ClientTier)(0), // 8: common.v2.ClientTier
553556
}
554557
var file_polykey_v2_auth_proto_depIdxs = []int32{
555558
7, // 0: polykey.v2.AuthenticateResponse.issued_at:type_name -> google.protobuf.Timestamp
556-
8, // 1: polykey.v2.AuthenticateResponse.service_tier:type_name -> polykey.v2.ClientTier
559+
8, // 1: polykey.v2.AuthenticateResponse.client_tier:type_name -> common.v2.ClientTier
557560
7, // 2: polykey.v2.RefreshTokenResponse.issued_at:type_name -> google.protobuf.Timestamp
558561
7, // 3: polykey.v2.RevokeTokenResponse.revoked_at:type_name -> google.protobuf.Timestamp
559562
7, // 4: polykey.v2.ClientInfo.created_at:type_name -> google.protobuf.Timestamp
560563
7, // 5: polykey.v2.ClientInfo.last_used_at:type_name -> google.protobuf.Timestamp
561-
8, // 6: polykey.v2.ClientInfo.service_tier:type_name -> polykey.v2.ClientTier
564+
8, // 6: polykey.v2.ClientInfo.client_tier:type_name -> common.v2.ClientTier
562565
7, // [7:7] is the sub-list for method output_type
563566
7, // [7:7] is the sub-list for method input_type
564567
7, // [7:7] is the sub-list for extension type_name
@@ -571,7 +574,6 @@ func file_polykey_v2_auth_proto_init() {
571574
if File_polykey_v2_auth_proto != nil {
572575
return
573576
}
574-
file_polykey_v2_common_proto_init()
575577
type x struct{}
576578
out := protoimpl.TypeBuilder{
577579
File: protoimpl.DescBuilder{

0 commit comments

Comments
 (0)