diff --git a/test/v2-migration-tests/src/test/resources/software/amazon/awssdk/v2migrationtests/maven-nocompile/after/pom.xml b/test/v2-migration-tests/src/test/resources/software/amazon/awssdk/v2migrationtests/maven-nocompile/after/pom.xml
index cd6274a6a517..f1b3db956b61 100644
--- a/test/v2-migration-tests/src/test/resources/software/amazon/awssdk/v2migrationtests/maven-nocompile/after/pom.xml
+++ b/test/v2-migration-tests/src/test/resources/software/amazon/awssdk/v2migrationtests/maven-nocompile/after/pom.xml
@@ -46,6 +46,11 @@
s3
V2_VERSION
+
+ software.amazon.awssdk
+ s3-event-notifications
+ V2_VERSION
+
software.amazon.awssdk
s3-transfer-manager
diff --git a/test/v2-migration-tests/src/test/resources/software/amazon/awssdk/v2migrationtests/maven-nocompile/after/src/main/java/foo/bar/S3EnDateTime.java b/test/v2-migration-tests/src/test/resources/software/amazon/awssdk/v2migrationtests/maven-nocompile/after/src/main/java/foo/bar/S3EnDateTime.java
new file mode 100644
index 000000000000..bee0b278b9af
--- /dev/null
+++ b/test/v2-migration-tests/src/test/resources/software/amazon/awssdk/v2migrationtests/maven-nocompile/after/src/main/java/foo/bar/S3EnDateTime.java
@@ -0,0 +1,40 @@
+/*
+ * 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 foo.bar;
+import software.amazon.awssdk.eventnotifications.s3.model.S3EventNotification;
+import software.amazon.awssdk.eventnotifications.s3.model.S3EventNotificationRecord;
+import software.amazon.awssdk.eventnotifications.s3.model.RestoreEventData;
+import software.amazon.awssdk.eventnotifications.s3.model.GlacierEventData;
+import org.joda.time.DateTime;
+
+public class S3EnDateTime {
+
+ public void parseEvent(String jsonInput) {
+ S3EventNotification notification = S3EventNotification.fromJson(jsonInput);
+
+ for (S3EventNotification.S3EventNotificationRecord record : notification.getRecords()) {
+ DateTime eventTime = /*AWS SDK for Java v2 migration: getEventTime returns Instant instead of DateTime in v2. AWS SDK v2 does not include org.joda.time as a dependency. If you want to keep using DateTime, you'll need to manually add "org.joda.time:joda-time" dependency to your project after migration.*/new DateTime(record.getEventTime().toEpochMilli());
+
+ GlacierEventData glacierEventData = record.getGlacierEventData();
+
+ RestoreEventData restoreEventData = glacierEventData.getRestoreEventData();
+
+ DateTime expireTime = /*AWS SDK for Java v2 migration: getLifecycleRestorationExpiryTime returns Instant instead of DateTime in v2. AWS SDK v2 does not include org.joda.time as a dependency. If you want to keep using DateTime, you'll need to manually add "org.joda.time:joda-time" dependency to your project after migration.*/new DateTime(restoreEventData.getLifecycleRestorationExpiryTime().toEpochMilli());
+
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/test/v2-migration-tests/src/test/resources/software/amazon/awssdk/v2migrationtests/maven-nocompile/after/src/main/java/foo/bar/S3Transforms.java b/test/v2-migration-tests/src/test/resources/software/amazon/awssdk/v2migrationtests/maven-nocompile/after/src/main/java/foo/bar/S3Transforms.java
index 2b20f4b92707..e2bd389664dd 100644
--- a/test/v2-migration-tests/src/test/resources/software/amazon/awssdk/v2migrationtests/maven-nocompile/after/src/main/java/foo/bar/S3Transforms.java
+++ b/test/v2-migration-tests/src/test/resources/software/amazon/awssdk/v2migrationtests/maven-nocompile/after/src/main/java/foo/bar/S3Transforms.java
@@ -18,10 +18,6 @@
import com.amazonaws.HttpMethod;
import com.amazonaws.services.s3.model.SSEAwsKeyManagementParams;
import com.amazonaws.services.s3.model.SSECustomerKey;
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Date;
import software.amazon.awssdk.core.async.AsyncRequestBody;
import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.s3.model.AccessControlPolicy;
@@ -34,6 +30,11 @@
import software.amazon.awssdk.transfer.s3.S3TransferManager;
import software.amazon.awssdk.transfer.s3.model.UploadRequest;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Date;
+
public class S3Transforms {
S3Client s3;
diff --git a/test/v2-migration-tests/src/test/resources/software/amazon/awssdk/v2migrationtests/maven-nocompile/before/src/main/java/foo/bar/S3EnDateTime.java b/test/v2-migration-tests/src/test/resources/software/amazon/awssdk/v2migrationtests/maven-nocompile/before/src/main/java/foo/bar/S3EnDateTime.java
new file mode 100644
index 000000000000..a2faa2a53e8c
--- /dev/null
+++ b/test/v2-migration-tests/src/test/resources/software/amazon/awssdk/v2migrationtests/maven-nocompile/before/src/main/java/foo/bar/S3EnDateTime.java
@@ -0,0 +1,42 @@
+/*
+ * 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 foo.bar;
+
+import com.amazonaws.services.s3.event.S3EventNotification;
+import com.amazonaws.services.s3.event.S3EventNotification.S3EventNotificationRecord;
+import com.amazonaws.services.s3.event.S3EventNotification.RestoreEventDataEntity;
+import com.amazonaws.services.s3.event.S3EventNotification.GlacierEventDataEntity;
+import com.amazonaws.services.s3.model.S3Event;
+import org.joda.time.DateTime;
+
+public class S3EnDateTime {
+
+ public void parseEvent(String jsonInput) {
+ S3EventNotification notification = S3EventNotification.parseJson(jsonInput);
+
+ for (S3EventNotification.S3EventNotificationRecord record : notification.getRecords()) {
+ DateTime eventTime = record.getEventTime();
+
+ GlacierEventDataEntity glacierEventData = record.getGlacierEventData();
+
+ RestoreEventDataEntity restoreEventData = glacierEventData.getRestoreEventData();
+
+ DateTime expireTime = restoreEventData.getLifecycleRestorationExpiryTime();
+
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/test/v2-migration-tests/src/test/resources/software/amazon/awssdk/v2migrationtests/maven/after/pom.xml b/test/v2-migration-tests/src/test/resources/software/amazon/awssdk/v2migrationtests/maven/after/pom.xml
index c4fa83bdc7a0..693894ce86eb 100644
--- a/test/v2-migration-tests/src/test/resources/software/amazon/awssdk/v2migrationtests/maven/after/pom.xml
+++ b/test/v2-migration-tests/src/test/resources/software/amazon/awssdk/v2migrationtests/maven/after/pom.xml
@@ -57,6 +57,11 @@
netty-nio-client
V2_VERSION
+
+ software.amazon.awssdk
+ s3-event-notifications
+ V2_VERSION
+
software.amazon.awssdk
s3
diff --git a/test/v2-migration-tests/src/test/resources/software/amazon/awssdk/v2migrationtests/maven/after/src/main/java/foo/bar/S3EventNotificationTest.java b/test/v2-migration-tests/src/test/resources/software/amazon/awssdk/v2migrationtests/maven/after/src/main/java/foo/bar/S3EventNotificationTest.java
new file mode 100644
index 000000000000..16dcc8b5892d
--- /dev/null
+++ b/test/v2-migration-tests/src/test/resources/software/amazon/awssdk/v2migrationtests/maven/after/src/main/java/foo/bar/S3EventNotificationTest.java
@@ -0,0 +1,65 @@
+/*
+ * 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 foo.bar;
+
+import software.amazon.awssdk.eventnotifications.s3.model.S3Bucket;
+import software.amazon.awssdk.eventnotifications.s3.model.S3EventNotification;
+import software.amazon.awssdk.eventnotifications.s3.model.S3;
+import software.amazon.awssdk.eventnotifications.s3.model.S3EventNotificationRecord;
+import software.amazon.awssdk.eventnotifications.s3.model.S3Object;
+import software.amazon.awssdk.eventnotifications.s3.model.RequestParameters;
+import software.amazon.awssdk.eventnotifications.s3.model.ResponseElements;
+import software.amazon.awssdk.eventnotifications.s3.model.RestoreEventData;
+import software.amazon.awssdk.eventnotifications.s3.model.UserIdentity;
+import software.amazon.awssdk.eventnotifications.s3.model.GlacierEventData;
+import software.amazon.awssdk.eventnotifications.s3.model.LifecycleEventData;
+import software.amazon.awssdk.eventnotifications.s3.model.IntelligentTieringEventData;
+import software.amazon.awssdk.eventnotifications.s3.model.ReplicationEventData;
+
+public class S3EventNotificationTest {
+ public void parseEvent(String jsonInput) {
+ S3EventNotification notification = S3EventNotification.fromJson(jsonInput);
+
+ for (S3EventNotificationRecord record : notification.getRecords()) {
+ S3 s3 = record.getS3();
+
+ S3Bucket bucket = s3.getBucket();
+
+ S3Object object = s3.getObject();
+
+ String eventName = record.getEventName();
+
+ String eventNameEnum = record.getEventName();
+
+ RequestParameters requestParams = record.getRequestParameters();
+
+ ResponseElements responseElements = record.getResponseElements();
+
+ UserIdentity userIdentity = record.getUserIdentity();
+
+ GlacierEventData glacierEventData = record.getGlacierEventData();
+
+ RestoreEventData restoreEventData = glacierEventData.getRestoreEventData();
+
+ LifecycleEventData lifecycleEventData = record.getLifecycleEventData();
+
+ IntelligentTieringEventData intelligentTieringEventData = record.getIntelligentTieringEventData();
+
+ ReplicationEventData replicationEventData = record.getReplicationEventData();
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/test/v2-migration-tests/src/test/resources/software/amazon/awssdk/v2migrationtests/maven/before/src/main/java/foo/bar/S3EventNotificationTest.java b/test/v2-migration-tests/src/test/resources/software/amazon/awssdk/v2migrationtests/maven/before/src/main/java/foo/bar/S3EventNotificationTest.java
new file mode 100644
index 000000000000..40c92bc94e15
--- /dev/null
+++ b/test/v2-migration-tests/src/test/resources/software/amazon/awssdk/v2migrationtests/maven/before/src/main/java/foo/bar/S3EventNotificationTest.java
@@ -0,0 +1,66 @@
+/*
+ * 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 foo.bar;
+
+import com.amazonaws.services.s3.event.S3EventNotification;
+import com.amazonaws.services.s3.event.S3EventNotification.S3BucketEntity;
+import com.amazonaws.services.s3.event.S3EventNotification.S3Entity;
+import com.amazonaws.services.s3.event.S3EventNotification.S3EventNotificationRecord;
+import com.amazonaws.services.s3.event.S3EventNotification.S3ObjectEntity;
+import com.amazonaws.services.s3.event.S3EventNotification.RequestParametersEntity;
+import com.amazonaws.services.s3.event.S3EventNotification.ResponseElementsEntity;
+import com.amazonaws.services.s3.event.S3EventNotification.RestoreEventDataEntity;
+import com.amazonaws.services.s3.event.S3EventNotification.UserIdentityEntity;
+import com.amazonaws.services.s3.event.S3EventNotification.GlacierEventDataEntity;
+import com.amazonaws.services.s3.event.S3EventNotification.LifecycleEventDataEntity;
+import com.amazonaws.services.s3.event.S3EventNotification.IntelligentTieringEventDataEntity;
+import com.amazonaws.services.s3.event.S3EventNotification.ReplicationEventDataEntity;
+import com.amazonaws.services.s3.model.S3Event;
+
+public class S3EventNotificationTest {
+ public void parseEvent(String jsonInput) {
+ S3EventNotification notification = S3EventNotification.parseJson(jsonInput);
+
+ for (S3EventNotificationRecord record : notification.getRecords()) {
+ S3Entity s3 = record.getS3();
+
+ S3BucketEntity bucket = s3.getBucket();
+
+ S3ObjectEntity object = s3.getObject();
+
+ String eventName = record.getEventName();
+
+ S3Event eventNameEnum = record.getEventNameAsEnum();
+
+ RequestParametersEntity requestParams = record.getRequestParameters();
+
+ ResponseElementsEntity responseElements = record.getResponseElements();
+
+ UserIdentityEntity userIdentity = record.getUserIdentity();
+
+ GlacierEventDataEntity glacierEventData = record.getGlacierEventData();
+
+ RestoreEventDataEntity restoreEventData = glacierEventData.getRestoreEventData();
+
+ LifecycleEventDataEntity lifecycleEventData = record.getLifecycleEventData();
+
+ IntelligentTieringEventDataEntity intelligentTieringEventData = record.getIntelligentTieringEventData();
+
+ ReplicationEventDataEntity replicationEventData = record.getReplicationEventDataEntity();
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/v2-migration/src/main/java/software/amazon/awssdk/v2migration/S3AddImportsAndComments.java b/v2-migration/src/main/java/software/amazon/awssdk/v2migration/S3AddImportsAndComments.java
index 3f23bc31aa68..ff8a55c2597d 100644
--- a/v2-migration/src/main/java/software/amazon/awssdk/v2migration/S3AddImportsAndComments.java
+++ b/v2-migration/src/main/java/software/amazon/awssdk/v2migration/S3AddImportsAndComments.java
@@ -18,6 +18,7 @@
import static software.amazon.awssdk.v2migration.internal.utils.S3TransformUtils.V1_S3_MODEL_PKG;
import static software.amazon.awssdk.v2migration.internal.utils.S3TransformUtils.V2_S3_MODEL_PKG;
import static software.amazon.awssdk.v2migration.internal.utils.S3TransformUtils.createComments;
+import static software.amazon.awssdk.v2migration.internal.utils.S3TransformUtils.v1EnMethodMatcher;
import static software.amazon.awssdk.v2migration.internal.utils.S3TransformUtils.v1S3MethodMatcher;
import java.util.List;
@@ -52,6 +53,10 @@ public class S3AddImportsAndComments extends Recipe {
private static final MethodMatcher SELECT_OBJECT_CONTENT = v1S3MethodMatcher("selectObjectContent(..)");
private static final MethodMatcher SET_LIFECYCLE_CONFIGURATION = v1S3MethodMatcher("setBucketLifecycleConfiguration(..)");
private static final MethodMatcher SET_TAGGING_CONFIGURATION = v1S3MethodMatcher("setBucketTaggingConfiguration(..)");
+ private static final MethodMatcher GET_EVENT_TIME = v1EnMethodMatcher("S3EventNotification.S3EventNotificationRecord "
+ + "getEventTime(..)");
+ private static final MethodMatcher GET_EXPIRY_TIME = v1EnMethodMatcher("S3EventNotification.RestoreEventDataEntity "
+ + "getLifecycleRestorationExpiryTime(..)");
private static final Pattern CANNED_ACL = Pattern.compile(V1_S3_MODEL_PKG + "CannedAccessControlList");
@@ -191,6 +196,13 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu
return method.withComments(createComments(comment));
}
+ if (GET_EVENT_TIME.matches(method) || GET_EXPIRY_TIME.matches(method)) {
+ String comment = method.getSimpleName() + " returns Instant instead of DateTime in v2. AWS SDK v2 does not "
+ + "include org.joda.time as a dependency. If you want to keep using DateTime, you'll need to "
+ + "manually add \"org.joda.time:joda-time\" dependency to your"
+ + " project after migration.";
+ return method.withComments(createComments(comment));
+ }
return method;
}
diff --git a/v2-migration/src/main/java/software/amazon/awssdk/v2migration/S3EventNotificationMethodToV2.java b/v2-migration/src/main/java/software/amazon/awssdk/v2migration/S3EventNotificationMethodToV2.java
new file mode 100644
index 000000000000..c5267d642f69
--- /dev/null
+++ b/v2-migration/src/main/java/software/amazon/awssdk/v2migration/S3EventNotificationMethodToV2.java
@@ -0,0 +1,68 @@
+/*
+ * 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.v2migration;
+
+import static software.amazon.awssdk.v2migration.internal.utils.S3TransformUtils.v1EnMethodMatcher;
+
+import org.openrewrite.ExecutionContext;
+import org.openrewrite.Recipe;
+import org.openrewrite.TreeVisitor;
+import org.openrewrite.java.JavaTemplate;
+import org.openrewrite.java.JavaVisitor;
+import org.openrewrite.java.MethodMatcher;
+import org.openrewrite.java.tree.J;
+import software.amazon.awssdk.annotations.SdkInternalApi;
+
+@SdkInternalApi
+public class S3EventNotificationMethodToV2 extends Recipe {
+
+ private static final MethodMatcher GET_EVENT_TIME = v1EnMethodMatcher("S3EventNotification.S3EventNotificationRecord "
+ + "getEventTime(..)");
+
+ private static final MethodMatcher GET_EXPIRY_TIME = v1EnMethodMatcher("S3EventNotification.RestoreEventDataEntity "
+ + "getLifecycleRestorationExpiryTime(..)");
+
+ @Override
+ public String getDisplayName() {
+ return "S3 Event Notification method to v2";
+ }
+
+ @Override
+ public String getDescription() {
+ return "S3 Event Notification method to v2";
+ }
+
+ @Override
+ public TreeVisitor, ExecutionContext> getVisitor() {
+ return new Visitor();
+ }
+
+ private static class Visitor extends JavaVisitor {
+ @Override
+ public J visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx) {
+ if (GET_EVENT_TIME.matches(method) || GET_EXPIRY_TIME.matches(method)) {
+ JavaTemplate template = JavaTemplate.builder("new DateTime(#{any(java.time.Instant)}.toEpochMilli())")
+ .build();
+ J m = super.visitMethodInvocation(method, ctx);
+ m = template.apply(getCursor(), ((J.MethodInvocation) m).getCoordinates().replace(), m);
+ return m;
+ }
+ return method;
+ }
+
+ }
+
+}
diff --git a/v2-migration/src/main/java/software/amazon/awssdk/v2migration/internal/utils/S3TransformUtils.java b/v2-migration/src/main/java/software/amazon/awssdk/v2migration/internal/utils/S3TransformUtils.java
index eda4a98a5a87..2a4895952edc 100644
--- a/v2-migration/src/main/java/software/amazon/awssdk/v2migration/internal/utils/S3TransformUtils.java
+++ b/v2-migration/src/main/java/software/amazon/awssdk/v2migration/internal/utils/S3TransformUtils.java
@@ -37,6 +37,7 @@ public final class S3TransformUtils {
public static final String V1_S3_CLIENT = "com.amazonaws.services.s3.AmazonS3";
public static final String V1_S3_MODEL_PKG = "com.amazonaws.services.s3.model.";
public static final String V1_S3_PKG = "com.amazonaws.services.s3.";
+ public static final String V1_EN_PKG = "com.amazonaws.services.s3.event.";
public static final String V2_S3_CLIENT = "software.amazon.awssdk.services.s3.S3Client";
public static final String V2_S3_MODEL_PKG = "software.amazon.awssdk.services.s3.model.";
@@ -77,6 +78,10 @@ public static MethodMatcher v1S3MethodMatcher(String methodSignature) {
return new MethodMatcher(V1_S3_CLIENT + " " + methodSignature, true);
}
+ public static MethodMatcher v1EnMethodMatcher(String methodSignature) {
+ return new MethodMatcher(V1_EN_PKG + methodSignature, true);
+ }
+
public static MethodMatcher v2S3MethodMatcher(String methodSignature) {
return new MethodMatcher(V2_S3_CLIENT + " " + methodSignature, true);
}
diff --git a/v2-migration/src/main/java/software/amazon/awssdk/v2migration/internal/utils/SdkTypeUtils.java b/v2-migration/src/main/java/software/amazon/awssdk/v2migration/internal/utils/SdkTypeUtils.java
index 2aa13502b9ca..da0ad412b90b 100644
--- a/v2-migration/src/main/java/software/amazon/awssdk/v2migration/internal/utils/SdkTypeUtils.java
+++ b/v2-migration/src/main/java/software/amazon/awssdk/v2migration/internal/utils/SdkTypeUtils.java
@@ -174,6 +174,7 @@ public final class SdkTypeUtils {
CLASSES_TO_SKIP.add(V1_S3_MODEL_PKG + "S3ObjectId");
CLASSES_TO_SKIP.add(V1_S3_MODEL_PKG + "S3ObjectIdBuilder");
CLASSES_TO_SKIP.add(V1_S3_MODEL_PKG + "TagSet");
+ CLASSES_TO_SKIP.add(V1_S3_MODEL_PKG + "SelectObjectContentEvent");
// S3 Enums with no v2 equivalent
CLASSES_TO_SKIP.add(V1_S3_MODEL_PKG + "GroupGrantee");
diff --git a/v2-migration/src/main/resources/META-INF/rewrite/aws-sdk-java-v1-to-v2-with-tm.yml b/v2-migration/src/main/resources/META-INF/rewrite/aws-sdk-java-v1-to-v2-with-tm.yml
index 99b4b6991845..1409d4f853c0 100644
--- a/v2-migration/src/main/resources/META-INF/rewrite/aws-sdk-java-v1-to-v2-with-tm.yml
+++ b/v2-migration/src/main/resources/META-INF/rewrite/aws-sdk-java-v1-to-v2-with-tm.yml
@@ -22,17 +22,21 @@ tags:
- sdk
recipeList:
- software.amazon.awssdk.v2migration.AddTransferManagerDependency
+ - software.amazon.awssdk.v2migration.AddS3EventNotificationDependency
- software.amazon.awssdk.v2migration.UpgradeSdkDependencies
- software.amazon.awssdk.v2migration.S3AddImportsAndComments
+ - software.amazon.awssdk.v2migration.S3EventNotificationMethodToV2
- software.amazon.awssdk.v2migration.S3TypesToV2
- software.amazon.awssdk.v2migration.S3StreamingResponseToV2
- software.amazon.awssdk.v2migration.S3StreamingRequestToV2
- software.amazon.awssdk.v2migration.S3NonStreamingRequestToV2
- software.amazon.awssdk.v2migration.S3MethodsToV2
+ - software.amazon.awssdk.v2migration.S3EventNotificationMethodsToV2
- software.amazon.awssdk.v2migration.S3MethodsConstructorToFluent
- software.amazon.awssdk.v2migration.S3UriToV2
- software.amazon.awssdk.v2migration.EnumGettersToV2
- software.amazon.awssdk.v2migration.ChangeTransferManagerTypes
+ - software.amazon.awssdk.v2migration.ChangeS3EventNotificationTypes
- software.amazon.awssdk.v2migration.ChangeSdkType
- software.amazon.awssdk.v2migration.ChangeSdkCoreTypes
# At this point, all classes should be changed to v2 equivalents
diff --git a/v2-migration/src/main/resources/META-INF/rewrite/aws-sdk-java-v1-to-v2.yml b/v2-migration/src/main/resources/META-INF/rewrite/aws-sdk-java-v1-to-v2.yml
index f6b624998e48..3c4f420719f5 100644
--- a/v2-migration/src/main/resources/META-INF/rewrite/aws-sdk-java-v1-to-v2.yml
+++ b/v2-migration/src/main/resources/META-INF/rewrite/aws-sdk-java-v1-to-v2.yml
@@ -21,16 +21,20 @@ tags:
- aws
- sdk
recipeList:
+ - software.amazon.awssdk.v2migration.AddS3EventNotificationDependency
- software.amazon.awssdk.v2migration.UpgradeSdkDependencies
- software.amazon.awssdk.v2migration.S3AddImportsAndComments
+ - software.amazon.awssdk.v2migration.S3EventNotificationMethodToV2
- software.amazon.awssdk.v2migration.S3TypesToV2
- software.amazon.awssdk.v2migration.S3StreamingResponseToV2
- software.amazon.awssdk.v2migration.S3StreamingRequestToV2
- software.amazon.awssdk.v2migration.S3NonStreamingRequestToV2
- software.amazon.awssdk.v2migration.S3MethodsToV2
+ - software.amazon.awssdk.v2migration.S3EventNotificationMethodsToV2
- software.amazon.awssdk.v2migration.S3MethodsConstructorToFluent
- software.amazon.awssdk.v2migration.S3UriToV2
- software.amazon.awssdk.v2migration.EnumGettersToV2
+ - software.amazon.awssdk.v2migration.ChangeS3EventNotificationTypes
- software.amazon.awssdk.v2migration.ChangeSdkType
- software.amazon.awssdk.v2migration.ChangeSdkCoreTypes
# At this point, all classes should be changed to v2 equivalents
diff --git a/v2-migration/src/main/resources/META-INF/rewrite/change-s3-event-notification-methods.yml b/v2-migration/src/main/resources/META-INF/rewrite/change-s3-event-notification-methods.yml
new file mode 100644
index 000000000000..d43fc06bdb39
--- /dev/null
+++ b/v2-migration/src/main/resources/META-INF/rewrite/change-s3-event-notification-methods.yml
@@ -0,0 +1,34 @@
+#
+# 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.
+---
+type: specs.openrewrite.org/v1beta/recipe
+name: software.amazon.awssdk.v2migration.S3EventNotificationMethodsToV2
+displayName: Change S3EventNotification methods to v2.
+description: Change S3EventNotification methods to v2.
+recipeList:
+ - software.amazon.awssdk.v2migration.openrewrite.ChangeMethodInvocationReturnType:
+ methodPattern: com.amazonaws.services.s3.event.S3EventNotification.S3EventNotificationRecord getEventNameAsEnum()
+ newReturnType: String
+ - org.openrewrite.java.ChangeMethodName:
+ methodPattern: com.amazonaws.services.s3.event.S3EventNotification.GlacierEventDataEntity getRestoreEventDataEntity()
+ newMethodName: getRestoreEventData
+ - org.openrewrite.java.ChangeMethodName:
+ methodPattern: com.amazonaws.services.s3.event.S3EventNotification.S3EventNotificationRecord getEventNameAsEnum()
+ newMethodName: getEventName
+ - org.openrewrite.java.ChangeMethodName:
+ methodPattern: com.amazonaws.services.s3.event.S3EventNotification.S3EventNotificationRecord getReplicationEventDataEntity()
+ newMethodName: getReplicationEventData
+ - org.openrewrite.java.ChangeMethodName:
+ methodPattern: com.amazonaws.services.s3.event.S3EventNotification parseJson(String)
+ newMethodName: fromJson
\ No newline at end of file
diff --git a/v2-migration/src/main/resources/META-INF/rewrite/change-s3-event-notification-types.yml b/v2-migration/src/main/resources/META-INF/rewrite/change-s3-event-notification-types.yml
new file mode 100644
index 000000000000..32c7efcc1cb1
--- /dev/null
+++ b/v2-migration/src/main/resources/META-INF/rewrite/change-s3-event-notification-types.yml
@@ -0,0 +1,62 @@
+#
+# 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.
+#
+---
+type: specs.openrewrite.org/v1beta/recipe
+name: software.amazon.awssdk.v2migration.ChangeS3EventNotificationTypes
+displayName: Change SDK S3EventNotification types from v1 to v2
+description: Change SDK S3EventNotification types from v1 to v2.
+recipeList:
+ - org.openrewrite.java.ChangeType:
+ oldFullyQualifiedTypeName: com.amazonaws.services.s3.event.S3EventNotification.S3EventNotificationRecord
+ newFullyQualifiedTypeName: software.amazon.awssdk.eventnotifications.s3.model.S3EventNotificationRecord
+ - org.openrewrite.java.ChangeType:
+ oldFullyQualifiedTypeName: com.amazonaws.services.s3.event.S3EventNotification.GlacierEventDataEntity
+ newFullyQualifiedTypeName: software.amazon.awssdk.eventnotifications.s3.model.GlacierEventData
+ - org.openrewrite.java.ChangeType:
+ oldFullyQualifiedTypeName: com.amazonaws.services.s3.event.S3EventNotification.IntelligentTieringEventDataEntity
+ newFullyQualifiedTypeName: software.amazon.awssdk.eventnotifications.s3.model.IntelligentTieringEventData
+ - org.openrewrite.java.ChangeType:
+ oldFullyQualifiedTypeName: com.amazonaws.services.s3.event.S3EventNotification.LifecycleEventDataEntity
+ newFullyQualifiedTypeName: software.amazon.awssdk.eventnotifications.s3.model.LifecycleEventData
+ - org.openrewrite.java.ChangeType:
+ oldFullyQualifiedTypeName: com.amazonaws.services.s3.event.S3EventNotification.ReplicationEventDataEntity
+ newFullyQualifiedTypeName: software.amazon.awssdk.eventnotifications.s3.model.ReplicationEventData
+ - org.openrewrite.java.ChangeType:
+ oldFullyQualifiedTypeName: com.amazonaws.services.s3.event.S3EventNotification.RequestParametersEntity
+ newFullyQualifiedTypeName: software.amazon.awssdk.eventnotifications.s3.model.RequestParameters
+ - org.openrewrite.java.ChangeType:
+ oldFullyQualifiedTypeName: com.amazonaws.services.s3.event.S3EventNotification.ResponseElementsEntity
+ newFullyQualifiedTypeName: software.amazon.awssdk.eventnotifications.s3.model.ResponseElements
+ - org.openrewrite.java.ChangeType:
+ oldFullyQualifiedTypeName: com.amazonaws.services.s3.event.S3EventNotification.RestoreEventDataEntity
+ newFullyQualifiedTypeName: software.amazon.awssdk.eventnotifications.s3.model.RestoreEventData
+ - org.openrewrite.java.ChangeType:
+ oldFullyQualifiedTypeName: com.amazonaws.services.s3.event.S3EventNotification.S3BucketEntity
+ newFullyQualifiedTypeName: software.amazon.awssdk.eventnotifications.s3.model.S3Bucket
+ - org.openrewrite.java.ChangeType:
+ oldFullyQualifiedTypeName: com.amazonaws.services.s3.event.S3EventNotification.S3Entity
+ newFullyQualifiedTypeName: software.amazon.awssdk.eventnotifications.s3.model.S3
+ - org.openrewrite.java.ChangeType:
+ oldFullyQualifiedTypeName: com.amazonaws.services.s3.event.S3EventNotification.S3ObjectEntity
+ newFullyQualifiedTypeName: software.amazon.awssdk.eventnotifications.s3.model.S3Object
+ - org.openrewrite.java.ChangeType:
+ oldFullyQualifiedTypeName: com.amazonaws.services.s3.event.S3EventNotification.TransitionEventDataEntity
+ newFullyQualifiedTypeName: software.amazon.awssdk.eventnotifications.s3.model.TransitionEventData
+ - org.openrewrite.java.ChangeType:
+ oldFullyQualifiedTypeName: com.amazonaws.services.s3.event.S3EventNotification.UserIdentityEntity
+ newFullyQualifiedTypeName: software.amazon.awssdk.eventnotifications.s3.model.UserIdentity
+ - org.openrewrite.java.ChangeType:
+ oldFullyQualifiedTypeName: com.amazonaws.services.s3.event.S3EventNotification
+ newFullyQualifiedTypeName: software.amazon.awssdk.eventnotifications.s3.model.S3EventNotification
\ No newline at end of file
diff --git a/v2-migration/src/main/resources/recipe-vm-templates/add-s3-event-notification-dependency.yml.vm b/v2-migration/src/main/resources/recipe-vm-templates/add-s3-event-notification-dependency.yml.vm
new file mode 100644
index 000000000000..eedb1cb23732
--- /dev/null
+++ b/v2-migration/src/main/resources/recipe-vm-templates/add-s3-event-notification-dependency.yml.vm
@@ -0,0 +1,28 @@
+#
+# 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.
+#
+---
+type: specs.openrewrite.org/v1beta/recipe
+name: software.amazon.awssdk.v2migration.AddS3EventNotificationDependency
+displayName: Add AWS SDK for Java v2 S3 Event Notification dependency if needed
+description: This recipe will add the Java v2 S3 Event Notification dependency if v1 S3EventNotification is used
+tags:
+ - aws
+ - sdk
+recipeList:
+ - org.openrewrite.java.dependencies.AddDependency:
+ groupId: software.amazon.awssdk
+ artifactId: s3-event-notifications
+ version: ${sdkVersion}
+ onlyIfUsing: com.amazonaws.services.s3.event.S3EventNotification
\ No newline at end of file