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

software.amazon.awssdk.services.cloudwatch.model.DescribeAlarmHistoryRequest Maven / Gradle / Ivy

Go to download

The AWS Java SDK for Amazon CloudWatch module holds the client classes that are used for communicating with Amazon CloudWatch 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.cloudwatch.model;

import java.time.Instant;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
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 DescribeAlarmHistoryRequest extends CloudWatchRequest implements
        ToCopyableBuilder {
    private static final SdkField ALARM_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("AlarmName").getter(getter(DescribeAlarmHistoryRequest::alarmName)).setter(setter(Builder::alarmName))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AlarmName").build()).build();

    private static final SdkField> ALARM_TYPES_FIELD = SdkField
            .> builder(MarshallingType.LIST)
            .memberName("AlarmTypes")
            .getter(getter(DescribeAlarmHistoryRequest::alarmTypesAsStrings))
            .setter(setter(Builder::alarmTypesWithStrings))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AlarmTypes").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 HISTORY_ITEM_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("HistoryItemType").getter(getter(DescribeAlarmHistoryRequest::historyItemTypeAsString))
            .setter(setter(Builder::historyItemType))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("HistoryItemType").build()).build();

    private static final SdkField START_DATE_FIELD = SdkField. builder(MarshallingType.INSTANT)
            .memberName("StartDate").getter(getter(DescribeAlarmHistoryRequest::startDate)).setter(setter(Builder::startDate))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StartDate").build()).build();

    private static final SdkField END_DATE_FIELD = SdkField. builder(MarshallingType.INSTANT)
            .memberName("EndDate").getter(getter(DescribeAlarmHistoryRequest::endDate)).setter(setter(Builder::endDate))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EndDate").build()).build();

    private static final SdkField MAX_RECORDS_FIELD = SdkField. builder(MarshallingType.INTEGER)
            .memberName("MaxRecords").getter(getter(DescribeAlarmHistoryRequest::maxRecords)).setter(setter(Builder::maxRecords))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MaxRecords").build()).build();

    private static final SdkField NEXT_TOKEN_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("NextToken").getter(getter(DescribeAlarmHistoryRequest::nextToken)).setter(setter(Builder::nextToken))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NextToken").build()).build();

    private static final SdkField SCAN_BY_FIELD = SdkField. builder(MarshallingType.STRING).memberName("ScanBy")
            .getter(getter(DescribeAlarmHistoryRequest::scanByAsString)).setter(setter(Builder::scanBy))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ScanBy").build()).build();

    private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ALARM_NAME_FIELD,
            ALARM_TYPES_FIELD, HISTORY_ITEM_TYPE_FIELD, START_DATE_FIELD, END_DATE_FIELD, MAX_RECORDS_FIELD, NEXT_TOKEN_FIELD,
            SCAN_BY_FIELD));

    private static final Map> SDK_NAME_TO_FIELD = memberNameToFieldInitializer();

    private final String alarmName;

    private final List alarmTypes;

    private final String historyItemType;

    private final Instant startDate;

    private final Instant endDate;

    private final Integer maxRecords;

    private final String nextToken;

    private final String scanBy;

    private DescribeAlarmHistoryRequest(BuilderImpl builder) {
        super(builder);
        this.alarmName = builder.alarmName;
        this.alarmTypes = builder.alarmTypes;
        this.historyItemType = builder.historyItemType;
        this.startDate = builder.startDate;
        this.endDate = builder.endDate;
        this.maxRecords = builder.maxRecords;
        this.nextToken = builder.nextToken;
        this.scanBy = builder.scanBy;
    }

    /**
     * 

* The name of the alarm. *

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

* Use this parameter to specify whether you want the operation to return metric alarms or composite alarms. If you * omit this parameter, only metric alarms are returned. *

*

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

* * @return Use this parameter to specify whether you want the operation to return metric alarms or composite alarms. * If you omit this parameter, only metric alarms are returned. */ public final List alarmTypes() { return AlarmTypesCopier.copyStringToEnum(alarmTypes); } /** * For responses, this returns true if the service returned a value for the AlarmTypes 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 hasAlarmTypes() { return alarmTypes != null && !(alarmTypes instanceof SdkAutoConstructList); } /** *

* Use this parameter to specify whether you want the operation to return metric alarms or composite alarms. If you * omit this parameter, only metric alarms are returned. *

*

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

* * @return Use this parameter to specify whether you want the operation to return metric alarms or composite alarms. * If you omit this parameter, only metric alarms are returned. */ public final List alarmTypesAsStrings() { return alarmTypes; } /** *

* The type of alarm histories to retrieve. *

*

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

* * @return The type of alarm histories to retrieve. * @see HistoryItemType */ public final HistoryItemType historyItemType() { return HistoryItemType.fromValue(historyItemType); } /** *

* The type of alarm histories to retrieve. *

*

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

* * @return The type of alarm histories to retrieve. * @see HistoryItemType */ public final String historyItemTypeAsString() { return historyItemType; } /** *

* The starting date to retrieve alarm history. *

* * @return The starting date to retrieve alarm history. */ public final Instant startDate() { return startDate; } /** *

* The ending date to retrieve alarm history. *

* * @return The ending date to retrieve alarm history. */ public final Instant endDate() { return endDate; } /** *

* The maximum number of alarm history records to retrieve. *

* * @return The maximum number of alarm history records to retrieve. */ public final Integer maxRecords() { return maxRecords; } /** *

* The token returned by a previous call to indicate that there is more data available. *

* * @return The token returned by a previous call to indicate that there is more data available. */ public final String nextToken() { return nextToken; } /** *

* Specified whether to return the newest or oldest alarm history first. Specify TimestampDescending to * have the newest event history returned first, and specify TimestampAscending to have the oldest * history returned first. *

*

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

* * @return Specified whether to return the newest or oldest alarm history first. Specify * TimestampDescending to have the newest event history returned first, and specify * TimestampAscending to have the oldest history returned first. * @see ScanBy */ public final ScanBy scanBy() { return ScanBy.fromValue(scanBy); } /** *

* Specified whether to return the newest or oldest alarm history first. Specify TimestampDescending to * have the newest event history returned first, and specify TimestampAscending to have the oldest * history returned first. *

*

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

* * @return Specified whether to return the newest or oldest alarm history first. Specify * TimestampDescending to have the newest event history returned first, and specify * TimestampAscending to have the oldest history returned first. * @see ScanBy */ public final String scanByAsString() { return scanBy; } @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(alarmName()); hashCode = 31 * hashCode + Objects.hashCode(hasAlarmTypes() ? alarmTypesAsStrings() : null); hashCode = 31 * hashCode + Objects.hashCode(historyItemTypeAsString()); hashCode = 31 * hashCode + Objects.hashCode(startDate()); hashCode = 31 * hashCode + Objects.hashCode(endDate()); hashCode = 31 * hashCode + Objects.hashCode(maxRecords()); hashCode = 31 * hashCode + Objects.hashCode(nextToken()); hashCode = 31 * hashCode + Objects.hashCode(scanByAsString()); 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 DescribeAlarmHistoryRequest)) { return false; } DescribeAlarmHistoryRequest other = (DescribeAlarmHistoryRequest) obj; return Objects.equals(alarmName(), other.alarmName()) && hasAlarmTypes() == other.hasAlarmTypes() && Objects.equals(alarmTypesAsStrings(), other.alarmTypesAsStrings()) && Objects.equals(historyItemTypeAsString(), other.historyItemTypeAsString()) && Objects.equals(startDate(), other.startDate()) && Objects.equals(endDate(), other.endDate()) && Objects.equals(maxRecords(), other.maxRecords()) && Objects.equals(nextToken(), other.nextToken()) && Objects.equals(scanByAsString(), other.scanByAsString()); } /** * 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("DescribeAlarmHistoryRequest").add("AlarmName", alarmName()) .add("AlarmTypes", hasAlarmTypes() ? alarmTypesAsStrings() : null) .add("HistoryItemType", historyItemTypeAsString()).add("StartDate", startDate()).add("EndDate", endDate()) .add("MaxRecords", maxRecords()).add("NextToken", nextToken()).add("ScanBy", scanByAsString()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "AlarmName": return Optional.ofNullable(clazz.cast(alarmName())); case "AlarmTypes": return Optional.ofNullable(clazz.cast(alarmTypesAsStrings())); case "HistoryItemType": return Optional.ofNullable(clazz.cast(historyItemTypeAsString())); case "StartDate": return Optional.ofNullable(clazz.cast(startDate())); case "EndDate": return Optional.ofNullable(clazz.cast(endDate())); case "MaxRecords": return Optional.ofNullable(clazz.cast(maxRecords())); case "NextToken": return Optional.ofNullable(clazz.cast(nextToken())); case "ScanBy": return Optional.ofNullable(clazz.cast(scanByAsString())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } @Override public final Map> sdkFieldNameToField() { return SDK_NAME_TO_FIELD; } private static Map> memberNameToFieldInitializer() { Map> map = new HashMap<>(); map.put("AlarmName", ALARM_NAME_FIELD); map.put("AlarmTypes", ALARM_TYPES_FIELD); map.put("HistoryItemType", HISTORY_ITEM_TYPE_FIELD); map.put("StartDate", START_DATE_FIELD); map.put("EndDate", END_DATE_FIELD); map.put("MaxRecords", MAX_RECORDS_FIELD); map.put("NextToken", NEXT_TOKEN_FIELD); map.put("ScanBy", SCAN_BY_FIELD); return Collections.unmodifiableMap(map); } private static Function getter(Function g) { return obj -> g.apply((DescribeAlarmHistoryRequest) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends CloudWatchRequest.Builder, SdkPojo, CopyableBuilder { /** *

* The name of the alarm. *

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

* Use this parameter to specify whether you want the operation to return metric alarms or composite alarms. If * you omit this parameter, only metric alarms are returned. *

* * @param alarmTypes * Use this parameter to specify whether you want the operation to return metric alarms or composite * alarms. If you omit this parameter, only metric alarms are returned. * @return Returns a reference to this object so that method calls can be chained together. */ Builder alarmTypesWithStrings(Collection alarmTypes); /** *

* Use this parameter to specify whether you want the operation to return metric alarms or composite alarms. If * you omit this parameter, only metric alarms are returned. *

* * @param alarmTypes * Use this parameter to specify whether you want the operation to return metric alarms or composite * alarms. If you omit this parameter, only metric alarms are returned. * @return Returns a reference to this object so that method calls can be chained together. */ Builder alarmTypesWithStrings(String... alarmTypes); /** *

* Use this parameter to specify whether you want the operation to return metric alarms or composite alarms. If * you omit this parameter, only metric alarms are returned. *

* * @param alarmTypes * Use this parameter to specify whether you want the operation to return metric alarms or composite * alarms. If you omit this parameter, only metric alarms are returned. * @return Returns a reference to this object so that method calls can be chained together. */ Builder alarmTypes(Collection alarmTypes); /** *

* Use this parameter to specify whether you want the operation to return metric alarms or composite alarms. If * you omit this parameter, only metric alarms are returned. *

* * @param alarmTypes * Use this parameter to specify whether you want the operation to return metric alarms or composite * alarms. If you omit this parameter, only metric alarms are returned. * @return Returns a reference to this object so that method calls can be chained together. */ Builder alarmTypes(AlarmType... alarmTypes); /** *

* The type of alarm histories to retrieve. *

* * @param historyItemType * The type of alarm histories to retrieve. * @see HistoryItemType * @return Returns a reference to this object so that method calls can be chained together. * @see HistoryItemType */ Builder historyItemType(String historyItemType); /** *

* The type of alarm histories to retrieve. *

* * @param historyItemType * The type of alarm histories to retrieve. * @see HistoryItemType * @return Returns a reference to this object so that method calls can be chained together. * @see HistoryItemType */ Builder historyItemType(HistoryItemType historyItemType); /** *

* The starting date to retrieve alarm history. *

* * @param startDate * The starting date to retrieve alarm history. * @return Returns a reference to this object so that method calls can be chained together. */ Builder startDate(Instant startDate); /** *

* The ending date to retrieve alarm history. *

* * @param endDate * The ending date to retrieve alarm history. * @return Returns a reference to this object so that method calls can be chained together. */ Builder endDate(Instant endDate); /** *

* The maximum number of alarm history records to retrieve. *

* * @param maxRecords * The maximum number of alarm history records to retrieve. * @return Returns a reference to this object so that method calls can be chained together. */ Builder maxRecords(Integer maxRecords); /** *

* The token returned by a previous call to indicate that there is more data available. *

* * @param nextToken * The token returned by a previous call to indicate that there is more data available. * @return Returns a reference to this object so that method calls can be chained together. */ Builder nextToken(String nextToken); /** *

* Specified whether to return the newest or oldest alarm history first. Specify * TimestampDescending to have the newest event history returned first, and specify * TimestampAscending to have the oldest history returned first. *

* * @param scanBy * Specified whether to return the newest or oldest alarm history first. Specify * TimestampDescending to have the newest event history returned first, and specify * TimestampAscending to have the oldest history returned first. * @see ScanBy * @return Returns a reference to this object so that method calls can be chained together. * @see ScanBy */ Builder scanBy(String scanBy); /** *

* Specified whether to return the newest or oldest alarm history first. Specify * TimestampDescending to have the newest event history returned first, and specify * TimestampAscending to have the oldest history returned first. *

* * @param scanBy * Specified whether to return the newest or oldest alarm history first. Specify * TimestampDescending to have the newest event history returned first, and specify * TimestampAscending to have the oldest history returned first. * @see ScanBy * @return Returns a reference to this object so that method calls can be chained together. * @see ScanBy */ Builder scanBy(ScanBy scanBy); @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @Override Builder overrideConfiguration(Consumer builderConsumer); } static final class BuilderImpl extends CloudWatchRequest.BuilderImpl implements Builder { private String alarmName; private List alarmTypes = DefaultSdkAutoConstructList.getInstance(); private String historyItemType; private Instant startDate; private Instant endDate; private Integer maxRecords; private String nextToken; private String scanBy; private BuilderImpl() { } private BuilderImpl(DescribeAlarmHistoryRequest model) { super(model); alarmName(model.alarmName); alarmTypesWithStrings(model.alarmTypes); historyItemType(model.historyItemType); startDate(model.startDate); endDate(model.endDate); maxRecords(model.maxRecords); nextToken(model.nextToken); scanBy(model.scanBy); } public final String getAlarmName() { return alarmName; } public final void setAlarmName(String alarmName) { this.alarmName = alarmName; } @Override public final Builder alarmName(String alarmName) { this.alarmName = alarmName; return this; } public final Collection getAlarmTypes() { if (alarmTypes instanceof SdkAutoConstructList) { return null; } return alarmTypes; } public final void setAlarmTypes(Collection alarmTypes) { this.alarmTypes = AlarmTypesCopier.copy(alarmTypes); } @Override public final Builder alarmTypesWithStrings(Collection alarmTypes) { this.alarmTypes = AlarmTypesCopier.copy(alarmTypes); return this; } @Override @SafeVarargs public final Builder alarmTypesWithStrings(String... alarmTypes) { alarmTypesWithStrings(Arrays.asList(alarmTypes)); return this; } @Override public final Builder alarmTypes(Collection alarmTypes) { this.alarmTypes = AlarmTypesCopier.copyEnumToString(alarmTypes); return this; } @Override @SafeVarargs public final Builder alarmTypes(AlarmType... alarmTypes) { alarmTypes(Arrays.asList(alarmTypes)); return this; } public final String getHistoryItemType() { return historyItemType; } public final void setHistoryItemType(String historyItemType) { this.historyItemType = historyItemType; } @Override public final Builder historyItemType(String historyItemType) { this.historyItemType = historyItemType; return this; } @Override public final Builder historyItemType(HistoryItemType historyItemType) { this.historyItemType(historyItemType == null ? null : historyItemType.toString()); return this; } public final Instant getStartDate() { return startDate; } public final void setStartDate(Instant startDate) { this.startDate = startDate; } @Override public final Builder startDate(Instant startDate) { this.startDate = startDate; return this; } public final Instant getEndDate() { return endDate; } public final void setEndDate(Instant endDate) { this.endDate = endDate; } @Override public final Builder endDate(Instant endDate) { this.endDate = endDate; return this; } public final Integer getMaxRecords() { return maxRecords; } public final void setMaxRecords(Integer maxRecords) { this.maxRecords = maxRecords; } @Override public final Builder maxRecords(Integer maxRecords) { this.maxRecords = maxRecords; return this; } public final String getNextToken() { return nextToken; } public final void setNextToken(String nextToken) { this.nextToken = nextToken; } @Override public final Builder nextToken(String nextToken) { this.nextToken = nextToken; return this; } public final String getScanBy() { return scanBy; } public final void setScanBy(String scanBy) { this.scanBy = scanBy; } @Override public final Builder scanBy(String scanBy) { this.scanBy = scanBy; return this; } @Override public final Builder scanBy(ScanBy scanBy) { this.scanBy(scanBy == null ? null : scanBy.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 DescribeAlarmHistoryRequest build() { return new DescribeAlarmHistoryRequest(this); } @Override public List> sdkFields() { return SDK_FIELDS; } @Override public Map> sdkFieldNameToField() { return SDK_NAME_TO_FIELD; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy