From 9a37d48e75aacbc29ab44a0fd4bbab1e7a78b247 Mon Sep 17 00:00:00 2001 From: Andrew Farries Date: Wed, 14 Sep 2022 07:58:28 +0000 Subject: [PATCH 1/4] Remove `subscribeTeamToStripe` method --- components/gitpod-protocol/src/gitpod-service.ts | 1 - components/server/ee/src/workspace/gitpod-server-impl.ts | 5 ----- components/server/src/auth/rate-limiter.ts | 1 - components/server/src/workspace/gitpod-server-impl.ts | 3 --- 4 files changed, 10 deletions(-) diff --git a/components/gitpod-protocol/src/gitpod-service.ts b/components/gitpod-protocol/src/gitpod-service.ts index 42d6c3e663e6d4..dafefcb6f01577 100644 --- a/components/gitpod-protocol/src/gitpod-service.ts +++ b/components/gitpod-protocol/src/gitpod-service.ts @@ -291,7 +291,6 @@ export interface GitpodServer extends JsonRpcServer, AdminServer, createOrUpdateStripeCustomerForTeam(teamId: string, currency: string): Promise; createOrUpdateStripeCustomerForUser(currency: string): Promise; subscribeToStripe(attributionId: string, setupIntentId: string): Promise; - subscribeTeamToStripe(teamId: string, setupIntentId: string): Promise; getStripePortalUrl(attributionId: string): Promise; getStripePortalUrlForTeam(teamId: string): Promise; getUsageLimit(attributionId: string): Promise; diff --git a/components/server/ee/src/workspace/gitpod-server-impl.ts b/components/server/ee/src/workspace/gitpod-server-impl.ts index 851d74dd076eca..75c7d9df867940 100644 --- a/components/server/ee/src/workspace/gitpod-server-impl.ts +++ b/components/server/ee/src/workspace/gitpod-server-impl.ts @@ -2175,11 +2175,6 @@ export class GitpodServerEEImpl extends GitpodServerImpl { } } - async subscribeTeamToStripe(ctx: TraceContext, teamId: string, setupIntentId: string): Promise { - const attributionId: AttributionId = { kind: "team", teamId: teamId }; - return this.subscribeToStripe(ctx, AttributionId.render(attributionId), setupIntentId); - } - async getStripePortalUrl(ctx: TraceContext, attributionId: string): Promise { const attrId = AttributionId.parse(attributionId); if (attrId === undefined) { diff --git a/components/server/src/auth/rate-limiter.ts b/components/server/src/auth/rate-limiter.ts index 1919d8c2e71927..5effeed2b60843 100644 --- a/components/server/src/auth/rate-limiter.ts +++ b/components/server/src/auth/rate-limiter.ts @@ -205,7 +205,6 @@ const defaultFunctions: FunctionsConfig = { 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 }, diff --git a/components/server/src/workspace/gitpod-server-impl.ts b/components/server/src/workspace/gitpod-server-impl.ts index 1d54f58867f9eb..f726662e198877 100644 --- a/components/server/src/workspace/gitpod-server-impl.ts +++ b/components/server/src/workspace/gitpod-server-impl.ts @@ -3139,9 +3139,6 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable { async createOrUpdateStripeCustomerForUser(ctx: TraceContext, currency: string): Promise { throw new ResponseError(ErrorCodes.SAAS_FEATURE, `Not implemented in this version`); } - async subscribeTeamToStripe(ctx: TraceContext, teamId: string, setupIntentId: string): Promise { - throw new ResponseError(ErrorCodes.SAAS_FEATURE, `Not implemented in this version`); - } async subscribeToStripe(ctx: TraceContext, attributionId: string, setupIntentId: string): Promise { throw new ResponseError(ErrorCodes.SAAS_FEATURE, `Not implemented in this version`); } From 8a21b2717a7c6680e06f440880bb66aefab46585 Mon Sep 17 00:00:00 2001 From: Andrew Farries Date: Wed, 14 Sep 2022 08:01:05 +0000 Subject: [PATCH 2/4] Remove `getStripePortalUrlForTeam` method --- components/gitpod-protocol/src/gitpod-service.ts | 1 - components/server/ee/src/workspace/gitpod-server-impl.ts | 5 ----- components/server/src/auth/rate-limiter.ts | 1 - components/server/src/workspace/gitpod-server-impl.ts | 3 --- 4 files changed, 10 deletions(-) diff --git a/components/gitpod-protocol/src/gitpod-service.ts b/components/gitpod-protocol/src/gitpod-service.ts index dafefcb6f01577..793bd12766dba7 100644 --- a/components/gitpod-protocol/src/gitpod-service.ts +++ b/components/gitpod-protocol/src/gitpod-service.ts @@ -292,7 +292,6 @@ export interface GitpodServer extends JsonRpcServer, AdminServer, createOrUpdateStripeCustomerForUser(currency: string): Promise; subscribeToStripe(attributionId: string, setupIntentId: string): Promise; getStripePortalUrl(attributionId: string): Promise; - getStripePortalUrlForTeam(teamId: string): Promise; getUsageLimit(attributionId: string): Promise; setUsageLimit(attributionId: string, usageLimit: number): Promise; getUsageLimitForTeam(teamId: string): Promise; diff --git a/components/server/ee/src/workspace/gitpod-server-impl.ts b/components/server/ee/src/workspace/gitpod-server-impl.ts index 75c7d9df867940..9fbf52754278a3 100644 --- a/components/server/ee/src/workspace/gitpod-server-impl.ts +++ b/components/server/ee/src/workspace/gitpod-server-impl.ts @@ -2212,11 +2212,6 @@ export class GitpodServerEEImpl extends GitpodServerImpl { return url; } - async getStripePortalUrlForTeam(ctx: TraceContext, teamId: string): Promise { - const attributionId: AttributionId = { kind: "team", teamId: teamId }; - return this.getStripePortalUrl(ctx, AttributionId.render(attributionId)); - } - async getUsageLimit(ctx: TraceContext, attributionId: string): Promise { const attrId = AttributionId.parse(attributionId); if (attrId === undefined) { diff --git a/components/server/src/auth/rate-limiter.ts b/components/server/src/auth/rate-limiter.ts index 5effeed2b60843..e3d7449ae14158 100644 --- a/components/server/src/auth/rate-limiter.ts +++ b/components/server/src/auth/rate-limiter.ts @@ -206,7 +206,6 @@ const defaultFunctions: FunctionsConfig = { createOrUpdateStripeCustomerForUser: { group: "default", points: 1 }, subscribeToStripe: { 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 }, diff --git a/components/server/src/workspace/gitpod-server-impl.ts b/components/server/src/workspace/gitpod-server-impl.ts index f726662e198877..7910f153d98d1a 100644 --- a/components/server/src/workspace/gitpod-server-impl.ts +++ b/components/server/src/workspace/gitpod-server-impl.ts @@ -3142,9 +3142,6 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable { async subscribeToStripe(ctx: TraceContext, attributionId: string, setupIntentId: string): Promise { throw new ResponseError(ErrorCodes.SAAS_FEATURE, `Not implemented in this version`); } - async getStripePortalUrlForTeam(ctx: TraceContext, teamId: string): Promise { - throw new ResponseError(ErrorCodes.SAAS_FEATURE, `Not implemented in this version`); - } async getStripePortalUrl(ctx: TraceContext, attributionId: string): Promise { throw new ResponseError(ErrorCodes.SAAS_FEATURE, `Not implemented in this version`); } From 0e441e7d99b1e9f48c4681e1198c3689642a61a1 Mon Sep 17 00:00:00 2001 From: Andrew Farries Date: Wed, 14 Sep 2022 08:03:46 +0000 Subject: [PATCH 3/4] Remove `get/setUsageLimitForTeam` methods --- components/gitpod-protocol/src/gitpod-service.ts | 2 -- .../server/ee/src/workspace/gitpod-server-impl.ts | 11 ----------- components/server/src/auth/rate-limiter.ts | 2 -- components/server/src/workspace/gitpod-server-impl.ts | 7 ------- 4 files changed, 22 deletions(-) diff --git a/components/gitpod-protocol/src/gitpod-service.ts b/components/gitpod-protocol/src/gitpod-service.ts index 793bd12766dba7..35f28782d4296c 100644 --- a/components/gitpod-protocol/src/gitpod-service.ts +++ b/components/gitpod-protocol/src/gitpod-service.ts @@ -294,8 +294,6 @@ export interface GitpodServer extends JsonRpcServer, AdminServer, getStripePortalUrl(attributionId: string): Promise; getUsageLimit(attributionId: string): Promise; setUsageLimit(attributionId: string, usageLimit: number): Promise; - getUsageLimitForTeam(teamId: string): Promise; - setUsageLimitForTeam(teamId: string, spendingLimit: number): Promise; listUsage(req: ListUsageRequest): Promise; diff --git a/components/server/ee/src/workspace/gitpod-server-impl.ts b/components/server/ee/src/workspace/gitpod-server-impl.ts index 9fbf52754278a3..72ea0fb5c94320 100644 --- a/components/server/ee/src/workspace/gitpod-server-impl.ts +++ b/components/server/ee/src/workspace/gitpod-server-impl.ts @@ -2269,17 +2269,6 @@ export class GitpodServerEEImpl extends GitpodServerImpl { this.messageBus.notifyOnSubscriptionUpdate(ctx, attrId).catch(); } - async getUsageLimitForTeam(ctx: TraceContext, teamId: string): Promise { - const attributionId: AttributionId = { kind: "team", teamId: teamId }; - - return this.getUsageLimit(ctx, AttributionId.render(attributionId)); - } - - async setUsageLimitForTeam(ctx: TraceContext, teamId: string, usageLimit: number): Promise { - const attributionId: AttributionId = { kind: "team", teamId: teamId }; - return this.setUsageLimit(ctx, AttributionId.render(attributionId), usageLimit); - } - async getNotifications(ctx: TraceContext): Promise { const result = await super.getNotifications(ctx); const user = this.checkAndBlockUser("getNotifications"); diff --git a/components/server/src/auth/rate-limiter.ts b/components/server/src/auth/rate-limiter.ts index e3d7449ae14158..86fe3fdc5592ab 100644 --- a/components/server/src/auth/rate-limiter.ts +++ b/components/server/src/auth/rate-limiter.ts @@ -218,8 +218,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 }, }; diff --git a/components/server/src/workspace/gitpod-server-impl.ts b/components/server/src/workspace/gitpod-server-impl.ts index 7910f153d98d1a..0042b734727d05 100644 --- a/components/server/src/workspace/gitpod-server-impl.ts +++ b/components/server/src/workspace/gitpod-server-impl.ts @@ -3158,13 +3158,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 { - throw new ResponseError(ErrorCodes.SAAS_FEATURE, `Not implemented in this version`); - } - async setUsageLimitForTeam(ctx: TraceContext, teamId: string, spendingLimit: number): Promise { - throw new ResponseError(ErrorCodes.SAAS_FEATURE, `Not implemented in this version`); - } - async setUsageAttribution(ctx: TraceContext, usageAttributionId: string): Promise { const user = this.checkAndBlockUser("setUsageAttribution"); try { From 0a1bb73f9cd84312aa1db5955d47e057988a2c64 Mon Sep 17 00:00:00 2001 From: Andrew Farries Date: Wed, 14 Sep 2022 11:55:56 +0000 Subject: [PATCH 4/4] Remove `findStripeSubscriptionIdForTeam` method --- components/gitpod-protocol/src/gitpod-service.ts | 1 - components/server/ee/src/workspace/gitpod-server-impl.ts | 5 ----- components/server/src/auth/rate-limiter.ts | 1 - components/server/src/workspace/gitpod-server-impl.ts | 3 --- 4 files changed, 10 deletions(-) diff --git a/components/gitpod-protocol/src/gitpod-service.ts b/components/gitpod-protocol/src/gitpod-service.ts index 35f28782d4296c..27334ac2fd50c0 100644 --- a/components/gitpod-protocol/src/gitpod-service.ts +++ b/components/gitpod-protocol/src/gitpod-service.ts @@ -287,7 +287,6 @@ export interface GitpodServer extends JsonRpcServer, AdminServer, getStripePublishableKey(): Promise; getStripeSetupIntentClientSecret(): Promise; findStripeSubscriptionId(attributionId: string): Promise; - findStripeSubscriptionIdForTeam(teamId: string): Promise; createOrUpdateStripeCustomerForTeam(teamId: string, currency: string): Promise; createOrUpdateStripeCustomerForUser(currency: string): Promise; subscribeToStripe(attributionId: string, setupIntentId: string): Promise; diff --git a/components/server/ee/src/workspace/gitpod-server-impl.ts b/components/server/ee/src/workspace/gitpod-server-impl.ts index 72ea0fb5c94320..6130d5e8837fb2 100644 --- a/components/server/ee/src/workspace/gitpod-server-impl.ts +++ b/components/server/ee/src/workspace/gitpod-server-impl.ts @@ -2087,11 +2087,6 @@ export class GitpodServerEEImpl extends GitpodServerImpl { } } - async findStripeSubscriptionIdForTeam(ctx: TraceContext, teamId: string): Promise { - const attributionId: AttributionId = { kind: "team", teamId: teamId }; - return this.findStripeSubscriptionId(ctx, AttributionId.render(attributionId)); - } - async createOrUpdateStripeCustomerForTeam(ctx: TraceContext, teamId: string, currency: string): Promise { const user = this.checkAndBlockUser("createOrUpdateStripeCustomerForTeam"); const team = await this.guardTeamOperation(teamId, "update"); diff --git a/components/server/src/auth/rate-limiter.ts b/components/server/src/auth/rate-limiter.ts index 86fe3fdc5592ab..245ef48f627755 100644 --- a/components/server/src/auth/rate-limiter.ts +++ b/components/server/src/auth/rate-limiter.ts @@ -201,7 +201,6 @@ 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 }, diff --git a/components/server/src/workspace/gitpod-server-impl.ts b/components/server/src/workspace/gitpod-server-impl.ts index 0042b734727d05..affb78333435a1 100644 --- a/components/server/src/workspace/gitpod-server-impl.ts +++ b/components/server/src/workspace/gitpod-server-impl.ts @@ -3130,9 +3130,6 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable { async findStripeSubscriptionId(ctx: TraceContext, attributionId: string): Promise { throw new ResponseError(ErrorCodes.SAAS_FEATURE, `Not implemented in this version`); } - async findStripeSubscriptionIdForTeam(ctx: TraceContext, teamId: string): Promise { - throw new ResponseError(ErrorCodes.SAAS_FEATURE, `Not implemented in this version`); - } async createOrUpdateStripeCustomerForTeam(ctx: TraceContext, teamId: string, currency: string): Promise { throw new ResponseError(ErrorCodes.SAAS_FEATURE, `Not implemented in this version`); }