diff --git a/components/usage-api/go/v1/billing.pb.go b/components/usage-api/go/v1/billing.pb.go index 97abb04e9e08b8..ce4f7e6bf441d8 100644 --- a/components/usage-api/go/v1/billing.pb.go +++ b/components/usage-api/go/v1/billing.pb.go @@ -269,6 +269,91 @@ func (x *GetLatestInvoiceResponse) GetAmount() float64 { return 0 } +type FinalizeInvoiceRequest 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"` +} + +func (x *FinalizeInvoiceRequest) Reset() { + *x = FinalizeInvoiceRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_usage_v1_billing_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FinalizeInvoiceRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FinalizeInvoiceRequest) ProtoMessage() {} + +func (x *FinalizeInvoiceRequest) ProtoReflect() protoreflect.Message { + mi := &file_usage_v1_billing_proto_msgTypes[4] + 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 FinalizeInvoiceRequest.ProtoReflect.Descriptor instead. +func (*FinalizeInvoiceRequest) Descriptor() ([]byte, []int) { + return file_usage_v1_billing_proto_rawDescGZIP(), []int{4} +} + +func (x *FinalizeInvoiceRequest) GetInvoiceId() string { + if x != nil { + return x.InvoiceId + } + return "" +} + +type FinalizeInvoiceResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *FinalizeInvoiceResponse) Reset() { + *x = FinalizeInvoiceResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_usage_v1_billing_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FinalizeInvoiceResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FinalizeInvoiceResponse) ProtoMessage() {} + +func (x *FinalizeInvoiceResponse) ProtoReflect() protoreflect.Message { + mi := &file_usage_v1_billing_proto_msgTypes[5] + 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 FinalizeInvoiceResponse.ProtoReflect.Descriptor instead. +func (*FinalizeInvoiceResponse) Descriptor() ([]byte, []int) { + return file_usage_v1_billing_proto_rawDescGZIP(), []int{5} +} + var File_usage_v1_billing_proto protoreflect.FileDescriptor var file_usage_v1_billing_proto_rawDesc = []byte{ @@ -304,22 +389,33 @@ var file_usage_v1_billing_proto_rawDesc = []byte{ 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, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5b, 0x0a, 0x10, + 0x6e, 0x74, 0x22, 0x37, 0x0a, 0x16, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x49, 0x6e, + 0x76, 0x6f, 0x69, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 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, 0x22, 0x19, 0x0a, 0x17, 0x46, + 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x9e, 0x02, 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, 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, - 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, + 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, 0x12, 0x58, 0x0a, + 0x0f, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, + 0x12, 0x20, 0x2e, 0x75, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x46, 0x69, 0x6e, 0x61, + 0x6c, 0x69, 0x7a, 0x65, 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x75, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x46, 0x69, + 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 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 ( @@ -334,25 +430,29 @@ 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, 4) +var file_usage_v1_billing_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_usage_v1_billing_proto_goTypes = []interface{}{ (*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 + (*FinalizeInvoiceRequest)(nil), // 4: usage.v1.FinalizeInvoiceRequest + (*FinalizeInvoiceResponse)(nil), // 5: usage.v1.FinalizeInvoiceResponse + (*timestamppb.Timestamp)(nil), // 6: google.protobuf.Timestamp + (*BilledSession)(nil), // 7: usage.v1.BilledSession } var file_usage_v1_billing_proto_depIdxs = []int32{ - 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 + 6, // 0: usage.v1.UpdateInvoicesRequest.start_time:type_name -> google.protobuf.Timestamp + 6, // 1: usage.v1.UpdateInvoicesRequest.end_time:type_name -> google.protobuf.Timestamp + 7, // 2: usage.v1.UpdateInvoicesRequest.sessions:type_name -> usage.v1.BilledSession 0, // 3: usage.v1.BillingService.UpdateInvoices:input_type -> usage.v1.UpdateInvoicesRequest 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 + 4, // 5: usage.v1.BillingService.FinalizeInvoice:input_type -> usage.v1.FinalizeInvoiceRequest + 1, // 6: usage.v1.BillingService.UpdateInvoices:output_type -> usage.v1.UpdateInvoicesResponse + 3, // 7: usage.v1.BillingService.GetLatestInvoice:output_type -> usage.v1.GetLatestInvoiceResponse + 5, // 8: usage.v1.BillingService.FinalizeInvoice:output_type -> usage.v1.FinalizeInvoiceResponse + 6, // [6:9] is the sub-list for method output_type + 3, // [3:6] 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 @@ -413,6 +513,30 @@ func file_usage_v1_billing_proto_init() { return nil } } + file_usage_v1_billing_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FinalizeInvoiceRequest); 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[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FinalizeInvoiceResponse); 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), @@ -424,7 +548,7 @@ func file_usage_v1_billing_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_usage_v1_billing_proto_rawDesc, NumEnums: 0, - NumMessages: 4, + NumMessages: 6, 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 c559e507848356..9f2ee4f9c9654f 100644 --- a/components/usage-api/go/v1/billing_grpc.pb.go +++ b/components/usage-api/go/v1/billing_grpc.pb.go @@ -32,6 +32,9 @@ type BillingServiceClient interface { 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) + // FinalizeInvoice marks all sessions occurring in the given Stripe invoice as + // having been invoiced. + FinalizeInvoice(ctx context.Context, in *FinalizeInvoiceRequest, opts ...grpc.CallOption) (*FinalizeInvoiceResponse, error) } type billingServiceClient struct { @@ -60,6 +63,15 @@ func (c *billingServiceClient) GetLatestInvoice(ctx context.Context, in *GetLate return out, nil } +func (c *billingServiceClient) FinalizeInvoice(ctx context.Context, in *FinalizeInvoiceRequest, opts ...grpc.CallOption) (*FinalizeInvoiceResponse, error) { + out := new(FinalizeInvoiceResponse) + err := c.cc.Invoke(ctx, "/usage.v1.BillingService/FinalizeInvoice", 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 @@ -70,6 +82,9 @@ type BillingServiceServer interface { UpdateInvoices(context.Context, *UpdateInvoicesRequest) (*UpdateInvoicesResponse, error) // GetLatestInvoice retrieves the latest invoice for a given query. GetLatestInvoice(context.Context, *GetLatestInvoiceRequest) (*GetLatestInvoiceResponse, error) + // FinalizeInvoice marks all sessions occurring in the given Stripe invoice as + // having been invoiced. + FinalizeInvoice(context.Context, *FinalizeInvoiceRequest) (*FinalizeInvoiceResponse, error) mustEmbedUnimplementedBillingServiceServer() } @@ -83,6 +98,9 @@ func (UnimplementedBillingServiceServer) UpdateInvoices(context.Context, *Update func (UnimplementedBillingServiceServer) GetLatestInvoice(context.Context, *GetLatestInvoiceRequest) (*GetLatestInvoiceResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetLatestInvoice not implemented") } +func (UnimplementedBillingServiceServer) FinalizeInvoice(context.Context, *FinalizeInvoiceRequest) (*FinalizeInvoiceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method FinalizeInvoice not implemented") +} func (UnimplementedBillingServiceServer) mustEmbedUnimplementedBillingServiceServer() {} // UnsafeBillingServiceServer may be embedded to opt out of forward compatibility for this service. @@ -132,6 +150,24 @@ func _BillingService_GetLatestInvoice_Handler(srv interface{}, ctx context.Conte return interceptor(ctx, in, info, handler) } +func _BillingService_FinalizeInvoice_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(FinalizeInvoiceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(BillingServiceServer).FinalizeInvoice(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/usage.v1.BillingService/FinalizeInvoice", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(BillingServiceServer).FinalizeInvoice(ctx, req.(*FinalizeInvoiceRequest)) + } + 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) @@ -147,6 +183,10 @@ var BillingService_ServiceDesc = grpc.ServiceDesc{ MethodName: "GetLatestInvoice", Handler: _BillingService_GetLatestInvoice_Handler, }, + { + MethodName: "FinalizeInvoice", + Handler: _BillingService_FinalizeInvoice_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 a9927e16ca5ac2..86702bcc56d9da 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 @@ -18,6 +18,7 @@ import * as usage_v1_usage_pb from "../../usage/v1/usage_pb"; interface IBillingServiceService extends grpc.ServiceDefinition { updateInvoices: IBillingServiceService_IUpdateInvoices; getLatestInvoice: IBillingServiceService_IGetLatestInvoice; + finalizeInvoice: IBillingServiceService_IFinalizeInvoice; } interface IBillingServiceService_IUpdateInvoices extends grpc.MethodDefinition { @@ -38,12 +39,22 @@ interface IBillingServiceService_IGetLatestInvoice extends grpc.MethodDefinition responseSerialize: grpc.serialize; responseDeserialize: grpc.deserialize; } +interface IBillingServiceService_IFinalizeInvoice extends grpc.MethodDefinition { + path: "/usage.v1.BillingService/FinalizeInvoice"; + 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; + finalizeInvoice: grpc.handleUnaryCall; } export interface IBillingServiceClient { @@ -53,6 +64,9 @@ export interface IBillingServiceClient { 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; + finalizeInvoice(request: usage_v1_billing_pb.FinalizeInvoiceRequest, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.FinalizeInvoiceResponse) => void): grpc.ClientUnaryCall; + finalizeInvoice(request: usage_v1_billing_pb.FinalizeInvoiceRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.FinalizeInvoiceResponse) => void): grpc.ClientUnaryCall; + finalizeInvoice(request: usage_v1_billing_pb.FinalizeInvoiceRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.FinalizeInvoiceResponse) => void): grpc.ClientUnaryCall; } export class BillingServiceClient extends grpc.Client implements IBillingServiceClient { @@ -63,4 +77,7 @@ export class BillingServiceClient extends grpc.Client implements IBillingService 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; + public finalizeInvoice(request: usage_v1_billing_pb.FinalizeInvoiceRequest, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.FinalizeInvoiceResponse) => void): grpc.ClientUnaryCall; + public finalizeInvoice(request: usage_v1_billing_pb.FinalizeInvoiceRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.FinalizeInvoiceResponse) => void): grpc.ClientUnaryCall; + public finalizeInvoice(request: usage_v1_billing_pb.FinalizeInvoiceRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.FinalizeInvoiceResponse) => 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 9d39491038df56..6332565cb73829 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_FinalizeInvoiceRequest(arg) { + if (!(arg instanceof usage_v1_billing_pb.FinalizeInvoiceRequest)) { + throw new Error('Expected argument of type usage.v1.FinalizeInvoiceRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_usage_v1_FinalizeInvoiceRequest(buffer_arg) { + return usage_v1_billing_pb.FinalizeInvoiceRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_usage_v1_FinalizeInvoiceResponse(arg) { + if (!(arg instanceof usage_v1_billing_pb.FinalizeInvoiceResponse)) { + throw new Error('Expected argument of type usage.v1.FinalizeInvoiceResponse'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_usage_v1_FinalizeInvoiceResponse(buffer_arg) { + return usage_v1_billing_pb.FinalizeInvoiceResponse.deserializeBinary(new Uint8Array(buffer_arg)); +} + function serialize_usage_v1_GetLatestInvoiceRequest(arg) { if (!(arg instanceof usage_v1_billing_pb.GetLatestInvoiceRequest)) { throw new Error('Expected argument of type usage.v1.GetLatestInvoiceRequest'); @@ -84,6 +106,19 @@ getLatestInvoice: { responseSerialize: serialize_usage_v1_GetLatestInvoiceResponse, responseDeserialize: deserialize_usage_v1_GetLatestInvoiceResponse, }, + // FinalizeInvoice marks all sessions occurring in the given Stripe invoice as +// having been invoiced. +finalizeInvoice: { + path: '/usage.v1.BillingService/FinalizeInvoice', + requestStream: false, + responseStream: false, + requestType: usage_v1_billing_pb.FinalizeInvoiceRequest, + responseType: usage_v1_billing_pb.FinalizeInvoiceResponse, + requestSerialize: serialize_usage_v1_FinalizeInvoiceRequest, + requestDeserialize: deserialize_usage_v1_FinalizeInvoiceRequest, + responseSerialize: serialize_usage_v1_FinalizeInvoiceResponse, + responseDeserialize: deserialize_usage_v1_FinalizeInvoiceResponse, + }, }; 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 a8cb313e9df7c5..56b3cd3ebd775c 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 @@ -128,3 +128,40 @@ export namespace GetLatestInvoiceResponse { amount: number, } } + +export class FinalizeInvoiceRequest extends jspb.Message { + getInvoiceId(): string; + setInvoiceId(value: string): FinalizeInvoiceRequest; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): FinalizeInvoiceRequest.AsObject; + static toObject(includeInstance: boolean, msg: FinalizeInvoiceRequest): FinalizeInvoiceRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: FinalizeInvoiceRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): FinalizeInvoiceRequest; + static deserializeBinaryFromReader(message: FinalizeInvoiceRequest, reader: jspb.BinaryReader): FinalizeInvoiceRequest; +} + +export namespace FinalizeInvoiceRequest { + export type AsObject = { + invoiceId: string, + } +} + +export class FinalizeInvoiceResponse extends jspb.Message { + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): FinalizeInvoiceResponse.AsObject; + static toObject(includeInstance: boolean, msg: FinalizeInvoiceResponse): FinalizeInvoiceResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: FinalizeInvoiceResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): FinalizeInvoiceResponse; + static deserializeBinaryFromReader(message: FinalizeInvoiceResponse, reader: jspb.BinaryReader): FinalizeInvoiceResponse; +} + +export namespace FinalizeInvoiceResponse { + export type AsObject = { + } +} 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 708f01aca05e50..2eca2c0e7ced55 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,8 @@ 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.FinalizeInvoiceRequest', null, global); +goog.exportSymbol('proto.usage.v1.FinalizeInvoiceResponse', null, global); 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); @@ -114,6 +116,48 @@ if (goog.DEBUG && !COMPILED) { */ proto.usage.v1.GetLatestInvoiceResponse.displayName = 'proto.usage.v1.GetLatestInvoiceResponse'; } +/** + * 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.FinalizeInvoiceRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.usage.v1.FinalizeInvoiceRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.usage.v1.FinalizeInvoiceRequest.displayName = 'proto.usage.v1.FinalizeInvoiceRequest'; +} +/** + * 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.FinalizeInvoiceResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.usage.v1.FinalizeInvoiceResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.usage.v1.FinalizeInvoiceResponse.displayName = 'proto.usage.v1.FinalizeInvoiceResponse'; +} /** * List of repeated fields within this message type. @@ -889,4 +933,235 @@ proto.usage.v1.GetLatestInvoiceResponse.prototype.setAmount = function(value) { }; + + + +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.FinalizeInvoiceRequest.prototype.toObject = function(opt_includeInstance) { + return proto.usage.v1.FinalizeInvoiceRequest.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.FinalizeInvoiceRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.usage.v1.FinalizeInvoiceRequest.toObject = function(includeInstance, msg) { + var f, obj = { + invoiceId: jspb.Message.getFieldWithDefault(msg, 1, "") + }; + + 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.FinalizeInvoiceRequest} + */ +proto.usage.v1.FinalizeInvoiceRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.usage.v1.FinalizeInvoiceRequest; + return proto.usage.v1.FinalizeInvoiceRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.usage.v1.FinalizeInvoiceRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.usage.v1.FinalizeInvoiceRequest} + */ +proto.usage.v1.FinalizeInvoiceRequest.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; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.usage.v1.FinalizeInvoiceRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.usage.v1.FinalizeInvoiceRequest.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.FinalizeInvoiceRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.usage.v1.FinalizeInvoiceRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getInvoiceId(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } +}; + + +/** + * optional string invoice_id = 1; + * @return {string} + */ +proto.usage.v1.FinalizeInvoiceRequest.prototype.getInvoiceId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.usage.v1.FinalizeInvoiceRequest} returns this + */ +proto.usage.v1.FinalizeInvoiceRequest.prototype.setInvoiceId = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + + + + +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.FinalizeInvoiceResponse.prototype.toObject = function(opt_includeInstance) { + return proto.usage.v1.FinalizeInvoiceResponse.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.FinalizeInvoiceResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.usage.v1.FinalizeInvoiceResponse.toObject = function(includeInstance, msg) { + var f, obj = { + + }; + + 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.FinalizeInvoiceResponse} + */ +proto.usage.v1.FinalizeInvoiceResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.usage.v1.FinalizeInvoiceResponse; + return proto.usage.v1.FinalizeInvoiceResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.usage.v1.FinalizeInvoiceResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.usage.v1.FinalizeInvoiceResponse} + */ +proto.usage.v1.FinalizeInvoiceResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.usage.v1.FinalizeInvoiceResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.usage.v1.FinalizeInvoiceResponse.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.FinalizeInvoiceResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.usage.v1.FinalizeInvoiceResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; +}; + + 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 25a481f503b787..befcc136f4452f 100644 --- a/components/usage-api/usage/v1/billing.proto +++ b/components/usage-api/usage/v1/billing.proto @@ -15,6 +15,10 @@ service BillingService { // GetLatestInvoice retrieves the latest invoice for a given query. rpc GetLatestInvoice(GetLatestInvoiceRequest) returns (GetLatestInvoiceResponse) {}; + + // FinalizeInvoice marks all sessions occurring in the given Stripe invoice as + // having been invoiced. + rpc FinalizeInvoice(FinalizeInvoiceRequest) returns (FinalizeInvoiceResponse) {}; } message UpdateInvoicesRequest { @@ -39,3 +43,10 @@ message GetLatestInvoiceResponse { string currency = 2; double amount = 3; } + +message FinalizeInvoiceRequest { + string invoice_id = 1; +} + +message FinalizeInvoiceResponse { +}