Skip to content

Commit 1b355c7

Browse files
Move Billing Service Proto to Common (#1088)
* new billing service proto file * generate go files * remove unused import * move client to common * using test loggers --------- Co-authored-by: Patrick <[email protected]>
1 parent 46f0d8f commit 1b355c7

10 files changed

+2807
-3
lines changed

pkg/billing/pb/billing_service.pb.go

+1,420
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/billing/pb/billing_service.proto

+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
syntax = "proto3";
2+
3+
package pb;
4+
5+
import "google/protobuf/timestamp.proto";
6+
import "capabilities/pb/capabilities.proto";
7+
8+
option go_package = "./pb";
9+
10+
// ------------------------------------------
11+
// Shared messages
12+
// ------------------------------------------
13+
14+
message EmptyRequest {}
15+
message EmptyResponse {
16+
string message = 1;
17+
}
18+
19+
message AccountCreditsInput {
20+
float credits = 1;
21+
string credit_type = 2; // TODO make ENUM
22+
}
23+
24+
message AllocateCreditsRequest {
25+
string account_id = 1;
26+
repeated AccountCreditsInput credits = 2;
27+
}
28+
29+
message AllocateCreditsResponse {
30+
bool Success = 1;
31+
}
32+
33+
message BillAccountRequest {
34+
string account_id = 1;
35+
float amt = 2;
36+
string currency = 3;
37+
string idempotency_key = 4;
38+
}
39+
40+
message BillAccountResponse {
41+
string bill_id = 1;
42+
}
43+
44+
45+
message GetAccountCreditsRequest {
46+
string account_id = 1;
47+
}
48+
message GetAccountCreditsResponse {
49+
string account_id = 1;
50+
repeated AccountCredits credits = 2;
51+
}
52+
message BatchGetCreditsForAccountsRequest {
53+
repeated string account_ids = 1;
54+
}
55+
message BatchGetCreditsForAccountsResponse {
56+
repeated AccountWithCredits accounts = 1;
57+
}
58+
59+
message AccountCredits {
60+
float credits = 1;
61+
float credits_reserved = 2;
62+
string credit_type = 3; // TODO make ENUM
63+
google.protobuf.Timestamp created_at = 4;
64+
google.protobuf.Timestamp updated_at = 5;
65+
}
66+
67+
message AccountWithCredits {
68+
string account_id = 1;
69+
repeated AccountCredits credits = 2;
70+
}
71+
72+
// Reserve/Consume messages
73+
message ReserveCreditsRequest {
74+
string account_id = 1;
75+
string workflow_id = 2;
76+
string workflow_execution_id = 3;
77+
repeated AccountCreditsInput credits = 4;
78+
}
79+
message ReserveCreditsResponse {
80+
bool success = 1;
81+
}
82+
message ReleaseReservationRequest {
83+
string account_id = 1;
84+
string workflow_id = 2;
85+
string workflow_execution_id = 3;
86+
}
87+
message ReleaseReservationResponse {
88+
bool success = 1;
89+
}
90+
message ConsumeCreditsRequest {
91+
string account_id = 1;
92+
string workflow_id = 2;
93+
repeated AccountCreditsInput credits = 3;
94+
}
95+
message ConsumeCreditsResponse {
96+
bool success = 1;
97+
}
98+
message ConsumeReservationRequest {
99+
string account_id = 1;
100+
string workflow_id = 2;
101+
string workflow_execution_id = 3;
102+
}
103+
message ConsumeReservationResponse {
104+
bool success = 1;
105+
}
106+
message SubmitWorkflowReceiptRequest {
107+
string account_id = 1;
108+
string workflow_id = 2;
109+
string workflow_execution_id = 3;
110+
capabilities.MeteringReport metering = 4;
111+
}
112+
message SubmitWorkflowReceiptResponse {
113+
bool success = 1;
114+
}
115+
116+
// SubscriptionService
117+
service SubscriptionService {
118+
rpc GetAccountCredits(GetAccountCreditsRequest) returns (GetAccountCreditsResponse);
119+
rpc AllocateCredits(AllocateCreditsRequest) returns (AllocateCreditsResponse);
120+
rpc BillAccount(BillAccountRequest) returns (BillAccountResponse);
121+
}
122+
123+
// WorkflowService
124+
service WorkflowService {
125+
rpc GetAccountCredits(GetAccountCreditsRequest) returns (GetAccountCreditsResponse);
126+
rpc BatchGetCreditsForAccounts(BatchGetCreditsForAccountsRequest) returns (BatchGetCreditsForAccountsResponse);
127+
rpc ReserveCredits(ReserveCreditsRequest) returns (ReserveCreditsResponse);
128+
rpc ReleaseReservation(ReleaseReservationRequest) returns (ReleaseReservationResponse);
129+
rpc ConsumeCredits(ConsumeCreditsRequest) returns (ConsumeCreditsResponse);
130+
rpc ConsumeReservation(ConsumeReservationRequest) returns (ConsumeReservationResponse);
131+
rpc WorkflowReceipt(SubmitWorkflowReceiptRequest) returns (SubmitWorkflowReceiptResponse);
132+
}

0 commit comments

Comments
 (0)