Skip to content
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

Merged
merged 13 commits into from
Dec 19, 2024
Merged

Conversation

mathias-vandaele
Copy link
Collaborator

Description

Related issues

closes #

Checklist

  • PR has a milestone or the no milestone label.

@mathias-vandaele mathias-vandaele marked this pull request as ready for review December 4, 2024 16:30
@mathias-vandaele mathias-vandaele requested a review from a team as a code owner December 4, 2024 16:30
@mathias-vandaele mathias-vandaele self-assigned this Dec 4, 2024
@mathias-vandaele mathias-vandaele added this to the 8.7.0-alpha3 milestone Dec 4, 2024
@mathias-vandaele mathias-vandaele changed the title Aws s3 connector feature(aws-s3-connector): AWS s3 connector Dec 4, 2024
Copy link
Collaborator

@johnBgood johnBgood left a 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/",
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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 = "....",
Copy link
Collaborator

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 {
Copy link
Collaborator

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();
Copy link
Collaborator

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();
Copy link
Collaborator

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();
Copy link
Collaborator

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() {
Copy link
Collaborator

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/?

Copy link
Collaborator Author

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.

@mathias-vandaele mathias-vandaele added deploy-preview component:qa Task containing all details related to QA qa:required Will trigger the QA workflow labels Dec 11, 2024
@johnBgood
Copy link
Collaborator

QA information

Test Environment

  • Environment:
    • SaaS only
    • SM only
    • Both
  • Connectors version: <TO_BE_REPLACED>

Test Scope

Please describe the test scope, happy path, edge cases that come to your mind, and whatever you think might relevant to test

Test Data

Please provide the test data, if needed (files, URLs, code snippets, FEEL expressions)

@github-actions github-actions bot temporarily deployed to connectors-aws-s3-connecto-c8sm December 11, 2024 11:30 Destroyed
@github-actions github-actions bot temporarily deployed to connectors-aws-s3-connecto-c8sm December 11, 2024 11:34 Destroyed
"value" : "uploadObject",
"group" : "action",
"binding" : {
"name" : "actionDiscriminator",
Copy link
Contributor

@sbuettner sbuettner Dec 17, 2024

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", ...}}

Comment on lines 35 to 37
public S3Action getData() {
return action;
}
Copy link
Contributor

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?

Comment on lines 15 to 16
@TemplateSubType(id = "uploadObject", label = "Upload document")
public record UploadS3Action(
Copy link
Contributor

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) {}
Copy link
Contributor

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.

Comment on lines 286 to +294
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()) ->
Copy link
Contributor

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?

@github-actions github-actions bot temporarily deployed to connectors-aws-s3-connecto-c8sm December 18, 2024 10:14 Destroyed
@github-actions github-actions bot temporarily deployed to connectors-aws-s3-connecto-c8sm December 18, 2024 13:24 Destroyed
@github-actions github-actions bot temporarily deployed to connectors-aws-s3-connecto-c8sm December 18, 2024 13:46 Destroyed
@github-actions github-actions bot temporarily deployed to connectors-aws-s3-connecto-c8sm December 19, 2024 10:51 Destroyed
Copy link
Collaborator

@johnBgood johnBgood left a 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()));
Copy link
Collaborator

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()) {
Copy link
Collaborator

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.

Copy link
Collaborator

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ContentType returned should always be standard
image

@mathias-vandaele mathias-vandaele added this pull request to the merge queue Dec 19, 2024
Merged via the queue into main with commit 9b775d1 Dec 19, 2024
12 checks passed
@mathias-vandaele mathias-vandaele deleted the aws-s3-connector branch December 19, 2024 18:13
@johnBgood johnBgood assigned mathias-vandaele and unassigned Szik Jan 10, 2025
@johnBgood johnBgood added qa:required Will trigger the QA workflow and removed qa:required Will trigger the QA workflow labels Jan 10, 2025
@camunda camunda deleted a comment from slolatte Jan 10, 2025
@johnBgood johnBgood added qa:required Will trigger the QA workflow and removed qa:required Will trigger the QA workflow labels Jan 10, 2025
@johnBgood johnBgood removed deploy-preview qa:required Will trigger the QA workflow labels Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:qa Task containing all details related to QA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants