software.amazon.awssdk.services.cloudwatch.model.DescribeAlarmHistoryRequest Maven / Gradle / Ivy
Show all versions of cloudwatch 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.cloudwatch.model;
import java.time.Instant;
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 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 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.
*
*
* You can use {@link #hasAlarmTypes()} to see if a value was sent in this field.
*
*
* @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);
}
/**
* Returns true if the AlarmTypes property was specified by the sender (it may be empty), or false if the sender did
* not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service.
*/
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.
*
*
* You can use {@link #hasAlarmTypes()} to see if a value was sent in this field.
*
*
* @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 extends Builder> 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;
}
private static Function