-
Notifications
You must be signed in to change notification settings - Fork 5
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
[DC-1117] Fix dataset name validation for createSnapshot #1703
Merged
s-rubenstein
merged 15 commits into
develop
from
sr/dc-1117-update-create-snapshot-endpoint
Jun 11, 2024
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
6aedfa6
Fix dataset name validation for createSnapshot
s-rubenstein eca193a
Fetch datasets only once
s-rubenstein fed6d6f
Make source dataset a parameter for createSnapshot flight
s-rubenstein 2187ad2
Only pass around ID
s-rubenstein a73de1a
Store ID
s-rubenstein f88070d
Pull lists
s-rubenstein e6af73c
Fix compilation
s-rubenstein 19e2cd4
Remove old comment
s-rubenstein defe7b5
Fix spotless
s-rubenstein 6175cbc
Fix tests
s-rubenstein a294a32
Merge branch 'develop' into sr/dc-1117-update-create-snapshot-endpoint
s-rubenstein a6b9413
Add bad request exception and content validation
s-rubenstein 41eae96
Fix merge
s-rubenstein 967ac74
Fix merge again and remove unused code
s-rubenstein f129d18
Fix grammar
s-rubenstein File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -174,10 +174,9 @@ public SnapshotService( | |
* @return jobId (flightId) of the job | ||
*/ | ||
public String createSnapshot( | ||
SnapshotRequestModel snapshotRequestModel, AuthenticatedUserRequest userReq) { | ||
SnapshotRequestContentsModel requestContents = snapshotRequestModel.getContents().get(0); | ||
String sourceDatasetName = requestContents.getDatasetName(); | ||
Dataset dataset = datasetService.retrieveByName(sourceDatasetName); | ||
SnapshotRequestModel snapshotRequestModel, | ||
Dataset dataset, | ||
AuthenticatedUserRequest userReq) { | ||
if (snapshotRequestModel.getProfileId() == null) { | ||
snapshotRequestModel.setProfileId(dataset.getDefaultProfileId()); | ||
logger.warn( | ||
|
@@ -200,9 +199,7 @@ public String createSnapshot( | |
return jobService | ||
.newJob(description, SnapshotCreateFlight.class, snapshotRequestModel, userReq) | ||
.addParameter(CommonMapKeys.CREATED_AT, Instant.now().toEpochMilli()) | ||
.addParameter(JobMapKeys.IAM_RESOURCE_TYPE.getKeyName(), IamResourceType.DATASET) | ||
.addParameter(JobMapKeys.IAM_RESOURCE_ID.getKeyName(), dataset.getId()) | ||
.addParameter(JobMapKeys.IAM_ACTION.getKeyName(), IamAction.LINK_SNAPSHOT) | ||
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. are you removing these keys because they aren't used anywhere? 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. Yes |
||
.addParameter(JobMapKeys.DATASET_ID.getKeyName(), dataset.getId()) | ||
.addParameter(JobMapKeys.SNAPSHOT_ID.getKeyName(), snapshotId.toString()) | ||
.submit(); | ||
} | ||
|
@@ -653,26 +650,15 @@ public static AssetSpecification getAssetByNameFromDataset(Dataset dataset, Stri | |
"This dataset does not have an asset specification with name: " + assetName)); | ||
} | ||
|
||
public List<UUID> getSourceDatasetIdsFromSnapshotRequest( | ||
SnapshotRequestModel snapshotRequestModel) { | ||
return getSourceDatasetsFromSnapshotRequest(snapshotRequestModel).stream() | ||
.map(Dataset::getId) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
public List<Dataset> getSourceDatasetsFromSnapshotRequest( | ||
SnapshotRequestModel snapshotRequestModel) { | ||
return snapshotRequestModel.getContents().stream() | ||
.map( | ||
c -> | ||
c.getMode() == SnapshotRequestContentsModel.ModeEnum.BYREQUESTID | ||
? retrieve( | ||
snapshotRequestDao | ||
.getById(c.getRequestIdSpec().getSnapshotRequestId()) | ||
.getSourceSnapshotId()) | ||
.getSourceDataset() | ||
: datasetService.retrieveByName(c.getDatasetName())) | ||
.collect(Collectors.toList()); | ||
public Dataset getSourceDatasetFromSnapshotRequest(SnapshotRequestModel snapshotRequestModel) { | ||
SnapshotRequestContentsModel contents = snapshotRequestModel.getContents().get(0); | ||
return contents.getMode() == SnapshotRequestContentsModel.ModeEnum.BYREQUESTID | ||
? retrieve( | ||
snapshotRequestDao | ||
.getById(contents.getRequestIdSpec().getSnapshotRequestId()) | ||
.getSourceSnapshotId()) | ||
.getSourceDataset() | ||
: datasetService.retrieveByName(contents.getDatasetName()); | ||
} | ||
|
||
public AddAuthDomainResponseModel addSnapshotDataAccessControls( | ||
|
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
can this be dataset-name and dataset-id?
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.
No, cause that would make it different than existing labels. And I don't think I have confidence that users don't have workflows that fetch their google resources and check these labels. If we wanted to do that we would have to roll it out as a breaking change.
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.
maybe this is something that could happen as part of the V2 endpoint change