diff --git a/components/usage-api/go/v1/billing.pb.go b/components/usage-api/go/v1/billing.pb.go index 0293031c9fceda..97abb04e9e08b8 100644 --- a/components/usage-api/go/v1/billing.pb.go +++ b/components/usage-api/go/v1/billing.pb.go @@ -126,6 +126,149 @@ func (*UpdateInvoicesResponse) Descriptor() ([]byte, []int) { return file_usage_v1_billing_proto_rawDescGZIP(), []int{1} } +type GetLatestInvoiceRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Identifier: + // *GetLatestInvoiceRequest_TeamId + // *GetLatestInvoiceRequest_UserId + Identifier isGetLatestInvoiceRequest_Identifier `protobuf_oneof:"identifier"` +} + +func (x *GetLatestInvoiceRequest) Reset() { + *x = GetLatestInvoiceRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_usage_v1_billing_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetLatestInvoiceRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetLatestInvoiceRequest) ProtoMessage() {} + +func (x *GetLatestInvoiceRequest) ProtoReflect() protoreflect.Message { + mi := &file_usage_v1_billing_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetLatestInvoiceRequest.ProtoReflect.Descriptor instead. +func (*GetLatestInvoiceRequest) Descriptor() ([]byte, []int) { + return file_usage_v1_billing_proto_rawDescGZIP(), []int{2} +} + +func (m *GetLatestInvoiceRequest) GetIdentifier() isGetLatestInvoiceRequest_Identifier { + if m != nil { + return m.Identifier + } + return nil +} + +func (x *GetLatestInvoiceRequest) GetTeamId() string { + if x, ok := x.GetIdentifier().(*GetLatestInvoiceRequest_TeamId); ok { + return x.TeamId + } + return "" +} + +func (x *GetLatestInvoiceRequest) GetUserId() string { + if x, ok := x.GetIdentifier().(*GetLatestInvoiceRequest_UserId); ok { + return x.UserId + } + return "" +} + +type isGetLatestInvoiceRequest_Identifier interface { + isGetLatestInvoiceRequest_Identifier() +} + +type GetLatestInvoiceRequest_TeamId struct { + TeamId string `protobuf:"bytes,1,opt,name=team_id,json=teamId,proto3,oneof"` +} + +type GetLatestInvoiceRequest_UserId struct { + UserId string `protobuf:"bytes,2,opt,name=user_id,json=userId,proto3,oneof"` +} + +func (*GetLatestInvoiceRequest_TeamId) isGetLatestInvoiceRequest_Identifier() {} + +func (*GetLatestInvoiceRequest_UserId) isGetLatestInvoiceRequest_Identifier() {} + +type GetLatestInvoiceResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + InvoiceId string `protobuf:"bytes,1,opt,name=invoice_id,json=invoiceId,proto3" json:"invoice_id,omitempty"` + Currency string `protobuf:"bytes,2,opt,name=currency,proto3" json:"currency,omitempty"` + Amount float64 `protobuf:"fixed64,3,opt,name=amount,proto3" json:"amount,omitempty"` +} + +func (x *GetLatestInvoiceResponse) Reset() { + *x = GetLatestInvoiceResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_usage_v1_billing_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetLatestInvoiceResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetLatestInvoiceResponse) ProtoMessage() {} + +func (x *GetLatestInvoiceResponse) ProtoReflect() protoreflect.Message { + mi := &file_usage_v1_billing_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetLatestInvoiceResponse.ProtoReflect.Descriptor instead. +func (*GetLatestInvoiceResponse) Descriptor() ([]byte, []int) { + return file_usage_v1_billing_proto_rawDescGZIP(), []int{3} +} + +func (x *GetLatestInvoiceResponse) GetInvoiceId() string { + if x != nil { + return x.InvoiceId + } + return "" +} + +func (x *GetLatestInvoiceResponse) GetCurrency() string { + if x != nil { + return x.Currency + } + return "" +} + +func (x *GetLatestInvoiceResponse) GetAmount() float64 { + if x != nil { + return x.Amount + } + return 0 +} + var File_usage_v1_billing_proto protoreflect.FileDescriptor var file_usage_v1_billing_proto_rawDesc = []byte{ @@ -148,17 +291,35 @@ var file_usage_v1_billing_proto_rawDesc = []byte{ 0x76, 0x31, 0x2e, 0x42, 0x69, 0x6c, 0x6c, 0x65, 0x64, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x18, 0x0a, 0x16, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x67, 0x0a, 0x0e, 0x42, 0x69, 0x6c, 0x6c, 0x69, 0x6e, 0x67, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x55, 0x0a, 0x0e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x73, 0x12, 0x1f, 0x2e, 0x75, 0x73, 0x61, 0x67, 0x65, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x5d, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x4c, 0x61, 0x74, 0x65, 0x73, + 0x74, 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x19, 0x0a, 0x07, 0x74, 0x65, 0x61, 0x6d, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x48, 0x00, 0x52, 0x06, 0x74, 0x65, 0x61, 0x6d, 0x49, 0x64, 0x12, 0x19, 0x0a, 0x07, 0x75, 0x73, + 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x06, 0x75, + 0x73, 0x65, 0x72, 0x49, 0x64, 0x42, 0x0c, 0x0a, 0x0a, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, + 0x69, 0x65, 0x72, 0x22, 0x6d, 0x0a, 0x18, 0x47, 0x65, 0x74, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, + 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x1d, 0x0a, 0x0a, 0x69, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x09, 0x69, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x49, 0x64, 0x12, 0x1a, + 0x0a, 0x08, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x08, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x6d, + 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x01, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, + 0x6e, 0x74, 0x32, 0xc4, 0x01, 0x0a, 0x0e, 0x42, 0x69, 0x6c, 0x6c, 0x69, 0x6e, 0x67, 0x53, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x55, 0x0a, 0x0e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x49, + 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x73, 0x12, 0x1f, 0x2e, 0x75, 0x73, 0x61, 0x67, 0x65, 0x2e, + 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, + 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x75, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, - 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x75, 0x73, 0x61, 0x67, - 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x76, 0x6f, 0x69, - 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x2a, 0x5a, - 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x69, 0x74, 0x70, - 0x6f, 0x64, 0x2d, 0x69, 0x6f, 0x2f, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2f, 0x75, 0x73, 0x61, - 0x67, 0x65, 0x2d, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5b, 0x0a, 0x10, + 0x47, 0x65, 0x74, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, + 0x12, 0x21, 0x2e, 0x75, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x4c, + 0x61, 0x74, 0x65, 0x73, 0x74, 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x75, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, + 0x65, 0x74, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x2a, 0x5a, 0x28, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2d, 0x69, + 0x6f, 0x2f, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2f, 0x75, 0x73, 0x61, 0x67, 0x65, 0x2d, 0x61, + 0x70, 0x69, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -173,21 +334,25 @@ func file_usage_v1_billing_proto_rawDescGZIP() []byte { return file_usage_v1_billing_proto_rawDescData } -var file_usage_v1_billing_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_usage_v1_billing_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_usage_v1_billing_proto_goTypes = []interface{}{ - (*UpdateInvoicesRequest)(nil), // 0: usage.v1.UpdateInvoicesRequest - (*UpdateInvoicesResponse)(nil), // 1: usage.v1.UpdateInvoicesResponse - (*timestamppb.Timestamp)(nil), // 2: google.protobuf.Timestamp - (*BilledSession)(nil), // 3: usage.v1.BilledSession + (*UpdateInvoicesRequest)(nil), // 0: usage.v1.UpdateInvoicesRequest + (*UpdateInvoicesResponse)(nil), // 1: usage.v1.UpdateInvoicesResponse + (*GetLatestInvoiceRequest)(nil), // 2: usage.v1.GetLatestInvoiceRequest + (*GetLatestInvoiceResponse)(nil), // 3: usage.v1.GetLatestInvoiceResponse + (*timestamppb.Timestamp)(nil), // 4: google.protobuf.Timestamp + (*BilledSession)(nil), // 5: usage.v1.BilledSession } var file_usage_v1_billing_proto_depIdxs = []int32{ - 2, // 0: usage.v1.UpdateInvoicesRequest.start_time:type_name -> google.protobuf.Timestamp - 2, // 1: usage.v1.UpdateInvoicesRequest.end_time:type_name -> google.protobuf.Timestamp - 3, // 2: usage.v1.UpdateInvoicesRequest.sessions:type_name -> usage.v1.BilledSession + 4, // 0: usage.v1.UpdateInvoicesRequest.start_time:type_name -> google.protobuf.Timestamp + 4, // 1: usage.v1.UpdateInvoicesRequest.end_time:type_name -> google.protobuf.Timestamp + 5, // 2: usage.v1.UpdateInvoicesRequest.sessions:type_name -> usage.v1.BilledSession 0, // 3: usage.v1.BillingService.UpdateInvoices:input_type -> usage.v1.UpdateInvoicesRequest - 1, // 4: usage.v1.BillingService.UpdateInvoices:output_type -> usage.v1.UpdateInvoicesResponse - 4, // [4:5] is the sub-list for method output_type - 3, // [3:4] is the sub-list for method input_type + 2, // 4: usage.v1.BillingService.GetLatestInvoice:input_type -> usage.v1.GetLatestInvoiceRequest + 1, // 5: usage.v1.BillingService.UpdateInvoices:output_type -> usage.v1.UpdateInvoicesResponse + 3, // 6: usage.v1.BillingService.GetLatestInvoice:output_type -> usage.v1.GetLatestInvoiceResponse + 5, // [5:7] is the sub-list for method output_type + 3, // [3:5] is the sub-list for method input_type 3, // [3:3] is the sub-list for extension type_name 3, // [3:3] is the sub-list for extension extendee 0, // [0:3] is the sub-list for field type_name @@ -224,6 +389,34 @@ func file_usage_v1_billing_proto_init() { return nil } } + file_usage_v1_billing_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetLatestInvoiceRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_usage_v1_billing_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetLatestInvoiceResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_usage_v1_billing_proto_msgTypes[2].OneofWrappers = []interface{}{ + (*GetLatestInvoiceRequest_TeamId)(nil), + (*GetLatestInvoiceRequest_UserId)(nil), } type x struct{} out := protoimpl.TypeBuilder{ @@ -231,7 +424,7 @@ func file_usage_v1_billing_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_usage_v1_billing_proto_rawDesc, NumEnums: 0, - NumMessages: 2, + NumMessages: 4, NumExtensions: 0, NumServices: 1, }, diff --git a/components/usage-api/go/v1/billing_grpc.pb.go b/components/usage-api/go/v1/billing_grpc.pb.go index da74382ff62629..c559e507848356 100644 --- a/components/usage-api/go/v1/billing_grpc.pb.go +++ b/components/usage-api/go/v1/billing_grpc.pb.go @@ -30,6 +30,8 @@ type BillingServiceClient interface { // in a billing system. // This is an Internal RPC used by the usage reconciler and not intended for general consumption. UpdateInvoices(ctx context.Context, in *UpdateInvoicesRequest, opts ...grpc.CallOption) (*UpdateInvoicesResponse, error) + // GetLatestInvoice retrieves the latest invoice for a given query. + GetLatestInvoice(ctx context.Context, in *GetLatestInvoiceRequest, opts ...grpc.CallOption) (*GetLatestInvoiceResponse, error) } type billingServiceClient struct { @@ -49,6 +51,15 @@ func (c *billingServiceClient) UpdateInvoices(ctx context.Context, in *UpdateInv return out, nil } +func (c *billingServiceClient) GetLatestInvoice(ctx context.Context, in *GetLatestInvoiceRequest, opts ...grpc.CallOption) (*GetLatestInvoiceResponse, error) { + out := new(GetLatestInvoiceResponse) + err := c.cc.Invoke(ctx, "/usage.v1.BillingService/GetLatestInvoice", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // BillingServiceServer is the server API for BillingService service. // All implementations must embed UnimplementedBillingServiceServer // for forward compatibility @@ -57,6 +68,8 @@ type BillingServiceServer interface { // in a billing system. // This is an Internal RPC used by the usage reconciler and not intended for general consumption. UpdateInvoices(context.Context, *UpdateInvoicesRequest) (*UpdateInvoicesResponse, error) + // GetLatestInvoice retrieves the latest invoice for a given query. + GetLatestInvoice(context.Context, *GetLatestInvoiceRequest) (*GetLatestInvoiceResponse, error) mustEmbedUnimplementedBillingServiceServer() } @@ -67,6 +80,9 @@ type UnimplementedBillingServiceServer struct { func (UnimplementedBillingServiceServer) UpdateInvoices(context.Context, *UpdateInvoicesRequest) (*UpdateInvoicesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateInvoices not implemented") } +func (UnimplementedBillingServiceServer) GetLatestInvoice(context.Context, *GetLatestInvoiceRequest) (*GetLatestInvoiceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetLatestInvoice not implemented") +} func (UnimplementedBillingServiceServer) mustEmbedUnimplementedBillingServiceServer() {} // UnsafeBillingServiceServer may be embedded to opt out of forward compatibility for this service. @@ -98,6 +114,24 @@ func _BillingService_UpdateInvoices_Handler(srv interface{}, ctx context.Context return interceptor(ctx, in, info, handler) } +func _BillingService_GetLatestInvoice_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetLatestInvoiceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(BillingServiceServer).GetLatestInvoice(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/usage.v1.BillingService/GetLatestInvoice", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(BillingServiceServer).GetLatestInvoice(ctx, req.(*GetLatestInvoiceRequest)) + } + return interceptor(ctx, in, info, handler) +} + // BillingService_ServiceDesc is the grpc.ServiceDesc for BillingService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -109,6 +143,10 @@ var BillingService_ServiceDesc = grpc.ServiceDesc{ MethodName: "UpdateInvoices", Handler: _BillingService_UpdateInvoices_Handler, }, + { + MethodName: "GetLatestInvoice", + Handler: _BillingService_GetLatestInvoice_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "usage/v1/billing.proto", diff --git a/components/usage-api/typescript/src/usage/v1/billing_grpc_pb.d.ts b/components/usage-api/typescript/src/usage/v1/billing_grpc_pb.d.ts index 933119960ba27f..a9927e16ca5ac2 100644 --- a/components/usage-api/typescript/src/usage/v1/billing_grpc_pb.d.ts +++ b/components/usage-api/typescript/src/usage/v1/billing_grpc_pb.d.ts @@ -17,6 +17,7 @@ import * as usage_v1_usage_pb from "../../usage/v1/usage_pb"; interface IBillingServiceService extends grpc.ServiceDefinition { updateInvoices: IBillingServiceService_IUpdateInvoices; + getLatestInvoice: IBillingServiceService_IGetLatestInvoice; } interface IBillingServiceService_IUpdateInvoices extends grpc.MethodDefinition { @@ -28,17 +29,30 @@ interface IBillingServiceService_IUpdateInvoices extends grpc.MethodDefinition; responseDeserialize: grpc.deserialize; } +interface IBillingServiceService_IGetLatestInvoice extends grpc.MethodDefinition { + path: "/usage.v1.BillingService/GetLatestInvoice"; + requestStream: false; + responseStream: false; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} export const BillingServiceService: IBillingServiceService; export interface IBillingServiceServer extends grpc.UntypedServiceImplementation { updateInvoices: grpc.handleUnaryCall; + getLatestInvoice: grpc.handleUnaryCall; } export interface IBillingServiceClient { updateInvoices(request: usage_v1_billing_pb.UpdateInvoicesRequest, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.UpdateInvoicesResponse) => void): grpc.ClientUnaryCall; updateInvoices(request: usage_v1_billing_pb.UpdateInvoicesRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.UpdateInvoicesResponse) => void): grpc.ClientUnaryCall; updateInvoices(request: usage_v1_billing_pb.UpdateInvoicesRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.UpdateInvoicesResponse) => void): grpc.ClientUnaryCall; + getLatestInvoice(request: usage_v1_billing_pb.GetLatestInvoiceRequest, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.GetLatestInvoiceResponse) => void): grpc.ClientUnaryCall; + getLatestInvoice(request: usage_v1_billing_pb.GetLatestInvoiceRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.GetLatestInvoiceResponse) => void): grpc.ClientUnaryCall; + getLatestInvoice(request: usage_v1_billing_pb.GetLatestInvoiceRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.GetLatestInvoiceResponse) => void): grpc.ClientUnaryCall; } export class BillingServiceClient extends grpc.Client implements IBillingServiceClient { @@ -46,4 +60,7 @@ export class BillingServiceClient extends grpc.Client implements IBillingService public updateInvoices(request: usage_v1_billing_pb.UpdateInvoicesRequest, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.UpdateInvoicesResponse) => void): grpc.ClientUnaryCall; public updateInvoices(request: usage_v1_billing_pb.UpdateInvoicesRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.UpdateInvoicesResponse) => void): grpc.ClientUnaryCall; public updateInvoices(request: usage_v1_billing_pb.UpdateInvoicesRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.UpdateInvoicesResponse) => void): grpc.ClientUnaryCall; + public getLatestInvoice(request: usage_v1_billing_pb.GetLatestInvoiceRequest, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.GetLatestInvoiceResponse) => void): grpc.ClientUnaryCall; + public getLatestInvoice(request: usage_v1_billing_pb.GetLatestInvoiceRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.GetLatestInvoiceResponse) => void): grpc.ClientUnaryCall; + public getLatestInvoice(request: usage_v1_billing_pb.GetLatestInvoiceRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.GetLatestInvoiceResponse) => void): grpc.ClientUnaryCall; } diff --git a/components/usage-api/typescript/src/usage/v1/billing_grpc_pb.js b/components/usage-api/typescript/src/usage/v1/billing_grpc_pb.js index f8ad4c0d59c3d9..9d39491038df56 100644 --- a/components/usage-api/typescript/src/usage/v1/billing_grpc_pb.js +++ b/components/usage-api/typescript/src/usage/v1/billing_grpc_pb.js @@ -12,6 +12,28 @@ var usage_v1_billing_pb = require('../../usage/v1/billing_pb.js'); var google_protobuf_timestamp_pb = require('google-protobuf/google/protobuf/timestamp_pb.js'); var usage_v1_usage_pb = require('../../usage/v1/usage_pb.js'); +function serialize_usage_v1_GetLatestInvoiceRequest(arg) { + if (!(arg instanceof usage_v1_billing_pb.GetLatestInvoiceRequest)) { + throw new Error('Expected argument of type usage.v1.GetLatestInvoiceRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_usage_v1_GetLatestInvoiceRequest(buffer_arg) { + return usage_v1_billing_pb.GetLatestInvoiceRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_usage_v1_GetLatestInvoiceResponse(arg) { + if (!(arg instanceof usage_v1_billing_pb.GetLatestInvoiceResponse)) { + throw new Error('Expected argument of type usage.v1.GetLatestInvoiceResponse'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_usage_v1_GetLatestInvoiceResponse(buffer_arg) { + return usage_v1_billing_pb.GetLatestInvoiceResponse.deserializeBinary(new Uint8Array(buffer_arg)); +} + function serialize_usage_v1_UpdateInvoicesRequest(arg) { if (!(arg instanceof usage_v1_billing_pb.UpdateInvoicesRequest)) { throw new Error('Expected argument of type usage.v1.UpdateInvoicesRequest'); @@ -50,6 +72,18 @@ updateInvoices: { responseSerialize: serialize_usage_v1_UpdateInvoicesResponse, responseDeserialize: deserialize_usage_v1_UpdateInvoicesResponse, }, + // GetLatestInvoice retrieves the latest invoice for a given query. +getLatestInvoice: { + path: '/usage.v1.BillingService/GetLatestInvoice', + requestStream: false, + responseStream: false, + requestType: usage_v1_billing_pb.GetLatestInvoiceRequest, + responseType: usage_v1_billing_pb.GetLatestInvoiceResponse, + requestSerialize: serialize_usage_v1_GetLatestInvoiceRequest, + requestDeserialize: deserialize_usage_v1_GetLatestInvoiceRequest, + responseSerialize: serialize_usage_v1_GetLatestInvoiceResponse, + responseDeserialize: deserialize_usage_v1_GetLatestInvoiceResponse, + }, }; exports.BillingServiceClient = grpc.makeGenericClientConstructor(BillingServiceService); diff --git a/components/usage-api/typescript/src/usage/v1/billing_pb.d.ts b/components/usage-api/typescript/src/usage/v1/billing_pb.d.ts index fae61cbe2604e0..a8cb313e9df7c5 100644 --- a/components/usage-api/typescript/src/usage/v1/billing_pb.d.ts +++ b/components/usage-api/typescript/src/usage/v1/billing_pb.d.ts @@ -64,3 +64,67 @@ export namespace UpdateInvoicesResponse { export type AsObject = { } } + +export class GetLatestInvoiceRequest extends jspb.Message { + + hasTeamId(): boolean; + clearTeamId(): void; + getTeamId(): string; + setTeamId(value: string): GetLatestInvoiceRequest; + + hasUserId(): boolean; + clearUserId(): void; + getUserId(): string; + setUserId(value: string): GetLatestInvoiceRequest; + + getIdentifierCase(): GetLatestInvoiceRequest.IdentifierCase; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetLatestInvoiceRequest.AsObject; + static toObject(includeInstance: boolean, msg: GetLatestInvoiceRequest): GetLatestInvoiceRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetLatestInvoiceRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetLatestInvoiceRequest; + static deserializeBinaryFromReader(message: GetLatestInvoiceRequest, reader: jspb.BinaryReader): GetLatestInvoiceRequest; +} + +export namespace GetLatestInvoiceRequest { + export type AsObject = { + teamId: string, + userId: string, + } + + export enum IdentifierCase { + IDENTIFIER_NOT_SET = 0, + TEAM_ID = 1, + USER_ID = 2, + } + +} + +export class GetLatestInvoiceResponse extends jspb.Message { + getInvoiceId(): string; + setInvoiceId(value: string): GetLatestInvoiceResponse; + getCurrency(): string; + setCurrency(value: string): GetLatestInvoiceResponse; + getAmount(): number; + setAmount(value: number): GetLatestInvoiceResponse; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetLatestInvoiceResponse.AsObject; + static toObject(includeInstance: boolean, msg: GetLatestInvoiceResponse): GetLatestInvoiceResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetLatestInvoiceResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetLatestInvoiceResponse; + static deserializeBinaryFromReader(message: GetLatestInvoiceResponse, reader: jspb.BinaryReader): GetLatestInvoiceResponse; +} + +export namespace GetLatestInvoiceResponse { + export type AsObject = { + invoiceId: string, + currency: string, + amount: number, + } +} diff --git a/components/usage-api/typescript/src/usage/v1/billing_pb.js b/components/usage-api/typescript/src/usage/v1/billing_pb.js index c4ba9ef41a66b5..708f01aca05e50 100644 --- a/components/usage-api/typescript/src/usage/v1/billing_pb.js +++ b/components/usage-api/typescript/src/usage/v1/billing_pb.js @@ -25,6 +25,9 @@ var google_protobuf_timestamp_pb = require('google-protobuf/google/protobuf/time goog.object.extend(proto, google_protobuf_timestamp_pb); var usage_v1_usage_pb = require('../../usage/v1/usage_pb.js'); goog.object.extend(proto, usage_v1_usage_pb); +goog.exportSymbol('proto.usage.v1.GetLatestInvoiceRequest', null, global); +goog.exportSymbol('proto.usage.v1.GetLatestInvoiceRequest.IdentifierCase', null, global); +goog.exportSymbol('proto.usage.v1.GetLatestInvoiceResponse', null, global); goog.exportSymbol('proto.usage.v1.UpdateInvoicesRequest', null, global); goog.exportSymbol('proto.usage.v1.UpdateInvoicesResponse', null, global); /** @@ -69,6 +72,48 @@ if (goog.DEBUG && !COMPILED) { */ proto.usage.v1.UpdateInvoicesResponse.displayName = 'proto.usage.v1.UpdateInvoicesResponse'; } +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.usage.v1.GetLatestInvoiceRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, proto.usage.v1.GetLatestInvoiceRequest.oneofGroups_); +}; +goog.inherits(proto.usage.v1.GetLatestInvoiceRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.usage.v1.GetLatestInvoiceRequest.displayName = 'proto.usage.v1.GetLatestInvoiceRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.usage.v1.GetLatestInvoiceResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.usage.v1.GetLatestInvoiceResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.usage.v1.GetLatestInvoiceResponse.displayName = 'proto.usage.v1.GetLatestInvoiceResponse'; +} /** * List of repeated fields within this message type. @@ -432,4 +477,416 @@ proto.usage.v1.UpdateInvoicesResponse.serializeBinaryToWriter = function(message }; + +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.usage.v1.GetLatestInvoiceRequest.oneofGroups_ = [[1,2]]; + +/** + * @enum {number} + */ +proto.usage.v1.GetLatestInvoiceRequest.IdentifierCase = { + IDENTIFIER_NOT_SET: 0, + TEAM_ID: 1, + USER_ID: 2 +}; + +/** + * @return {proto.usage.v1.GetLatestInvoiceRequest.IdentifierCase} + */ +proto.usage.v1.GetLatestInvoiceRequest.prototype.getIdentifierCase = function() { + return /** @type {proto.usage.v1.GetLatestInvoiceRequest.IdentifierCase} */(jspb.Message.computeOneofCase(this, proto.usage.v1.GetLatestInvoiceRequest.oneofGroups_[0])); +}; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.usage.v1.GetLatestInvoiceRequest.prototype.toObject = function(opt_includeInstance) { + return proto.usage.v1.GetLatestInvoiceRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.usage.v1.GetLatestInvoiceRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.usage.v1.GetLatestInvoiceRequest.toObject = function(includeInstance, msg) { + var f, obj = { + teamId: jspb.Message.getFieldWithDefault(msg, 1, ""), + userId: jspb.Message.getFieldWithDefault(msg, 2, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.usage.v1.GetLatestInvoiceRequest} + */ +proto.usage.v1.GetLatestInvoiceRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.usage.v1.GetLatestInvoiceRequest; + return proto.usage.v1.GetLatestInvoiceRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.usage.v1.GetLatestInvoiceRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.usage.v1.GetLatestInvoiceRequest} + */ +proto.usage.v1.GetLatestInvoiceRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setTeamId(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setUserId(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.usage.v1.GetLatestInvoiceRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.usage.v1.GetLatestInvoiceRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.usage.v1.GetLatestInvoiceRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.usage.v1.GetLatestInvoiceRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeString( + 2, + f + ); + } +}; + + +/** + * optional string team_id = 1; + * @return {string} + */ +proto.usage.v1.GetLatestInvoiceRequest.prototype.getTeamId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.usage.v1.GetLatestInvoiceRequest} returns this + */ +proto.usage.v1.GetLatestInvoiceRequest.prototype.setTeamId = function(value) { + return jspb.Message.setOneofField(this, 1, proto.usage.v1.GetLatestInvoiceRequest.oneofGroups_[0], value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.usage.v1.GetLatestInvoiceRequest} returns this + */ +proto.usage.v1.GetLatestInvoiceRequest.prototype.clearTeamId = function() { + return jspb.Message.setOneofField(this, 1, proto.usage.v1.GetLatestInvoiceRequest.oneofGroups_[0], undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.usage.v1.GetLatestInvoiceRequest.prototype.hasTeamId = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional string user_id = 2; + * @return {string} + */ +proto.usage.v1.GetLatestInvoiceRequest.prototype.getUserId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.usage.v1.GetLatestInvoiceRequest} returns this + */ +proto.usage.v1.GetLatestInvoiceRequest.prototype.setUserId = function(value) { + return jspb.Message.setOneofField(this, 2, proto.usage.v1.GetLatestInvoiceRequest.oneofGroups_[0], value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.usage.v1.GetLatestInvoiceRequest} returns this + */ +proto.usage.v1.GetLatestInvoiceRequest.prototype.clearUserId = function() { + return jspb.Message.setOneofField(this, 2, proto.usage.v1.GetLatestInvoiceRequest.oneofGroups_[0], undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.usage.v1.GetLatestInvoiceRequest.prototype.hasUserId = function() { + return jspb.Message.getField(this, 2) != null; +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.usage.v1.GetLatestInvoiceResponse.prototype.toObject = function(opt_includeInstance) { + return proto.usage.v1.GetLatestInvoiceResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.usage.v1.GetLatestInvoiceResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.usage.v1.GetLatestInvoiceResponse.toObject = function(includeInstance, msg) { + var f, obj = { + invoiceId: jspb.Message.getFieldWithDefault(msg, 1, ""), + currency: jspb.Message.getFieldWithDefault(msg, 2, ""), + amount: jspb.Message.getFloatingPointFieldWithDefault(msg, 3, 0.0) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.usage.v1.GetLatestInvoiceResponse} + */ +proto.usage.v1.GetLatestInvoiceResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.usage.v1.GetLatestInvoiceResponse; + return proto.usage.v1.GetLatestInvoiceResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.usage.v1.GetLatestInvoiceResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.usage.v1.GetLatestInvoiceResponse} + */ +proto.usage.v1.GetLatestInvoiceResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setInvoiceId(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setCurrency(value); + break; + case 3: + var value = /** @type {number} */ (reader.readDouble()); + msg.setAmount(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.usage.v1.GetLatestInvoiceResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.usage.v1.GetLatestInvoiceResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.usage.v1.GetLatestInvoiceResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.usage.v1.GetLatestInvoiceResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getInvoiceId(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getCurrency(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } + f = message.getAmount(); + if (f !== 0.0) { + writer.writeDouble( + 3, + f + ); + } +}; + + +/** + * optional string invoice_id = 1; + * @return {string} + */ +proto.usage.v1.GetLatestInvoiceResponse.prototype.getInvoiceId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.usage.v1.GetLatestInvoiceResponse} returns this + */ +proto.usage.v1.GetLatestInvoiceResponse.prototype.setInvoiceId = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional string currency = 2; + * @return {string} + */ +proto.usage.v1.GetLatestInvoiceResponse.prototype.getCurrency = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.usage.v1.GetLatestInvoiceResponse} returns this + */ +proto.usage.v1.GetLatestInvoiceResponse.prototype.setCurrency = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); +}; + + +/** + * optional double amount = 3; + * @return {number} + */ +proto.usage.v1.GetLatestInvoiceResponse.prototype.getAmount = function() { + return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 3, 0.0)); +}; + + +/** + * @param {number} value + * @return {!proto.usage.v1.GetLatestInvoiceResponse} returns this + */ +proto.usage.v1.GetLatestInvoiceResponse.prototype.setAmount = function(value) { + return jspb.Message.setProto3FloatField(this, 3, value); +}; + + goog.object.extend(exports, proto.usage.v1); diff --git a/components/usage-api/usage/v1/billing.proto b/components/usage-api/usage/v1/billing.proto index d69707e30a209d..25a481f503b787 100644 --- a/components/usage-api/usage/v1/billing.proto +++ b/components/usage-api/usage/v1/billing.proto @@ -12,6 +12,9 @@ service BillingService { // in a billing system. // This is an Internal RPC used by the usage reconciler and not intended for general consumption. rpc UpdateInvoices(UpdateInvoicesRequest) returns (UpdateInvoicesResponse) {}; + + // GetLatestInvoice retrieves the latest invoice for a given query. + rpc GetLatestInvoice(GetLatestInvoiceRequest) returns (GetLatestInvoiceResponse) {}; } message UpdateInvoicesRequest { @@ -23,3 +26,16 @@ message UpdateInvoicesRequest { message UpdateInvoicesResponse { } + +message GetLatestInvoiceRequest { + oneof identifier { + string team_id = 1; + string user_id = 2; + } +} + +message GetLatestInvoiceResponse { + string invoice_id = 1; + string currency = 2; + double amount = 3; +} diff --git a/components/usage/pkg/controller/reconciler_test.go b/components/usage/pkg/controller/reconciler_test.go index 2c85694964d765..249020db43852c 100644 --- a/components/usage/pkg/controller/reconciler_test.go +++ b/components/usage/pkg/controller/reconciler_test.go @@ -77,6 +77,10 @@ func (c *NoOpBillingServiceClient) UpdateInvoices(ctx context.Context, in *v1.Up return &v1.UpdateInvoicesResponse{}, nil } +func (c *NoOpBillingServiceClient) GetLatestInvoice(ctx context.Context, in *v1.GetLatestInvoiceRequest, opts ...grpc.CallOption) (*v1.GetLatestInvoiceResponse, error) { + return &v1.GetLatestInvoiceResponse{}, nil +} + func TestInstanceToUsageRecords(t *testing.T) { maxStopTime := time.Date(2022, 05, 31, 23, 00, 00, 00, time.UTC) teamID, ownerID, projectID := uuid.New().String(), uuid.New(), uuid.New()