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

software.amazon.awssdk.services.costexplorer.model.AnomalySubscription Maven / Gradle / Ivy

Go to download

The AWS Java SDK for AWS Cost Explorer module holds the client classes that are used for communicating with AWS Cost Explorer Service

There is a newer version: 2.29.39
Show newest version
/*
 * 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 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 getter(Function g) { return obj -> g.apply((AnomalySubscription) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* The AnomalySubscription Amazon Resource Name (ARN). *

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

* Your unique account identifier. *

* * @param accountId * Your unique account identifier. * @return Returns a reference to this object so that method calls can be chained together. */ Builder accountId(String accountId); /** *

* A list of cost anomaly monitors. *

* * @param monitorArnList * A list of cost anomaly monitors. * @return Returns a reference to this object so that method calls can be chained together. */ Builder monitorArnList(Collection monitorArnList); /** *

* A list of cost anomaly monitors. *

* * @param monitorArnList * A list of cost anomaly monitors. * @return Returns a reference to this object so that method calls can be chained together. */ Builder monitorArnList(String... monitorArnList); /** *

* A list of subscribers to notify. *

* * @param subscribers * A list of subscribers to notify. * @return Returns a reference to this object so that method calls can be chained together. */ Builder subscribers(Collection subscribers); /** *

* A list of subscribers to notify. *

* * @param subscribers * A list of subscribers to notify. * @return Returns a reference to this object so that method calls can be chained together. */ Builder subscribers(Subscriber... subscribers); /** *

* A list of subscribers to notify. *

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

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

* The dollar value that triggers a notification if the threshold is exceeded. *

* * @param threshold * The dollar value that triggers a notification if the threshold is exceeded. * @return Returns a reference to this object so that method calls can be chained together. */ Builder threshold(Double threshold); /** *

* The frequency that anomaly reports are sent over email. *

* * @param frequency * The frequency that anomaly reports are sent over email. * @see AnomalySubscriptionFrequency * @return Returns a reference to this object so that method calls can be chained together. * @see AnomalySubscriptionFrequency */ Builder frequency(String frequency); /** *

* The frequency that anomaly reports are sent over email. *

* * @param frequency * The frequency that anomaly reports are sent over email. * @see AnomalySubscriptionFrequency * @return Returns a reference to this object so that method calls can be chained together. * @see AnomalySubscriptionFrequency */ Builder frequency(AnomalySubscriptionFrequency frequency); /** *

* The name for the subscription. *

* * @param subscriptionName * The name for the subscription. * @return Returns a reference to this object so that method calls can be chained together. */ Builder subscriptionName(String subscriptionName); } static final class BuilderImpl implements Builder { private String subscriptionArn; private String accountId; private List monitorArnList = DefaultSdkAutoConstructList.getInstance(); private List subscribers = DefaultSdkAutoConstructList.getInstance(); private Double threshold; private String frequency; private String subscriptionName; private BuilderImpl() { } private BuilderImpl(AnomalySubscription model) { subscriptionArn(model.subscriptionArn); accountId(model.accountId); monitorArnList(model.monitorArnList); subscribers(model.subscribers); threshold(model.threshold); frequency(model.frequency); subscriptionName(model.subscriptionName); } public final String getSubscriptionArn() { return subscriptionArn; } public final void setSubscriptionArn(String subscriptionArn) { this.subscriptionArn = subscriptionArn; } @Override public final Builder subscriptionArn(String subscriptionArn) { this.subscriptionArn = subscriptionArn; return this; } public final String getAccountId() { return accountId; } public final void setAccountId(String accountId) { this.accountId = accountId; } @Override public final Builder accountId(String accountId) { this.accountId = accountId; return this; } public final Collection getMonitorArnList() { if (monitorArnList instanceof SdkAutoConstructList) { return null; } return monitorArnList; } public final void setMonitorArnList(Collection monitorArnList) { this.monitorArnList = MonitorArnListCopier.copy(monitorArnList); } @Override public final Builder monitorArnList(Collection monitorArnList) { this.monitorArnList = MonitorArnListCopier.copy(monitorArnList); return this; } @Override @SafeVarargs public final Builder monitorArnList(String... monitorArnList) { monitorArnList(Arrays.asList(monitorArnList)); return this; } public final List getSubscribers() { List result = SubscribersCopier.copyToBuilder(this.subscribers); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setSubscribers(Collection subscribers) { this.subscribers = SubscribersCopier.copyFromBuilder(subscribers); } @Override public final Builder subscribers(Collection subscribers) { this.subscribers = SubscribersCopier.copy(subscribers); return this; } @Override @SafeVarargs public final Builder subscribers(Subscriber... subscribers) { subscribers(Arrays.asList(subscribers)); return this; } @Override @SafeVarargs public final Builder subscribers(Consumer... subscribers) { subscribers(Stream.of(subscribers).map(c -> Subscriber.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final Double getThreshold() { return threshold; } public final void setThreshold(Double threshold) { this.threshold = threshold; } @Override public final Builder threshold(Double threshold) { this.threshold = threshold; return this; } public final String getFrequency() { return frequency; } public final void setFrequency(String frequency) { this.frequency = frequency; } @Override public final Builder frequency(String frequency) { this.frequency = frequency; return this; } @Override public final Builder frequency(AnomalySubscriptionFrequency frequency) { this.frequency(frequency == null ? null : frequency.toString()); return this; } public final String getSubscriptionName() { return subscriptionName; } public final void setSubscriptionName(String subscriptionName) { this.subscriptionName = subscriptionName; } @Override public final Builder subscriptionName(String subscriptionName) { this.subscriptionName = subscriptionName; return this; } @Override public AnomalySubscription build() { return new AnomalySubscription(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy