-
Notifications
You must be signed in to change notification settings - Fork 645
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
S3: Bucket management #1608
Merged
Merged
S3: Bucket management #1608
Changes from all commits
Commits
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
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 |
---|---|---|
|
@@ -12,6 +12,7 @@ import akka.http.javadsl.model._ | |
import akka.http.javadsl.model.headers.ByteRange | ||
import akka.http.scaladsl.model.headers.{ByteRange => ScalaByteRange} | ||
import akka.http.scaladsl.model.{ContentType => ScalaContentType, HttpMethod => ScalaHttpMethod} | ||
import akka.stream.{Attributes, Materializer} | ||
import akka.stream.alpakka.s3.headers.{CannedAcl, ServerSideEncryption} | ||
import akka.stream.alpakka.s3.impl._ | ||
import akka.stream.alpakka.s3._ | ||
|
@@ -324,7 +325,7 @@ object S3 { | |
* @param key the s3 object key | ||
* @param contentType an optional [[akka.http.javadsl.model.ContentType ContentType]] | ||
* @param s3Headers any headers you want to add | ||
* @return a [[akka.stream.javadsl.Sink Sink]] that accepts [[akka.util.ByteString ByteString]]'s and materializes to a [[ava.util.concurrent.CompletionStage CompletionStage]] of [[MultipartUploadResult]] | ||
* @return a [[akka.stream.javadsl.Sink Sink]] that accepts [[akka.util.ByteString ByteString]]'s and materializes to a [[java.util.concurrent.CompletionStage CompletionStage]] of [[MultipartUploadResult]] | ||
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. Thank you! |
||
*/ | ||
def multipartUpload(bucket: String, | ||
key: String, | ||
|
@@ -353,7 +354,7 @@ object S3 { | |
* | ||
* @param bucket the s3 bucket name | ||
* @param key the s3 object key | ||
* @return a [[akka.stream.javadsl.Sink Sink]] that accepts [[akka.util.ByteString ByteString]]'s and materializes to a [[ava.util.concurrent.CompletionStage CompletionStage]] of [[MultipartUploadResult]] | ||
* @return a [[akka.stream.javadsl.Sink Sink]] that accepts [[akka.util.ByteString ByteString]]'s and materializes to a [[java.util.concurrent.CompletionStage CompletionStage]] of [[MultipartUploadResult]] | ||
*/ | ||
def multipartUpload(bucket: String, key: String): Sink[ByteString, CompletionStage[MultipartUploadResult]] = | ||
multipartUpload(bucket, key, ContentTypes.APPLICATION_OCTET_STREAM) | ||
|
@@ -466,6 +467,107 @@ object S3 { | |
targetKey: String): RunnableGraph[CompletionStage[MultipartUploadResult]] = | ||
multipartCopy(sourceBucket, sourceKey, targetBucket, targetKey, ContentTypes.APPLICATION_OCTET_STREAM, S3Headers()) | ||
|
||
/** | ||
* Create new bucket with a given name | ||
* | ||
* @see https://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUT.html | ||
* @param bucketName bucket name | ||
* @param materializer materializer to run with | ||
* @param attributes attributes to run request with | ||
* @return [[java.util.concurrent.CompletionStage CompletionStage]] of type [[Done]] as API doesn't return any additional information | ||
*/ | ||
def makeBucket(bucketName: String, materializer: Materializer, attributes: Attributes): CompletionStage[Done] = | ||
S3Stream.makeBucket(bucketName)(materializer, attributes).toJava | ||
|
||
/** | ||
* Create new bucket with a given name | ||
* | ||
* @see https://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUT.html | ||
* @param bucketName bucket name | ||
* @param materializer materializer to run with | ||
* @return [[java.util.concurrent.CompletionStage CompletionStage]] of type [[Done]] as API doesn't return any additional information | ||
*/ | ||
def makeBucket(bucketName: String, materializer: Materializer): CompletionStage[Done] = | ||
S3Stream.makeBucket(bucketName)(materializer, Attributes()).toJava | ||
|
||
/** | ||
* Create new bucket with a given name | ||
* | ||
* @see https://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUT.html | ||
* @param bucketName bucket name | ||
* @return [[akka.stream.javadsl.Source Source]] of type [[Done]] as API doesn't return any additional information | ||
*/ | ||
def makeBucketSource(bucketName: String): Source[Done, NotUsed] = | ||
S3Stream.makeBucketSource(bucketName).asJava | ||
|
||
/** | ||
* Delete bucket with a given name | ||
* | ||
* @see https://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketDELETE.html | ||
* @param bucketName bucket name | ||
* @param materializer materializer to run with | ||
* @param attributes attributes to run request with | ||
* @return [[java.util.concurrent.CompletionStage CompletionStage]] of type [[Done]] as API doesn't return any additional information | ||
*/ | ||
def deleteBucket(bucketName: String, materializer: Materializer, attributes: Attributes): CompletionStage[Done] = | ||
S3Stream.deleteBucket(bucketName)(materializer, attributes).toJava | ||
|
||
/** | ||
* Delete bucket with a given name | ||
* | ||
* @see https://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketDELETE.html | ||
* @param bucketName bucket name | ||
* @param materializer materializer to run with | ||
* @return [[java.util.concurrent.CompletionStage CompletionStage]] of type [[Done]] as API doesn't return any additional information | ||
*/ | ||
def deleteBucket(bucketName: String, materializer: Materializer): CompletionStage[Done] = | ||
S3Stream.deleteBucket(bucketName)(materializer, Attributes()).toJava | ||
|
||
/** | ||
* Delete bucket with a given name | ||
* | ||
* @see https://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketDELETE.html | ||
* @param bucketName bucket name | ||
* @return [[akka.stream.javadsl.Source Source]] of type [[Done]] as API doesn't return any additional information | ||
*/ | ||
def deleteBucketSource(bucketName: String): Source[Done, NotUsed] = | ||
S3Stream.deleteBucketSource(bucketName).asJava | ||
|
||
/** | ||
* Checks whether the bucket exists and the user has rights to perform the `ListBucket` operation | ||
* | ||
* @see https://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketHEAD.html | ||
* @param bucketName bucket name | ||
* @param materializer materializer to run with | ||
* @param attributes attributes to run request with | ||
* @return [[java.util.concurrent.CompletionStage CompletionStage]] of type [[BucketAccess]] | ||
*/ | ||
def checkIfBucketExists(bucketName: String, | ||
materializer: Materializer, | ||
attributes: Attributes): CompletionStage[BucketAccess] = | ||
S3Stream.checkIfBucketExists(bucketName)(materializer, attributes).toJava | ||
|
||
/** | ||
* Checks whether the bucket exits and user has rights to perform ListBucket operation | ||
* | ||
* @see https://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketHEAD.html | ||
* @param bucketName bucket name | ||
* @param materializer materializer to run with | ||
* @return [[java.util.concurrent.CompletionStage CompletionStage]] of type [[BucketAccess]] | ||
*/ | ||
def checkIfBucketExists(bucketName: String, materializer: Materializer): CompletionStage[BucketAccess] = | ||
S3Stream.checkIfBucketExists(bucketName)(materializer, Attributes()).toJava | ||
|
||
/** | ||
* Checks whether the bucket exits and user has rights to perform ListBucket operation | ||
* | ||
* @see https://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketHEAD.html | ||
* @param bucketName bucket name | ||
* @return [[akka.stream.javadsl.Source Source]] of type [[BucketAccess]] | ||
*/ | ||
def checkIfBucketExistsSource(bucketName: String): Source[BucketAccess, NotUsed] = | ||
S3Stream.checkIfBucketExistsSource(bucketName).asJava | ||
|
||
private def func[T, R](f: T => R) = new akka.japi.function.Function[T, R] { | ||
override def apply(param: T): R = f(param) | ||
} | ||
|
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.
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.
The link seems to be the wrong one (cloudtrail), guess this is the right one ? -> https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html#bucketnamingrules
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.
Yes, thank you for noticing. My bad on not checking it before merging. I will submit another PR tomorrow referencing that issue