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

software.amazon.awssdk.services.notifications.model.GetEventRuleResponse 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.time.Instant;
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.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.traits.MapTrait;
import software.amazon.awssdk.core.traits.TimestampFormatTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructMap;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructMap;
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 GetEventRuleResponse extends NotificationsResponse implements
        ToCopyableBuilder {
    private static final SdkField ARN_FIELD = SdkField. builder(MarshallingType.STRING).memberName("arn")
            .getter(getter(GetEventRuleResponse::arn)).setter(setter(Builder::arn))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("arn").build()).build();

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

    private static final SdkField CREATION_TIME_FIELD = SdkField
            . builder(MarshallingType.INSTANT)
            .memberName("creationTime")
            .getter(getter(GetEventRuleResponse::creationTime))
            .setter(setter(Builder::creationTime))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("creationTime").build(),
                    TimestampFormatTrait.create(TimestampFormatTrait.Format.ISO_8601)).build();

    private static final SdkField SOURCE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("source")
            .getter(getter(GetEventRuleResponse::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(GetEventRuleResponse::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(GetEventRuleResponse::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(GetEventRuleResponse::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 SdkField> MANAGED_RULES_FIELD = SdkField
            .> builder(MarshallingType.LIST)
            .memberName("managedRules")
            .getter(getter(GetEventRuleResponse::managedRules))
            .setter(setter(Builder::managedRules))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("managedRules").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> STATUS_SUMMARY_BY_REGION_FIELD = SdkField
            .> builder(MarshallingType.MAP)
            .memberName("statusSummaryByRegion")
            .getter(getter(GetEventRuleResponse::statusSummaryByRegion))
            .setter(setter(Builder::statusSummaryByRegion))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("statusSummaryByRegion").build(),
                    MapTrait.builder()
                            .keyLocationName("key")
                            .valueLocationName("value")
                            .valueFieldInfo(
                                    SdkField. builder(MarshallingType.SDK_POJO)
                                            .constructor(EventRuleStatusSummary::builder)
                                            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
                                                    .locationName("value").build()).build()).build()).build();

    private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ARN_FIELD,
            NOTIFICATION_CONFIGURATION_ARN_FIELD, CREATION_TIME_FIELD, SOURCE_FIELD, EVENT_TYPE_FIELD, EVENT_PATTERN_FIELD,
            REGIONS_FIELD, MANAGED_RULES_FIELD, STATUS_SUMMARY_BY_REGION_FIELD));

    private static final Map> SDK_NAME_TO_FIELD = Collections
            .unmodifiableMap(new HashMap>() {
                {
                    put("arn", ARN_FIELD);
                    put("notificationConfigurationArn", NOTIFICATION_CONFIGURATION_ARN_FIELD);
                    put("creationTime", CREATION_TIME_FIELD);
                    put("source", SOURCE_FIELD);
                    put("eventType", EVENT_TYPE_FIELD);
                    put("eventPattern", EVENT_PATTERN_FIELD);
                    put("regions", REGIONS_FIELD);
                    put("managedRules", MANAGED_RULES_FIELD);
                    put("statusSummaryByRegion", STATUS_SUMMARY_BY_REGION_FIELD);
                }
            });

    private final String arn;

    private final String notificationConfigurationArn;

    private final Instant creationTime;

    private final String source;

    private final String eventType;

    private final String eventPattern;

    private final List regions;

    private final List managedRules;

    private final Map statusSummaryByRegion;

    private GetEventRuleResponse(BuilderImpl builder) {
        super(builder);
        this.arn = builder.arn;
        this.notificationConfigurationArn = builder.notificationConfigurationArn;
        this.creationTime = builder.creationTime;
        this.source = builder.source;
        this.eventType = builder.eventType;
        this.eventPattern = builder.eventPattern;
        this.regions = builder.regions;
        this.managedRules = builder.managedRules;
        this.statusSummaryByRegion = builder.statusSummaryByRegion;
    }

    /**
     * 

* The ARN of the resource. *

* * @return The ARN of the resource. */ public final String arn() { return arn; } /** *

* The ARN of a NotificationConfiguration. *

* * @return The ARN of a NotificationConfiguration. */ public final String notificationConfigurationArn() { return notificationConfigurationArn; } /** *

* The date when the EventRule was created. *

* * @return The date when the EventRule was created. */ public final Instant creationTime() { return creationTime; } /** *

* 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; } /** * For responses, this returns true if the service returned a value for the ManagedRules 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 hasManagedRules() { return managedRules != null && !(managedRules instanceof SdkAutoConstructList); } /** *

* A list of managed rules from EventBridge that are are associated with this EventRule. *

* *

* These are created by AWS User Notifications within your account so this EventRule functions. *

*
*

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

* * @return A list of managed rules from EventBridge that are are associated with this EventRule.

*

* These are created by AWS User Notifications within your account so this EventRule functions. *

*/ public final List managedRules() { return managedRules; } /** * For responses, this returns true if the service returned a value for the StatusSummaryByRegion 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 hasStatusSummaryByRegion() { return statusSummaryByRegion != null && !(statusSummaryByRegion instanceof SdkAutoConstructMap); } /** *

* A list of an EventRule's status by Region. Regions are mapped to EventRuleStatusSummary. *

*

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

* * @return A list of an EventRule's status by Region. Regions are mapped to EventRuleStatusSummary. */ public final Map statusSummaryByRegion() { return statusSummaryByRegion; } @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(arn()); hashCode = 31 * hashCode + Objects.hashCode(notificationConfigurationArn()); hashCode = 31 * hashCode + Objects.hashCode(creationTime()); 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); hashCode = 31 * hashCode + Objects.hashCode(hasManagedRules() ? managedRules() : null); hashCode = 31 * hashCode + Objects.hashCode(hasStatusSummaryByRegion() ? statusSummaryByRegion() : 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 GetEventRuleResponse)) { return false; } GetEventRuleResponse other = (GetEventRuleResponse) obj; return Objects.equals(arn(), other.arn()) && Objects.equals(notificationConfigurationArn(), other.notificationConfigurationArn()) && Objects.equals(creationTime(), other.creationTime()) && Objects.equals(source(), other.source()) && Objects.equals(eventType(), other.eventType()) && Objects.equals(eventPattern(), other.eventPattern()) && hasRegions() == other.hasRegions() && Objects.equals(regions(), other.regions()) && hasManagedRules() == other.hasManagedRules() && Objects.equals(managedRules(), other.managedRules()) && hasStatusSummaryByRegion() == other.hasStatusSummaryByRegion() && Objects.equals(statusSummaryByRegion(), other.statusSummaryByRegion()); } /** * 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("GetEventRuleResponse").add("Arn", arn()) .add("NotificationConfigurationArn", notificationConfigurationArn()).add("CreationTime", creationTime()) .add("Source", source()).add("EventType", eventType()).add("EventPattern", eventPattern()) .add("Regions", hasRegions() ? regions() : null).add("ManagedRules", hasManagedRules() ? managedRules() : null) .add("StatusSummaryByRegion", hasStatusSummaryByRegion() ? statusSummaryByRegion() : null).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "arn": return Optional.ofNullable(clazz.cast(arn())); case "notificationConfigurationArn": return Optional.ofNullable(clazz.cast(notificationConfigurationArn())); case "creationTime": return Optional.ofNullable(clazz.cast(creationTime())); 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())); case "managedRules": return Optional.ofNullable(clazz.cast(managedRules())); case "statusSummaryByRegion": return Optional.ofNullable(clazz.cast(statusSummaryByRegion())); 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((GetEventRuleResponse) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends NotificationsResponse.Builder, SdkPojo, CopyableBuilder { /** *

* The ARN of the resource. *

* * @param arn * The ARN of the resource. * @return Returns a reference to this object so that method calls can be chained together. */ Builder arn(String arn); /** *

* The ARN of a NotificationConfiguration. *

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

* The date when the EventRule was created. *

* * @param creationTime * The date when the EventRule was created. * @return Returns a reference to this object so that method calls can be chained together. */ Builder creationTime(Instant creationTime); /** *

* 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); /** *

* A list of managed rules from EventBridge that are are associated with this EventRule. *

* *

* These are created by AWS User Notifications within your account so this EventRule functions. *

*
* * @param managedRules * A list of managed rules from EventBridge that are are associated with this EventRule.

*

* These are created by AWS User Notifications within your account so this EventRule functions. *

* @return Returns a reference to this object so that method calls can be chained together. */ Builder managedRules(Collection managedRules); /** *

* A list of managed rules from EventBridge that are are associated with this EventRule. *

* *

* These are created by AWS User Notifications within your account so this EventRule functions. *

*
* * @param managedRules * A list of managed rules from EventBridge that are are associated with this EventRule.

*

* These are created by AWS User Notifications within your account so this EventRule functions. *

* @return Returns a reference to this object so that method calls can be chained together. */ Builder managedRules(String... managedRules); /** *

* A list of an EventRule's status by Region. Regions are mapped to EventRuleStatusSummary. *

* * @param statusSummaryByRegion * A list of an EventRule's status by Region. Regions are mapped to EventRuleStatusSummary. * @return Returns a reference to this object so that method calls can be chained together. */ Builder statusSummaryByRegion(Map statusSummaryByRegion); } static final class BuilderImpl extends NotificationsResponse.BuilderImpl implements Builder { private String arn; private String notificationConfigurationArn; private Instant creationTime; private String source; private String eventType; private String eventPattern; private List regions = DefaultSdkAutoConstructList.getInstance(); private List managedRules = DefaultSdkAutoConstructList.getInstance(); private Map statusSummaryByRegion = DefaultSdkAutoConstructMap.getInstance(); private BuilderImpl() { } private BuilderImpl(GetEventRuleResponse model) { super(model); arn(model.arn); notificationConfigurationArn(model.notificationConfigurationArn); creationTime(model.creationTime); source(model.source); eventType(model.eventType); eventPattern(model.eventPattern); regions(model.regions); managedRules(model.managedRules); statusSummaryByRegion(model.statusSummaryByRegion); } public final String getArn() { return arn; } public final void setArn(String arn) { this.arn = arn; } @Override public final Builder arn(String arn) { this.arn = arn; return this; } 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 Instant getCreationTime() { return creationTime; } public final void setCreationTime(Instant creationTime) { this.creationTime = creationTime; } @Override public final Builder creationTime(Instant creationTime) { this.creationTime = creationTime; 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; } public final Collection getManagedRules() { if (managedRules instanceof SdkAutoConstructList) { return null; } return managedRules; } public final void setManagedRules(Collection managedRules) { this.managedRules = ManagedRuleArnsCopier.copy(managedRules); } @Override public final Builder managedRules(Collection managedRules) { this.managedRules = ManagedRuleArnsCopier.copy(managedRules); return this; } @Override @SafeVarargs public final Builder managedRules(String... managedRules) { managedRules(Arrays.asList(managedRules)); return this; } public final Map getStatusSummaryByRegion() { Map result = StatusSummaryByRegionCopier .copyToBuilder(this.statusSummaryByRegion); if (result instanceof SdkAutoConstructMap) { return null; } return result; } public final void setStatusSummaryByRegion(Map statusSummaryByRegion) { this.statusSummaryByRegion = StatusSummaryByRegionCopier.copyFromBuilder(statusSummaryByRegion); } @Override public final Builder statusSummaryByRegion(Map statusSummaryByRegion) { this.statusSummaryByRegion = StatusSummaryByRegionCopier.copy(statusSummaryByRegion); return this; } @Override public GetEventRuleResponse build() { return new GetEventRuleResponse(this); } @Override public List> sdkFields() { return SDK_FIELDS; } @Override public Map> sdkFieldNameToField() { return SDK_NAME_TO_FIELD; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy