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

software.amazon.awssdk.services.codestarnotifications.model.UpdateNotificationRuleRequest 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.codestarnotifications.model;

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.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
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 UpdateNotificationRuleRequest extends CodestarNotificationsRequest implements
        ToCopyableBuilder {
    private static final SdkField ARN_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Arn")
            .getter(getter(UpdateNotificationRuleRequest::arn)).setter(setter(Builder::arn))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Arn").build()).build();

    private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Name")
            .getter(getter(UpdateNotificationRuleRequest::name)).setter(setter(Builder::name))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Name").build()).build();

    private static final SdkField STATUS_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Status")
            .getter(getter(UpdateNotificationRuleRequest::statusAsString)).setter(setter(Builder::status))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Status").build()).build();

    private static final SdkField> EVENT_TYPE_IDS_FIELD = SdkField
            .> builder(MarshallingType.LIST)
            .memberName("EventTypeIds")
            .getter(getter(UpdateNotificationRuleRequest::eventTypeIds))
            .setter(setter(Builder::eventTypeIds))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EventTypeIds").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> TARGETS_FIELD = SdkField
            .> builder(MarshallingType.LIST)
            .memberName("Targets")
            .getter(getter(UpdateNotificationRuleRequest::targets))
            .setter(setter(Builder::targets))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Targets").build(),
                    ListTrait
                            .builder()
                            .memberLocationName(null)
                            .memberFieldInfo(
                                    SdkField. builder(MarshallingType.SDK_POJO)
                                            .constructor(Target::builder)
                                            .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(UpdateNotificationRuleRequest::detailTypeAsString))
            .setter(setter(Builder::detailType))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DetailType").build()).build();

    private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ARN_FIELD, NAME_FIELD,
            STATUS_FIELD, EVENT_TYPE_IDS_FIELD, TARGETS_FIELD, DETAIL_TYPE_FIELD));

    private final String arn;

    private final String name;

    private final String status;

    private final List eventTypeIds;

    private final List targets;

    private final String detailType;

    private UpdateNotificationRuleRequest(BuilderImpl builder) {
        super(builder);
        this.arn = builder.arn;
        this.name = builder.name;
        this.status = builder.status;
        this.eventTypeIds = builder.eventTypeIds;
        this.targets = builder.targets;
        this.detailType = builder.detailType;
    }

    /**
     * 

* The Amazon Resource Name (ARN) of the notification rule. *

* * @return The Amazon Resource Name (ARN) of the notification rule. */ public final String arn() { return arn; } /** *

* The name of the notification rule. *

* * @return The name of the notification rule. */ public final String name() { return name; } /** *

* The status of the notification rule. Valid statuses include enabled (sending notifications) or disabled (not * sending notifications). *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #status} will * return {@link NotificationRuleStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available * from {@link #statusAsString}. *

* * @return The status of the notification rule. Valid statuses include enabled (sending notifications) or disabled * (not sending notifications). * @see NotificationRuleStatus */ public final NotificationRuleStatus status() { return NotificationRuleStatus.fromValue(status); } /** *

* The status of the notification rule. Valid statuses include enabled (sending notifications) or disabled (not * sending notifications). *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #status} will * return {@link NotificationRuleStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available * from {@link #statusAsString}. *

* * @return The status of the notification rule. Valid statuses include enabled (sending notifications) or disabled * (not sending notifications). * @see NotificationRuleStatus */ public final String statusAsString() { return status; } /** * For responses, this returns true if the service returned a value for the EventTypeIds 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 hasEventTypeIds() { return eventTypeIds != null && !(eventTypeIds instanceof SdkAutoConstructList); } /** *

* A list of event types associated with this notification rule. For a complete list of event types and IDs, see Notification * concepts in the Developer Tools Console User Guide. *

*

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

* * @return A list of event types associated with this notification rule. For a complete list of event types and IDs, * see Notification concepts in the Developer Tools Console User Guide. */ public final List eventTypeIds() { return eventTypeIds; } /** * For responses, this returns true if the service returned a value for the Targets 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 hasTargets() { return targets != null && !(targets instanceof SdkAutoConstructList); } /** *

* The address and type of the targets to receive notifications from this notification rule. *

*

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

* * @return The address and type of the targets to receive notifications from this notification rule. */ public final List targets() { return targets; } /** *

* The level of detail to include in the notifications for this resource. BASIC will include only the contents of * the event as it would appear in Amazon CloudWatch. FULL will include any supplemental information provided by AWS * CodeStar Notifications and/or the service for the resource for which the notification is created. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #detailType} will * return {@link DetailType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #detailTypeAsString}. *

* * @return The level of detail to include in the notifications for this resource. BASIC will include only the * contents of the event as it would appear in Amazon CloudWatch. FULL will include any supplemental * information provided by AWS CodeStar Notifications and/or the service for the resource for which the * notification is created. * @see DetailType */ public final DetailType detailType() { return DetailType.fromValue(detailType); } /** *

* The level of detail to include in the notifications for this resource. BASIC will include only the contents of * the event as it would appear in Amazon CloudWatch. FULL will include any supplemental information provided by AWS * CodeStar Notifications and/or the service for the resource for which the notification is created. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #detailType} will * return {@link DetailType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #detailTypeAsString}. *

* * @return The level of detail to include in the notifications for this resource. BASIC will include only the * contents of the event as it would appear in Amazon CloudWatch. FULL will include any supplemental * information provided by AWS CodeStar Notifications and/or the service for the resource for which the * notification is created. * @see DetailType */ public final String detailTypeAsString() { return detailType; } @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(name()); hashCode = 31 * hashCode + Objects.hashCode(statusAsString()); hashCode = 31 * hashCode + Objects.hashCode(hasEventTypeIds() ? eventTypeIds() : null); hashCode = 31 * hashCode + Objects.hashCode(hasTargets() ? targets() : null); hashCode = 31 * hashCode + Objects.hashCode(detailTypeAsString()); 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 UpdateNotificationRuleRequest)) { return false; } UpdateNotificationRuleRequest other = (UpdateNotificationRuleRequest) obj; return Objects.equals(arn(), other.arn()) && Objects.equals(name(), other.name()) && Objects.equals(statusAsString(), other.statusAsString()) && hasEventTypeIds() == other.hasEventTypeIds() && Objects.equals(eventTypeIds(), other.eventTypeIds()) && hasTargets() == other.hasTargets() && Objects.equals(targets(), other.targets()) && Objects.equals(detailTypeAsString(), other.detailTypeAsString()); } /** * 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("UpdateNotificationRuleRequest").add("Arn", arn()) .add("Name", name() == null ? null : "*** Sensitive Data Redacted ***").add("Status", statusAsString()) .add("EventTypeIds", hasEventTypeIds() ? eventTypeIds() : null).add("Targets", hasTargets() ? targets() : null) .add("DetailType", detailTypeAsString()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "Arn": return Optional.ofNullable(clazz.cast(arn())); case "Name": return Optional.ofNullable(clazz.cast(name())); case "Status": return Optional.ofNullable(clazz.cast(statusAsString())); case "EventTypeIds": return Optional.ofNullable(clazz.cast(eventTypeIds())); case "Targets": return Optional.ofNullable(clazz.cast(targets())); case "DetailType": return Optional.ofNullable(clazz.cast(detailTypeAsString())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((UpdateNotificationRuleRequest) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends CodestarNotificationsRequest.Builder, SdkPojo, CopyableBuilder { /** *

* The Amazon Resource Name (ARN) of the notification rule. *

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

* The name of the notification rule. *

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

* The status of the notification rule. Valid statuses include enabled (sending notifications) or disabled (not * sending notifications). *

* * @param status * The status of the notification rule. Valid statuses include enabled (sending notifications) or * disabled (not sending notifications). * @see NotificationRuleStatus * @return Returns a reference to this object so that method calls can be chained together. * @see NotificationRuleStatus */ Builder status(String status); /** *

* The status of the notification rule. Valid statuses include enabled (sending notifications) or disabled (not * sending notifications). *

* * @param status * The status of the notification rule. Valid statuses include enabled (sending notifications) or * disabled (not sending notifications). * @see NotificationRuleStatus * @return Returns a reference to this object so that method calls can be chained together. * @see NotificationRuleStatus */ Builder status(NotificationRuleStatus status); /** *

* A list of event types associated with this notification rule. For a complete list of event types and IDs, see * * Notification concepts in the Developer Tools Console User Guide. *

* * @param eventTypeIds * A list of event types associated with this notification rule. For a complete list of event types and * IDs, see Notification concepts in the Developer Tools Console User Guide. * @return Returns a reference to this object so that method calls can be chained together. */ Builder eventTypeIds(Collection eventTypeIds); /** *

* A list of event types associated with this notification rule. For a complete list of event types and IDs, see * * Notification concepts in the Developer Tools Console User Guide. *

* * @param eventTypeIds * A list of event types associated with this notification rule. For a complete list of event types and * IDs, see Notification concepts in the Developer Tools Console User Guide. * @return Returns a reference to this object so that method calls can be chained together. */ Builder eventTypeIds(String... eventTypeIds); /** *

* The address and type of the targets to receive notifications from this notification rule. *

* * @param targets * The address and type of the targets to receive notifications from this notification rule. * @return Returns a reference to this object so that method calls can be chained together. */ Builder targets(Collection targets); /** *

* The address and type of the targets to receive notifications from this notification rule. *

* * @param targets * The address and type of the targets to receive notifications from this notification rule. * @return Returns a reference to this object so that method calls can be chained together. */ Builder targets(Target... targets); /** *

* The address and type of the targets to receive notifications from this notification rule. *

* This is a convenience method that creates an instance of the * {@link software.amazon.awssdk.services.codestarnotifications.model.Target.Builder} avoiding the need to * create one manually via {@link software.amazon.awssdk.services.codestarnotifications.model.Target#builder()}. * *

* When the {@link Consumer} completes, * {@link software.amazon.awssdk.services.codestarnotifications.model.Target.Builder#build()} is called * immediately and its result is passed to {@link #targets(List)}. * * @param targets * a consumer that will call methods on * {@link software.amazon.awssdk.services.codestarnotifications.model.Target.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #targets(java.util.Collection) */ Builder targets(Consumer... targets); /** *

* The level of detail to include in the notifications for this resource. BASIC will include only the contents * of the event as it would appear in Amazon CloudWatch. FULL will include any supplemental information provided * by AWS CodeStar Notifications and/or the service for the resource for which the notification is created. *

* * @param detailType * The level of detail to include in the notifications for this resource. BASIC will include only the * contents of the event as it would appear in Amazon CloudWatch. FULL will include any supplemental * information provided by AWS CodeStar Notifications and/or the service for the resource for which the * notification is created. * @see DetailType * @return Returns a reference to this object so that method calls can be chained together. * @see DetailType */ Builder detailType(String detailType); /** *

* The level of detail to include in the notifications for this resource. BASIC will include only the contents * of the event as it would appear in Amazon CloudWatch. FULL will include any supplemental information provided * by AWS CodeStar Notifications and/or the service for the resource for which the notification is created. *

* * @param detailType * The level of detail to include in the notifications for this resource. BASIC will include only the * contents of the event as it would appear in Amazon CloudWatch. FULL will include any supplemental * information provided by AWS CodeStar Notifications and/or the service for the resource for which the * notification is created. * @see DetailType * @return Returns a reference to this object so that method calls can be chained together. * @see DetailType */ Builder detailType(DetailType detailType); @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @Override Builder overrideConfiguration(Consumer builderConsumer); } static final class BuilderImpl extends CodestarNotificationsRequest.BuilderImpl implements Builder { private String arn; private String name; private String status; private List eventTypeIds = DefaultSdkAutoConstructList.getInstance(); private List targets = DefaultSdkAutoConstructList.getInstance(); private String detailType; private BuilderImpl() { } private BuilderImpl(UpdateNotificationRuleRequest model) { super(model); arn(model.arn); name(model.name); status(model.status); eventTypeIds(model.eventTypeIds); targets(model.targets); detailType(model.detailType); } 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 getName() { return name; } public final void setName(String name) { this.name = name; } @Override public final Builder name(String name) { this.name = name; return this; } public final String getStatus() { return status; } public final void setStatus(String status) { this.status = status; } @Override public final Builder status(String status) { this.status = status; return this; } @Override public final Builder status(NotificationRuleStatus status) { this.status(status == null ? null : status.toString()); return this; } public final Collection getEventTypeIds() { if (eventTypeIds instanceof SdkAutoConstructList) { return null; } return eventTypeIds; } public final void setEventTypeIds(Collection eventTypeIds) { this.eventTypeIds = EventTypeIdsCopier.copy(eventTypeIds); } @Override public final Builder eventTypeIds(Collection eventTypeIds) { this.eventTypeIds = EventTypeIdsCopier.copy(eventTypeIds); return this; } @Override @SafeVarargs public final Builder eventTypeIds(String... eventTypeIds) { eventTypeIds(Arrays.asList(eventTypeIds)); return this; } public final List getTargets() { List result = TargetsCopier.copyToBuilder(this.targets); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setTargets(Collection targets) { this.targets = TargetsCopier.copyFromBuilder(targets); } @Override public final Builder targets(Collection targets) { this.targets = TargetsCopier.copy(targets); return this; } @Override @SafeVarargs public final Builder targets(Target... targets) { targets(Arrays.asList(targets)); return this; } @Override @SafeVarargs public final Builder targets(Consumer... targets) { targets(Stream.of(targets).map(c -> Target.builder().applyMutation(c).build()).collect(Collectors.toList())); 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; } @Override public final Builder detailType(DetailType detailType) { this.detailType(detailType == null ? null : detailType.toString()); 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 UpdateNotificationRuleRequest build() { return new UpdateNotificationRuleRequest(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy