Skip to content

Commit 984dfa7

Browse files
authored
S3 Event Notification javadoc improvement (#5063)
* S3 Event Notification java-doc improvement. * S3 Event Notification java-doc improvement.
1 parent d3e828a commit 984dfa7

File tree

10 files changed

+181
-5
lines changed

10 files changed

+181
-5
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"type": "documentation",
3+
"category": "S3",
4+
"contributor": "",
5+
"description": "improve javadoc for S3 Event Notification module."
6+
}

services-custom/s3-event-notifications/src/main/java/software/amazon/awssdk/eventnotifications/s3/model/IntelligentTieringEventData.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
import software.amazon.awssdk.utils.ToString;
2222

2323
/**
24-
* The IntelligentTieringEventData key is only visible for S3 Intelligent-Tiering events.
24+
* The IntelligentTieringEventData key is only visible for
25+
* <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/intelligent-tiering.html">S3 Intelligent-Tiering</a>
26+
* related events.
2527
*/
2628
@SdkPublicApi
2729
public class IntelligentTieringEventData {

services-custom/s3-event-notifications/src/main/java/software/amazon/awssdk/eventnotifications/s3/model/LifecycleEventData.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
import software.amazon.awssdk.utils.ToString;
2222

2323
/**
24-
* The LifecycleEventData is only visible for S3 Lifecycle transition events.
24+
* The LifecycleEventData is only visible for
25+
* <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/lifecycle-transition-general-considerations.html">
26+
* S3 Lifecycle transition</a> related events.
2527
*/
2628
@SdkPublicApi
2729
public class LifecycleEventData {

services-custom/s3-event-notifications/src/main/java/software/amazon/awssdk/eventnotifications/s3/model/ReplicationEventData.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
import software.amazon.awssdk.utils.ToString;
2222

2323
/**
24-
* The ReplicationEventData is only visible for replication events.
24+
* The ReplicationEventData is only visible for
25+
* <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/replication.html">replication</a> related events.
2526
*/
2627
@SdkPublicApi
2728
public class ReplicationEventData {

services-custom/s3-event-notifications/src/main/java/software/amazon/awssdk/eventnotifications/s3/model/ResponseElements.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919
import software.amazon.awssdk.annotations.SdkPublicApi;
2020
import software.amazon.awssdk.utils.ToString;
2121

22+
/**
23+
* The responseElements key value is useful if you want to trace a request by following up with AWS Support.
24+
* Both x-amz-request-id and x-amz-id-2 help Amazon S3 trace an individual request. These values are the same as those that
25+
* Amazon S3 returns in the response to the request that initiates the events. This is so they can be used to match the event
26+
* to the request.
27+
*/
2228
@SdkPublicApi
2329
public class ResponseElements {
2430

services-custom/s3-event-notifications/src/main/java/software/amazon/awssdk/eventnotifications/s3/model/S3.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
import software.amazon.awssdk.annotations.SdkPublicApi;
2020
import software.amazon.awssdk.utils.ToString;
2121

22+
/**
23+
* The s3 key provides information about the bucket and object involved in the event. The object key name value is URL encoded.
24+
* For example, "red flower.jpg" becomes "red+flower.jpg" (Amazon S3 returns "application/x-www-form-urlencoded" as the content
25+
* type in the response).
26+
*/
2227
@SdkPublicApi
2328
public class S3 {
2429

@@ -34,14 +39,24 @@ public S3(String configurationId, S3Bucket bucket, S3Object object, String s3Sch
3439
this.s3SchemaVersion = s3SchemaVersion;
3540
}
3641

42+
/**
43+
* @return the ID found in the bucket notification configuration
44+
*/
3745
public String getConfigurationId() {
3846
return configurationId;
3947
}
4048

49+
/**
50+
* @return the bucket information.
51+
*/
4152
public S3Bucket getBucket() {
4253
return bucket;
4354
}
4455

56+
/**
57+
*
58+
* @return
59+
*/
4560
public S3Object getObject() {
4661
return object;
4762
}

services-custom/s3-event-notifications/src/main/java/software/amazon/awssdk/eventnotifications/s3/model/S3Bucket.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
import software.amazon.awssdk.annotations.SdkPublicApi;
2121
import software.amazon.awssdk.utils.ToString;
2222

23+
/**
24+
* Bucket information.
25+
*/
2326
@SdkPublicApi
2427
public class S3Bucket {
2528

@@ -33,14 +36,23 @@ public S3Bucket(String name, UserIdentity ownerIdentity, String arn) {
3336
this.arn = arn;
3437
}
3538

39+
/**
40+
* @return the bucket name.
41+
*/
3642
public String getName() {
3743
return name;
3844
}
3945

46+
/**
47+
* @return the user identity containing the Amazon customer ID of the bucket owner.
48+
*/
4049
public UserIdentity getOwnerIdentity() {
4150
return ownerIdentity;
4251
}
4352

53+
/**
54+
* @return The bucket ARN.
55+
*/
4456
public String getArn() {
4557
return arn;
4658
}

services-custom/s3-event-notifications/src/main/java/software/amazon/awssdk/eventnotifications/s3/model/S3EventNotification.java

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@
2525
import software.amazon.awssdk.utils.ToString;
2626

2727
/**
28-
* A helper class that represents a strongly typed S3 EventNotification item sent to SQS, SNS, or Lambda.
28+
* A helper class that represents a strongly typed S3 Event Notification item sent to SQS, SNS, or Lambda. For more information
29+
* about Amazon S3 Event Notifications, visit the
30+
* <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/EventNotifications.html">S3 User Guide</a>.
31+
* This class can be used to parse notification messages in the json format or to serialize a S3EventNotification instance to
32+
* json.
2933
*/
3034
@SdkPublicApi
3135
public class S3EventNotification {
@@ -40,23 +44,58 @@ public List<S3EventNotificationRecord> getRecords() {
4044
return records;
4145
}
4246

47+
/**
48+
* Converts a json representation of the notification message to an instance of S3EventNotification. Any missing fields
49+
* of the json will be null in the resulting object.
50+
* Any extra fields will be ignored.
51+
* @param json the notification message in json format
52+
* @return an instance of notification message S3EventNotification
53+
*/
4354
public static S3EventNotification fromJson(String json) {
4455
return S3EventNotificationReader.create().read(json);
4556
}
4657

47-
58+
/**
59+
* Converts a json representation of the notification message to an instance of S3EventNotification. Any missing fields
60+
* of the json will be null in the resulting object.
61+
* Any extra fields will be ignored.
62+
* @param json the notification message in json format
63+
* @return an instance of notification message S3EventNotification
64+
*/
4865
public static S3EventNotification fromJson(byte[] json) {
4966
return S3EventNotificationReader.create().read(json);
5067
}
5168

69+
/**
70+
* Converts a json representation of the notification message to an instance of S3EventNotification. Any missing fields
71+
* of the json will be null in the resulting object.
72+
* Any extra fields will be ignored.
73+
* @param json the notification message in json format
74+
* @return an instance of notification message S3EventNotification
75+
*/
5276
public S3EventNotification fromJson(InputStream json) {
5377
return S3EventNotificationReader.create().read(json);
5478
}
5579

80+
/**
81+
* Serialize this instance to json format. {@link GlacierEventData}, {@link ReplicationEventData},
82+
* {@link IntelligentTieringEventData} and {@link LifecycleEventData} keys
83+
* will be excluded from the json if {@code null}. Any other null fields of the object will be serialized as
84+
* json {@code null}.
85+
* @return the json representation of this class.
86+
*/
5687
public String toJson() {
5788
return S3EventNotificationWriter.create().writeToString(this);
5889
}
5990

91+
/**
92+
* Serialize this instance to json format, with new line and correct indentation levels. {@link GlacierEventData},
93+
* {@link ReplicationEventData},
94+
* {@link IntelligentTieringEventData} and {@link LifecycleEventData} keys
95+
* will be excluded from the json if {@code null}. Any other null fields of the object will be serialized as
96+
* json {@code null}.
97+
* @return the json representation of this class.
98+
*/
6099
public String toJsonPretty() {
61100
S3EventNotificationWriter writer = S3EventNotificationWriter.builder()
62101
.prettyPrint(true)

services-custom/s3-event-notifications/src/main/java/software/amazon/awssdk/eventnotifications/s3/model/S3EventNotificationRecord.java

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121
import software.amazon.awssdk.annotations.SdkTestInternalApi;
2222
import software.amazon.awssdk.utils.ToString;
2323

24+
/**
25+
* A record representing a notification for a single event. The
26+
* <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/notification-content-structure.html">Event message structure</a>
27+
* page of S3 user guide contains additional information about the different fields of the
28+
* notification record.
29+
*/
2430
@SdkPublicApi
2531
public class S3EventNotificationRecord {
2632

@@ -101,50 +107,116 @@ public String getAwsRegion() {
101107
return awsRegion;
102108
}
103109

110+
/**
111+
* The name of the event type for this notification. For more information about the various event type, visit the
112+
* <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/notification-how-to-event-types-and-destinations.html#supported-notification-event-types">
113+
* Event notification types and destinations
114+
* </a> page of S3 user guide.
115+
* It references the list of event notification types but doesn't contain the s3: prefix.
116+
* @return the event name.
117+
*/
104118
public String getEventName() {
105119
return eventName;
106120
}
107121

122+
123+
/**
124+
* The service from which this event was generated, usually {@code "aws:s3"}.
125+
* @return the event source.
126+
*/
108127
public String getEventSource() {
109128
return eventSource;
110129
}
111130

131+
/**
132+
* @return The time, in ISO-8601 format, for example, 1970-01-01T00:00:00.000Z, when Amazon S3 finished processing the
133+
* request.
134+
*/
112135
public Instant getEventTime() {
113136
return eventTime;
114137
}
115138

139+
/**
140+
* The eventVersion key value contains a major and minor version in the form {@code <major>.<minor>}.
141+
* @return the event version.
142+
*/
116143
public String getEventVersion() {
117144
return eventVersion;
118145
}
119146

147+
/**
148+
* Request Parameters contains the {@code sourceIPAddress} field, which is the ip address where request came from.
149+
* @return the request parameter containing the source IP address.
150+
*/
120151
public RequestParameters getRequestParameters() {
121152
return requestParameters;
122153
}
123154

155+
/**
156+
* The responseElements key value is useful if you want to trace a request by following up with AWS Support.
157+
* Both x-amz-request-id and x-amz-id-2 help Amazon S3 trace an individual request.
158+
* These values are the same as those that Amazon S3 returns in the response to the request that initiates the events.
159+
* This is so they can be used to match the event to the request.
160+
* @return The response element containing the trace information.
161+
*/
124162
public ResponseElements getResponseElements() {
125163
return responseElements;
126164
}
127165

166+
/**
167+
* Contains information about the bucket and object involved in the event. The object key name value is URL encoded. For
168+
* example, "red flower.jpg" becomes "red+flower.jpg" (Amazon S3 returns "application/x-www-form-urlencoded" as the
169+
* content type in the response).
170+
* @return the instance of {@link S3} containing object information.
171+
*/
128172
public S3 getS3() {
129173
return s3;
130174
}
131175

176+
/**
177+
* The user identity contains the {@code principalId} field, which has the Amazon customer ID of the user who caused the
178+
* event.
179+
* @return the user identity containing the {@code principalId}.
180+
*/
132181
public UserIdentity getUserIdentity() {
133182
return userIdentity;
134183
}
135184

185+
/**
186+
* The GlacierEventData is only visible for s3:ObjectRestore:Completed events.
187+
* Contains information related to restoring an archived object. For more information about archive and storage classes, see
188+
* <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/restoring-objects.html">Restoring an archived object</a>
189+
* @return the glacier event data.
190+
*/
136191
public GlacierEventData getGlacierEventData() {
137192
return glacierEventData;
138193
}
139194

195+
/**
196+
* The LifecycleEventData is only visible for
197+
* <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/lifecycle-transition-general-considerations.html">
198+
* S3 Lifecycle transition</a> related events.
199+
* @return the lifecycle event data.
200+
*/
140201
public LifecycleEventData getLifecycleEventData() {
141202
return lifecycleEventData;
142203
}
143204

205+
/**
206+
* The IntelligentTieringEventData key is only visible for
207+
* <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/intelligent-tiering.html">S3 Intelligent-Tiering</a>
208+
* related events.
209+
* @return the intelligent tiering event data.
210+
*/
144211
public IntelligentTieringEventData getIntelligentTieringEventData() {
145212
return intelligentTieringEventData;
146213
}
147214

215+
/**
216+
* The ReplicationEventData is only visible for
217+
* <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/replication.html">replication</a> related events.
218+
* @return
219+
*/
148220
public ReplicationEventData getReplicationEventData() {
149221
return replicationEventData;
150222
}

services-custom/s3-event-notifications/src/main/java/software/amazon/awssdk/eventnotifications/s3/model/S3Object.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
import software.amazon.awssdk.annotations.SdkPublicApi;
2323
import software.amazon.awssdk.utils.ToString;
2424

25+
/**
26+
* Object information.
27+
*/
2528
@SdkPublicApi
2629
public class S3Object {
2730

@@ -39,6 +42,9 @@ public S3Object(String key, Long size, String eTag, String versionId, String seq
3942
this.sequencer = sequencer;
4043
}
4144

45+
/**
46+
* @return the object key.
47+
*/
4248
public String getKey() {
4349
return key;
4450
}
@@ -57,18 +63,33 @@ public String getUrlDecodedKey() {
5763
}
5864
}
5965

66+
/**
67+
* @return the object size in bytes.
68+
*/
6069
public Long getSizeAsLong() {
6170
return size;
6271
}
6372

73+
/**
74+
* @return the object eTag
75+
*/
6476
public String getETag() {
6577
return eTag;
6678
}
6779

80+
/**
81+
* @return the object version if bucket is versioning-enabled, otherwise null
82+
*/
6883
public String getVersionId() {
6984
return versionId;
7085
}
7186

87+
/**
88+
* The sequencer key provides a way to determine the sequence of events. Event notifications aren't guaranteed to arrive in
89+
* the same order that the events occurred. However, notifications from events that create objects (PUTs) and delete
90+
* objects contain a sequencer. It can be used to determine the order of events for a given object key.
91+
* @return A string representation of a hexadecimal value used to determine event sequence, only used with PUTs and DELETEs.
92+
*/
7293
public String getSequencer() {
7394
return sequencer;
7495
}

0 commit comments

Comments
 (0)