Skip to content

[UBP] Remove team specific Stripe APIs from server JSON-RPC API #12957

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 4 commits into from
Sep 23, 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
5 changes: 0 additions & 5 deletions components/gitpod-protocol/src/gitpod-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,17 +287,12 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
getStripePublishableKey(): Promise<string>;
getStripeSetupIntentClientSecret(): Promise<string>;
findStripeSubscriptionId(attributionId: string): Promise<string | undefined>;
findStripeSubscriptionIdForTeam(teamId: string): Promise<string | undefined>;
createOrUpdateStripeCustomerForTeam(teamId: string, currency: string): Promise<void>;
createOrUpdateStripeCustomerForUser(currency: string): Promise<void>;
subscribeToStripe(attributionId: string, setupIntentId: string): Promise<void>;
subscribeTeamToStripe(teamId: string, setupIntentId: string): Promise<void>;
getStripePortalUrl(attributionId: string): Promise<string>;
getStripePortalUrlForTeam(teamId: string): Promise<string>;
getUsageLimit(attributionId: string): Promise<number | undefined>;
setUsageLimit(attributionId: string, usageLimit: number): Promise<void>;
getUsageLimitForTeam(teamId: string): Promise<number | undefined>;
setUsageLimitForTeam(teamId: string, spendingLimit: number): Promise<void>;

listUsage(req: ListUsageRequest): Promise<ListUsageResponse>;

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

async findStripeSubscriptionIdForTeam(ctx: TraceContext, teamId: string): Promise<string | undefined> {
const attributionId: AttributionId = { kind: "team", teamId: teamId };
return this.findStripeSubscriptionId(ctx, AttributionId.render(attributionId));
}

async createOrUpdateStripeCustomerForTeam(ctx: TraceContext, teamId: string, currency: string): Promise<void> {
const user = this.checkAndBlockUser("createOrUpdateStripeCustomerForTeam");
const team = await this.guardTeamOperation(teamId, "update");
Expand Down Expand Up @@ -2175,11 +2170,6 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
}
}

async subscribeTeamToStripe(ctx: TraceContext, teamId: string, setupIntentId: string): Promise<void> {
const attributionId: AttributionId = { kind: "team", teamId: teamId };
return this.subscribeToStripe(ctx, AttributionId.render(attributionId), setupIntentId);
}

async getStripePortalUrl(ctx: TraceContext, attributionId: string): Promise<string> {
const attrId = AttributionId.parse(attributionId);
if (attrId === undefined) {
Expand Down Expand Up @@ -2217,11 +2207,6 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
return url;
}

async getStripePortalUrlForTeam(ctx: TraceContext, teamId: string): Promise<string> {
const attributionId: AttributionId = { kind: "team", teamId: teamId };
return this.getStripePortalUrl(ctx, AttributionId.render(attributionId));
}

async getUsageLimit(ctx: TraceContext, attributionId: string): Promise<number | undefined> {
const attrId = AttributionId.parse(attributionId);
if (attrId === undefined) {
Expand Down Expand Up @@ -2279,17 +2264,6 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
this.messageBus.notifyOnSubscriptionUpdate(ctx, attrId).catch();
}

async getUsageLimitForTeam(ctx: TraceContext, teamId: string): Promise<number | undefined> {
const attributionId: AttributionId = { kind: "team", teamId: teamId };

return this.getUsageLimit(ctx, AttributionId.render(attributionId));
}

async setUsageLimitForTeam(ctx: TraceContext, teamId: string, usageLimit: number): Promise<void> {
const attributionId: AttributionId = { kind: "team", teamId: teamId };
return this.setUsageLimit(ctx, AttributionId.render(attributionId), usageLimit);
}

async getNotifications(ctx: TraceContext): Promise<string[]> {
const result = await super.getNotifications(ctx);
const user = this.checkAndBlockUser("getNotifications");
Expand Down
5 changes: 0 additions & 5 deletions components/server/src/auth/rate-limiter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,10 @@ const defaultFunctions: FunctionsConfig = {
getStripePublishableKey: { group: "default", points: 1 },
getStripeSetupIntentClientSecret: { group: "default", points: 1 },
findStripeSubscriptionId: { group: "default", points: 1 },
findStripeSubscriptionIdForTeam: { group: "default", points: 1 },
createOrUpdateStripeCustomerForTeam: { group: "default", points: 1 },
createOrUpdateStripeCustomerForUser: { group: "default", points: 1 },
subscribeToStripe: { group: "default", points: 1 },
subscribeTeamToStripe: { group: "default", points: 1 },
getStripePortalUrl: { group: "default", points: 1 },
getStripePortalUrlForTeam: { group: "default", points: 1 },
listUsage: { group: "default", points: 1 },
getBillingModeForTeam: { group: "default", points: 1 },
getBillingModeForUser: { group: "default", points: 1 },
Expand All @@ -220,8 +217,6 @@ const defaultFunctions: FunctionsConfig = {
setUsageAttribution: { group: "default", points: 1 },
getUsageLimit: { group: "default", points: 1 },
setUsageLimit: { group: "default", points: 1 },
getUsageLimitForTeam: { group: "default", points: 1 },
setUsageLimitForTeam: { group: "default", points: 1 },
getNotifications: { group: "default", points: 1 },
getSupportedWorkspaceClasses: { group: "default", points: 1 },
};
Expand Down
16 changes: 0 additions & 16 deletions components/server/src/workspace/gitpod-server-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3130,24 +3130,15 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
async findStripeSubscriptionId(ctx: TraceContext, attributionId: string): Promise<string | undefined> {
throw new ResponseError(ErrorCodes.SAAS_FEATURE, `Not implemented in this version`);
}
async findStripeSubscriptionIdForTeam(ctx: TraceContext, teamId: string): Promise<string | undefined> {
throw new ResponseError(ErrorCodes.SAAS_FEATURE, `Not implemented in this version`);
}
async createOrUpdateStripeCustomerForTeam(ctx: TraceContext, teamId: string, currency: string): Promise<void> {
throw new ResponseError(ErrorCodes.SAAS_FEATURE, `Not implemented in this version`);
}
async createOrUpdateStripeCustomerForUser(ctx: TraceContext, currency: string): Promise<void> {
throw new ResponseError(ErrorCodes.SAAS_FEATURE, `Not implemented in this version`);
}
async subscribeTeamToStripe(ctx: TraceContext, teamId: string, setupIntentId: string): Promise<void> {
throw new ResponseError(ErrorCodes.SAAS_FEATURE, `Not implemented in this version`);
}
async subscribeToStripe(ctx: TraceContext, attributionId: string, setupIntentId: string): Promise<void> {
throw new ResponseError(ErrorCodes.SAAS_FEATURE, `Not implemented in this version`);
}
async getStripePortalUrlForTeam(ctx: TraceContext, teamId: string): Promise<string> {
throw new ResponseError(ErrorCodes.SAAS_FEATURE, `Not implemented in this version`);
}
async getStripePortalUrl(ctx: TraceContext, attributionId: string): Promise<string> {
throw new ResponseError(ErrorCodes.SAAS_FEATURE, `Not implemented in this version`);
}
Expand All @@ -3164,13 +3155,6 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
throw new ResponseError(ErrorCodes.SAAS_FEATURE, `Not implemented in this version`);
}

async getUsageLimitForTeam(ctx: TraceContext, teamId: string): Promise<number | undefined> {
throw new ResponseError(ErrorCodes.SAAS_FEATURE, `Not implemented in this version`);
}
async setUsageLimitForTeam(ctx: TraceContext, teamId: string, spendingLimit: number): Promise<void> {
throw new ResponseError(ErrorCodes.SAAS_FEATURE, `Not implemented in this version`);
}

async setUsageAttribution(ctx: TraceContext, usageAttributionId: string): Promise<void> {
const user = this.checkAndBlockUser("setUsageAttribution");
try {
Expand Down