Search in sources :

Example 1 with SpendProfile

use of bio.terra.workspace.service.spendprofile.SpendProfile in project terra-workspace-manager by DataBiosphere.

the class CheckSpendProfileStep method doStep.

@Override
public StepResult doStep(FlightContext context) throws InterruptedException, RetryException {
    FlightMap workingMap = context.getWorkingMap();
    Workspace workspace = workspaceDao.getWorkspace(workspaceId);
    SpendProfileId spendProfileId = workspace.getSpendProfileId().orElseThrow(() -> MissingSpendProfileException.forWorkspace(workspaceId));
    SpendProfile spendProfile = spendProfileService.authorizeLinking(spendProfileId, userRequest);
    if (spendProfile.billingAccountId().isEmpty()) {
        throw NoBillingAccountException.forSpendProfile(spendProfileId);
    }
    workingMap.put(BILLING_ACCOUNT_ID, spendProfile.billingAccountId());
    return StepResult.getStepResultSuccess();
}
Also used : FlightMap(bio.terra.stairway.FlightMap) SpendProfileId(bio.terra.workspace.service.spendprofile.SpendProfileId) Workspace(bio.terra.workspace.service.workspace.model.Workspace) SpendProfile(bio.terra.workspace.service.spendprofile.SpendProfile)

Aggregations

FlightMap (bio.terra.stairway.FlightMap)1 SpendProfile (bio.terra.workspace.service.spendprofile.SpendProfile)1 SpendProfileId (bio.terra.workspace.service.spendprofile.SpendProfileId)1 Workspace (bio.terra.workspace.service.workspace.model.Workspace)1