software.amazon.awssdk.services.costexplorer.model.AnomalySubscription 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.io.Serializable;
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.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;
/**
*
* The association between a monitor, threshold, and list of subscribers used to deliver notifications about anomalies
* detected by a monitor that exceeds a threshold. The content consists of the detailed metadata and the current status
* of the AnomalySubscription
object.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class AnomalySubscription implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField SUBSCRIPTION_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("SubscriptionArn").getter(getter(AnomalySubscription::subscriptionArn))
.setter(setter(Builder::subscriptionArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SubscriptionArn").build()).build();
private static final SdkField ACCOUNT_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("AccountId").getter(getter(AnomalySubscription::accountId)).setter(setter(Builder::accountId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AccountId").build()).build();
private static final SdkField> MONITOR_ARN_LIST_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("MonitorArnList")
.getter(getter(AnomalySubscription::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(AnomalySubscription::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 THRESHOLD_FIELD = SdkField. builder(MarshallingType.DOUBLE)
.memberName("Threshold").getter(getter(AnomalySubscription::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(AnomalySubscription::frequencyAsString)).setter(setter(Builder::frequency))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Frequency").build()).build();
private static final SdkField SUBSCRIPTION_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("SubscriptionName").getter(getter(AnomalySubscription::subscriptionName))
.setter(setter(Builder::subscriptionName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SubscriptionName").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(SUBSCRIPTION_ARN_FIELD,
ACCOUNT_ID_FIELD, MONITOR_ARN_LIST_FIELD, SUBSCRIBERS_FIELD, THRESHOLD_FIELD, FREQUENCY_FIELD,
SUBSCRIPTION_NAME_FIELD));
private static final long serialVersionUID = 1L;
private final String subscriptionArn;
private final String accountId;
private final List monitorArnList;
private final List subscribers;
private final Double threshold;
private final String frequency;
private final String subscriptionName;
private AnomalySubscription(BuilderImpl builder) {
this.subscriptionArn = builder.subscriptionArn;
this.accountId = builder.accountId;
this.monitorArnList = builder.monitorArnList;
this.subscribers = builder.subscribers;
this.threshold = builder.threshold;
this.frequency = builder.frequency;
this.subscriptionName = builder.subscriptionName;
}
/**
*
* The AnomalySubscription
Amazon Resource Name (ARN).
*
*
* @return The AnomalySubscription
Amazon Resource Name (ARN).
*/
public final String subscriptionArn() {
return subscriptionArn;
}
/**
*
* Your unique account identifier.
*
*
* @return Your unique account identifier.
*/
public final String accountId() {
return accountId;
}
/**
* 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 monitors.
*
*
* 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 monitors.
*/
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);
}
/**
*
* A list of subscribers to notify.
*
*
* 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 A list of subscribers to notify.
*/
public final List subscribers() {
return subscribers;
}
/**
*
* The dollar value that triggers a notification if the threshold is exceeded.
*
*
* @return The dollar value that triggers a notification if the threshold is exceeded.
*/
public final Double threshold() {
return threshold;
}
/**
*
* The frequency that anomaly reports are sent over email.
*
*
* 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 frequency that anomaly reports are sent over email.
* @see AnomalySubscriptionFrequency
*/
public final AnomalySubscriptionFrequency frequency() {
return AnomalySubscriptionFrequency.fromValue(frequency);
}
/**
*
* The frequency that anomaly reports are sent over email.
*
*
* 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 frequency that anomaly reports are sent over email.
* @see AnomalySubscriptionFrequency
*/
public final String frequencyAsString() {
return frequency;
}
/**
*
* The name for the subscription.
*
*
* @return The name for the subscription.
*/
public final String subscriptionName() {
return subscriptionName;
}
@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 + Objects.hashCode(subscriptionArn());
hashCode = 31 * hashCode + Objects.hashCode(accountId());
hashCode = 31 * hashCode + Objects.hashCode(hasMonitorArnList() ? monitorArnList() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasSubscribers() ? subscribers() : null);
hashCode = 31 * hashCode + Objects.hashCode(threshold());
hashCode = 31 * hashCode + Objects.hashCode(frequencyAsString());
hashCode = 31 * hashCode + Objects.hashCode(subscriptionName());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof AnomalySubscription)) {
return false;
}
AnomalySubscription other = (AnomalySubscription) obj;
return Objects.equals(subscriptionArn(), other.subscriptionArn()) && Objects.equals(accountId(), other.accountId())
&& hasMonitorArnList() == other.hasMonitorArnList() && Objects.equals(monitorArnList(), other.monitorArnList())
&& hasSubscribers() == other.hasSubscribers() && Objects.equals(subscribers(), other.subscribers())
&& Objects.equals(threshold(), other.threshold())
&& Objects.equals(frequencyAsString(), other.frequencyAsString())
&& Objects.equals(subscriptionName(), other.subscriptionName());
}
/**
* 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("AnomalySubscription").add("SubscriptionArn", subscriptionArn()).add("AccountId", accountId())
.add("MonitorArnList", hasMonitorArnList() ? monitorArnList() : null)
.add("Subscribers", hasSubscribers() ? subscribers() : null).add("Threshold", threshold())
.add("Frequency", frequencyAsString()).add("SubscriptionName", subscriptionName()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "SubscriptionArn":
return Optional.ofNullable(clazz.cast(subscriptionArn()));
case "AccountId":
return Optional.ofNullable(clazz.cast(accountId()));
case "MonitorArnList":
return Optional.ofNullable(clazz.cast(monitorArnList()));
case "Subscribers":
return Optional.ofNullable(clazz.cast(subscribers()));
case "Threshold":
return Optional.ofNullable(clazz.cast(threshold()));
case "Frequency":
return Optional.ofNullable(clazz.cast(frequencyAsString()));
case "SubscriptionName":
return Optional.ofNullable(clazz.cast(subscriptionName()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function