-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[UBP] Add getUsageLimit
and setUsageLimit
methods to server
#12767
Conversation
started the job as gitpod-build-af-usage-limit-set-get-for-users.2 because the annotations in the pull request description changed |
1b147ee
to
150fcd2
Compare
150fcd2
to
791eea4
Compare
791eea4
to
3a73019
Compare
(get|set)UsageLimitForUser
methods to servergetUsageLimitFor
and setUsageLimitFor
methods to server
5d9e40f
to
d7fbf86
Compare
getUsageLimitFor
and setUsageLimitFor
methods to servergetUsageLimit
and setUsageLimit
methods to server
This has some conflicts to resolve now that #12776 is merged (putting costcenter access behind an API). Moving back to draft until that's done. |
/hold because it's based on #12843 |
In particular avoid the use of `||` against an enum type that can be 0. See: #12767 (comment)
switch (attrId.kind) { | ||
case "team": | ||
const team = await this.guardTeamOperation(attrId.teamId, "update"); | ||
await this.ensureStripeApiIsAllowed({ team }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This checks for m.mode === "usage-based" || (m.mode === "chargebee" && !!m.canUpgradeToUBB)
which seems like I could then change my spendinglimit although I haven't put my credit card into stripe, yet.
Maybe we should reconsider the special 'chargebee' case? What was the idea of it? cc @geropl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove the ensureStripeApiIsAllowed
checks here as well. The check below testing the billingStrategy !== "stripe"
is doing what we need and is more explicit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@svenefftinge Originally, Chargebee and Usage-Limit was strictly independent. After last weeks discussion, they are not anymore.
Let's remove the ensureStripeApiIsAllowed checks here as well.
💯 Agreed!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andrew-farries do you agree to remove the calls to ensureStripeApiIsAllowed
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes; I've removed them in a650ae7
850610e
to
568f5f2
Compare
/unhold because #12843 is merged. |
568f5f2
to
b86fba1
Compare
const user = this.checkAndBlockUser("getUsageLimit"); | ||
if (attrId.kind === "team") { | ||
const team = await this.guardTeamOperation(attrId.teamId, "get"); | ||
await this.ensureStripeApiIsAllowed({ team }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry if I wasn't clear. I meant to remove these calls for both attribution kinds (user and team).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this check aswell.
b86fba1
to
a1b0c95
Compare
a1b0c95
to
f02cdb4
Compare
Needs rebased again now that #12903 landed 😅 |
f02cdb4
to
35e207c
Compare
Add two new methods to the server API for getting and setting usage limits. Both new functions take an attributionId and work for both users and teams. For backwards compatibility, leave the `getUsageLimitForTeam` and `setUsageLimitForTeam` methods as they are still used by the dashboard, but change them to be implemented in terms of the more general `get/set` methods.
35e207c
to
6d9c770
Compare
Also the `guardTeamOperation` call as both are not needed given the `guardCostCenterAccess` call below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
In particular avoid the use of `||` against an enum type that can be 0. See: #12767 (comment)
Description
Add two new methods to the server API for getting and setting usage limits. Both new functions take an attributionId and work for both users and teams.
For backwards compatibility, leave the
getUsageLimitForTeam
andsetUsageLimitForTeam
methods as they are still used by the dashboard, but change them to be implemented in terms of the more generalget/set
methods.Related Issue(s)
Part of #12685
How to test
Gitpod
in the name in the preview environment and sign the team up for usage based pricing.The team usage limit can also be updated from the team billing page.
The usage limits for the team are correctly persisted.
Setting usage limits from the the UI for individual users will be done in a later PR.
Release Notes
Documentation
Werft options: