-
Notifications
You must be signed in to change notification settings - Fork 5
[DT-1361]SnapshotCreateFlight: Create new steps to replace AuthorizeBillingProfileUseStep #1958
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,8 +34,10 @@ | |
import bio.terra.service.policy.PolicyService; | ||
import bio.terra.service.profile.ProfileService; | ||
import bio.terra.service.profile.flight.AuthorizeBillingProfileUseStep; | ||
import bio.terra.service.profile.flight.AuthorizeRawlsBillingProjectsUseStep; | ||
import bio.terra.service.profile.flight.VerifyBillingAccountAccessStep; | ||
import bio.terra.service.profile.google.GoogleBillingService; | ||
import bio.terra.service.rawls.RawlsService; | ||
import bio.terra.service.resourcemanagement.BufferService; | ||
import bio.terra.service.resourcemanagement.ResourceService; | ||
import bio.terra.service.resourcemanagement.azure.AzureAuthService; | ||
|
@@ -109,6 +111,7 @@ public SnapshotCreateFlight(FlightMap inputParameters, Object applicationContext | |
SnapshotBuilderService snapshotBuilderService = | ||
appContext.getBean(SnapshotBuilderService.class); | ||
IamService iamService = appContext.getBean(IamService.class); | ||
RawlsService rawlsService = appContext.getBean(RawlsService.class); | ||
|
||
SnapshotRequestModel snapshotReq = | ||
inputParameters.get(JobMapKeys.REQUEST.getKeyName(), SnapshotRequestModel.class); | ||
|
@@ -140,13 +143,25 @@ public SnapshotCreateFlight(FlightMap inputParameters, Object applicationContext | |
var platform = | ||
CloudPlatformWrapper.of(sourceDataset.getDatasetSummary().getStorageCloudPlatform()); | ||
|
||
boolean isTdrBillingProfile = | ||
inputParameters.get(JobMapKeys.TDR_BILLING_PROFILE_FALLBACK.getKeyName(), Boolean.class); | ||
|
||
// Take out a shared lock on the source dataset, to guard against it being deleted out from | ||
// under us (for example) | ||
addStep(new LockDatasetStep(datasetService, datasetId, true), randomBackoffRetry); | ||
|
||
// Make sure this user is authorized to use the billing profile in SAM | ||
addStep( | ||
new AuthorizeBillingProfileUseStep(profileService, snapshotReq.getProfileId(), userReq)); | ||
if (isTdrBillingProfile) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This now duplicates the code in Another benefit (or shortcoming, depending on how you look at it) of this refactoring is that changing |
||
// If using TDR billing profile, make sure this user is authorized to use the billing profile | ||
// in Sam | ||
addStep( | ||
new AuthorizeBillingProfileUseStep(profileService, snapshotReq.getProfileId(), userReq)); | ||
} else { | ||
// If using Rawls billing project, make sure this user is authorized to use the billing | ||
// project in Sam | ||
addStep( | ||
new AuthorizeRawlsBillingProjectsUseStep( | ||
rawlsService, snapshotReq.getProfileId(), userReq)); | ||
} | ||
|
||
if (platform.isGcp()) { | ||
addStep(new VerifyBillingAccountAccessStep(googleBillingService)); | ||
|
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.
Up to you, but now that this is a function you can use
return
here and in thecatch
and removeisTdrBillingProfile
from the function.