-
Notifications
You must be signed in to change notification settings - Fork 41
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
feature(aws-s3-connector): AWS s3 connector #3744
Conversation
f771d56
to
c0c81b1
Compare
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.
Some questions, overall great!
@ElementTemplate.PropertyGroup(id = "uploadObject", label = "Upload an object"), | ||
@ElementTemplate.PropertyGroup(id = "downloadObject", label = "Download an object"), | ||
}, | ||
documentationRef = "https://docs.camunda.io/docs/", |
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 forget to update this link
feel = Property.FeelMode.optional, | ||
binding = @TemplateProperty.PropertyBinding(name = "action.bucket")) | ||
@Valid | ||
@NotNull |
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.
NotBlank ?
tooltip = "Bucket from where an object should be deleted", | ||
feel = Property.FeelMode.optional, | ||
binding = @TemplateProperty.PropertyBinding(name = "action.bucket")) | ||
@Valid |
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.
Not needed I guess
tooltip = "Key of the object which should be deleted", | ||
feel = Property.FeelMode.optional, | ||
binding = @TemplateProperty.PropertyBinding(name = "action.key")) | ||
@Valid |
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.
same
label = "Create document", | ||
id = "downloadActionAsFile", | ||
group = "downloadObject", | ||
tooltip = "....", |
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.
todo ?
import software.amazon.awssdk.services.s3.model.GetObjectResponse; | ||
import software.amazon.awssdk.services.s3.model.PutObjectRequest; | ||
|
||
public class S3Executor { |
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 can we move the response
package in the model
package, not sure how we do usually
@MethodSource("loadUploadActionVariables") | ||
void executeUploadActionReturnsCorrectResult(String variables) { | ||
|
||
var bedrockConnectorFunction = new S3ConnectorFunction(); |
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.
should rename this :p
@MethodSource("loadDownloadActionVariables") | ||
void executeDownloadActionReturnsCorrectResult(String variables) { | ||
|
||
var bedrockConnectorFunction = new S3ConnectorFunction(); |
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.
same
@MethodSource("loadDeleteActionVariables") | ||
void executeDeleteActionReturnsCorrectResult(String variables) { | ||
|
||
var bedrockConnectorFunction = new S3ConnectorFunction(); |
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.
same
|
||
public class BaseTest { | ||
|
||
public static Stream<String> loadUploadActionVariables() { |
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.
What about creating integration tests using https://java.testcontainers.org/modules/localstack/?
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, I might created a separated PR for integration tests.
74ead97
to
cfe069d
Compare
QA informationTest Environment
Test ScopePlease describe the test scope, happy path, edge cases that come to your mind, and whatever you think might relevant to test Test DataPlease provide the test data, if needed (files, URLs, code snippets, FEEL expressions) |
"value" : "uploadObject", | ||
"group" : "action", | ||
"binding" : { | ||
"name" : "actionDiscriminator", |
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.
Shouldnt this be part of the action
object? Like:
{ "action": {"type":"upload", ...}}
public S3Action getData() { | ||
return action; | ||
} |
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 do we call this getData and not getAction?
@TemplateSubType(id = "uploadObject", label = "Upload document") | ||
public record UploadS3Action( |
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.
We now have 3 names 😄
id: uploadObject
,
label: Upload document
record: UploadS3Action
Should we go with a single one? Either PutObject
or UploadObject
?
|
||
import io.camunda.document.Document; | ||
|
||
public record DownloadResponse(String bucket, String key, Document document, Object content) {} |
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.
@mathias-vandaele Is it either a Document
or the content
?
If so please create a simple sealed type which indicates that.
switch (bodyPart.getContent()) { | ||
case InputStream attachment when bodyPart | ||
.getDisposition() | ||
.equalsIgnoreCase(Part.ATTACHMENT) -> | ||
case InputStream attachment when Part.ATTACHMENT.equalsIgnoreCase( | ||
bodyPart.getDisposition()) -> | ||
emailBodyBuilder.addAttachment( | ||
new EmailAttachment( | ||
attachment, | ||
bodyPart.getFileName(), | ||
new ContentType(bodyPart.getContentType()).getBaseType())); | ||
case String textAttachment when Part.ATTACHMENT.equalsIgnoreCase(bodyPart.getDisposition()) -> |
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.
Is this change related to S3?
809fa3f
to
ecc2b88
Compare
058a8c3
to
f122b34
Compare
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.
One question, but happy to approve :)
return new UploadResponse( | ||
uploadObject.bucket(), | ||
uploadObject.key(), | ||
String.format("https://%s.s3.amazonaws.com/%s", uploadObject.bucket(), uploadObject.key())); |
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.
we can prob introduce a constant here
String bucket, String key, ResponseInputStream<GetObjectResponse> responseResponseInputStream) | ||
throws IOException { | ||
byte[] rawBytes = responseResponseInputStream.readAllBytes(); | ||
return switch (responseResponseInputStream.response().contentType()) { |
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.
not sure here, but be aware that sometimes the case is weird (uppercase letters etc), and also we might have application/json; charset=utf-8
. Maybe it's not applicable here though.
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 should we use MimeType class for this
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.
Description
Related issues
closes #
Checklist
no milestone
label.