All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.notifications.model.CreateEventRuleRequest Maven / Gradle / Ivy

/*
 * 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.notifications.model;

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
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;

/**
 */
@Generated("software.amazon.awssdk:codegen")
public final class CreateEventRuleRequest extends NotificationsRequest implements
        ToCopyableBuilder {
    private static final SdkField NOTIFICATION_CONFIGURATION_ARN_FIELD = SdkField
            . builder(MarshallingType.STRING)
            .memberName("notificationConfigurationArn")
            .getter(getter(CreateEventRuleRequest::notificationConfigurationArn))
            .setter(setter(Builder::notificationConfigurationArn))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("notificationConfigurationArn")
                    .build()).build();

    private static final SdkField SOURCE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("source")
            .getter(getter(CreateEventRuleRequest::source)).setter(setter(Builder::source))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("source").build()).build();

    private static final SdkField EVENT_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("eventType").getter(getter(CreateEventRuleRequest::eventType)).setter(setter(Builder::eventType))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("eventType").build()).build();

    private static final SdkField EVENT_PATTERN_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("eventPattern").getter(getter(CreateEventRuleRequest::eventPattern))
            .setter(setter(Builder::eventPattern))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("eventPattern").build()).build();

    private static final SdkField> REGIONS_FIELD = SdkField
            .> builder(MarshallingType.LIST)
            .memberName("regions")
            .getter(getter(CreateEventRuleRequest::regions))
            .setter(setter(Builder::regions))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("regions").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 List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(
            NOTIFICATION_CONFIGURATION_ARN_FIELD, SOURCE_FIELD, EVENT_TYPE_FIELD, EVENT_PATTERN_FIELD, REGIONS_FIELD));

    private static final Map> SDK_NAME_TO_FIELD = Collections
            .unmodifiableMap(new HashMap>() {
                {
                    put("notificationConfigurationArn", NOTIFICATION_CONFIGURATION_ARN_FIELD);
                    put("source", SOURCE_FIELD);
                    put("eventType", EVENT_TYPE_FIELD);
                    put("eventPattern", EVENT_PATTERN_FIELD);
                    put("regions", REGIONS_FIELD);
                }
            });

    private final String notificationConfigurationArn;

    private final String source;

    private final String eventType;

    private final String eventPattern;

    private final List regions;

    private CreateEventRuleRequest(BuilderImpl builder) {
        super(builder);
        this.notificationConfigurationArn = builder.notificationConfigurationArn;
        this.source = builder.source;
        this.eventType = builder.eventType;
        this.eventPattern = builder.eventPattern;
        this.regions = builder.regions;
    }

    /**
     * 

* The Amazon Resource Name (ARN) of the NotificationConfiguration associated with this EventRule. *

* * @return The Amazon Resource Name (ARN) of the NotificationConfiguration associated with this EventRule. */ public final String notificationConfigurationArn() { return notificationConfigurationArn; } /** *

* The matched event source. *

*

* Must match one of the valid EventBridge sources. Only AWS service sourced events are supported. For example, * aws.ec2 and aws.cloudwatch. For more information, see Event delivery from AWS services in the Amazon EventBridge User Guide. *

* * @return The matched event source.

*

* Must match one of the valid EventBridge sources. Only AWS service sourced events are supported. For * example, aws.ec2 and aws.cloudwatch. For more information, see Event delivery from AWS services in the Amazon EventBridge User Guide. */ public final String source() { return source; } /** *

* The event type to match. *

*

* Must match one of the valid Amazon EventBridge event types. For example, EC2 Instance State-change Notification * and AWS CloudWatch Alarm State Change. For more information, see Event delivery from AWS services in the Amazon EventBridge User Guide. *

* * @return The event type to match.

*

* Must match one of the valid Amazon EventBridge event types. For example, EC2 Instance State-change * Notification and AWS CloudWatch Alarm State Change. For more information, see Event delivery from AWS services in the Amazon EventBridge User Guide. */ public final String eventType() { return eventType; } /** *

* An additional event pattern used to further filter the events this EventRule receives. *

*

* For more information, see Amazon EventBridge event * patterns in the Amazon EventBridge User Guide. *

* * @return An additional event pattern used to further filter the events this EventRule receives.

*

* For more information, see Amazon EventBridge * event patterns in the Amazon EventBridge User Guide. */ public final String eventPattern() { return eventPattern; } /** * For responses, this returns true if the service returned a value for the Regions 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 hasRegions() { return regions != null && !(regions instanceof SdkAutoConstructList); } /** *

* A list of AWS Regions that send events to this EventRule. *

*

* 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 #hasRegions} method. *

* * @return A list of AWS Regions that send events to this EventRule. */ public final List regions() { return regions; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + super.hashCode(); hashCode = 31 * hashCode + Objects.hashCode(notificationConfigurationArn()); hashCode = 31 * hashCode + Objects.hashCode(source()); hashCode = 31 * hashCode + Objects.hashCode(eventType()); hashCode = 31 * hashCode + Objects.hashCode(eventPattern()); hashCode = 31 * hashCode + Objects.hashCode(hasRegions() ? regions() : null); return hashCode; } @Override public final boolean equals(Object obj) { return super.equals(obj) && equalsBySdkFields(obj); } @Override public final boolean equalsBySdkFields(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof CreateEventRuleRequest)) { return false; } CreateEventRuleRequest other = (CreateEventRuleRequest) obj; return Objects.equals(notificationConfigurationArn(), other.notificationConfigurationArn()) && Objects.equals(source(), other.source()) && Objects.equals(eventType(), other.eventType()) && Objects.equals(eventPattern(), other.eventPattern()) && hasRegions() == other.hasRegions() && Objects.equals(regions(), other.regions()); } /** * 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("CreateEventRuleRequest").add("NotificationConfigurationArn", notificationConfigurationArn()) .add("Source", source()).add("EventType", eventType()).add("EventPattern", eventPattern()) .add("Regions", hasRegions() ? regions() : null).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "notificationConfigurationArn": return Optional.ofNullable(clazz.cast(notificationConfigurationArn())); case "source": return Optional.ofNullable(clazz.cast(source())); case "eventType": return Optional.ofNullable(clazz.cast(eventType())); case "eventPattern": return Optional.ofNullable(clazz.cast(eventPattern())); case "regions": return Optional.ofNullable(clazz.cast(regions())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } @Override public final Map> sdkFieldNameToField() { return SDK_NAME_TO_FIELD; } private static Function getter(Function g) { return obj -> g.apply((CreateEventRuleRequest) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends NotificationsRequest.Builder, SdkPojo, CopyableBuilder { /** *

* The Amazon Resource Name (ARN) of the NotificationConfiguration associated with this EventRule. *

* * @param notificationConfigurationArn * The Amazon Resource Name (ARN) of the NotificationConfiguration associated with this EventRule. * @return Returns a reference to this object so that method calls can be chained together. */ Builder notificationConfigurationArn(String notificationConfigurationArn); /** *

* The matched event source. *

*

* Must match one of the valid EventBridge sources. Only AWS service sourced events are supported. For example, * aws.ec2 and aws.cloudwatch. For more information, see Event delivery from AWS services in the Amazon EventBridge User Guide. *

* * @param source * The matched event source.

*

* Must match one of the valid EventBridge sources. Only AWS service sourced events are supported. For * example, aws.ec2 and aws.cloudwatch. For more information, see Event delivery from AWS services in the Amazon EventBridge User Guide. * @return Returns a reference to this object so that method calls can be chained together. */ Builder source(String source); /** *

* The event type to match. *

*

* Must match one of the valid Amazon EventBridge event types. For example, EC2 Instance State-change * Notification and AWS CloudWatch Alarm State Change. For more information, see Event delivery from AWS services in the Amazon EventBridge User Guide. *

* * @param eventType * The event type to match.

*

* Must match one of the valid Amazon EventBridge event types. For example, EC2 Instance State-change * Notification and AWS CloudWatch Alarm State Change. For more information, see Event delivery from AWS services in the Amazon EventBridge User Guide. * @return Returns a reference to this object so that method calls can be chained together. */ Builder eventType(String eventType); /** *

* An additional event pattern used to further filter the events this EventRule receives. *

*

* For more information, see Amazon EventBridge * event patterns in the Amazon EventBridge User Guide. *

* * @param eventPattern * An additional event pattern used to further filter the events this EventRule receives.

*

* For more information, see Amazon * EventBridge event patterns in the Amazon EventBridge User Guide. * @return Returns a reference to this object so that method calls can be chained together. */ Builder eventPattern(String eventPattern); /** *

* A list of AWS Regions that send events to this EventRule. *

* * @param regions * A list of AWS Regions that send events to this EventRule. * @return Returns a reference to this object so that method calls can be chained together. */ Builder regions(Collection regions); /** *

* A list of AWS Regions that send events to this EventRule. *

* * @param regions * A list of AWS Regions that send events to this EventRule. * @return Returns a reference to this object so that method calls can be chained together. */ Builder regions(String... regions); @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @Override Builder overrideConfiguration(Consumer builderConsumer); } static final class BuilderImpl extends NotificationsRequest.BuilderImpl implements Builder { private String notificationConfigurationArn; private String source; private String eventType; private String eventPattern; private List regions = DefaultSdkAutoConstructList.getInstance(); private BuilderImpl() { } private BuilderImpl(CreateEventRuleRequest model) { super(model); notificationConfigurationArn(model.notificationConfigurationArn); source(model.source); eventType(model.eventType); eventPattern(model.eventPattern); regions(model.regions); } public final String getNotificationConfigurationArn() { return notificationConfigurationArn; } public final void setNotificationConfigurationArn(String notificationConfigurationArn) { this.notificationConfigurationArn = notificationConfigurationArn; } @Override public final Builder notificationConfigurationArn(String notificationConfigurationArn) { this.notificationConfigurationArn = notificationConfigurationArn; 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 String getEventType() { return eventType; } public final void setEventType(String eventType) { this.eventType = eventType; } @Override public final Builder eventType(String eventType) { this.eventType = eventType; return this; } public final String getEventPattern() { return eventPattern; } public final void setEventPattern(String eventPattern) { this.eventPattern = eventPattern; } @Override public final Builder eventPattern(String eventPattern) { this.eventPattern = eventPattern; return this; } public final Collection getRegions() { if (regions instanceof SdkAutoConstructList) { return null; } return regions; } public final void setRegions(Collection regions) { this.regions = RegionsCopier.copy(regions); } @Override public final Builder regions(Collection regions) { this.regions = RegionsCopier.copy(regions); return this; } @Override @SafeVarargs public final Builder regions(String... regions) { regions(Arrays.asList(regions)); return this; } @Override public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) { super.overrideConfiguration(overrideConfiguration); return this; } @Override public Builder overrideConfiguration(Consumer builderConsumer) { super.overrideConfiguration(builderConsumer); return this; } @Override public CreateEventRuleRequest build() { return new CreateEventRuleRequest(this); } @Override public List> sdkFields() { return SDK_FIELDS; } @Override public Map> sdkFieldNameToField() { return SDK_NAME_TO_FIELD; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy