software.amazon.awssdk.services.eventbridge.model.PutEventsRequestEntry Maven / Gradle / Ivy
Show all versions of eventbridge Show documentation
/*
* 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.services.eventbridge.model;
import java.io.Serializable;
import java.time.Instant;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Represents an event to be submitted.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class PutEventsRequestEntry implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.getter(getter(PutEventsRequestEntry::time)).setter(setter(Builder::time))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Time").build()).build();
private static final SdkField SOURCE_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(PutEventsRequestEntry::source)).setter(setter(Builder::source))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Source").build()).build();
private static final SdkField> RESOURCES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.getter(getter(PutEventsRequestEntry::resources))
.setter(setter(Builder::resources))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Resources").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField DETAIL_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(PutEventsRequestEntry::detailType)).setter(setter(Builder::detailType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DetailType").build()).build();
private static final SdkField DETAIL_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(PutEventsRequestEntry::detail)).setter(setter(Builder::detail))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Detail").build()).build();
private static final SdkField EVENT_BUS_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(PutEventsRequestEntry::eventBusName)).setter(setter(Builder::eventBusName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EventBusName").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(TIME_FIELD, SOURCE_FIELD,
RESOURCES_FIELD, DETAIL_TYPE_FIELD, DETAIL_FIELD, EVENT_BUS_NAME_FIELD));
private static final long serialVersionUID = 1L;
private final Instant time;
private final String source;
private final List resources;
private final String detailType;
private final String detail;
private final String eventBusName;
private PutEventsRequestEntry(BuilderImpl builder) {
this.time = builder.time;
this.source = builder.source;
this.resources = builder.resources;
this.detailType = builder.detailType;
this.detail = builder.detail;
this.eventBusName = builder.eventBusName;
}
/**
*
* The time stamp of the event, per RFC3339. If no time
* stamp is provided, the time stamp of the PutEvents call is used.
*
*
* @return The time stamp of the event, per RFC3339. If no
* time stamp is provided, the time stamp of the PutEvents call is used.
*/
public Instant time() {
return time;
}
/**
*
* The source of the event.
*
*
* @return The source of the event.
*/
public String source() {
return source;
}
/**
* Returns true if the Resources property was specified by the sender (it may be empty), or false if the sender did
* not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service.
*/
public boolean hasResources() {
return resources != null && !(resources instanceof SdkAutoConstructList);
}
/**
*
* AWS resources, identified by Amazon Resource Name (ARN), which the event primarily concerns. Any number,
* including zero, may be present.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasResources()} to see if a value was sent in this field.
*
*
* @return AWS resources, identified by Amazon Resource Name (ARN), which the event primarily concerns. Any number,
* including zero, may be present.
*/
public List resources() {
return resources;
}
/**
*
* Free-form string used to decide what fields to expect in the event detail.
*
*
* @return Free-form string used to decide what fields to expect in the event detail.
*/
public String detailType() {
return detailType;
}
/**
*
* A valid JSON string. There is no other schema imposed. The JSON string may contain fields and nested subobjects.
*
*
* @return A valid JSON string. There is no other schema imposed. The JSON string may contain fields and nested
* subobjects.
*/
public String detail() {
return detail;
}
/**
*
* The event bus that will receive the event. Only the rules that are associated with this event bus will be able to
* match the event.
*
*
* @return The event bus that will receive the event. Only the rules that are associated with this event bus will be
* able to match the event.
*/
public String eventBusName() {
return eventBusName;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(time());
hashCode = 31 * hashCode + Objects.hashCode(source());
hashCode = 31 * hashCode + Objects.hashCode(resources());
hashCode = 31 * hashCode + Objects.hashCode(detailType());
hashCode = 31 * hashCode + Objects.hashCode(detail());
hashCode = 31 * hashCode + Objects.hashCode(eventBusName());
return hashCode;
}
@Override
public boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof PutEventsRequestEntry)) {
return false;
}
PutEventsRequestEntry other = (PutEventsRequestEntry) obj;
return Objects.equals(time(), other.time()) && Objects.equals(source(), other.source())
&& Objects.equals(resources(), other.resources()) && Objects.equals(detailType(), other.detailType())
&& Objects.equals(detail(), other.detail()) && Objects.equals(eventBusName(), other.eventBusName());
}
/**
* Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
* redacted from this string using a placeholder value.
*/
@Override
public String toString() {
return ToString.builder("PutEventsRequestEntry").add("Time", time()).add("Source", source())
.add("Resources", resources()).add("DetailType", detailType()).add("Detail", detail())
.add("EventBusName", eventBusName()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Time":
return Optional.ofNullable(clazz.cast(time()));
case "Source":
return Optional.ofNullable(clazz.cast(source()));
case "Resources":
return Optional.ofNullable(clazz.cast(resources()));
case "DetailType":
return Optional.ofNullable(clazz.cast(detailType()));
case "Detail":
return Optional.ofNullable(clazz.cast(detail()));
case "EventBusName":
return Optional.ofNullable(clazz.cast(eventBusName()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function