software.amazon.awssdk.services.cloudwatch.model.DescribeAlarmsRequest 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.beans.Transient;
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 DescribeAlarmsRequest extends CloudWatchRequest implements
ToCopyableBuilder {
private static final SdkField> ALARM_NAMES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("AlarmNames")
.getter(getter(DescribeAlarmsRequest::alarmNames))
.setter(setter(Builder::alarmNames))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AlarmNames").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 ALARM_NAME_PREFIX_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("AlarmNamePrefix").getter(getter(DescribeAlarmsRequest::alarmNamePrefix))
.setter(setter(Builder::alarmNamePrefix))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AlarmNamePrefix").build()).build();
private static final SdkField> ALARM_TYPES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("AlarmTypes")
.getter(getter(DescribeAlarmsRequest::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 CHILDREN_OF_ALARM_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ChildrenOfAlarmName").getter(getter(DescribeAlarmsRequest::childrenOfAlarmName))
.setter(setter(Builder::childrenOfAlarmName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ChildrenOfAlarmName").build())
.build();
private static final SdkField PARENTS_OF_ALARM_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ParentsOfAlarmName").getter(getter(DescribeAlarmsRequest::parentsOfAlarmName))
.setter(setter(Builder::parentsOfAlarmName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ParentsOfAlarmName").build())
.build();
private static final SdkField STATE_VALUE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("StateValue").getter(getter(DescribeAlarmsRequest::stateValueAsString))
.setter(setter(Builder::stateValue))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StateValue").build()).build();
private static final SdkField ACTION_PREFIX_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ActionPrefix").getter(getter(DescribeAlarmsRequest::actionPrefix)).setter(setter(Builder::actionPrefix))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ActionPrefix").build()).build();
private static final SdkField MAX_RECORDS_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("MaxRecords").getter(getter(DescribeAlarmsRequest::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(DescribeAlarmsRequest::nextToken)).setter(setter(Builder::nextToken))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NextToken").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ALARM_NAMES_FIELD,
ALARM_NAME_PREFIX_FIELD, ALARM_TYPES_FIELD, CHILDREN_OF_ALARM_NAME_FIELD, PARENTS_OF_ALARM_NAME_FIELD,
STATE_VALUE_FIELD, ACTION_PREFIX_FIELD, MAX_RECORDS_FIELD, NEXT_TOKEN_FIELD));
private final List alarmNames;
private final String alarmNamePrefix;
private final List alarmTypes;
private final String childrenOfAlarmName;
private final String parentsOfAlarmName;
private final String stateValue;
private final String actionPrefix;
private final Integer maxRecords;
private final String nextToken;
private DescribeAlarmsRequest(BuilderImpl builder) {
super(builder);
this.alarmNames = builder.alarmNames;
this.alarmNamePrefix = builder.alarmNamePrefix;
this.alarmTypes = builder.alarmTypes;
this.childrenOfAlarmName = builder.childrenOfAlarmName;
this.parentsOfAlarmName = builder.parentsOfAlarmName;
this.stateValue = builder.stateValue;
this.actionPrefix = builder.actionPrefix;
this.maxRecords = builder.maxRecords;
this.nextToken = builder.nextToken;
}
/**
* For responses, this returns true if the service returned a value for the AlarmNames 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 hasAlarmNames() {
return alarmNames != null && !(alarmNames instanceof SdkAutoConstructList);
}
/**
*
* The names of the alarms to retrieve information about.
*
*
* 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 #hasAlarmNames} method.
*
*
* @return The names of the alarms to retrieve information about.
*/
public final List alarmNames() {
return alarmNames;
}
/**
*
* An alarm name prefix. If you specify this parameter, you receive information about all alarms that have names
* that start with this prefix.
*
*
* If this parameter is specified, you cannot specify AlarmNames
.
*
*
* @return An alarm name prefix. If you specify this parameter, you receive information about all alarms that have
* names that start with this prefix.
*
* If this parameter is specified, you cannot specify AlarmNames
.
*/
public final String alarmNamePrefix() {
return alarmNamePrefix;
}
/**
*
* 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;
}
/**
*
* If you use this parameter and specify the name of a composite alarm, the operation returns information about the
* "children" alarms of the alarm you specify. These are the metric alarms and composite alarms referenced in the
* AlarmRule
field of the composite alarm that you specify in ChildrenOfAlarmName
.
* Information about the composite alarm that you name in ChildrenOfAlarmName
is not returned.
*
*
* If you specify ChildrenOfAlarmName
, you cannot specify any other parameters in the request except
* for MaxRecords
and NextToken
. If you do so, you receive a validation error.
*
*
*
* Only the Alarm Name
, ARN
, StateValue
(OK/ALARM/INSUFFICIENT_DATA), and
* StateUpdatedTimestamp
information are returned by this operation when you use this parameter. To get
* complete information about these alarms, perform another DescribeAlarms
operation and specify the
* parent alarm names in the AlarmNames
parameter.
*
*
*
* @return If you use this parameter and specify the name of a composite alarm, the operation returns information
* about the "children" alarms of the alarm you specify. These are the metric alarms and composite alarms
* referenced in the AlarmRule
field of the composite alarm that you specify in
* ChildrenOfAlarmName
. Information about the composite alarm that you name in
* ChildrenOfAlarmName
is not returned.
*
* If you specify ChildrenOfAlarmName
, you cannot specify any other parameters in the request
* except for MaxRecords
and NextToken
. If you do so, you receive a validation
* error.
*
*
*
* Only the Alarm Name
, ARN
, StateValue
(OK/ALARM/INSUFFICIENT_DATA),
* and StateUpdatedTimestamp
information are returned by this operation when you use this
* parameter. To get complete information about these alarms, perform another DescribeAlarms
* operation and specify the parent alarm names in the AlarmNames
parameter.
*
*/
public final String childrenOfAlarmName() {
return childrenOfAlarmName;
}
/**
*
* If you use this parameter and specify the name of a metric or composite alarm, the operation returns information
* about the "parent" alarms of the alarm you specify. These are the composite alarms that have
* AlarmRule
parameters that reference the alarm named in ParentsOfAlarmName
. Information
* about the alarm that you specify in ParentsOfAlarmName
is not returned.
*
*
* If you specify ParentsOfAlarmName
, you cannot specify any other parameters in the request except for
* MaxRecords
and NextToken
. If you do so, you receive a validation error.
*
*
*
* Only the Alarm Name and ARN are returned by this operation when you use this parameter. To get complete
* information about these alarms, perform another DescribeAlarms
operation and specify the parent
* alarm names in the AlarmNames
parameter.
*
*
*
* @return If you use this parameter and specify the name of a metric or composite alarm, the operation returns
* information about the "parent" alarms of the alarm you specify. These are the composite alarms that have
* AlarmRule
parameters that reference the alarm named in ParentsOfAlarmName
.
* Information about the alarm that you specify in ParentsOfAlarmName
is not returned.
*
* If you specify ParentsOfAlarmName
, you cannot specify any other parameters in the request
* except for MaxRecords
and NextToken
. If you do so, you receive a validation
* error.
*
*
*
* Only the Alarm Name and ARN are returned by this operation when you use this parameter. To get complete
* information about these alarms, perform another DescribeAlarms
operation and specify the
* parent alarm names in the AlarmNames
parameter.
*
*/
public final String parentsOfAlarmName() {
return parentsOfAlarmName;
}
/**
*
* Specify this parameter to receive information only about alarms that are currently in the state that you specify.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #stateValue} will
* return {@link StateValue#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stateValueAsString}.
*
*
* @return Specify this parameter to receive information only about alarms that are currently in the state that you
* specify.
* @see StateValue
*/
public final StateValue stateValue() {
return StateValue.fromValue(stateValue);
}
/**
*
* Specify this parameter to receive information only about alarms that are currently in the state that you specify.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #stateValue} will
* return {@link StateValue#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stateValueAsString}.
*
*
* @return Specify this parameter to receive information only about alarms that are currently in the state that you
* specify.
* @see StateValue
*/
public final String stateValueAsString() {
return stateValue;
}
/**
*
* Use this parameter to filter the results of the operation to only those alarms that use a certain alarm action.
* For example, you could specify the ARN of an SNS topic to find all alarms that send notifications to that topic.
*
*
* @return Use this parameter to filter the results of the operation to only those alarms that use a certain alarm
* action. For example, you could specify the ARN of an SNS topic to find all alarms that send notifications
* to that topic.
*/
public final String actionPrefix() {
return actionPrefix;
}
/**
*
* The maximum number of alarm descriptions to retrieve.
*
*
* @return The maximum number of alarm descriptions 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;
}
@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(hasAlarmNames() ? alarmNames() : null);
hashCode = 31 * hashCode + Objects.hashCode(alarmNamePrefix());
hashCode = 31 * hashCode + Objects.hashCode(hasAlarmTypes() ? alarmTypesAsStrings() : null);
hashCode = 31 * hashCode + Objects.hashCode(childrenOfAlarmName());
hashCode = 31 * hashCode + Objects.hashCode(parentsOfAlarmName());
hashCode = 31 * hashCode + Objects.hashCode(stateValueAsString());
hashCode = 31 * hashCode + Objects.hashCode(actionPrefix());
hashCode = 31 * hashCode + Objects.hashCode(maxRecords());
hashCode = 31 * hashCode + Objects.hashCode(nextToken());
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 DescribeAlarmsRequest)) {
return false;
}
DescribeAlarmsRequest other = (DescribeAlarmsRequest) obj;
return hasAlarmNames() == other.hasAlarmNames() && Objects.equals(alarmNames(), other.alarmNames())
&& Objects.equals(alarmNamePrefix(), other.alarmNamePrefix()) && hasAlarmTypes() == other.hasAlarmTypes()
&& Objects.equals(alarmTypesAsStrings(), other.alarmTypesAsStrings())
&& Objects.equals(childrenOfAlarmName(), other.childrenOfAlarmName())
&& Objects.equals(parentsOfAlarmName(), other.parentsOfAlarmName())
&& Objects.equals(stateValueAsString(), other.stateValueAsString())
&& Objects.equals(actionPrefix(), other.actionPrefix()) && Objects.equals(maxRecords(), other.maxRecords())
&& Objects.equals(nextToken(), other.nextToken());
}
/**
* 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("DescribeAlarmsRequest").add("AlarmNames", hasAlarmNames() ? alarmNames() : null)
.add("AlarmNamePrefix", alarmNamePrefix()).add("AlarmTypes", hasAlarmTypes() ? alarmTypesAsStrings() : null)
.add("ChildrenOfAlarmName", childrenOfAlarmName()).add("ParentsOfAlarmName", parentsOfAlarmName())
.add("StateValue", stateValueAsString()).add("ActionPrefix", actionPrefix()).add("MaxRecords", maxRecords())
.add("NextToken", nextToken()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "AlarmNames":
return Optional.ofNullable(clazz.cast(alarmNames()));
case "AlarmNamePrefix":
return Optional.ofNullable(clazz.cast(alarmNamePrefix()));
case "AlarmTypes":
return Optional.ofNullable(clazz.cast(alarmTypesAsStrings()));
case "ChildrenOfAlarmName":
return Optional.ofNullable(clazz.cast(childrenOfAlarmName()));
case "ParentsOfAlarmName":
return Optional.ofNullable(clazz.cast(parentsOfAlarmName()));
case "StateValue":
return Optional.ofNullable(clazz.cast(stateValueAsString()));
case "ActionPrefix":
return Optional.ofNullable(clazz.cast(actionPrefix()));
case "MaxRecords":
return Optional.ofNullable(clazz.cast(maxRecords()));
case "NextToken":
return Optional.ofNullable(clazz.cast(nextToken()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function