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();
}
Aggregations