Skip to content

[usage] Implement GetBilledUsage RPC #11387

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/dashboard/src/teams/TeamUsage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function TeamUsage() {
}
(async () => {
const attributionId = AttributionId.render({ kind: "team", teamId: team.id });
const billedUsageResult = await getGitpodService().server.getBilledUsage(attributionId);
const billedUsageResult = await getGitpodService().server.listBilledUsage(attributionId);
setBilledUsage(billedUsageResult);
})();
}, [team]);
Expand Down
2 changes: 1 addition & 1 deletion components/gitpod-protocol/src/gitpod-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
subscribeTeamToStripe(teamId: string, setupIntentId: string, currency: Currency): Promise<void>;
getStripePortalUrlForTeam(teamId: string): Promise<string>;

getBilledUsage(attributionId: string): Promise<BillableSession[]>;
listBilledUsage(attributionId: string): Promise<BillableSession[]>;

/**
* Analytics
Expand Down
6 changes: 3 additions & 3 deletions components/server/ee/src/workspace/gitpod-server-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2066,14 +2066,14 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
}
}

async getBilledUsage(ctx: TraceContext, attributionId: string): Promise<BillableSession[]> {
async listBilledUsage(ctx: TraceContext, attributionId: string): Promise<BillableSession[]> {
traceAPIParams(ctx, { attributionId });
const user = this.checkAndBlockUser("getBilledUsage");
const user = this.checkAndBlockUser("listBilledUsage");

await this.guardCostCenterAccess(ctx, user.id, attributionId, "get");

const usageClient = this.usageServiceClientProvider.getDefault();
const response = await usageClient.getBilledUsage(ctx, attributionId);
const response = await usageClient.listBilledUsage(ctx, attributionId);
const sessions = response.getSessionsList().map((s) => this.mapBilledSession(s));

return sessions.concat(billableSessionDummyData); // to at least return some data for testing
Expand Down
2 changes: 1 addition & 1 deletion components/server/src/auth/rate-limiter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ function getConfig(config: RateLimiterConfig): RateLimiterConfig {
findStripeSubscriptionIdForTeam: { group: "default", points: 1 },
subscribeTeamToStripe: { group: "default", points: 1 },
getStripePortalUrlForTeam: { group: "default", points: 1 },
getBilledUsage: { group: "default", points: 1 },
listBilledUsage: { group: "default", points: 1 },
trackEvent: { group: "default", points: 1 },
trackLocation: { group: "default", points: 1 },
identifyUser: { group: "default", points: 1 },
Expand Down
2 changes: 1 addition & 1 deletion components/server/src/workspace/gitpod-server-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3191,7 +3191,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
throw new ResponseError(ErrorCodes.SAAS_FEATURE, `Not implemented in this version`);
}

async getBilledUsage(ctx: TraceContext, attributionId: string): Promise<BillableSession[]> {
async listBilledUsage(ctx: TraceContext, attributionId: string): Promise<BillableSession[]> {
throw new ResponseError(ErrorCodes.SAAS_FEATURE, `Not implemented in this version`);
}

Expand Down
146 changes: 73 additions & 73 deletions components/usage-api/go/v1/usage.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading