From 8d604b73a20e66f05d2df1cf791a61289eadd4c6 Mon Sep 17 00:00:00 2001 From: Milan Pavlik Date: Tue, 26 Jul 2022 11:03:32 +0000 Subject: [PATCH] [usage] Add BillingService with UpdateInvoices RPC --- components/usage-api/go/v1/billing.pb.go | 246 ++++++++++ components/usage-api/go/v1/billing_grpc.pb.go | 115 +++++ .../src/usage/v1/billing_grpc_pb.d.ts | 49 ++ .../src/usage/v1/billing_grpc_pb.js | 55 +++ .../typescript/src/usage/v1/billing_pb.d.ts | 66 +++ .../typescript/src/usage/v1/billing_pb.js | 435 ++++++++++++++++++ components/usage-api/usage/v1/billing.proto | 25 + 7 files changed, 991 insertions(+) create mode 100644 components/usage-api/go/v1/billing.pb.go create mode 100644 components/usage-api/go/v1/billing_grpc.pb.go create mode 100644 components/usage-api/typescript/src/usage/v1/billing_grpc_pb.d.ts create mode 100644 components/usage-api/typescript/src/usage/v1/billing_grpc_pb.js create mode 100644 components/usage-api/typescript/src/usage/v1/billing_pb.d.ts create mode 100644 components/usage-api/typescript/src/usage/v1/billing_pb.js create mode 100644 components/usage-api/usage/v1/billing.proto diff --git a/components/usage-api/go/v1/billing.pb.go b/components/usage-api/go/v1/billing.pb.go new file mode 100644 index 00000000000000..0293031c9fceda --- /dev/null +++ b/components/usage-api/go/v1/billing.pb.go @@ -0,0 +1,246 @@ +// Copyright (c) 2022 Gitpod GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.0 +// protoc v3.20.1 +// source: usage/v1/billing.proto + +package v1 + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type UpdateInvoicesRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + StartTime *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=start_time,json=startTime,proto3" json:"start_time,omitempty"` + EndTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=end_time,json=endTime,proto3" json:"end_time,omitempty"` + Sessions []*BilledSession `protobuf:"bytes,3,rep,name=sessions,proto3" json:"sessions,omitempty"` +} + +func (x *UpdateInvoicesRequest) Reset() { + *x = UpdateInvoicesRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_usage_v1_billing_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateInvoicesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateInvoicesRequest) ProtoMessage() {} + +func (x *UpdateInvoicesRequest) ProtoReflect() protoreflect.Message { + mi := &file_usage_v1_billing_proto_msgTypes[0] + 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 UpdateInvoicesRequest.ProtoReflect.Descriptor instead. +func (*UpdateInvoicesRequest) Descriptor() ([]byte, []int) { + return file_usage_v1_billing_proto_rawDescGZIP(), []int{0} +} + +func (x *UpdateInvoicesRequest) GetStartTime() *timestamppb.Timestamp { + if x != nil { + return x.StartTime + } + return nil +} + +func (x *UpdateInvoicesRequest) GetEndTime() *timestamppb.Timestamp { + if x != nil { + return x.EndTime + } + return nil +} + +func (x *UpdateInvoicesRequest) GetSessions() []*BilledSession { + if x != nil { + return x.Sessions + } + return nil +} + +type UpdateInvoicesResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *UpdateInvoicesResponse) Reset() { + *x = UpdateInvoicesResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_usage_v1_billing_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateInvoicesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateInvoicesResponse) ProtoMessage() {} + +func (x *UpdateInvoicesResponse) ProtoReflect() protoreflect.Message { + mi := &file_usage_v1_billing_proto_msgTypes[1] + 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 UpdateInvoicesResponse.ProtoReflect.Descriptor instead. +func (*UpdateInvoicesResponse) Descriptor() ([]byte, []int) { + return file_usage_v1_billing_proto_rawDescGZIP(), []int{1} +} + +var File_usage_v1_billing_proto protoreflect.FileDescriptor + +var file_usage_v1_billing_proto_rawDesc = []byte{ + 0x0a, 0x16, 0x75, 0x73, 0x61, 0x67, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x62, 0x69, 0x6c, 0x6c, 0x69, + 0x6e, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x75, 0x73, 0x61, 0x67, 0x65, 0x2e, + 0x76, 0x31, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x1a, 0x14, 0x75, 0x73, 0x61, 0x67, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x75, 0x73, + 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xbe, 0x01, 0x0a, 0x15, 0x55, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x39, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x69, 0x6d, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x52, 0x09, 0x73, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x35, + 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x07, 0x65, 0x6e, + 0x64, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x33, 0x0a, 0x08, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, + 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x75, 0x73, 0x61, 0x67, 0x65, 0x2e, + 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, + 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, +} + +var ( + file_usage_v1_billing_proto_rawDescOnce sync.Once + file_usage_v1_billing_proto_rawDescData = file_usage_v1_billing_proto_rawDesc +) + +func file_usage_v1_billing_proto_rawDescGZIP() []byte { + file_usage_v1_billing_proto_rawDescOnce.Do(func() { + file_usage_v1_billing_proto_rawDescData = protoimpl.X.CompressGZIP(file_usage_v1_billing_proto_rawDescData) + }) + return file_usage_v1_billing_proto_rawDescData +} + +var file_usage_v1_billing_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +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 +} +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 + 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 + 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 +} + +func init() { file_usage_v1_billing_proto_init() } +func file_usage_v1_billing_proto_init() { + if File_usage_v1_billing_proto != nil { + return + } + file_usage_v1_usage_proto_init() + if !protoimpl.UnsafeEnabled { + file_usage_v1_billing_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateInvoicesRequest); 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[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateInvoicesResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_usage_v1_billing_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_usage_v1_billing_proto_goTypes, + DependencyIndexes: file_usage_v1_billing_proto_depIdxs, + MessageInfos: file_usage_v1_billing_proto_msgTypes, + }.Build() + File_usage_v1_billing_proto = out.File + file_usage_v1_billing_proto_rawDesc = nil + file_usage_v1_billing_proto_goTypes = nil + file_usage_v1_billing_proto_depIdxs = nil +} diff --git a/components/usage-api/go/v1/billing_grpc.pb.go b/components/usage-api/go/v1/billing_grpc.pb.go new file mode 100644 index 00000000000000..da74382ff62629 --- /dev/null +++ b/components/usage-api/go/v1/billing_grpc.pb.go @@ -0,0 +1,115 @@ +// Copyright (c) 2022 Gitpod GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. + +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc v3.20.1 +// source: usage/v1/billing.proto + +package v1 + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// BillingServiceClient is the client API for BillingService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type BillingServiceClient interface { + // UpdateInvoices takes provides BilledSessions and reflects their usage + // 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) +} + +type billingServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewBillingServiceClient(cc grpc.ClientConnInterface) BillingServiceClient { + return &billingServiceClient{cc} +} + +func (c *billingServiceClient) UpdateInvoices(ctx context.Context, in *UpdateInvoicesRequest, opts ...grpc.CallOption) (*UpdateInvoicesResponse, error) { + out := new(UpdateInvoicesResponse) + err := c.cc.Invoke(ctx, "/usage.v1.BillingService/UpdateInvoices", 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 +type BillingServiceServer interface { + // UpdateInvoices takes provides BilledSessions and reflects their usage + // 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) + mustEmbedUnimplementedBillingServiceServer() +} + +// UnimplementedBillingServiceServer must be embedded to have forward compatible implementations. +type UnimplementedBillingServiceServer struct { +} + +func (UnimplementedBillingServiceServer) UpdateInvoices(context.Context, *UpdateInvoicesRequest) (*UpdateInvoicesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateInvoices not implemented") +} +func (UnimplementedBillingServiceServer) mustEmbedUnimplementedBillingServiceServer() {} + +// UnsafeBillingServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to BillingServiceServer will +// result in compilation errors. +type UnsafeBillingServiceServer interface { + mustEmbedUnimplementedBillingServiceServer() +} + +func RegisterBillingServiceServer(s grpc.ServiceRegistrar, srv BillingServiceServer) { + s.RegisterService(&BillingService_ServiceDesc, srv) +} + +func _BillingService_UpdateInvoices_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateInvoicesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(BillingServiceServer).UpdateInvoices(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/usage.v1.BillingService/UpdateInvoices", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(BillingServiceServer).UpdateInvoices(ctx, req.(*UpdateInvoicesRequest)) + } + 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) +var BillingService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "usage.v1.BillingService", + HandlerType: (*BillingServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "UpdateInvoices", + Handler: _BillingService_UpdateInvoices_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 new file mode 100644 index 00000000000000..933119960ba27f --- /dev/null +++ b/components/usage-api/typescript/src/usage/v1/billing_grpc_pb.d.ts @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2022 Gitpod GmbH. All rights reserved. + * Licensed under the GNU Affero General Public License (AGPL). + * See License-AGPL.txt in the project root for license information. + */ + +// package: usage.v1 +// file: usage/v1/billing.proto + +/* tslint:disable */ +/* eslint-disable */ + +import * as grpc from "@grpc/grpc-js"; +import * as usage_v1_billing_pb from "../../usage/v1/billing_pb"; +import * as google_protobuf_timestamp_pb from "google-protobuf/google/protobuf/timestamp_pb"; +import * as usage_v1_usage_pb from "../../usage/v1/usage_pb"; + +interface IBillingServiceService extends grpc.ServiceDefinition { + updateInvoices: IBillingServiceService_IUpdateInvoices; +} + +interface IBillingServiceService_IUpdateInvoices extends grpc.MethodDefinition { + path: "/usage.v1.BillingService/UpdateInvoices"; + 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; +} + +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; +} + +export class BillingServiceClient extends grpc.Client implements IBillingServiceClient { + constructor(address: string, credentials: grpc.ChannelCredentials, options?: Partial); + 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; +} 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 new file mode 100644 index 00000000000000..f8ad4c0d59c3d9 --- /dev/null +++ b/components/usage-api/typescript/src/usage/v1/billing_grpc_pb.js @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2022 Gitpod GmbH. All rights reserved. + * Licensed under the GNU Affero General Public License (AGPL). + * See License-AGPL.txt in the project root for license information. + */ + +// GENERATED CODE -- DO NOT EDIT! + +'use strict'; +var grpc = require('@grpc/grpc-js'); +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_UpdateInvoicesRequest(arg) { + if (!(arg instanceof usage_v1_billing_pb.UpdateInvoicesRequest)) { + throw new Error('Expected argument of type usage.v1.UpdateInvoicesRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_usage_v1_UpdateInvoicesRequest(buffer_arg) { + return usage_v1_billing_pb.UpdateInvoicesRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_usage_v1_UpdateInvoicesResponse(arg) { + if (!(arg instanceof usage_v1_billing_pb.UpdateInvoicesResponse)) { + throw new Error('Expected argument of type usage.v1.UpdateInvoicesResponse'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_usage_v1_UpdateInvoicesResponse(buffer_arg) { + return usage_v1_billing_pb.UpdateInvoicesResponse.deserializeBinary(new Uint8Array(buffer_arg)); +} + + +var BillingServiceService = exports.BillingServiceService = { + // UpdateInvoices takes provides BilledSessions and reflects their usage +// in a billing system. +// This is an Internal RPC used by the usage reconciler and not intended for general consumption. +updateInvoices: { + path: '/usage.v1.BillingService/UpdateInvoices', + requestStream: false, + responseStream: false, + requestType: usage_v1_billing_pb.UpdateInvoicesRequest, + responseType: usage_v1_billing_pb.UpdateInvoicesResponse, + requestSerialize: serialize_usage_v1_UpdateInvoicesRequest, + requestDeserialize: deserialize_usage_v1_UpdateInvoicesRequest, + responseSerialize: serialize_usage_v1_UpdateInvoicesResponse, + responseDeserialize: deserialize_usage_v1_UpdateInvoicesResponse, + }, +}; + +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 new file mode 100644 index 00000000000000..fae61cbe2604e0 --- /dev/null +++ b/components/usage-api/typescript/src/usage/v1/billing_pb.d.ts @@ -0,0 +1,66 @@ +/** + * Copyright (c) 2022 Gitpod GmbH. All rights reserved. + * Licensed under the GNU Affero General Public License (AGPL). + * See License-AGPL.txt in the project root for license information. + */ + +// package: usage.v1 +// file: usage/v1/billing.proto + +/* tslint:disable */ +/* eslint-disable */ + +import * as jspb from "google-protobuf"; +import * as google_protobuf_timestamp_pb from "google-protobuf/google/protobuf/timestamp_pb"; +import * as usage_v1_usage_pb from "../../usage/v1/usage_pb"; + +export class UpdateInvoicesRequest extends jspb.Message { + + hasStartTime(): boolean; + clearStartTime(): void; + getStartTime(): google_protobuf_timestamp_pb.Timestamp | undefined; + setStartTime(value?: google_protobuf_timestamp_pb.Timestamp): UpdateInvoicesRequest; + + hasEndTime(): boolean; + clearEndTime(): void; + getEndTime(): google_protobuf_timestamp_pb.Timestamp | undefined; + setEndTime(value?: google_protobuf_timestamp_pb.Timestamp): UpdateInvoicesRequest; + clearSessionsList(): void; + getSessionsList(): Array; + setSessionsList(value: Array): UpdateInvoicesRequest; + addSessions(value?: usage_v1_usage_pb.BilledSession, index?: number): usage_v1_usage_pb.BilledSession; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): UpdateInvoicesRequest.AsObject; + static toObject(includeInstance: boolean, msg: UpdateInvoicesRequest): UpdateInvoicesRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: UpdateInvoicesRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): UpdateInvoicesRequest; + static deserializeBinaryFromReader(message: UpdateInvoicesRequest, reader: jspb.BinaryReader): UpdateInvoicesRequest; +} + +export namespace UpdateInvoicesRequest { + export type AsObject = { + startTime?: google_protobuf_timestamp_pb.Timestamp.AsObject, + endTime?: google_protobuf_timestamp_pb.Timestamp.AsObject, + sessionsList: Array, + } +} + +export class UpdateInvoicesResponse extends jspb.Message { + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): UpdateInvoicesResponse.AsObject; + static toObject(includeInstance: boolean, msg: UpdateInvoicesResponse): UpdateInvoicesResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: UpdateInvoicesResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): UpdateInvoicesResponse; + static deserializeBinaryFromReader(message: UpdateInvoicesResponse, reader: jspb.BinaryReader): UpdateInvoicesResponse; +} + +export namespace UpdateInvoicesResponse { + 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 new file mode 100644 index 00000000000000..c4ba9ef41a66b5 --- /dev/null +++ b/components/usage-api/typescript/src/usage/v1/billing_pb.js @@ -0,0 +1,435 @@ +/** + * Copyright (c) 2022 Gitpod GmbH. All rights reserved. + * Licensed under the GNU Affero General Public License (AGPL). + * See License-AGPL.txt in the project root for license information. + */ + +// source: usage/v1/billing.proto +/** + * @fileoverview + * @enhanceable + * @suppress {missingRequire} reports error on implicit type usages. + * @suppress {messageConventions} JS Compiler reports an error if a variable or + * field starts with 'MSG_' and isn't a translatable message. + * @public + */ +// GENERATED CODE -- DO NOT EDIT! +/* eslint-disable */ +// @ts-nocheck + +var jspb = require('google-protobuf'); +var goog = jspb; +var global = (function() { return this || window || global || self || Function('return this')(); }).call(null); + +var google_protobuf_timestamp_pb = require('google-protobuf/google/protobuf/timestamp_pb.js'); +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.UpdateInvoicesRequest', null, global); +goog.exportSymbol('proto.usage.v1.UpdateInvoicesResponse', null, global); +/** + * 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.UpdateInvoicesRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.usage.v1.UpdateInvoicesRequest.repeatedFields_, null); +}; +goog.inherits(proto.usage.v1.UpdateInvoicesRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.usage.v1.UpdateInvoicesRequest.displayName = 'proto.usage.v1.UpdateInvoicesRequest'; +} +/** + * 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.UpdateInvoicesResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.usage.v1.UpdateInvoicesResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.usage.v1.UpdateInvoicesResponse.displayName = 'proto.usage.v1.UpdateInvoicesResponse'; +} + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.usage.v1.UpdateInvoicesRequest.repeatedFields_ = [3]; + + + +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.UpdateInvoicesRequest.prototype.toObject = function(opt_includeInstance) { + return proto.usage.v1.UpdateInvoicesRequest.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.UpdateInvoicesRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.usage.v1.UpdateInvoicesRequest.toObject = function(includeInstance, msg) { + var f, obj = { + startTime: (f = msg.getStartTime()) && google_protobuf_timestamp_pb.Timestamp.toObject(includeInstance, f), + endTime: (f = msg.getEndTime()) && google_protobuf_timestamp_pb.Timestamp.toObject(includeInstance, f), + sessionsList: jspb.Message.toObjectList(msg.getSessionsList(), + usage_v1_usage_pb.BilledSession.toObject, includeInstance) + }; + + 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.UpdateInvoicesRequest} + */ +proto.usage.v1.UpdateInvoicesRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.usage.v1.UpdateInvoicesRequest; + return proto.usage.v1.UpdateInvoicesRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.usage.v1.UpdateInvoicesRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.usage.v1.UpdateInvoicesRequest} + */ +proto.usage.v1.UpdateInvoicesRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new google_protobuf_timestamp_pb.Timestamp; + reader.readMessage(value,google_protobuf_timestamp_pb.Timestamp.deserializeBinaryFromReader); + msg.setStartTime(value); + break; + case 2: + var value = new google_protobuf_timestamp_pb.Timestamp; + reader.readMessage(value,google_protobuf_timestamp_pb.Timestamp.deserializeBinaryFromReader); + msg.setEndTime(value); + break; + case 3: + var value = new usage_v1_usage_pb.BilledSession; + reader.readMessage(value,usage_v1_usage_pb.BilledSession.deserializeBinaryFromReader); + msg.addSessions(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.usage.v1.UpdateInvoicesRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.usage.v1.UpdateInvoicesRequest.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.UpdateInvoicesRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.usage.v1.UpdateInvoicesRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getStartTime(); + if (f != null) { + writer.writeMessage( + 1, + f, + google_protobuf_timestamp_pb.Timestamp.serializeBinaryToWriter + ); + } + f = message.getEndTime(); + if (f != null) { + writer.writeMessage( + 2, + f, + google_protobuf_timestamp_pb.Timestamp.serializeBinaryToWriter + ); + } + f = message.getSessionsList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 3, + f, + usage_v1_usage_pb.BilledSession.serializeBinaryToWriter + ); + } +}; + + +/** + * optional google.protobuf.Timestamp start_time = 1; + * @return {?proto.google.protobuf.Timestamp} + */ +proto.usage.v1.UpdateInvoicesRequest.prototype.getStartTime = function() { + return /** @type{?proto.google.protobuf.Timestamp} */ ( + jspb.Message.getWrapperField(this, google_protobuf_timestamp_pb.Timestamp, 1)); +}; + + +/** + * @param {?proto.google.protobuf.Timestamp|undefined} value + * @return {!proto.usage.v1.UpdateInvoicesRequest} returns this +*/ +proto.usage.v1.UpdateInvoicesRequest.prototype.setStartTime = function(value) { + return jspb.Message.setWrapperField(this, 1, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.usage.v1.UpdateInvoicesRequest} returns this + */ +proto.usage.v1.UpdateInvoicesRequest.prototype.clearStartTime = function() { + return this.setStartTime(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.usage.v1.UpdateInvoicesRequest.prototype.hasStartTime = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional google.protobuf.Timestamp end_time = 2; + * @return {?proto.google.protobuf.Timestamp} + */ +proto.usage.v1.UpdateInvoicesRequest.prototype.getEndTime = function() { + return /** @type{?proto.google.protobuf.Timestamp} */ ( + jspb.Message.getWrapperField(this, google_protobuf_timestamp_pb.Timestamp, 2)); +}; + + +/** + * @param {?proto.google.protobuf.Timestamp|undefined} value + * @return {!proto.usage.v1.UpdateInvoicesRequest} returns this +*/ +proto.usage.v1.UpdateInvoicesRequest.prototype.setEndTime = function(value) { + return jspb.Message.setWrapperField(this, 2, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.usage.v1.UpdateInvoicesRequest} returns this + */ +proto.usage.v1.UpdateInvoicesRequest.prototype.clearEndTime = function() { + return this.setEndTime(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.usage.v1.UpdateInvoicesRequest.prototype.hasEndTime = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * repeated BilledSession sessions = 3; + * @return {!Array} + */ +proto.usage.v1.UpdateInvoicesRequest.prototype.getSessionsList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, usage_v1_usage_pb.BilledSession, 3)); +}; + + +/** + * @param {!Array} value + * @return {!proto.usage.v1.UpdateInvoicesRequest} returns this +*/ +proto.usage.v1.UpdateInvoicesRequest.prototype.setSessionsList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 3, value); +}; + + +/** + * @param {!proto.usage.v1.BilledSession=} opt_value + * @param {number=} opt_index + * @return {!proto.usage.v1.BilledSession} + */ +proto.usage.v1.UpdateInvoicesRequest.prototype.addSessions = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 3, opt_value, proto.usage.v1.BilledSession, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.usage.v1.UpdateInvoicesRequest} returns this + */ +proto.usage.v1.UpdateInvoicesRequest.prototype.clearSessionsList = function() { + return this.setSessionsList([]); +}; + + + + + +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.UpdateInvoicesResponse.prototype.toObject = function(opt_includeInstance) { + return proto.usage.v1.UpdateInvoicesResponse.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.UpdateInvoicesResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.usage.v1.UpdateInvoicesResponse.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.UpdateInvoicesResponse} + */ +proto.usage.v1.UpdateInvoicesResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.usage.v1.UpdateInvoicesResponse; + return proto.usage.v1.UpdateInvoicesResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.usage.v1.UpdateInvoicesResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.usage.v1.UpdateInvoicesResponse} + */ +proto.usage.v1.UpdateInvoicesResponse.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.UpdateInvoicesResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.usage.v1.UpdateInvoicesResponse.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.UpdateInvoicesResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.usage.v1.UpdateInvoicesResponse.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 new file mode 100644 index 00000000000000..d69707e30a209d --- /dev/null +++ b/components/usage-api/usage/v1/billing.proto @@ -0,0 +1,25 @@ +syntax = "proto3"; + +package usage.v1; + +option go_package = "github.com/gitpod-io/gitpod/usage-api/v1"; + +import "google/protobuf/timestamp.proto"; +import "usage/v1/usage.proto"; + +service BillingService { + // UpdateInvoices takes provides BilledSessions and reflects their usage + // 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) {}; +} + +message UpdateInvoicesRequest { + google.protobuf.Timestamp start_time = 1; + google.protobuf.Timestamp end_time = 2; + + repeated BilledSession sessions = 3; +} + +message UpdateInvoicesResponse { +}