-
Notifications
You must be signed in to change notification settings - Fork 916
Adds S3CrossRegion clients and codegen for retrieving bucket name #4008
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
Merged
cenedhryn
merged 3 commits into
cross_region_bucket_access/project_branch
from
salande/crossregion-client-bucket-params
May 17, 2023
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 hidden or 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
47 changes: 47 additions & 0 deletions
47
...ava/software/amazon/awssdk/services/s3/internal/crossregion/S3CrossRegionAsyncClient.java
This file contains hidden or 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,47 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package software.amazon.awssdk.services.s3.internal.crossregion; | ||
|
||
import java.util.Optional; | ||
import java.util.function.Function; | ||
import software.amazon.awssdk.annotations.SdkInternalApi; | ||
import software.amazon.awssdk.services.s3.DelegatingS3AsyncClient; | ||
import software.amazon.awssdk.services.s3.S3AsyncClient; | ||
import software.amazon.awssdk.services.s3.model.S3Request; | ||
|
||
@SdkInternalApi | ||
public final class S3CrossRegionAsyncClient extends DelegatingS3AsyncClient { | ||
|
||
public S3CrossRegionAsyncClient(S3AsyncClient s3Client) { | ||
super(s3Client); | ||
} | ||
|
||
@Override | ||
protected <T extends S3Request, ReturnT> ReturnT invokeOperation(T request, Function<T, ReturnT> operation) { | ||
Optional<String> bucket = request.getValueForField("bucket", String.class); | ||
|
||
if (!bucket.isPresent()) { | ||
return operation.apply(request); | ||
} | ||
|
||
//TODO: add modifyRequest logic | ||
return operation.apply(request); | ||
} | ||
|
||
private void handleOperationFailure(Throwable t, String bucket) { | ||
//TODO: handle failure case | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...java/software/amazon/awssdk/services/s3/internal/crossregion/S3CrossRegionSyncClient.java
This file contains hidden or 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,50 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package software.amazon.awssdk.services.s3.internal.crossregion; | ||
|
||
import java.util.Optional; | ||
import java.util.function.Function; | ||
import software.amazon.awssdk.annotations.SdkInternalApi; | ||
import software.amazon.awssdk.services.s3.DelegatingS3Client; | ||
import software.amazon.awssdk.services.s3.S3Client; | ||
import software.amazon.awssdk.services.s3.model.S3Request; | ||
|
||
@SdkInternalApi | ||
public final class S3CrossRegionSyncClient extends DelegatingS3Client { | ||
|
||
public S3CrossRegionSyncClient(S3Client s3Client) { | ||
super(s3Client); | ||
} | ||
|
||
@Override | ||
protected <T extends S3Request, ReturnT> ReturnT invokeOperation(T request, Function<T, ReturnT> operation) { | ||
Optional<String> bucket = request.getValueForField("bucket", String.class); | ||
|
||
if (bucket.isPresent()) { | ||
try { | ||
operation.apply(request); //TODO: add modifyRequest logic | ||
} catch (Exception e) { | ||
handleOperationFailure(e, bucket.get()); | ||
} | ||
} | ||
|
||
return operation.apply(request); | ||
} | ||
|
||
private void handleOperationFailure(Throwable t, String bucket) { | ||
//TODO: handle failure case | ||
} | ||
} |
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.
Why are we removing these?
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.
They are superfluous since the definition of these are in
SdkServiceClientConfiguration.Builder
.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.
Don't they refine the return type?
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.
It would be backwards-incompatible (and imo, incorrect) to remove them. They have a different return type.
Uh oh!
There was an error while loading. Please reload this page.
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.
Yeah, talked with @cenedhryn offline and they were added back