software.amazon.awssdk.services.eventbridge.model.Rule Maven / Gradle / Ivy
Show all versions of eventbridge Show documentation
/*
* Copyright 2015-2020 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.util.Arrays;
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.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Contains information about a rule in Amazon EventBridge.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Rule implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(Rule::name)).setter(setter(Builder::name))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Name").build()).build();
private static final SdkField ARN_FIELD = SdkField. builder(MarshallingType.STRING).getter(getter(Rule::arn))
.setter(setter(Builder::arn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Arn").build()).build();
private static final SdkField EVENT_PATTERN_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(Rule::eventPattern)).setter(setter(Builder::eventPattern))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EventPattern").build()).build();
private static final SdkField STATE_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(Rule::stateAsString)).setter(setter(Builder::state))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("State").build()).build();
private static final SdkField DESCRIPTION_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(Rule::description)).setter(setter(Builder::description))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Description").build()).build();
private static final SdkField SCHEDULE_EXPRESSION_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(Rule::scheduleExpression)).setter(setter(Builder::scheduleExpression))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ScheduleExpression").build())
.build();
private static final SdkField ROLE_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(Rule::roleArn)).setter(setter(Builder::roleArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RoleArn").build()).build();
private static final SdkField MANAGED_BY_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(Rule::managedBy)).setter(setter(Builder::managedBy))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ManagedBy").build()).build();
private static final SdkField EVENT_BUS_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(Rule::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(NAME_FIELD, ARN_FIELD,
EVENT_PATTERN_FIELD, STATE_FIELD, DESCRIPTION_FIELD, SCHEDULE_EXPRESSION_FIELD, ROLE_ARN_FIELD, MANAGED_BY_FIELD,
EVENT_BUS_NAME_FIELD));
private static final long serialVersionUID = 1L;
private final String name;
private final String arn;
private final String eventPattern;
private final String state;
private final String description;
private final String scheduleExpression;
private final String roleArn;
private final String managedBy;
private final String eventBusName;
private Rule(BuilderImpl builder) {
this.name = builder.name;
this.arn = builder.arn;
this.eventPattern = builder.eventPattern;
this.state = builder.state;
this.description = builder.description;
this.scheduleExpression = builder.scheduleExpression;
this.roleArn = builder.roleArn;
this.managedBy = builder.managedBy;
this.eventBusName = builder.eventBusName;
}
/**
*
* The name of the rule.
*
*
* @return The name of the rule.
*/
public String name() {
return name;
}
/**
*
* The Amazon Resource Name (ARN) of the rule.
*
*
* @return The Amazon Resource Name (ARN) of the rule.
*/
public String arn() {
return arn;
}
/**
*
* The event pattern of the rule. For more information, see Event
* Patterns in the Amazon EventBridge User Guide.
*
*
* @return The event pattern of the rule. For more information, see Event
* Patterns in the Amazon EventBridge User Guide.
*/
public String eventPattern() {
return eventPattern;
}
/**
*
* The state of the rule.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link RuleState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stateAsString}.
*
*
* @return The state of the rule.
* @see RuleState
*/
public RuleState state() {
return RuleState.fromValue(state);
}
/**
*
* The state of the rule.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link RuleState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stateAsString}.
*
*
* @return The state of the rule.
* @see RuleState
*/
public String stateAsString() {
return state;
}
/**
*
* The description of the rule.
*
*
* @return The description of the rule.
*/
public String description() {
return description;
}
/**
*
* The scheduling expression: for example, "cron(0 20 * * ? *)"
or "rate(5 minutes)"
.
*
*
* @return The scheduling expression: for example, "cron(0 20 * * ? *)"
or
* "rate(5 minutes)"
.
*/
public String scheduleExpression() {
return scheduleExpression;
}
/**
*
* The Amazon Resource Name (ARN) of the role that is used for target invocation.
*
*
* @return The Amazon Resource Name (ARN) of the role that is used for target invocation.
*/
public String roleArn() {
return roleArn;
}
/**
*
* If an AWS service created the rule on behalf of your account, this field displays the principal name of the
* service that created the rule.
*
*
* @return If an AWS service created the rule on behalf of your account, this field displays the principal name of
* the service that created the rule.
*/
public String managedBy() {
return managedBy;
}
/**
*
* The event bus associated with the rule.
*
*
* @return The event bus associated with the rule.
*/
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(name());
hashCode = 31 * hashCode + Objects.hashCode(arn());
hashCode = 31 * hashCode + Objects.hashCode(eventPattern());
hashCode = 31 * hashCode + Objects.hashCode(stateAsString());
hashCode = 31 * hashCode + Objects.hashCode(description());
hashCode = 31 * hashCode + Objects.hashCode(scheduleExpression());
hashCode = 31 * hashCode + Objects.hashCode(roleArn());
hashCode = 31 * hashCode + Objects.hashCode(managedBy());
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 Rule)) {
return false;
}
Rule other = (Rule) obj;
return Objects.equals(name(), other.name()) && Objects.equals(arn(), other.arn())
&& Objects.equals(eventPattern(), other.eventPattern()) && Objects.equals(stateAsString(), other.stateAsString())
&& Objects.equals(description(), other.description())
&& Objects.equals(scheduleExpression(), other.scheduleExpression()) && Objects.equals(roleArn(), other.roleArn())
&& Objects.equals(managedBy(), other.managedBy()) && 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("Rule").add("Name", name()).add("Arn", arn()).add("EventPattern", eventPattern())
.add("State", stateAsString()).add("Description", description()).add("ScheduleExpression", scheduleExpression())
.add("RoleArn", roleArn()).add("ManagedBy", managedBy()).add("EventBusName", eventBusName()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Name":
return Optional.ofNullable(clazz.cast(name()));
case "Arn":
return Optional.ofNullable(clazz.cast(arn()));
case "EventPattern":
return Optional.ofNullable(clazz.cast(eventPattern()));
case "State":
return Optional.ofNullable(clazz.cast(stateAsString()));
case "Description":
return Optional.ofNullable(clazz.cast(description()));
case "ScheduleExpression":
return Optional.ofNullable(clazz.cast(scheduleExpression()));
case "RoleArn":
return Optional.ofNullable(clazz.cast(roleArn()));
case "ManagedBy":
return Optional.ofNullable(clazz.cast(managedBy()));
case "EventBusName":
return Optional.ofNullable(clazz.cast(eventBusName()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function