diff --git a/components/dashboard/src/components/UsageView.tsx b/components/dashboard/src/components/UsageView.tsx
index 4ec6c744c3c253..092e3dc9d27e9d 100644
--- a/components/dashboard/src/components/UsageView.tsx
+++ b/components/dashboard/src/components/UsageView.tsx
@@ -62,7 +62,7 @@ function UsageView({ attributionId }: UsageViewProps) {
try {
const page = await getGitpodService().server.listUsage(request);
setUsagePage(page);
- setTotalCreditsUsed(page.creditBalanceAtEnd);
+ setTotalCreditsUsed(page.creditsUsed);
} catch (error) {
if (error.code === ErrorCodes.PERMISSION_DENIED) {
setErrorMessage("Access to usage details is restricted to team owners.");
@@ -173,7 +173,7 @@ function UsageView({ attributionId }: UsageViewProps) {
Total usage
- {totalCreditsUsed} Credits
+ {totalCreditsUsed.toLocaleString()} Credits
diff --git a/components/gitpod-protocol/src/usage.ts b/components/gitpod-protocol/src/usage.ts
index 350c714b2c27cf..81f7131d4b6e97 100644
--- a/components/gitpod-protocol/src/usage.ts
+++ b/components/gitpod-protocol/src/usage.ts
@@ -28,8 +28,7 @@ export interface PaginationRequest {
export interface ListUsageResponse {
usageEntriesList: Usage[];
pagination?: PaginationResponse;
- creditBalanceAtStart: number;
- creditBalanceAtEnd: number;
+ creditsUsed: number;
}
export interface PaginationResponse {
diff --git a/components/server/ee/src/workspace/gitpod-server-impl.ts b/components/server/ee/src/workspace/gitpod-server-impl.ts
index 851d74dd076eca..f5889cd616ada5 100644
--- a/components/server/ee/src/workspace/gitpod-server-impl.ts
+++ b/components/server/ee/src/workspace/gitpod-server-impl.ts
@@ -2355,8 +2355,7 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
totalPages: response.pagination.totalPages,
}
: undefined,
- creditBalanceAtEnd: response.creditBalanceAtEnd,
- creditBalanceAtStart: response.creditBalanceAtStart,
+ creditsUsed: response.creditsUsed,
};
}
diff --git a/components/usage-api/go/v1/usage.pb.go b/components/usage-api/go/v1/usage.pb.go
index 6637070360b1c7..75f806d5243b14 100644
--- a/components/usage-api/go/v1/usage.pb.go
+++ b/components/usage-api/go/v1/usage.pb.go
@@ -474,10 +474,8 @@ type ListUsageResponse struct {
UsageEntries []*Usage `protobuf:"bytes,1,rep,name=usage_entries,json=usageEntries,proto3" json:"usage_entries,omitempty"`
Pagination *PaginatedResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"`
- // the amount of credits the given account (attributionId) had at the beginning of the requested period
- CreditBalanceAtStart float64 `protobuf:"fixed64,3,opt,name=credit_balance_at_start,json=creditBalanceAtStart,proto3" json:"credit_balance_at_start,omitempty"`
- // the amount of credits the given account (attributionId) had at the end of the requested period
- CreditBalanceAtEnd float64 `protobuf:"fixed64,4,opt,name=credit_balance_at_end,json=creditBalanceAtEnd,proto3" json:"credit_balance_at_end,omitempty"`
+ // the amount of credits the given account (attributionId) has used during the requested period
+ CreditsUsed float64 `protobuf:"fixed64,3,opt,name=credits_used,json=creditsUsed,proto3" json:"credits_used,omitempty"`
}
func (x *ListUsageResponse) Reset() {
@@ -526,16 +524,9 @@ func (x *ListUsageResponse) GetPagination() *PaginatedResponse {
return nil
}
-func (x *ListUsageResponse) GetCreditBalanceAtStart() float64 {
+func (x *ListUsageResponse) GetCreditsUsed() float64 {
if x != nil {
- return x.CreditBalanceAtStart
- }
- return 0
-}
-
-func (x *ListUsageResponse) GetCreditBalanceAtEnd() float64 {
- if x != nil {
- return x.CreditBalanceAtEnd
+ return x.CreditsUsed
}
return 0
}
@@ -1044,7 +1035,7 @@ var file_usage_v1_usage_proto_rawDesc = []byte{
0x08, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x17, 0x0a, 0x13, 0x4f, 0x52, 0x44,
0x45, 0x52, 0x49, 0x4e, 0x47, 0x5f, 0x44, 0x45, 0x53, 0x43, 0x45, 0x4e, 0x44, 0x49, 0x4e, 0x47,
0x10, 0x00, 0x12, 0x16, 0x0a, 0x12, 0x4f, 0x52, 0x44, 0x45, 0x52, 0x49, 0x4e, 0x47, 0x5f, 0x41,
- 0x53, 0x43, 0x45, 0x4e, 0x44, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x22, 0xf0, 0x01, 0x0a, 0x11, 0x4c,
+ 0x53, 0x43, 0x45, 0x4e, 0x44, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x22, 0xa9, 0x01, 0x0a, 0x11, 0x4c,
0x69, 0x73, 0x74, 0x55, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x12, 0x34, 0x0a, 0x0d, 0x75, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x65, 0x6e, 0x74, 0x72, 0x69, 0x65,
0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x75, 0x73, 0x61, 0x67, 0x65, 0x2e,
@@ -1053,109 +1044,105 @@ var file_usage_v1_usage_proto_rawDesc = []byte{
0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x75, 0x73, 0x61,
0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x65, 0x64, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74,
- 0x69, 0x6f, 0x6e, 0x12, 0x35, 0x0a, 0x17, 0x63, 0x72, 0x65, 0x64, 0x69, 0x74, 0x5f, 0x62, 0x61,
- 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x61, 0x74, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x18, 0x03,
- 0x20, 0x01, 0x28, 0x01, 0x52, 0x14, 0x63, 0x72, 0x65, 0x64, 0x69, 0x74, 0x42, 0x61, 0x6c, 0x61,
- 0x6e, 0x63, 0x65, 0x41, 0x74, 0x53, 0x74, 0x61, 0x72, 0x74, 0x12, 0x31, 0x0a, 0x15, 0x63, 0x72,
- 0x65, 0x64, 0x69, 0x74, 0x5f, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x61, 0x74, 0x5f,
- 0x65, 0x6e, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x01, 0x52, 0x12, 0x63, 0x72, 0x65, 0x64, 0x69,
- 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x41, 0x74, 0x45, 0x6e, 0x64, 0x22, 0x84, 0x03,
- 0x0a, 0x05, 0x55, 0x73, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20,
- 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x25, 0x0a, 0x0e, 0x61, 0x74, 0x74, 0x72, 0x69,
- 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
- 0x0d, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x20,
- 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20,
- 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e,
- 0x12, 0x18, 0x0a, 0x07, 0x63, 0x72, 0x65, 0x64, 0x69, 0x74, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28,
- 0x01, 0x52, 0x07, 0x63, 0x72, 0x65, 0x64, 0x69, 0x74, 0x73, 0x12, 0x41, 0x0a, 0x0e, 0x65, 0x66,
- 0x66, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x05, 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, 0x0d,
- 0x65, 0x66, 0x66, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x28, 0x0a,
- 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x75, 0x73,
- 0x61, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x4b, 0x69, 0x6e,
- 0x64, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x12, 0x32, 0x0a, 0x15, 0x77, 0x6f, 0x72, 0x6b, 0x73,
- 0x70, 0x61, 0x63, 0x65, 0x5f, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x69, 0x64,
- 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x13, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63,
- 0x65, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x64,
- 0x72, 0x61, 0x66, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x64, 0x72, 0x61, 0x66,
- 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x09, 0x20,
- 0x01, 0x28, 0x09, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x22, 0x35, 0x0a,
- 0x04, 0x4b, 0x69, 0x6e, 0x64, 0x12, 0x1b, 0x0a, 0x17, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x57, 0x4f,
- 0x52, 0x4b, 0x53, 0x50, 0x41, 0x43, 0x45, 0x5f, 0x49, 0x4e, 0x53, 0x54, 0x41, 0x4e, 0x43, 0x45,
- 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x49, 0x4e, 0x56, 0x4f, 0x49,
- 0x43, 0x45, 0x10, 0x01, 0x22, 0x4d, 0x0a, 0x14, 0x53, 0x65, 0x74, 0x43, 0x6f, 0x73, 0x74, 0x43,
- 0x65, 0x6e, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x35, 0x0a, 0x0b,
- 0x63, 0x6f, 0x73, 0x74, 0x5f, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28,
- 0x0b, 0x32, 0x14, 0x2e, 0x75, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x73,
- 0x74, 0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x52, 0x0a, 0x63, 0x6f, 0x73, 0x74, 0x43, 0x65, 0x6e,
- 0x74, 0x65, 0x72, 0x22, 0x17, 0x0a, 0x15, 0x53, 0x65, 0x74, 0x43, 0x6f, 0x73, 0x74, 0x43, 0x65,
- 0x6e, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x3a, 0x0a, 0x11,
- 0x47, 0x65, 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
- 0x74, 0x12, 0x25, 0x0a, 0x0e, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e,
- 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x61, 0x74, 0x74, 0x72, 0x69,
- 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x22, 0x2e, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x42,
- 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18,
- 0x0a, 0x07, 0x63, 0x72, 0x65, 0x64, 0x69, 0x74, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x01, 0x52,
- 0x07, 0x63, 0x72, 0x65, 0x64, 0x69, 0x74, 0x73, 0x22, 0x3d, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x43,
- 0x6f, 0x73, 0x74, 0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
+ 0x69, 0x6f, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x63, 0x72, 0x65, 0x64, 0x69, 0x74, 0x73, 0x5f, 0x75,
+ 0x73, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0b, 0x63, 0x72, 0x65, 0x64, 0x69,
+ 0x74, 0x73, 0x55, 0x73, 0x65, 0x64, 0x22, 0x84, 0x03, 0x0a, 0x05, 0x55, 0x73, 0x61, 0x67, 0x65,
+ 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64,
0x12, 0x25, 0x0a, 0x0e, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x5f,
- 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62,
- 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x22, 0x4e, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x43, 0x6f,
- 0x73, 0x74, 0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
- 0x12, 0x35, 0x0a, 0x0b, 0x63, 0x6f, 0x73, 0x74, 0x5f, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x18,
- 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x75, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x31,
- 0x2e, 0x43, 0x6f, 0x73, 0x74, 0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x52, 0x0a, 0x63, 0x6f, 0x73,
- 0x74, 0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x22, 0xbf, 0x02, 0x0a, 0x0a, 0x43, 0x6f, 0x73, 0x74,
- 0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x12, 0x25, 0x0a, 0x0e, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62,
- 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d,
- 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x25, 0x0a,
- 0x0e, 0x73, 0x70, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18,
- 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x73, 0x70, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x4c,
- 0x69, 0x6d, 0x69, 0x74, 0x12, 0x4f, 0x0a, 0x10, 0x62, 0x69, 0x6c, 0x6c, 0x69, 0x6e, 0x67, 0x5f,
- 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x24,
+ 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62,
+ 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72,
+ 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65,
+ 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x72, 0x65,
+ 0x64, 0x69, 0x74, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x01, 0x52, 0x07, 0x63, 0x72, 0x65, 0x64,
+ 0x69, 0x74, 0x73, 0x12, 0x41, 0x0a, 0x0e, 0x65, 0x66, 0x66, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65,
+ 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x05, 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, 0x0d, 0x65, 0x66, 0x66, 0x65, 0x63, 0x74, 0x69,
+ 0x76, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x28, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x06,
+ 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x75, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e,
+ 0x55, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x4b, 0x69, 0x6e, 0x64, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64,
+ 0x12, 0x32, 0x0a, 0x15, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x69, 0x6e,
+ 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52,
+ 0x13, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e,
+ 0x63, 0x65, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x64, 0x72, 0x61, 0x66, 0x74, 0x18, 0x08, 0x20,
+ 0x01, 0x28, 0x08, 0x52, 0x05, 0x64, 0x72, 0x61, 0x66, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x65,
+ 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6d, 0x65,
+ 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x22, 0x35, 0x0a, 0x04, 0x4b, 0x69, 0x6e, 0x64, 0x12, 0x1b,
+ 0x0a, 0x17, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x57, 0x4f, 0x52, 0x4b, 0x53, 0x50, 0x41, 0x43, 0x45,
+ 0x5f, 0x49, 0x4e, 0x53, 0x54, 0x41, 0x4e, 0x43, 0x45, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x4b,
+ 0x49, 0x4e, 0x44, 0x5f, 0x49, 0x4e, 0x56, 0x4f, 0x49, 0x43, 0x45, 0x10, 0x01, 0x22, 0x4d, 0x0a,
+ 0x14, 0x53, 0x65, 0x74, 0x43, 0x6f, 0x73, 0x74, 0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x52, 0x65,
+ 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x35, 0x0a, 0x0b, 0x63, 0x6f, 0x73, 0x74, 0x5f, 0x63, 0x65,
+ 0x6e, 0x74, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x75, 0x73, 0x61,
+ 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x73, 0x74, 0x43, 0x65, 0x6e, 0x74, 0x65, 0x72,
+ 0x52, 0x0a, 0x63, 0x6f, 0x73, 0x74, 0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x22, 0x17, 0x0a, 0x15,
+ 0x53, 0x65, 0x74, 0x43, 0x6f, 0x73, 0x74, 0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73,
+ 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x3a, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x42, 0x61, 0x6c, 0x61,
+ 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x25, 0x0a, 0x0e, 0x61, 0x74,
+ 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,
+ 0x28, 0x09, 0x52, 0x0d, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x49,
+ 0x64, 0x22, 0x2e, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x52,
+ 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x72, 0x65, 0x64, 0x69,
+ 0x74, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x01, 0x52, 0x07, 0x63, 0x72, 0x65, 0x64, 0x69, 0x74,
+ 0x73, 0x22, 0x3d, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x73, 0x74, 0x43, 0x65, 0x6e, 0x74,
+ 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x25, 0x0a, 0x0e, 0x61, 0x74, 0x74,
+ 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
+ 0x09, 0x52, 0x0d, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64,
+ 0x22, 0x4e, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x73, 0x74, 0x43, 0x65, 0x6e, 0x74, 0x65,
+ 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x0b, 0x63, 0x6f, 0x73,
+ 0x74, 0x5f, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14,
0x2e, 0x75, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x73, 0x74, 0x43, 0x65,
- 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x42, 0x69, 0x6c, 0x6c, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x72, 0x61,
- 0x74, 0x65, 0x67, 0x79, 0x52, 0x0f, 0x62, 0x69, 0x6c, 0x6c, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x72,
- 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x46, 0x0a, 0x11, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x62, 0x69,
- 0x6c, 0x6c, 0x69, 0x6e, 0x67, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x04, 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, 0x0f, 0x6e, 0x65,
- 0x78, 0x74, 0x42, 0x69, 0x6c, 0x6c, 0x69, 0x6e, 0x67, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x4a, 0x0a,
- 0x0f, 0x42, 0x69, 0x6c, 0x6c, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79,
- 0x12, 0x1b, 0x0a, 0x17, 0x42, 0x49, 0x4c, 0x4c, 0x49, 0x4e, 0x47, 0x5f, 0x53, 0x54, 0x52, 0x41,
- 0x54, 0x45, 0x47, 0x59, 0x5f, 0x53, 0x54, 0x52, 0x49, 0x50, 0x45, 0x10, 0x00, 0x12, 0x1a, 0x0a,
- 0x16, 0x42, 0x49, 0x4c, 0x4c, 0x49, 0x4e, 0x47, 0x5f, 0x53, 0x54, 0x52, 0x41, 0x54, 0x45, 0x47,
- 0x59, 0x5f, 0x4f, 0x54, 0x48, 0x45, 0x52, 0x10, 0x01, 0x32, 0xa0, 0x03, 0x0a, 0x0c, 0x55, 0x73,
- 0x61, 0x67, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x52, 0x0a, 0x0d, 0x47, 0x65,
- 0x74, 0x43, 0x6f, 0x73, 0x74, 0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x12, 0x1e, 0x2e, 0x75, 0x73,
- 0x61, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x73, 0x74, 0x43, 0x65,
- 0x6e, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x75, 0x73,
- 0x61, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x73, 0x74, 0x43, 0x65,
- 0x6e, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x52,
- 0x0a, 0x0d, 0x53, 0x65, 0x74, 0x43, 0x6f, 0x73, 0x74, 0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x12,
- 0x1e, 0x2e, 0x75, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x43, 0x6f,
- 0x73, 0x74, 0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
- 0x1f, 0x2e, 0x75, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x43, 0x6f,
- 0x73, 0x74, 0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 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, 0x12, 0x46, 0x0a, 0x09, 0x4c, 0x69, 0x73,
- 0x74, 0x55, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1a, 0x2e, 0x75, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x76,
- 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65,
- 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x75, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69,
- 0x73, 0x74, 0x55, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,
- 0x00, 0x12, 0x49, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x12,
- 0x1b, 0x2e, 0x75, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x61,
- 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x75,
- 0x73, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e,
- 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,
+ 0x6e, 0x74, 0x65, 0x72, 0x52, 0x0a, 0x63, 0x6f, 0x73, 0x74, 0x43, 0x65, 0x6e, 0x74, 0x65, 0x72,
+ 0x22, 0xbf, 0x02, 0x0a, 0x0a, 0x43, 0x6f, 0x73, 0x74, 0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x12,
+ 0x25, 0x0a, 0x0e, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69,
+ 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75,
+ 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x25, 0x0a, 0x0e, 0x73, 0x70, 0x65, 0x6e, 0x64, 0x69,
+ 0x6e, 0x67, 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d,
+ 0x73, 0x70, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x4f, 0x0a,
+ 0x10, 0x62, 0x69, 0x6c, 0x6c, 0x69, 0x6e, 0x67, 0x5f, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67,
+ 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x24, 0x2e, 0x75, 0x73, 0x61, 0x67, 0x65, 0x2e,
+ 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x73, 0x74, 0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x42, 0x69,
+ 0x6c, 0x6c, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x0f, 0x62,
+ 0x69, 0x6c, 0x6c, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x46,
+ 0x0a, 0x11, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x62, 0x69, 0x6c, 0x6c, 0x69, 0x6e, 0x67, 0x5f, 0x74,
+ 0x69, 0x6d, 0x65, 0x18, 0x04, 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, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x42, 0x69, 0x6c, 0x6c, 0x69,
+ 0x6e, 0x67, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x4a, 0x0a, 0x0f, 0x42, 0x69, 0x6c, 0x6c, 0x69, 0x6e,
+ 0x67, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x1b, 0x0a, 0x17, 0x42, 0x49, 0x4c,
+ 0x4c, 0x49, 0x4e, 0x47, 0x5f, 0x53, 0x54, 0x52, 0x41, 0x54, 0x45, 0x47, 0x59, 0x5f, 0x53, 0x54,
+ 0x52, 0x49, 0x50, 0x45, 0x10, 0x00, 0x12, 0x1a, 0x0a, 0x16, 0x42, 0x49, 0x4c, 0x4c, 0x49, 0x4e,
+ 0x47, 0x5f, 0x53, 0x54, 0x52, 0x41, 0x54, 0x45, 0x47, 0x59, 0x5f, 0x4f, 0x54, 0x48, 0x45, 0x52,
+ 0x10, 0x01, 0x32, 0xa0, 0x03, 0x0a, 0x0c, 0x55, 0x73, 0x61, 0x67, 0x65, 0x53, 0x65, 0x72, 0x76,
+ 0x69, 0x63, 0x65, 0x12, 0x52, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x73, 0x74, 0x43, 0x65,
+ 0x6e, 0x74, 0x65, 0x72, 0x12, 0x1e, 0x2e, 0x75, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e,
+ 0x47, 0x65, 0x74, 0x43, 0x6f, 0x73, 0x74, 0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71,
+ 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x75, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e,
+ 0x47, 0x65, 0x74, 0x43, 0x6f, 0x73, 0x74, 0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73,
+ 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x52, 0x0a, 0x0d, 0x53, 0x65, 0x74, 0x43, 0x6f,
+ 0x73, 0x74, 0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x12, 0x1e, 0x2e, 0x75, 0x73, 0x61, 0x67, 0x65,
+ 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x43, 0x6f, 0x73, 0x74, 0x43, 0x65, 0x6e, 0x74, 0x65,
+ 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x75, 0x73, 0x61, 0x67, 0x65,
+ 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x43, 0x6f, 0x73, 0x74, 0x43, 0x65, 0x6e, 0x74, 0x65,
+ 0x72, 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, 0x12, 0x46, 0x0a, 0x09, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x61, 0x67, 0x65, 0x12,
+ 0x1a, 0x2e, 0x75, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x55,
+ 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x75, 0x73,
+ 0x61, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x61, 0x67, 0x65,
+ 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x49, 0x0a, 0x0a, 0x47, 0x65,
+ 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x1b, 0x2e, 0x75, 0x73, 0x61, 0x67, 0x65,
+ 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65,
+ 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x75, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x31,
+ 0x2e, 0x47, 0x65, 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 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 (
diff --git a/components/usage-api/typescript/src/usage/v1/usage.pb.ts b/components/usage-api/typescript/src/usage/v1/usage.pb.ts
index 09c077c656c878..645c5c9846447a 100644
--- a/components/usage-api/typescript/src/usage/v1/usage.pb.ts
+++ b/components/usage-api/typescript/src/usage/v1/usage.pb.ts
@@ -104,10 +104,8 @@ export interface ListUsageResponse {
pagination:
| PaginatedResponse
| undefined;
- /** the amount of credits the given account (attributionId) had at the beginning of the requested period */
- creditBalanceAtStart: number;
- /** the amount of credits the given account (attributionId) had at the end of the requested period */
- creditBalanceAtEnd: number;
+ /** the amount of credits the given account (attributionId) has used during the requested period */
+ creditsUsed: number;
}
export interface Usage {
@@ -571,7 +569,7 @@ export const ListUsageRequest = {
};
function createBaseListUsageResponse(): ListUsageResponse {
- return { usageEntries: [], pagination: undefined, creditBalanceAtStart: 0, creditBalanceAtEnd: 0 };
+ return { usageEntries: [], pagination: undefined, creditsUsed: 0 };
}
export const ListUsageResponse = {
@@ -582,11 +580,8 @@ export const ListUsageResponse = {
if (message.pagination !== undefined) {
PaginatedResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim();
}
- if (message.creditBalanceAtStart !== 0) {
- writer.uint32(25).double(message.creditBalanceAtStart);
- }
- if (message.creditBalanceAtEnd !== 0) {
- writer.uint32(33).double(message.creditBalanceAtEnd);
+ if (message.creditsUsed !== 0) {
+ writer.uint32(25).double(message.creditsUsed);
}
return writer;
},
@@ -605,10 +600,7 @@ export const ListUsageResponse = {
message.pagination = PaginatedResponse.decode(reader, reader.uint32());
break;
case 3:
- message.creditBalanceAtStart = reader.double();
- break;
- case 4:
- message.creditBalanceAtEnd = reader.double();
+ message.creditsUsed = reader.double();
break;
default:
reader.skipType(tag & 7);
@@ -622,8 +614,7 @@ export const ListUsageResponse = {
return {
usageEntries: Array.isArray(object?.usageEntries) ? object.usageEntries.map((e: any) => Usage.fromJSON(e)) : [],
pagination: isSet(object.pagination) ? PaginatedResponse.fromJSON(object.pagination) : undefined,
- creditBalanceAtStart: isSet(object.creditBalanceAtStart) ? Number(object.creditBalanceAtStart) : 0,
- creditBalanceAtEnd: isSet(object.creditBalanceAtEnd) ? Number(object.creditBalanceAtEnd) : 0,
+ creditsUsed: isSet(object.creditsUsed) ? Number(object.creditsUsed) : 0,
};
},
@@ -636,8 +627,7 @@ export const ListUsageResponse = {
}
message.pagination !== undefined &&
(obj.pagination = message.pagination ? PaginatedResponse.toJSON(message.pagination) : undefined);
- message.creditBalanceAtStart !== undefined && (obj.creditBalanceAtStart = message.creditBalanceAtStart);
- message.creditBalanceAtEnd !== undefined && (obj.creditBalanceAtEnd = message.creditBalanceAtEnd);
+ message.creditsUsed !== undefined && (obj.creditsUsed = message.creditsUsed);
return obj;
},
@@ -647,8 +637,7 @@ export const ListUsageResponse = {
message.pagination = (object.pagination !== undefined && object.pagination !== null)
? PaginatedResponse.fromPartial(object.pagination)
: undefined;
- message.creditBalanceAtStart = object.creditBalanceAtStart ?? 0;
- message.creditBalanceAtEnd = object.creditBalanceAtEnd ?? 0;
+ message.creditsUsed = object.creditsUsed ?? 0;
return message;
},
};
diff --git a/components/usage-api/usage/v1/usage.proto b/components/usage-api/usage/v1/usage.proto
index 534beb03506596..fe94b96e9f8d78 100644
--- a/components/usage-api/usage/v1/usage.proto
+++ b/components/usage-api/usage/v1/usage.proto
@@ -70,11 +70,8 @@ message ListUsageRequest {
message ListUsageResponse {
repeated Usage usage_entries = 1;
PaginatedResponse pagination = 2;
- // the amount of credits the given account (attributionId) had at the beginning of the requested period
- double credit_balance_at_start = 3;
-
- // the amount of credits the given account (attributionId) had at the end of the requested period
- double credit_balance_at_end = 4;
+ // the amount of credits the given account (attributionId) has used during the requested period
+ double credits_used = 3;
}
message Usage {
diff --git a/components/usage/pkg/apiv1/usage.go b/components/usage/pkg/apiv1/usage.go
index eb5748f4431d9c..2293c4077cce66 100644
--- a/components/usage/pkg/apiv1/usage.go
+++ b/components/usage/pkg/apiv1/usage.go
@@ -129,30 +129,31 @@ func (s *UsageService) ListUsage(ctx context.Context, in *v1.ListUsageRequest) (
}
usageSummary, err := db.GetUsageSummary(ctx, s.conn,
- attributionId,
- from,
- to,
- excludeDrafts,
+ db.GetUsageSummaryParams{
+ AttributionId: attributionId,
+ From: from,
+ To: to,
+ ExcludeDrafts: excludeDrafts,
+ },
)
if err != nil {
logger.WithError(err).Error("Failed to fetch usage metadata.")
return nil, status.Error(codes.Internal, "unable to retrieve usage")
}
- totalPages := int64(math.Ceil(float64(usageSummary.NumRecordsInRange) / float64(perPage)))
+ totalPages := int64(math.Ceil(float64(usageSummary.NumberOfRecords) / float64(perPage)))
pagination := v1.PaginatedResponse{
PerPage: perPage,
Page: page,
TotalPages: totalPages,
- Total: int64(usageSummary.NumRecordsInRange),
+ Total: int64(usageSummary.NumberOfRecords),
}
return &v1.ListUsageResponse{
- UsageEntries: usageData,
- CreditBalanceAtStart: usageSummary.CreditCentsBalanceAtStart.ToCredits(),
- CreditBalanceAtEnd: usageSummary.CreditCentsBalanceAtEnd.ToCredits(),
- Pagination: &pagination,
+ UsageEntries: usageData,
+ CreditsUsed: usageSummary.CreditCentsUsed.ToCredits(),
+ Pagination: &pagination,
}, nil
}
diff --git a/components/usage/pkg/apiv1/usage_test.go b/components/usage/pkg/apiv1/usage_test.go
index ec51aee1ecbfbd..4505bed2f3c2e7 100644
--- a/components/usage/pkg/apiv1/usage_test.go
+++ b/components/usage/pkg/apiv1/usage_test.go
@@ -313,15 +313,14 @@ func TestListUsage(t *testing.T) {
tests := []struct {
start, end time.Time
// expectations
- creditsAtStart float64
- creditsAtEnd float64
+ creditsUsed float64
recordsInRange int64
}{
- {start, end, 3, 10, 2},
- {end, end, 10, 10, 0},
- {start, start, 3, 3, 0},
- {start.Add(-200 * 24 * time.Hour), end, 0, 10, 4},
- {start.Add(-200 * 24 * time.Hour), end.Add(10 * 24 * time.Hour), 0, 20, 5},
+ {start, end, 7, 2},
+ {end, end, 0, 0},
+ {start, start, 0, 0},
+ {start.Add(-200 * 24 * time.Hour), end, 10, 4},
+ {start.Add(-200 * 24 * time.Hour), end.Add(10 * 24 * time.Hour), 20, 5},
}
for i, test := range tests {
@@ -338,8 +337,7 @@ func TestListUsage(t *testing.T) {
})
require.NoError(t, err)
- require.Equal(t, test.creditsAtStart, metaData.CreditBalanceAtStart)
- require.Equal(t, test.creditsAtEnd, metaData.CreditBalanceAtEnd)
+ require.Equal(t, test.creditsUsed, metaData.CreditsUsed)
require.Equal(t, test.recordsInRange, metaData.Pagination.Total)
})
}
diff --git a/components/usage/pkg/db/cost_center.go b/components/usage/pkg/db/cost_center.go
index 8be0692244b009..c935115fb2b19b 100644
--- a/components/usage/pkg/db/cost_center.go
+++ b/components/usage/pkg/db/cost_center.go
@@ -158,11 +158,11 @@ func (c *CostCenterManager) UpdateCostCenter(ctx context.Context, costCenter Cos
func (c *CostCenterManager) ComputeInvoiceUsageRecord(ctx context.Context, attributionID AttributionID) (*Usage, error) {
now := time.Now()
- summary, err := GetUsageSummary(ctx, c.conn, attributionID, now, now, false)
+ creditCents, err := GetBalance(ctx, c.conn, attributionID)
if err != nil {
return nil, err
}
- if summary.CreditCentsBalanceAtEnd.ToCredits() <= 0 {
+ if creditCents.ToCredits() <= 0 {
// account has no debt, do nothing
return nil, nil
}
@@ -170,7 +170,7 @@ func (c *CostCenterManager) ComputeInvoiceUsageRecord(ctx context.Context, attri
ID: uuid.New(),
AttributionID: attributionID,
Description: "Credits",
- CreditCents: summary.CreditCentsBalanceAtEnd * -1,
+ CreditCents: creditCents * -1,
EffectiveTime: NewVarcharTime(now),
Kind: InvoiceUsageKind,
Draft: false,
diff --git a/components/usage/pkg/db/usage.go b/components/usage/pkg/db/usage.go
index 7e366766b1e588..67a745867adb52 100644
--- a/components/usage/pkg/db/usage.go
+++ b/components/usage/pkg/db/usage.go
@@ -6,7 +6,6 @@ package db
import (
"context"
- "database/sql"
"encoding/json"
"fmt"
"math"
@@ -139,7 +138,8 @@ func FindUsage(ctx context.Context, conn *gorm.DB, params *FindUsageParams) ([]U
db := conn.WithContext(ctx).
Where("attributionId = ?", params.AttributionId).
- Where("effectiveTime >= ? AND effectiveTime < ?", TimeToISO8601(params.From), TimeToISO8601(params.To))
+ Where("effectiveTime >= ? AND effectiveTime < ?", TimeToISO8601(params.From), TimeToISO8601(params.To)).
+ Where("kind = ?", WorkspaceInstanceUsageKind)
if params.ExcludeDrafts {
db = db.Where("draft = ?", false)
}
@@ -158,48 +158,37 @@ func FindUsage(ctx context.Context, conn *gorm.DB, params *FindUsageParams) ([]U
if result.Error != nil {
return nil, fmt.Errorf("failed to get usage records: %s", result.Error)
}
+
return usageRecords, nil
}
-type UsageSummary struct {
- NumRecordsInRange int
- CreditCentsBalanceAtStart CreditCents
- CreditCentsBalanceAtEnd CreditCents
+type GetUsageSummaryParams struct {
+ AttributionId AttributionID
+ From, To time.Time
+ ExcludeDrafts bool
+}
+
+type GetUsageSummaryResponse struct {
+ CreditCentsUsed CreditCents
+ NumberOfRecords int
}
-func GetUsageSummary(ctx context.Context, conn *gorm.DB, attributionId AttributionID, from, to time.Time, excludeDrafts bool) (*UsageSummary, error) {
+func GetUsageSummary(ctx context.Context, conn *gorm.DB, params GetUsageSummaryParams) (GetUsageSummaryResponse, error) {
db := conn.WithContext(ctx)
query1 := db.Table((&Usage{}).TableName()).
- Select("sum(creditCents) as creditCentsBalanceAtStart").
- Where("attributionId = ?", attributionId).
- Where("effectiveTime < ?", TimeToISO8601(from))
- if excludeDrafts {
+ Select("sum(creditCents) as CreditCentsUsed, count(*) as NumberOfRecords").
+ Where("attributionId = ?", params.AttributionId).
+ Where("effectiveTime >= ? AND effectiveTime < ?", TimeToISO8601(params.From), TimeToISO8601(params.To)).
+ Where("kind = ?", WorkspaceInstanceUsageKind)
+ if params.ExcludeDrafts {
query1 = query1.Where("draft = ?", false)
}
- var creditCentsBalanceAtStart sql.NullInt64
- err := query1.Row().Scan(&creditCentsBalanceAtStart)
- if err != nil {
- return nil, fmt.Errorf("failed to get usage meta data: %s", err)
- }
-
- query2 := db.Table((&Usage{}).TableName()).
- Select("sum(creditCents) as creditCentsBalanceInPeriod", "count(id) as numRecordsInRange").
- Where("attributionId = ?", attributionId).
- Where("? <= effectiveTime AND effectiveTime < ?", TimeToISO8601(from), TimeToISO8601(to))
- if excludeDrafts {
- query2 = query2.Where("draft = ?", false)
- }
- var creditCentsBalanceInPeriod sql.NullInt64
- var numRecordsInRange sql.NullInt32
- err = query2.Row().Scan(&creditCentsBalanceInPeriod, &numRecordsInRange)
+ var result GetUsageSummaryResponse
+ err := query1.Find(&result).Error
if err != nil {
- return nil, fmt.Errorf("failed to get usage meta data: %s", err)
+ return result, fmt.Errorf("failed to get usage meta data: %w", err)
}
- return &UsageSummary{
- NumRecordsInRange: int(numRecordsInRange.Int32),
- CreditCentsBalanceAtStart: CreditCents(creditCentsBalanceAtStart.Int64),
- CreditCentsBalanceAtEnd: CreditCents(creditCentsBalanceAtStart.Int64 + creditCentsBalanceInPeriod.Int64),
- }, nil
+ return result, nil
}
type Balance struct {
diff --git a/components/usage/pkg/db/usage_test.go b/components/usage/pkg/db/usage_test.go
index 42a76efc86e8dd..71be3c187e8c5f 100644
--- a/components/usage/pkg/db/usage_test.go
+++ b/components/usage/pkg/db/usage_test.go
@@ -93,33 +93,44 @@ func TestGetUsageSummary(t *testing.T) {
CreditCents: 1000,
})
- dbtest.CreateUsageRecords(t, conn, draftBefore, nondraftBefore, draftInside, nonDraftInside, nonDraftAfter)
+ invoice := dbtest.NewUsage(t, db.Usage{
+ AttributionID: attributionID,
+ Kind: db.InvoiceUsageKind,
+ EffectiveTime: db.NewVarcharTime(start.Add(2 * time.Hour)),
+ CreditCents: -400,
+ Draft: false,
+ })
+
+ dbtest.CreateUsageRecords(t, conn, draftBefore, nondraftBefore, draftInside, nonDraftInside, nonDraftAfter, invoice)
tests := []struct {
start, end time.Time
excludeDrafts bool
// expectations
- creditsAtStart int64
- creditsAtEnd int64
- recordsInRange int
+ creditCents db.CreditCents
+ numberOfRecords int
}{
- {start, end, false, 3, 10, 2},
- {start, end, true, 2, 6, 1},
- {end, end, false, 10, 10, 0},
- {end, end, true, 6, 6, 0},
- {start, start, false, 3, 3, 0},
- {start.Add(-500 * 24 * time.Hour), end, false, 0, 10, 4},
- {start.Add(-500 * 24 * time.Hour), end.Add(500 * 24 * time.Hour), false, 0, 20, 5},
+ {start, end, false, 700, 2},
+ {start, end, true, 400, 1},
+ {end, end, false, 0, 0},
+ {end, end, true, 0, 0},
+ {start, start, false, 0, 0},
+ {start.Add(-500 * 24 * time.Hour), end, false, 1000, 4},
+ {start.Add(-500 * 24 * time.Hour), end.Add(500 * 24 * time.Hour), false, 2000, 5},
}
for i, test := range tests {
t.Run(fmt.Sprintf("Running test no %d", i+1), func(t *testing.T) {
- metaData, err := db.GetUsageSummary(context.Background(), conn, attributionID, test.start, test.end, test.excludeDrafts)
+ usageSummary, err := db.GetUsageSummary(context.Background(), conn, db.GetUsageSummaryParams{
+ AttributionId: attributionID,
+ From: test.start,
+ To: test.end,
+ ExcludeDrafts: test.excludeDrafts,
+ })
require.NoError(t, err)
- require.EqualValues(t, test.creditsAtStart, metaData.CreditCentsBalanceAtStart.ToCredits())
- require.EqualValues(t, test.creditsAtEnd, metaData.CreditCentsBalanceAtEnd.ToCredits())
- require.Equal(t, test.recordsInRange, metaData.NumRecordsInRange)
+ require.EqualValues(t, test.creditCents, usageSummary.CreditCentsUsed)
+ require.EqualValues(t, test.numberOfRecords, usageSummary.NumberOfRecords)
})
}
}
@@ -326,6 +337,7 @@ func TestListBalance(t *testing.T) {
func TestGetBalance(t *testing.T) {
teamAttributionID := db.NewTeamAttributionID(uuid.New().String())
userAttributionID := db.NewUserAttributionID(uuid.New().String())
+ noUsageAttributionID := db.NewUserAttributionID(uuid.New().String())
conn := dbtest.ConnectForTests(t)
dbtest.CreateUsageRecords(t, conn,
@@ -355,4 +367,8 @@ func TestGetBalance(t *testing.T) {
userBalance, err := db.GetBalance(context.Background(), conn, userAttributionID)
require.NoError(t, err)
require.EqualValues(t, -50, int(userBalance))
+
+ noUsageBalance, err := db.GetBalance(context.Background(), conn, noUsageAttributionID)
+ require.NoError(t, err)
+ require.EqualValues(t, 0, int(noUsageBalance))
}