
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 extends Builder> 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