software.amazon.awssdk.services.costexplorer.model.UpdateAnomalySubscriptionRequest Maven / Gradle / Ivy
Show all versions of costexplorer 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.costexplorer.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 UpdateAnomalySubscriptionRequest extends CostExplorerRequest implements
ToCopyableBuilder {
private static final SdkField SUBSCRIPTION_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("SubscriptionArn").getter(getter(UpdateAnomalySubscriptionRequest::subscriptionArn))
.setter(setter(Builder::subscriptionArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SubscriptionArn").build()).build();
private static final SdkField THRESHOLD_FIELD = SdkField. builder(MarshallingType.DOUBLE)
.memberName("Threshold").getter(getter(UpdateAnomalySubscriptionRequest::threshold))
.setter(setter(Builder::threshold))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Threshold").build()).build();
private static final SdkField FREQUENCY_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Frequency").getter(getter(UpdateAnomalySubscriptionRequest::frequencyAsString))
.setter(setter(Builder::frequency))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Frequency").build()).build();
private static final SdkField> MONITOR_ARN_LIST_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("MonitorArnList")
.getter(getter(UpdateAnomalySubscriptionRequest::monitorArnList))
.setter(setter(Builder::monitorArnList))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MonitorArnList").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> SUBSCRIBERS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Subscribers")
.getter(getter(UpdateAnomalySubscriptionRequest::subscribers))
.setter(setter(Builder::subscribers))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Subscribers").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(Subscriber::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField SUBSCRIPTION_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("SubscriptionName").getter(getter(UpdateAnomalySubscriptionRequest::subscriptionName))
.setter(setter(Builder::subscriptionName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SubscriptionName").build()).build();
private static final SdkField THRESHOLD_EXPRESSION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("ThresholdExpression")
.getter(getter(UpdateAnomalySubscriptionRequest::thresholdExpression)).setter(setter(Builder::thresholdExpression))
.constructor(Expression::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ThresholdExpression").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(SUBSCRIPTION_ARN_FIELD,
THRESHOLD_FIELD, FREQUENCY_FIELD, MONITOR_ARN_LIST_FIELD, SUBSCRIBERS_FIELD, SUBSCRIPTION_NAME_FIELD,
THRESHOLD_EXPRESSION_FIELD));
private final String subscriptionArn;
private final Double threshold;
private final String frequency;
private final List monitorArnList;
private final List subscribers;
private final String subscriptionName;
private final Expression thresholdExpression;
private UpdateAnomalySubscriptionRequest(BuilderImpl builder) {
super(builder);
this.subscriptionArn = builder.subscriptionArn;
this.threshold = builder.threshold;
this.frequency = builder.frequency;
this.monitorArnList = builder.monitorArnList;
this.subscribers = builder.subscribers;
this.subscriptionName = builder.subscriptionName;
this.thresholdExpression = builder.thresholdExpression;
}
/**
*
* A cost anomaly subscription Amazon Resource Name (ARN).
*
*
* @return A cost anomaly subscription Amazon Resource Name (ARN).
*/
public final String subscriptionArn() {
return subscriptionArn;
}
/**
*
* (deprecated)
*
*
* The update to the threshold value for receiving notifications.
*
*
* This field has been deprecated. To update a threshold, use ThresholdExpression. Continued use of Threshold will
* be treated as shorthand syntax for a ThresholdExpression.
*
*
* You can specify either Threshold or ThresholdExpression, but not both.
*
*
* @return (deprecated)
*
* The update to the threshold value for receiving notifications.
*
*
* This field has been deprecated. To update a threshold, use ThresholdExpression. Continued use of
* Threshold will be treated as shorthand syntax for a ThresholdExpression.
*
*
* You can specify either Threshold or ThresholdExpression, but not both.
* @deprecated Threshold has been deprecated in favor of ThresholdExpression
*/
@Deprecated
public final Double threshold() {
return threshold;
}
/**
*
* The update to the frequency value that subscribers receive notifications.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #frequency} will
* return {@link AnomalySubscriptionFrequency#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is
* available from {@link #frequencyAsString}.
*
*
* @return The update to the frequency value that subscribers receive notifications.
* @see AnomalySubscriptionFrequency
*/
public final AnomalySubscriptionFrequency frequency() {
return AnomalySubscriptionFrequency.fromValue(frequency);
}
/**
*
* The update to the frequency value that subscribers receive notifications.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #frequency} will
* return {@link AnomalySubscriptionFrequency#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is
* available from {@link #frequencyAsString}.
*
*
* @return The update to the frequency value that subscribers receive notifications.
* @see AnomalySubscriptionFrequency
*/
public final String frequencyAsString() {
return frequency;
}
/**
* For responses, this returns true if the service returned a value for the MonitorArnList 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 hasMonitorArnList() {
return monitorArnList != null && !(monitorArnList instanceof SdkAutoConstructList);
}
/**
*
* A list of cost anomaly monitor ARNs.
*
*
* 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 #hasMonitorArnList} method.
*
*
* @return A list of cost anomaly monitor ARNs.
*/
public final List monitorArnList() {
return monitorArnList;
}
/**
* For responses, this returns true if the service returned a value for the Subscribers 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 hasSubscribers() {
return subscribers != null && !(subscribers instanceof SdkAutoConstructList);
}
/**
*
* The update to the subscriber list.
*
*
* 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 #hasSubscribers} method.
*
*
* @return The update to the subscriber list.
*/
public final List subscribers() {
return subscribers;
}
/**
*
* The new name of the subscription.
*
*
* @return The new name of the subscription.
*/
public final String subscriptionName() {
return subscriptionName;
}
/**
*
* The update to the Expression
* object used to specify the anomalies that you want to generate alerts for. This supports dimensions and nested
* expressions. The supported dimensions are ANOMALY_TOTAL_IMPACT_ABSOLUTE
and
* ANOMALY_TOTAL_IMPACT_PERCENTAGE
, corresponding to an anomaly’s TotalImpact and
* TotalImpactPercentage, respectively (see Impact for more
* details). The supported nested expression types are AND
and OR
. The match option
* GREATER_THAN_OR_EQUAL
is required. Values must be numbers between 0 and 10,000,000,000 in string
* format.
*
*
* You can specify either Threshold or ThresholdExpression, but not both.
*
*
* The following are examples of valid ThresholdExpressions:
*
*
* -
*
* Absolute threshold:
* { "Dimensions": { "Key": "ANOMALY_TOTAL_IMPACT_ABSOLUTE", "MatchOptions": [ "GREATER_THAN_OR_EQUAL" ], "Values": [ "100" ] } }
*
*
* -
*
* Percentage threshold:
* { "Dimensions": { "Key": "ANOMALY_TOTAL_IMPACT_PERCENTAGE", "MatchOptions": [ "GREATER_THAN_OR_EQUAL" ], "Values": [ "100" ] } }
*
*
* -
*
* AND
two thresholds together:
* { "And": [ { "Dimensions": { "Key": "ANOMALY_TOTAL_IMPACT_ABSOLUTE", "MatchOptions": [ "GREATER_THAN_OR_EQUAL" ], "Values": [ "100" ] } }, { "Dimensions": { "Key": "ANOMALY_TOTAL_IMPACT_PERCENTAGE", "MatchOptions": [ "GREATER_THAN_OR_EQUAL" ], "Values": [ "100" ] } } ] }
*
*
* -
*
* OR
two thresholds together:
* { "Or": [ { "Dimensions": { "Key": "ANOMALY_TOTAL_IMPACT_ABSOLUTE", "MatchOptions": [ "GREATER_THAN_OR_EQUAL" ], "Values": [ "100" ] } }, { "Dimensions": { "Key": "ANOMALY_TOTAL_IMPACT_PERCENTAGE", "MatchOptions": [ "GREATER_THAN_OR_EQUAL" ], "Values": [ "100" ] } } ] }
*
*
*
*
* @return The update to the Expression object used to specify the anomalies that you want to generate alerts for. This supports
* dimensions and nested expressions. The supported dimensions are
* ANOMALY_TOTAL_IMPACT_ABSOLUTE
and ANOMALY_TOTAL_IMPACT_PERCENTAGE
,
* corresponding to an anomaly’s TotalImpact and TotalImpactPercentage, respectively (see Impact for
* more details). The supported nested expression types are AND
and OR
. The match
* option GREATER_THAN_OR_EQUAL
is required. Values must be numbers between 0 and
* 10,000,000,000 in string format.
*
* You can specify either Threshold or ThresholdExpression, but not both.
*
*
* The following are examples of valid ThresholdExpressions:
*
*
* -
*
* Absolute threshold:
* { "Dimensions": { "Key": "ANOMALY_TOTAL_IMPACT_ABSOLUTE", "MatchOptions": [ "GREATER_THAN_OR_EQUAL" ], "Values": [ "100" ] } }
*
*
* -
*
* Percentage threshold:
* { "Dimensions": { "Key": "ANOMALY_TOTAL_IMPACT_PERCENTAGE", "MatchOptions": [ "GREATER_THAN_OR_EQUAL" ], "Values": [ "100" ] } }
*
*
* -
*
* AND
two thresholds together:
* { "And": [ { "Dimensions": { "Key": "ANOMALY_TOTAL_IMPACT_ABSOLUTE", "MatchOptions": [ "GREATER_THAN_OR_EQUAL" ], "Values": [ "100" ] } }, { "Dimensions": { "Key": "ANOMALY_TOTAL_IMPACT_PERCENTAGE", "MatchOptions": [ "GREATER_THAN_OR_EQUAL" ], "Values": [ "100" ] } } ] }
*
*
* -
*
* OR
two thresholds together:
* { "Or": [ { "Dimensions": { "Key": "ANOMALY_TOTAL_IMPACT_ABSOLUTE", "MatchOptions": [ "GREATER_THAN_OR_EQUAL" ], "Values": [ "100" ] } }, { "Dimensions": { "Key": "ANOMALY_TOTAL_IMPACT_PERCENTAGE", "MatchOptions": [ "GREATER_THAN_OR_EQUAL" ], "Values": [ "100" ] } } ] }
*
*
*/
public final Expression thresholdExpression() {
return thresholdExpression;
}
@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(subscriptionArn());
hashCode = 31 * hashCode + Objects.hashCode(threshold());
hashCode = 31 * hashCode + Objects.hashCode(frequencyAsString());
hashCode = 31 * hashCode + Objects.hashCode(hasMonitorArnList() ? monitorArnList() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasSubscribers() ? subscribers() : null);
hashCode = 31 * hashCode + Objects.hashCode(subscriptionName());
hashCode = 31 * hashCode + Objects.hashCode(thresholdExpression());
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 UpdateAnomalySubscriptionRequest)) {
return false;
}
UpdateAnomalySubscriptionRequest other = (UpdateAnomalySubscriptionRequest) obj;
return Objects.equals(subscriptionArn(), other.subscriptionArn()) && Objects.equals(threshold(), other.threshold())
&& Objects.equals(frequencyAsString(), other.frequencyAsString())
&& hasMonitorArnList() == other.hasMonitorArnList() && Objects.equals(monitorArnList(), other.monitorArnList())
&& hasSubscribers() == other.hasSubscribers() && Objects.equals(subscribers(), other.subscribers())
&& Objects.equals(subscriptionName(), other.subscriptionName())
&& Objects.equals(thresholdExpression(), other.thresholdExpression());
}
/**
* 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("UpdateAnomalySubscriptionRequest").add("SubscriptionArn", subscriptionArn())
.add("Threshold", threshold()).add("Frequency", frequencyAsString())
.add("MonitorArnList", hasMonitorArnList() ? monitorArnList() : null)
.add("Subscribers", hasSubscribers() ? subscribers() : null).add("SubscriptionName", subscriptionName())
.add("ThresholdExpression", thresholdExpression()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "SubscriptionArn":
return Optional.ofNullable(clazz.cast(subscriptionArn()));
case "Threshold":
return Optional.ofNullable(clazz.cast(threshold()));
case "Frequency":
return Optional.ofNullable(clazz.cast(frequencyAsString()));
case "MonitorArnList":
return Optional.ofNullable(clazz.cast(monitorArnList()));
case "Subscribers":
return Optional.ofNullable(clazz.cast(subscribers()));
case "SubscriptionName":
return Optional.ofNullable(clazz.cast(subscriptionName()));
case "ThresholdExpression":
return Optional.ofNullable(clazz.cast(thresholdExpression()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function