-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[risk=low][no ticket] Centralize billing account naming logic (#8790)
- Loading branch information
1 parent
4638011
commit 40259ff
Showing
27 changed files
with
122 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
api/src/main/java/org/pmiops/workbench/utils/BillingUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.pmiops.workbench.utils; | ||
|
||
import org.pmiops.workbench.config.WorkbenchConfig; | ||
import org.pmiops.workbench.model.BillingAccountType; | ||
|
||
public class BillingUtils { | ||
private BillingUtils() {} | ||
|
||
public static final String BILLING_ACCOUNT_PREFIX = "billingAccounts"; | ||
|
||
public static String fullBillingAccountName(String billingAccount) { | ||
return BILLING_ACCOUNT_PREFIX + "/" + billingAccount; | ||
} | ||
|
||
/** | ||
* Returns {@code true} if the given billing account is workbench initial credits billing account. | ||
*/ | ||
public static boolean isInitialCredits( | ||
String billingAccountName, WorkbenchConfig workbenchConfig) { | ||
return workbenchConfig.billing.initialCreditsBillingAccountName().equals(billingAccountName); | ||
} | ||
|
||
/** Returns {@code BillingAccountType} by given billing account name. */ | ||
public static BillingAccountType getBillingAccountType( | ||
String billingAccountName, WorkbenchConfig workbenchConfig) { | ||
return isInitialCredits(billingAccountName, workbenchConfig) | ||
? BillingAccountType.FREE_TIER | ||
: BillingAccountType.USER_PROVIDED; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 0 additions & 22 deletions
22
api/src/main/java/org/pmiops/workbench/workspaces/WorkspaceUtils.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.