Skip to content

Commit aa320ac

Browse files
committed
[usage] Expose CostCenter.CreationTime in the API
1 parent 88fa55e commit aa320ac

File tree

5 files changed

+89
-62
lines changed

5 files changed

+89
-62
lines changed

components/server/ee/src/billing/billing-mode.spec.db.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,10 @@ class UsageServiceClientMock implements UsageServiceClient {
7777
return {
7878
costCenter: {
7979
attributionId: request.attributionId,
80+
spendingLimit: 1234,
8081
billingStrategy,
8182
nextBillingTime: new Date(), // does not matter here.
82-
spendingLimit: 1234,
83+
creationTime: new Date(), // does not matter here.
8384
},
8485
};
8586
}

components/usage-api/go/v1/usage.pb.go

Lines changed: 74 additions & 61 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/usage-api/typescript/src/usage/v1/usage.pb.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ export interface CostCenter {
195195
billingStrategy: CostCenter_BillingStrategy;
196196
/** next_billing_time specifies when the next billing cycle happens. Only set when billing strategy is 'other'. This property is readonly. */
197197
nextBillingTime: Date | undefined;
198+
creationTime: Date | undefined;
198199
}
199200

200201
export enum CostCenter_BillingStrategy {
@@ -1077,6 +1078,7 @@ function createBaseCostCenter(): CostCenter {
10771078
spendingLimit: 0,
10781079
billingStrategy: CostCenter_BillingStrategy.BILLING_STRATEGY_STRIPE,
10791080
nextBillingTime: undefined,
1081+
creationTime: undefined,
10801082
};
10811083
}
10821084

@@ -1094,6 +1096,9 @@ export const CostCenter = {
10941096
if (message.nextBillingTime !== undefined) {
10951097
Timestamp.encode(toTimestamp(message.nextBillingTime), writer.uint32(34).fork()).ldelim();
10961098
}
1099+
if (message.creationTime !== undefined) {
1100+
Timestamp.encode(toTimestamp(message.creationTime), writer.uint32(42).fork()).ldelim();
1101+
}
10971102
return writer;
10981103
},
10991104

@@ -1116,6 +1121,9 @@ export const CostCenter = {
11161121
case 4:
11171122
message.nextBillingTime = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
11181123
break;
1124+
case 5:
1125+
message.creationTime = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
1126+
break;
11191127
default:
11201128
reader.skipType(tag & 7);
11211129
break;
@@ -1132,6 +1140,7 @@ export const CostCenter = {
11321140
? costCenter_BillingStrategyFromJSON(object.billingStrategy)
11331141
: CostCenter_BillingStrategy.BILLING_STRATEGY_STRIPE,
11341142
nextBillingTime: isSet(object.nextBillingTime) ? fromJsonTimestamp(object.nextBillingTime) : undefined,
1143+
creationTime: isSet(object.creationTime) ? fromJsonTimestamp(object.creationTime) : undefined,
11351144
};
11361145
},
11371146

@@ -1142,6 +1151,7 @@ export const CostCenter = {
11421151
message.billingStrategy !== undefined &&
11431152
(obj.billingStrategy = costCenter_BillingStrategyToJSON(message.billingStrategy));
11441153
message.nextBillingTime !== undefined && (obj.nextBillingTime = message.nextBillingTime.toISOString());
1154+
message.creationTime !== undefined && (obj.creationTime = message.creationTime.toISOString());
11451155
return obj;
11461156
},
11471157

@@ -1151,6 +1161,7 @@ export const CostCenter = {
11511161
message.spendingLimit = object.spendingLimit ?? 0;
11521162
message.billingStrategy = object.billingStrategy ?? CostCenter_BillingStrategy.BILLING_STRATEGY_STRIPE;
11531163
message.nextBillingTime = object.nextBillingTime ?? undefined;
1164+
message.creationTime = object.creationTime ?? undefined;
11541165
return message;
11551166
},
11561167
};

components/usage-api/usage/v1/usage.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ message CostCenter {
129129

130130
// next_billing_time specifies when the next billing cycle happens. Only set when billing strategy is 'other'. This property is readonly.
131131
google.protobuf.Timestamp next_billing_time = 4;
132+
google.protobuf.Timestamp creation_time = 5;
132133
}
133134

134135
message ResetUsageRequest {}

components/usage/pkg/apiv1/usage.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ func dbCostCenterToAPI(c db.CostCenter) *v1.CostCenter {
195195
SpendingLimit: c.SpendingLimit,
196196
BillingStrategy: convertBillingStrategyToAPI(c.BillingStrategy),
197197
NextBillingTime: timestamppb.New(c.NextBillingTime.Time()),
198+
CreationTime: timestamppb.New(c.CreationTime.Time()),
198199
}
199200
}
200201

0 commit comments

Comments
 (0)