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).memberName("Time")
.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).memberName("Source")
.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)
.memberName("Resources")
.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)
.memberName("DetailType").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).memberName("Detail")
.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)
.memberName("EventBusName").getter(getter(PutEventsRequestEntry::eventBusName)).setter(setter(Builder::eventBusName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EventBusName").build()).build();
private static final SdkField TRACE_HEADER_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("TraceHeader").getter(getter(PutEventsRequestEntry::traceHeader)).setter(setter(Builder::traceHeader))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TraceHeader").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, TRACE_HEADER_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 final String traceHeader;
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;
this.traceHeader = builder.traceHeader;
}
/**
*
* 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 final Instant time() {
return time;
}
/**
*
* The source of the event.
*
*
* @return The source of the event.
*/
public final String source() {
return source;
}
/**
* For responses, this returns true if the service returned a value for the Resources property. This DOES NOT check
* that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property). This is
* useful because the SDK will never return a null collection or map, but you may need to differentiate between the
* service returning nothing (or null) and the service returning an empty collection or map. For requests, this
* returns true if a value for the property was specified in the request builder, and false if a value was not
* specified.
*/
public final boolean hasResources() {
return resources != null && !(resources instanceof SdkAutoConstructList);
}
/**
*
* Amazon Web Services 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.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasResources} method.
*
*
* @return Amazon Web Services resources, identified by Amazon Resource Name (ARN), which the event primarily
* concerns. Any number, including zero, may be present.
*/
public final List resources() {
return resources;
}
/**
*
* Free-form string, with a maximum of 128 characters, used to decide what fields to expect in the event detail.
*
*
* @return Free-form string, with a maximum of 128 characters, used to decide what fields to expect in the event
* detail.
*/
public final String detailType() {
return detailType;
}
/**
*
* A valid JSON object. There is no other schema imposed. The JSON object may contain fields and nested subobjects.
*
*
* @return A valid JSON object. There is no other schema imposed. The JSON object may contain fields and nested
* subobjects.
*/
public final String detail() {
return detail;
}
/**
*
* The name or ARN of the event bus to receive the event. Only the rules that are associated with this event bus are
* used to match the event. If you omit this, the default event bus is used.
*
*
*
* If you're using a global endpoint with a custom bus, you must enter the name, not the ARN, of the event bus in
* either the primary or secondary Region here and the corresponding event bus in the other Region will be
* determined based on the endpoint referenced by the EndpointId
.
*
*
*
* @return The name or ARN of the event bus to receive the event. Only the rules that are associated with this event
* bus are used to match the event. If you omit this, the default event bus is used.
*
* If you're using a global endpoint with a custom bus, you must enter the name, not the ARN, of the event
* bus in either the primary or secondary Region here and the corresponding event bus in the other Region
* will be determined based on the endpoint referenced by the EndpointId
.
*
*/
public final String eventBusName() {
return eventBusName;
}
/**
*
* An X-Ray trace header, which is an http header (X-Amzn-Trace-Id) that contains the trace-id associated with the
* event.
*
*
* To learn more about X-Ray trace headers, see Tracing
* header in the X-Ray Developer Guide.
*
*
* @return An X-Ray trace header, which is an http header (X-Amzn-Trace-Id) that contains the trace-id associated
* with the event.
*
* To learn more about X-Ray trace headers, see Tracing header in the X-Ray Developer Guide.
*/
public final String traceHeader() {
return traceHeader;
}
@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 final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(time());
hashCode = 31 * hashCode + Objects.hashCode(source());
hashCode = 31 * hashCode + Objects.hashCode(hasResources() ? resources() : null);
hashCode = 31 * hashCode + Objects.hashCode(detailType());
hashCode = 31 * hashCode + Objects.hashCode(detail());
hashCode = 31 * hashCode + Objects.hashCode(eventBusName());
hashCode = 31 * hashCode + Objects.hashCode(traceHeader());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public final 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())
&& hasResources() == other.hasResources() && Objects.equals(resources(), other.resources())
&& Objects.equals(detailType(), other.detailType()) && Objects.equals(detail(), other.detail())
&& Objects.equals(eventBusName(), other.eventBusName()) && Objects.equals(traceHeader(), other.traceHeader());
}
/**
* 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 final String toString() {
return ToString.builder("PutEventsRequestEntry").add("Time", time()).add("Source", source())
.add("Resources", hasResources() ? resources() : null).add("DetailType", detailType()).add("Detail", detail())
.add("EventBusName", eventBusName()).add("TraceHeader", traceHeader()).build();
}
public final 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()));
case "TraceHeader":
return Optional.ofNullable(clazz.cast(traceHeader()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function
*
* If you're using a global endpoint with a custom bus, you must enter the name, not the ARN, of the
* event bus in either the primary or secondary Region here and the corresponding event bus in the other
* Region will be determined based on the endpoint referenced by the EndpointId
.
*
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder eventBusName(String eventBusName);
/**
*
* An X-Ray trace header, which is an http header (X-Amzn-Trace-Id) that contains the trace-id associated with
* the event.
*
*
* To learn more about X-Ray trace headers, see Tracing header in the X-Ray Developer Guide.
*
*
* @param traceHeader
* An X-Ray trace header, which is an http header (X-Amzn-Trace-Id) that contains the trace-id associated
* with the event.
*
* To learn more about X-Ray trace headers, see Tracing header in the X-Ray Developer Guide.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder traceHeader(String traceHeader);
}
static final class BuilderImpl implements Builder {
private Instant time;
private String source;
private List resources = DefaultSdkAutoConstructList.getInstance();
private String detailType;
private String detail;
private String eventBusName;
private String traceHeader;
private BuilderImpl() {
}
private BuilderImpl(PutEventsRequestEntry model) {
time(model.time);
source(model.source);
resources(model.resources);
detailType(model.detailType);
detail(model.detail);
eventBusName(model.eventBusName);
traceHeader(model.traceHeader);
}
public final Instant getTime() {
return time;
}
public final void setTime(Instant time) {
this.time = time;
}
@Override
public final Builder time(Instant time) {
this.time = time;
return this;
}
public final String getSource() {
return source;
}
public final void setSource(String source) {
this.source = source;
}
@Override
public final Builder source(String source) {
this.source = source;
return this;
}
public final Collection getResources() {
if (resources instanceof SdkAutoConstructList) {
return null;
}
return resources;
}
public final void setResources(Collection resources) {
this.resources = EventResourceListCopier.copy(resources);
}
@Override
public final Builder resources(Collection resources) {
this.resources = EventResourceListCopier.copy(resources);
return this;
}
@Override
@SafeVarargs
public final Builder resources(String... resources) {
resources(Arrays.asList(resources));
return this;
}
public final String getDetailType() {
return detailType;
}
public final void setDetailType(String detailType) {
this.detailType = detailType;
}
@Override
public final Builder detailType(String detailType) {
this.detailType = detailType;
return this;
}
public final String getDetail() {
return detail;
}
public final void setDetail(String detail) {
this.detail = detail;
}
@Override
public final Builder detail(String detail) {
this.detail = detail;
return this;
}
public final String getEventBusName() {
return eventBusName;
}
public final void setEventBusName(String eventBusName) {
this.eventBusName = eventBusName;
}
@Override
public final Builder eventBusName(String eventBusName) {
this.eventBusName = eventBusName;
return this;
}
public final String getTraceHeader() {
return traceHeader;
}
public final void setTraceHeader(String traceHeader) {
this.traceHeader = traceHeader;
}
@Override
public final Builder traceHeader(String traceHeader) {
this.traceHeader = traceHeader;
return this;
}
@Override
public PutEventsRequestEntry build() {
return new PutEventsRequestEntry(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
}
}