diff --git a/components/usage-api/go/v1/usage.pb.go b/components/usage-api/go/v1/usage.pb.go index 0548b3c3837476..42132de8d1ccd7 100644 --- a/components/usage-api/go/v1/usage.pb.go +++ b/components/usage-api/go/v1/usage.pb.go @@ -330,6 +330,108 @@ func (x *BilledSession) GetCredits() float64 { return 0 } +type ReconcileUsageRequest 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"` +} + +func (x *ReconcileUsageRequest) Reset() { + *x = ReconcileUsageRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_usage_v1_usage_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ReconcileUsageRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReconcileUsageRequest) ProtoMessage() {} + +func (x *ReconcileUsageRequest) ProtoReflect() protoreflect.Message { + mi := &file_usage_v1_usage_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 ReconcileUsageRequest.ProtoReflect.Descriptor instead. +func (*ReconcileUsageRequest) Descriptor() ([]byte, []int) { + return file_usage_v1_usage_proto_rawDescGZIP(), []int{3} +} + +func (x *ReconcileUsageRequest) GetStartTime() *timestamppb.Timestamp { + if x != nil { + return x.StartTime + } + return nil +} + +func (x *ReconcileUsageRequest) GetEndTime() *timestamppb.Timestamp { + if x != nil { + return x.EndTime + } + return nil +} + +type ReconcileUsageResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Sessions []*BilledSession `protobuf:"bytes,1,rep,name=sessions,proto3" json:"sessions,omitempty"` +} + +func (x *ReconcileUsageResponse) Reset() { + *x = ReconcileUsageResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_usage_v1_usage_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ReconcileUsageResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReconcileUsageResponse) ProtoMessage() {} + +func (x *ReconcileUsageResponse) ProtoReflect() protoreflect.Message { + mi := &file_usage_v1_usage_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 ReconcileUsageResponse.ProtoReflect.Descriptor instead. +func (*ReconcileUsageResponse) Descriptor() ([]byte, []int) { + return file_usage_v1_usage_proto_rawDescGZIP(), []int{4} +} + +func (x *ReconcileUsageResponse) GetSessions() []*BilledSession { + if x != nil { + return x.Sessions + } + return nil +} + var File_usage_v1_usage_proto protoreflect.FileDescriptor var file_usage_v1_usage_proto_rawDesc = []byte{ @@ -389,17 +491,36 @@ var file_usage_v1_usage_proto_rawDesc = []byte{ 0x74, 0x65, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x03, 0x42, 0x02, 0x18, 0x01, 0x52, 0x11, 0x63, 0x72, 0x65, 0x64, 0x69, 0x74, 0x73, 0x44, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x72, 0x65, 0x64, 0x69, 0x74, 0x73, 0x18, 0x0c, 0x20, 0x01, 0x28, - 0x01, 0x52, 0x07, 0x63, 0x72, 0x65, 0x64, 0x69, 0x74, 0x73, 0x32, 0x68, 0x0a, 0x0c, 0x55, 0x73, - 0x61, 0x67, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x58, 0x0a, 0x0f, 0x4c, 0x69, - 0x73, 0x74, 0x42, 0x69, 0x6c, 0x6c, 0x65, 0x64, 0x55, 0x73, 0x61, 0x67, 0x65, 0x12, 0x20, 0x2e, - 0x75, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x69, 0x6c, - 0x6c, 0x65, 0x64, 0x55, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x21, 0x2e, 0x75, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x42, - 0x69, 0x6c, 0x6c, 0x65, 0x64, 0x55, 0x73, 0x61, 0x67, 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, + 0x01, 0x52, 0x07, 0x63, 0x72, 0x65, 0x64, 0x69, 0x74, 0x73, 0x22, 0x89, 0x01, 0x0a, 0x15, 0x52, + 0x65, 0x63, 0x6f, 0x6e, 0x63, 0x69, 0x6c, 0x65, 0x55, 0x73, 0x61, 0x67, 0x65, 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, 0x22, 0x4d, 0x0a, 0x16, 0x52, 0x65, 0x63, 0x6f, 0x6e, 0x63, + 0x69, 0x6c, 0x65, 0x55, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x33, 0x0a, 0x08, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, 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, 0x32, 0xbf, 0x01, 0x0a, 0x0c, 0x55, 0x73, 0x61, 0x67, 0x65, 0x53, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x58, 0x0a, 0x0f, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x69, + 0x6c, 0x6c, 0x65, 0x64, 0x55, 0x73, 0x61, 0x67, 0x65, 0x12, 0x20, 0x2e, 0x75, 0x73, 0x61, 0x67, + 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x69, 0x6c, 0x6c, 0x65, 0x64, 0x55, + 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x75, 0x73, + 0x61, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x69, 0x6c, 0x6c, 0x65, + 0x64, 0x55, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x12, 0x55, 0x0a, 0x0e, 0x52, 0x65, 0x63, 0x6f, 0x6e, 0x63, 0x69, 0x6c, 0x65, 0x55, 0x73, 0x61, + 0x67, 0x65, 0x12, 0x1f, 0x2e, 0x75, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, + 0x63, 0x6f, 0x6e, 0x63, 0x69, 0x6c, 0x65, 0x55, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x75, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, + 0x65, 0x63, 0x6f, 0x6e, 0x63, 0x69, 0x6c, 0x65, 0x55, 0x73, 0x61, 0x67, 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 ( @@ -415,28 +536,35 @@ func file_usage_v1_usage_proto_rawDescGZIP() []byte { } var file_usage_v1_usage_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_usage_v1_usage_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_usage_v1_usage_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_usage_v1_usage_proto_goTypes = []interface{}{ (ListBilledUsageRequest_Ordering)(0), // 0: usage.v1.ListBilledUsageRequest.Ordering (*ListBilledUsageRequest)(nil), // 1: usage.v1.ListBilledUsageRequest (*ListBilledUsageResponse)(nil), // 2: usage.v1.ListBilledUsageResponse (*BilledSession)(nil), // 3: usage.v1.BilledSession - (*timestamppb.Timestamp)(nil), // 4: google.protobuf.Timestamp + (*ReconcileUsageRequest)(nil), // 4: usage.v1.ReconcileUsageRequest + (*ReconcileUsageResponse)(nil), // 5: usage.v1.ReconcileUsageResponse + (*timestamppb.Timestamp)(nil), // 6: google.protobuf.Timestamp } var file_usage_v1_usage_proto_depIdxs = []int32{ - 4, // 0: usage.v1.ListBilledUsageRequest.from:type_name -> google.protobuf.Timestamp - 4, // 1: usage.v1.ListBilledUsageRequest.to:type_name -> google.protobuf.Timestamp - 0, // 2: usage.v1.ListBilledUsageRequest.order:type_name -> usage.v1.ListBilledUsageRequest.Ordering - 3, // 3: usage.v1.ListBilledUsageResponse.sessions:type_name -> usage.v1.BilledSession - 4, // 4: usage.v1.BilledSession.start_time:type_name -> google.protobuf.Timestamp - 4, // 5: usage.v1.BilledSession.end_time:type_name -> google.protobuf.Timestamp - 1, // 6: usage.v1.UsageService.ListBilledUsage:input_type -> usage.v1.ListBilledUsageRequest - 2, // 7: usage.v1.UsageService.ListBilledUsage:output_type -> usage.v1.ListBilledUsageResponse - 7, // [7:8] is the sub-list for method output_type - 6, // [6:7] is the sub-list for method input_type - 6, // [6:6] is the sub-list for extension type_name - 6, // [6:6] is the sub-list for extension extendee - 0, // [0:6] is the sub-list for field type_name + 6, // 0: usage.v1.ListBilledUsageRequest.from:type_name -> google.protobuf.Timestamp + 6, // 1: usage.v1.ListBilledUsageRequest.to:type_name -> google.protobuf.Timestamp + 0, // 2: usage.v1.ListBilledUsageRequest.order:type_name -> usage.v1.ListBilledUsageRequest.Ordering + 3, // 3: usage.v1.ListBilledUsageResponse.sessions:type_name -> usage.v1.BilledSession + 6, // 4: usage.v1.BilledSession.start_time:type_name -> google.protobuf.Timestamp + 6, // 5: usage.v1.BilledSession.end_time:type_name -> google.protobuf.Timestamp + 6, // 6: usage.v1.ReconcileUsageRequest.start_time:type_name -> google.protobuf.Timestamp + 6, // 7: usage.v1.ReconcileUsageRequest.end_time:type_name -> google.protobuf.Timestamp + 3, // 8: usage.v1.ReconcileUsageResponse.sessions:type_name -> usage.v1.BilledSession + 1, // 9: usage.v1.UsageService.ListBilledUsage:input_type -> usage.v1.ListBilledUsageRequest + 4, // 10: usage.v1.UsageService.ReconcileUsage:input_type -> usage.v1.ReconcileUsageRequest + 2, // 11: usage.v1.UsageService.ListBilledUsage:output_type -> usage.v1.ListBilledUsageResponse + 5, // 12: usage.v1.UsageService.ReconcileUsage:output_type -> usage.v1.ReconcileUsageResponse + 11, // [11:13] is the sub-list for method output_type + 9, // [9:11] is the sub-list for method input_type + 9, // [9:9] is the sub-list for extension type_name + 9, // [9:9] is the sub-list for extension extendee + 0, // [0:9] is the sub-list for field type_name } func init() { file_usage_v1_usage_proto_init() } @@ -481,6 +609,30 @@ func file_usage_v1_usage_proto_init() { return nil } } + file_usage_v1_usage_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ReconcileUsageRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_usage_v1_usage_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ReconcileUsageResponse); 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{ @@ -488,7 +640,7 @@ func file_usage_v1_usage_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_usage_v1_usage_proto_rawDesc, NumEnums: 1, - NumMessages: 3, + NumMessages: 5, NumExtensions: 0, NumServices: 1, }, diff --git a/components/usage-api/go/v1/usage_grpc.pb.go b/components/usage-api/go/v1/usage_grpc.pb.go index 9c53069ac7d8ba..f780b9c31d18e6 100644 --- a/components/usage-api/go/v1/usage_grpc.pb.go +++ b/components/usage-api/go/v1/usage_grpc.pb.go @@ -28,6 +28,8 @@ const _ = grpc.SupportPackageIsVersion7 type UsageServiceClient interface { // ListBilledUsage retrieves all usage for the specified attributionId ListBilledUsage(ctx context.Context, in *ListBilledUsageRequest, opts ...grpc.CallOption) (*ListBilledUsageResponse, error) + // ReconcileUsage collects usage for the specified time period, and stores the usage records in the database, returning the records. + ReconcileUsage(ctx context.Context, in *ReconcileUsageRequest, opts ...grpc.CallOption) (*ReconcileUsageResponse, error) } type usageServiceClient struct { @@ -47,12 +49,23 @@ func (c *usageServiceClient) ListBilledUsage(ctx context.Context, in *ListBilled return out, nil } +func (c *usageServiceClient) ReconcileUsage(ctx context.Context, in *ReconcileUsageRequest, opts ...grpc.CallOption) (*ReconcileUsageResponse, error) { + out := new(ReconcileUsageResponse) + err := c.cc.Invoke(ctx, "/usage.v1.UsageService/ReconcileUsage", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // UsageServiceServer is the server API for UsageService service. // All implementations must embed UnimplementedUsageServiceServer // for forward compatibility type UsageServiceServer interface { // ListBilledUsage retrieves all usage for the specified attributionId ListBilledUsage(context.Context, *ListBilledUsageRequest) (*ListBilledUsageResponse, error) + // ReconcileUsage collects usage for the specified time period, and stores the usage records in the database, returning the records. + ReconcileUsage(context.Context, *ReconcileUsageRequest) (*ReconcileUsageResponse, error) mustEmbedUnimplementedUsageServiceServer() } @@ -63,6 +76,9 @@ type UnimplementedUsageServiceServer struct { func (UnimplementedUsageServiceServer) ListBilledUsage(context.Context, *ListBilledUsageRequest) (*ListBilledUsageResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ListBilledUsage not implemented") } +func (UnimplementedUsageServiceServer) ReconcileUsage(context.Context, *ReconcileUsageRequest) (*ReconcileUsageResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ReconcileUsage not implemented") +} func (UnimplementedUsageServiceServer) mustEmbedUnimplementedUsageServiceServer() {} // UnsafeUsageServiceServer may be embedded to opt out of forward compatibility for this service. @@ -94,6 +110,24 @@ func _UsageService_ListBilledUsage_Handler(srv interface{}, ctx context.Context, return interceptor(ctx, in, info, handler) } +func _UsageService_ReconcileUsage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ReconcileUsageRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UsageServiceServer).ReconcileUsage(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/usage.v1.UsageService/ReconcileUsage", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UsageServiceServer).ReconcileUsage(ctx, req.(*ReconcileUsageRequest)) + } + return interceptor(ctx, in, info, handler) +} + // UsageService_ServiceDesc is the grpc.ServiceDesc for UsageService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -105,6 +139,10 @@ var UsageService_ServiceDesc = grpc.ServiceDesc{ MethodName: "ListBilledUsage", Handler: _UsageService_ListBilledUsage_Handler, }, + { + MethodName: "ReconcileUsage", + Handler: _UsageService_ReconcileUsage_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "usage/v1/usage.proto", diff --git a/components/usage-api/typescript/src/usage/v1/usage_grpc_pb.d.ts b/components/usage-api/typescript/src/usage/v1/usage_grpc_pb.d.ts index 613d8320273d33..cdcd756a50bc52 100644 --- a/components/usage-api/typescript/src/usage/v1/usage_grpc_pb.d.ts +++ b/components/usage-api/typescript/src/usage/v1/usage_grpc_pb.d.ts @@ -16,6 +16,7 @@ import * as google_protobuf_timestamp_pb from "google-protobuf/google/protobuf/t interface IUsageServiceService extends grpc.ServiceDefinition { listBilledUsage: IUsageServiceService_IListBilledUsage; + reconcileUsage: IUsageServiceService_IReconcileUsage; } interface IUsageServiceService_IListBilledUsage extends grpc.MethodDefinition { @@ -27,17 +28,30 @@ interface IUsageServiceService_IListBilledUsage extends grpc.MethodDefinition; responseDeserialize: grpc.deserialize; } +interface IUsageServiceService_IReconcileUsage extends grpc.MethodDefinition { + path: "/usage.v1.UsageService/ReconcileUsage"; + requestStream: false; + responseStream: false; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} export const UsageServiceService: IUsageServiceService; export interface IUsageServiceServer extends grpc.UntypedServiceImplementation { listBilledUsage: grpc.handleUnaryCall; + reconcileUsage: grpc.handleUnaryCall; } export interface IUsageServiceClient { listBilledUsage(request: usage_v1_usage_pb.ListBilledUsageRequest, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.ListBilledUsageResponse) => void): grpc.ClientUnaryCall; listBilledUsage(request: usage_v1_usage_pb.ListBilledUsageRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.ListBilledUsageResponse) => void): grpc.ClientUnaryCall; listBilledUsage(request: usage_v1_usage_pb.ListBilledUsageRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.ListBilledUsageResponse) => void): grpc.ClientUnaryCall; + reconcileUsage(request: usage_v1_usage_pb.ReconcileUsageRequest, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.ReconcileUsageResponse) => void): grpc.ClientUnaryCall; + reconcileUsage(request: usage_v1_usage_pb.ReconcileUsageRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.ReconcileUsageResponse) => void): grpc.ClientUnaryCall; + reconcileUsage(request: usage_v1_usage_pb.ReconcileUsageRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.ReconcileUsageResponse) => void): grpc.ClientUnaryCall; } export class UsageServiceClient extends grpc.Client implements IUsageServiceClient { @@ -45,4 +59,7 @@ export class UsageServiceClient extends grpc.Client implements IUsageServiceClie public listBilledUsage(request: usage_v1_usage_pb.ListBilledUsageRequest, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.ListBilledUsageResponse) => void): grpc.ClientUnaryCall; public listBilledUsage(request: usage_v1_usage_pb.ListBilledUsageRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.ListBilledUsageResponse) => void): grpc.ClientUnaryCall; public listBilledUsage(request: usage_v1_usage_pb.ListBilledUsageRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.ListBilledUsageResponse) => void): grpc.ClientUnaryCall; + public reconcileUsage(request: usage_v1_usage_pb.ReconcileUsageRequest, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.ReconcileUsageResponse) => void): grpc.ClientUnaryCall; + public reconcileUsage(request: usage_v1_usage_pb.ReconcileUsageRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.ReconcileUsageResponse) => void): grpc.ClientUnaryCall; + public reconcileUsage(request: usage_v1_usage_pb.ReconcileUsageRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.ReconcileUsageResponse) => void): grpc.ClientUnaryCall; } diff --git a/components/usage-api/typescript/src/usage/v1/usage_grpc_pb.js b/components/usage-api/typescript/src/usage/v1/usage_grpc_pb.js index f72af7f5c45034..3161bc6aff85c3 100644 --- a/components/usage-api/typescript/src/usage/v1/usage_grpc_pb.js +++ b/components/usage-api/typescript/src/usage/v1/usage_grpc_pb.js @@ -33,6 +33,28 @@ function deserialize_usage_v1_ListBilledUsageResponse(buffer_arg) { return usage_v1_usage_pb.ListBilledUsageResponse.deserializeBinary(new Uint8Array(buffer_arg)); } +function serialize_usage_v1_ReconcileUsageRequest(arg) { + if (!(arg instanceof usage_v1_usage_pb.ReconcileUsageRequest)) { + throw new Error('Expected argument of type usage.v1.ReconcileUsageRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_usage_v1_ReconcileUsageRequest(buffer_arg) { + return usage_v1_usage_pb.ReconcileUsageRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_usage_v1_ReconcileUsageResponse(arg) { + if (!(arg instanceof usage_v1_usage_pb.ReconcileUsageResponse)) { + throw new Error('Expected argument of type usage.v1.ReconcileUsageResponse'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_usage_v1_ReconcileUsageResponse(buffer_arg) { + return usage_v1_usage_pb.ReconcileUsageResponse.deserializeBinary(new Uint8Array(buffer_arg)); +} + var UsageServiceService = exports.UsageServiceService = { // ListBilledUsage retrieves all usage for the specified attributionId @@ -47,6 +69,18 @@ listBilledUsage: { responseSerialize: serialize_usage_v1_ListBilledUsageResponse, responseDeserialize: deserialize_usage_v1_ListBilledUsageResponse, }, + // ReconcileUsage collects usage for the specified time period, and stores the usage records in the database, returning the records. +reconcileUsage: { + path: '/usage.v1.UsageService/ReconcileUsage', + requestStream: false, + responseStream: false, + requestType: usage_v1_usage_pb.ReconcileUsageRequest, + responseType: usage_v1_usage_pb.ReconcileUsageResponse, + requestSerialize: serialize_usage_v1_ReconcileUsageRequest, + requestDeserialize: deserialize_usage_v1_ReconcileUsageRequest, + responseSerialize: serialize_usage_v1_ReconcileUsageResponse, + responseDeserialize: deserialize_usage_v1_ReconcileUsageResponse, + }, }; exports.UsageServiceClient = grpc.makeGenericClientConstructor(UsageServiceService); diff --git a/components/usage-api/typescript/src/usage/v1/usage_pb.d.ts b/components/usage-api/typescript/src/usage/v1/usage_pb.d.ts index 0ac3dc0481daa0..1b37c71d476593 100644 --- a/components/usage-api/typescript/src/usage/v1/usage_pb.d.ts +++ b/components/usage-api/typescript/src/usage/v1/usage_pb.d.ts @@ -134,3 +134,54 @@ export namespace BilledSession { credits: number, } } + +export class ReconcileUsageRequest extends jspb.Message { + + hasStartTime(): boolean; + clearStartTime(): void; + getStartTime(): google_protobuf_timestamp_pb.Timestamp | undefined; + setStartTime(value?: google_protobuf_timestamp_pb.Timestamp): ReconcileUsageRequest; + + hasEndTime(): boolean; + clearEndTime(): void; + getEndTime(): google_protobuf_timestamp_pb.Timestamp | undefined; + setEndTime(value?: google_protobuf_timestamp_pb.Timestamp): ReconcileUsageRequest; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): ReconcileUsageRequest.AsObject; + static toObject(includeInstance: boolean, msg: ReconcileUsageRequest): ReconcileUsageRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: ReconcileUsageRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): ReconcileUsageRequest; + static deserializeBinaryFromReader(message: ReconcileUsageRequest, reader: jspb.BinaryReader): ReconcileUsageRequest; +} + +export namespace ReconcileUsageRequest { + export type AsObject = { + startTime?: google_protobuf_timestamp_pb.Timestamp.AsObject, + endTime?: google_protobuf_timestamp_pb.Timestamp.AsObject, + } +} + +export class ReconcileUsageResponse extends jspb.Message { + clearSessionsList(): void; + getSessionsList(): Array; + setSessionsList(value: Array): ReconcileUsageResponse; + addSessions(value?: BilledSession, index?: number): BilledSession; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): ReconcileUsageResponse.AsObject; + static toObject(includeInstance: boolean, msg: ReconcileUsageResponse): ReconcileUsageResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: ReconcileUsageResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): ReconcileUsageResponse; + static deserializeBinaryFromReader(message: ReconcileUsageResponse, reader: jspb.BinaryReader): ReconcileUsageResponse; +} + +export namespace ReconcileUsageResponse { + export type AsObject = { + sessionsList: Array, + } +} diff --git a/components/usage-api/typescript/src/usage/v1/usage_pb.js b/components/usage-api/typescript/src/usage/v1/usage_pb.js index 950754161617fb..e13dcef0716ca5 100644 --- a/components/usage-api/typescript/src/usage/v1/usage_pb.js +++ b/components/usage-api/typescript/src/usage/v1/usage_pb.js @@ -27,6 +27,8 @@ goog.exportSymbol('proto.usage.v1.BilledSession', null, global); goog.exportSymbol('proto.usage.v1.ListBilledUsageRequest', null, global); goog.exportSymbol('proto.usage.v1.ListBilledUsageRequest.Ordering', null, global); goog.exportSymbol('proto.usage.v1.ListBilledUsageResponse', null, global); +goog.exportSymbol('proto.usage.v1.ReconcileUsageRequest', null, global); +goog.exportSymbol('proto.usage.v1.ReconcileUsageResponse', null, global); /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a @@ -90,6 +92,48 @@ if (goog.DEBUG && !COMPILED) { */ proto.usage.v1.BilledSession.displayName = 'proto.usage.v1.BilledSession'; } +/** + * 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.ReconcileUsageRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.usage.v1.ReconcileUsageRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.usage.v1.ReconcileUsageRequest.displayName = 'proto.usage.v1.ReconcileUsageRequest'; +} +/** + * 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.ReconcileUsageResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.usage.v1.ReconcileUsageResponse.repeatedFields_, null); +}; +goog.inherits(proto.usage.v1.ReconcileUsageResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.usage.v1.ReconcileUsageResponse.displayName = 'proto.usage.v1.ReconcileUsageResponse'; +} @@ -1022,4 +1066,366 @@ proto.usage.v1.BilledSession.prototype.setCredits = 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.ReconcileUsageRequest.prototype.toObject = function(opt_includeInstance) { + return proto.usage.v1.ReconcileUsageRequest.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.ReconcileUsageRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.usage.v1.ReconcileUsageRequest.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) + }; + + 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.ReconcileUsageRequest} + */ +proto.usage.v1.ReconcileUsageRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.usage.v1.ReconcileUsageRequest; + return proto.usage.v1.ReconcileUsageRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.usage.v1.ReconcileUsageRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.usage.v1.ReconcileUsageRequest} + */ +proto.usage.v1.ReconcileUsageRequest.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; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.usage.v1.ReconcileUsageRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.usage.v1.ReconcileUsageRequest.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.ReconcileUsageRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.usage.v1.ReconcileUsageRequest.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 + ); + } +}; + + +/** + * optional google.protobuf.Timestamp start_time = 1; + * @return {?proto.google.protobuf.Timestamp} + */ +proto.usage.v1.ReconcileUsageRequest.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.ReconcileUsageRequest} returns this +*/ +proto.usage.v1.ReconcileUsageRequest.prototype.setStartTime = function(value) { + return jspb.Message.setWrapperField(this, 1, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.usage.v1.ReconcileUsageRequest} returns this + */ +proto.usage.v1.ReconcileUsageRequest.prototype.clearStartTime = function() { + return this.setStartTime(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.usage.v1.ReconcileUsageRequest.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.ReconcileUsageRequest.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.ReconcileUsageRequest} returns this +*/ +proto.usage.v1.ReconcileUsageRequest.prototype.setEndTime = function(value) { + return jspb.Message.setWrapperField(this, 2, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.usage.v1.ReconcileUsageRequest} returns this + */ +proto.usage.v1.ReconcileUsageRequest.prototype.clearEndTime = function() { + return this.setEndTime(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.usage.v1.ReconcileUsageRequest.prototype.hasEndTime = function() { + return jspb.Message.getField(this, 2) != null; +}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.usage.v1.ReconcileUsageResponse.repeatedFields_ = [1]; + + + +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.ReconcileUsageResponse.prototype.toObject = function(opt_includeInstance) { + return proto.usage.v1.ReconcileUsageResponse.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.ReconcileUsageResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.usage.v1.ReconcileUsageResponse.toObject = function(includeInstance, msg) { + var f, obj = { + sessionsList: jspb.Message.toObjectList(msg.getSessionsList(), + proto.usage.v1.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.ReconcileUsageResponse} + */ +proto.usage.v1.ReconcileUsageResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.usage.v1.ReconcileUsageResponse; + return proto.usage.v1.ReconcileUsageResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.usage.v1.ReconcileUsageResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.usage.v1.ReconcileUsageResponse} + */ +proto.usage.v1.ReconcileUsageResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.usage.v1.BilledSession; + reader.readMessage(value,proto.usage.v1.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.ReconcileUsageResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.usage.v1.ReconcileUsageResponse.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.ReconcileUsageResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.usage.v1.ReconcileUsageResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getSessionsList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 1, + f, + proto.usage.v1.BilledSession.serializeBinaryToWriter + ); + } +}; + + +/** + * repeated BilledSession sessions = 1; + * @return {!Array} + */ +proto.usage.v1.ReconcileUsageResponse.prototype.getSessionsList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.usage.v1.BilledSession, 1)); +}; + + +/** + * @param {!Array} value + * @return {!proto.usage.v1.ReconcileUsageResponse} returns this +*/ +proto.usage.v1.ReconcileUsageResponse.prototype.setSessionsList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 1, value); +}; + + +/** + * @param {!proto.usage.v1.BilledSession=} opt_value + * @param {number=} opt_index + * @return {!proto.usage.v1.BilledSession} + */ +proto.usage.v1.ReconcileUsageResponse.prototype.addSessions = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.usage.v1.BilledSession, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.usage.v1.ReconcileUsageResponse} returns this + */ +proto.usage.v1.ReconcileUsageResponse.prototype.clearSessionsList = function() { + return this.setSessionsList([]); +}; + + goog.object.extend(exports, proto.usage.v1); diff --git a/components/usage-api/usage/v1/usage.proto b/components/usage-api/usage/v1/usage.proto index 59a5c08241b48a..76d9a2f6f4d181 100644 --- a/components/usage-api/usage/v1/usage.proto +++ b/components/usage-api/usage/v1/usage.proto @@ -9,6 +9,9 @@ import "google/protobuf/timestamp.proto"; service UsageService { // ListBilledUsage retrieves all usage for the specified attributionId rpc ListBilledUsage(ListBilledUsageRequest) returns (ListBilledUsageResponse) {} + + // ReconcileUsage collects usage for the specified time period, and stores the usage records in the database, returning the records. + rpc ReconcileUsage(ReconcileUsageRequest) returns (ReconcileUsageResponse) {} } message ListBilledUsageRequest { @@ -52,3 +55,12 @@ message BilledSession { int64 credits_deprecated = 11 [deprecated=true]; // insufficient precision to represent credits for workspace time double credits = 12; } + +message ReconcileUsageRequest { + google.protobuf.Timestamp start_time = 1; + google.protobuf.Timestamp end_time = 2; +} + +message ReconcileUsageResponse { + repeated BilledSession sessions = 1; +}