software.amazon.awssdk.services.eventbridge.model.Rule 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.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).memberName("Name")
.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).memberName("Arn")
.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)
.memberName("EventPattern").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).memberName("State")
.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)
.memberName("Description").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)
.memberName("ScheduleExpression").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)
.memberName("RoleArn").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)
.memberName("ManagedBy").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)
.memberName("EventBusName").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 final String name() {
return name;
}
/**
*
* The Amazon Resource Name (ARN) of the rule.
*
*
* @return The Amazon Resource Name (ARN) of the rule.
*/
public final String arn() {
return arn;
}
/**
*
* The event pattern of the rule. For more information, see Events and
* Event Patterns in the Amazon EventBridge User Guide.
*
*
* @return The event pattern of the rule. For more information, see Events and Event Patterns in the Amazon EventBridge User Guide.
*/
public final 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 final 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 final String stateAsString() {
return state;
}
/**
*
* The description of the rule.
*
*
* @return The description of the rule.
*/
public final String description() {
return description;
}
/**
*
* The scheduling expression. For example, "cron(0 20 * * ? *)", "rate(5 minutes)". For more information, see Creating an Amazon
* EventBridge rule that runs on a schedule.
*
*
* @return The scheduling expression. For example, "cron(0 20 * * ? *)", "rate(5 minutes)". For more information,
* see Creating an
* Amazon EventBridge rule that runs on a schedule.
*/
public final String scheduleExpression() {
return scheduleExpression;
}
/**
*
* The Amazon Resource Name (ARN) of the role that is used for target invocation.
*
*
* If you're setting an event bus in another account as the target and that account granted permission to your
* account through an organization instead of directly by the account ID, you must specify a RoleArn
* with proper permissions in the Target
structure, instead of here in this parameter.
*
*
* @return The Amazon Resource Name (ARN) of the role that is used for target invocation.
*
* If you're setting an event bus in another account as the target and that account granted permission to
* your account through an organization instead of directly by the account ID, you must specify a
* RoleArn
with proper permissions in the Target
structure, instead of here in
* this parameter.
*/
public final String roleArn() {
return roleArn;
}
/**
*
* If the rule was created on behalf of your account by an Amazon Web Services service, this field displays the
* principal name of the service that created the rule.
*
*
* @return If the rule was created on behalf of your account by an Amazon Web Services service, this field displays
* the principal name of the service that created the rule.
*/
public final String managedBy() {
return managedBy;
}
/**
*
* The name or ARN of the event bus associated with the rule. If you omit this, the default event bus is used.
*
*
* @return The name or ARN of the event bus associated with the rule. If you omit this, the default event bus is
* used.
*/
public final 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 final 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 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 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 final 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 final 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 final List> sdkFields() {
return SDK_FIELDS;
}
private static Function