Skip to content

Commit 8719cdd

Browse files
committed
refactor: fix formatting in Copy.java
1 parent a82261b commit 8719cdd

File tree

1 file changed

+61
-61
lines changed
  • src/main/java/io/kestra/plugin/aws/s3

1 file changed

+61
-61
lines changed

src/main/java/io/kestra/plugin/aws/s3/Copy.java

Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
@Getter
2929
@NoArgsConstructor
3030
@Plugin(
31-
examples = {
32-
@Example(
33-
full = true,
34-
code = """
31+
examples = {
32+
@Example(
33+
full = true,
34+
code = """
3535
id: aws_s3_copy
3636
namespace: company.team
3737
@@ -52,24 +52,24 @@
5252
}
5353
)
5454
@Schema(
55-
title = "Copy a file between S3 buckets."
55+
title = "Copy a file between S3 buckets."
5656
)
5757
public class Copy extends AbstractConnection implements AbstractS3, RunnableTask<Copy.Output> {
5858

5959
@Schema(
60-
title = "The source bucket and key."
60+
title = "The source bucket and key."
6161
)
6262
@PluginProperty
6363
private CopyObjectFrom from;
6464

6565
@Schema(
66-
title = "The destination bucket and key."
66+
title = "The destination bucket and key."
6767
)
6868
@PluginProperty
6969
private CopyObject to;
7070

7171
@Schema(
72-
title = "Whether to delete the source file after download."
72+
title = "Whether to delete the source file after download."
7373
)
7474
@Builder.Default
7575
private Property<Boolean> delete = Property.ofValue(false);
@@ -78,48 +78,48 @@ public class Copy extends AbstractConnection implements AbstractS3, RunnableTask
7878
public Output run(RunContext runContext) throws Exception {
7979

8080
try (
81-
S3AsyncClient s3AsyncClient = this.asyncClient(runContext);
82-
S3TransferManager transferManager = S3TransferManager.
83-
builder().s3Client(s3AsyncClient).
84-
build()) {
81+
S3AsyncClient s3AsyncClient = this.asyncClient(runContext);
82+
S3TransferManager transferManager = S3TransferManager.builder()
83+
.s3Client(s3AsyncClient)
84+
.build()) {
8585

8686
CopyObjectRequest.Builder copyObjectBuilder = CopyObjectRequest.builder()
87-
.sourceBucket(runContext.render(this.from.bucket).as(String.class).orElseThrow())
88-
.sourceKey(runContext.render(this.from.key).as(String.class).orElseThrow())
89-
.destinationBucket(
90-
runContext.render(
91-
(this.to != null && this.to.bucket != null) ? this.to.bucket : this.from.bucket
92-
).as(String.class).orElseThrow()
93-
)
94-
.destinationKey(
95-
runContext.render(
96-
(this.to != null && this.to.key != null) ? this.to.key : this.from.key
97-
).as(String.class).orElseThrow()
98-
);
87+
.sourceBucket(runContext.render(this.from.bucket).as(String.class).orElseThrow())
88+
.sourceKey(runContext.render(this.from.key).as(String.class).orElseThrow())
89+
.destinationBucket(
90+
runContext.render(
91+
(this.to != null && this.to.bucket != null) ? this.to.bucket : this.from.bucket
92+
).as(String.class).orElseThrow()
93+
)
94+
.destinationKey(
95+
runContext.render(
96+
(this.to != null && this.to.key != null) ? this.to.key : this.from.key
97+
).as(String.class).orElseThrow()
98+
);
9999

100100
// Optional version ID
101101
if (this.from.versionId != null) {
102102
copyObjectBuilder.sourceVersionId(
103-
runContext.render(this.from.versionId).as(String.class).orElseThrow()
103+
runContext.render(this.from.versionId).as(String.class).orElseThrow()
104104
);
105105
}
106106

107107
// Server-side encryption
108108
if (this.to != null && this.to.serverSideEncryption != null) {
109109
S3ServerSideEncryption sse = runContext
110-
.render(this.to.serverSideEncryption)
111-
.as(S3ServerSideEncryption.class)
112-
.orElse(null);
110+
.render(this.to.serverSideEncryption)
111+
.as(S3ServerSideEncryption.class)
112+
.orElse(null);
113113

114114
if (sse != null && sse != S3ServerSideEncryption.NONE) {
115115
copyObjectBuilder.serverSideEncryption(
116-
software.amazon.awssdk.services.s3.model.ServerSideEncryption.valueOf(sse.name())
116+
software.amazon.awssdk.services.s3.model.ServerSideEncryption.valueOf(sse.name())
117117
);
118118

119119
// If using AWS_KMS encryption, set the KMS key ID
120120
if (sse == S3ServerSideEncryption.AWS_KMS && this.to.kmsKeyId != null) {
121121
copyObjectBuilder.ssekmsKeyId(
122-
runContext.render(this.to.kmsKeyId).as(String.class).orElseThrow()
122+
runContext.render(this.to.kmsKeyId).as(String.class).orElseThrow()
123123
);
124124
}
125125
}
@@ -129,40 +129,40 @@ public Output run(RunContext runContext) throws Exception {
129129

130130
// TransferManager copy (parallel & multipart aware)
131131
CopyRequest copyRequest = CopyRequest.builder()
132-
.copyObjectRequest(copyObjectRequest)
133-
.build();
132+
.copyObjectRequest(copyObjectRequest)
133+
.build();
134134

135135
CompletedCopy completedCopy = transferManager
136-
.copy(copyRequest)
137-
.completionFuture()
138-
.join();
136+
.copy(copyRequest)
137+
.completionFuture()
138+
.join();
139139

140140
// Optional delete source
141141
if (runContext.render(this.delete).as(Boolean.class).orElse(false)) {
142142
Delete.builder()
143-
.id(this.id)
144-
.type(Delete.class.getName())
145-
.region(this.region)
146-
.endpointOverride(this.endpointOverride)
147-
.accessKeyId(this.accessKeyId)
148-
.secretKeyId(this.secretKeyId)
149-
.sessionToken(this.sessionToken)
150-
.stsRoleArn(this.stsRoleArn)
151-
.stsRoleExternalId(this.stsRoleExternalId)
152-
.stsRoleSessionName(this.stsRoleSessionName)
153-
.stsRoleSessionDuration(this.stsRoleSessionDuration)
154-
.stsEndpointOverride(this.stsEndpointOverride)
155-
.bucket(Property.ofValue(copyObjectRequest.sourceBucket()))
156-
.key(Property.ofValue(copyObjectRequest.sourceKey()))
157-
.build()
158-
.run(runContext);
143+
.id(this.id)
144+
.type(Delete.class.getName())
145+
.region(this.region)
146+
.endpointOverride(this.endpointOverride)
147+
.accessKeyId(this.accessKeyId)
148+
.secretKeyId(this.secretKeyId)
149+
.sessionToken(this.sessionToken)
150+
.stsRoleArn(this.stsRoleArn)
151+
.stsRoleExternalId(this.stsRoleExternalId)
152+
.stsRoleSessionName(this.stsRoleSessionName)
153+
.stsRoleSessionDuration(this.stsRoleSessionDuration)
154+
.stsEndpointOverride(this.stsEndpointOverride)
155+
.bucket(Property.ofValue(copyObjectRequest.sourceBucket()))
156+
.key(Property.ofValue(copyObjectRequest.sourceKey()))
157+
.build()
158+
.run(runContext);
159159
}
160160

161161
return Output.builder()
162-
.bucket(copyObjectRequest.destinationBucket())
163-
.key(copyObjectRequest.destinationKey())
164-
.eTag(completedCopy.response().copyObjectResult().eTag())
165-
.build();
162+
.bucket(copyObjectRequest.destinationBucket())
163+
.key(copyObjectRequest.destinationKey())
164+
.eTag(completedCopy.response().copyObjectResult().eTag())
165+
.build();
166166
}
167167
}
168168

@@ -172,25 +172,25 @@ public Output run(RunContext runContext) throws Exception {
172172
public static class CopyObject {
173173

174174
@Schema(
175-
title = "The bucket name"
175+
title = "The bucket name"
176176
)
177177
@NotNull
178178
Property<String> bucket;
179179

180180
@Schema(
181-
title = "The bucket key"
181+
title = "The bucket key"
182182
)
183183
@NotNull
184184
Property<String> key;
185185

186186
@Schema(
187-
title = "Server side encryption to apply to the target object.",
188-
description = "Example: AES256 or AWS_KMS"
187+
title = "Server side encryption to apply to the target object.",
188+
description = "Example: AES256 or AWS_KMS"
189189
)
190190
private Property<S3ServerSideEncryption> serverSideEncryption;
191191

192192
@Schema(
193-
title = "KMS Key ARN or Key ID to use when server side encryption is AWS_KMS"
193+
title = "KMS Key ARN or Key ID to use when server side encryption is AWS_KMS"
194194
)
195195
private Property<String> kmsKeyId;
196196
}
@@ -201,7 +201,7 @@ public static class CopyObject {
201201
public static class CopyObjectFrom extends CopyObject {
202202

203203
@Schema(
204-
title = "The specific version of the object."
204+
title = "The specific version of the object."
205205
)
206206
private Property<String> versionId;
207207
}

0 commit comments

Comments
 (0)