software.amazon.awssdk.services.pi.model.GetResourceMetricsRequest Maven / Gradle / Ivy
Show all versions of pi 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.pi.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 java.util.stream.Collectors;
import java.util.stream.Stream;
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 GetResourceMetricsRequest extends PiRequest implements
ToCopyableBuilder {
private static final SdkField SERVICE_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ServiceType").getter(getter(GetResourceMetricsRequest::serviceTypeAsString))
.setter(setter(Builder::serviceType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ServiceType").build()).build();
private static final SdkField IDENTIFIER_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Identifier").getter(getter(GetResourceMetricsRequest::identifier)).setter(setter(Builder::identifier))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Identifier").build()).build();
private static final SdkField> METRIC_QUERIES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("MetricQueries")
.getter(getter(GetResourceMetricsRequest::metricQueries))
.setter(setter(Builder::metricQueries))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MetricQueries").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(MetricQuery::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField START_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("StartTime").getter(getter(GetResourceMetricsRequest::startTime)).setter(setter(Builder::startTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StartTime").build()).build();
private static final SdkField END_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("EndTime").getter(getter(GetResourceMetricsRequest::endTime)).setter(setter(Builder::endTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EndTime").build()).build();
private static final SdkField PERIOD_IN_SECONDS_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("PeriodInSeconds").getter(getter(GetResourceMetricsRequest::periodInSeconds))
.setter(setter(Builder::periodInSeconds))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PeriodInSeconds").build()).build();
private static final SdkField MAX_RESULTS_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("MaxResults").getter(getter(GetResourceMetricsRequest::maxResults)).setter(setter(Builder::maxResults))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MaxResults").build()).build();
private static final SdkField NEXT_TOKEN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("NextToken").getter(getter(GetResourceMetricsRequest::nextToken)).setter(setter(Builder::nextToken))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NextToken").build()).build();
private static final SdkField PERIOD_ALIGNMENT_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("PeriodAlignment").getter(getter(GetResourceMetricsRequest::periodAlignmentAsString))
.setter(setter(Builder::periodAlignment))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PeriodAlignment").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(SERVICE_TYPE_FIELD,
IDENTIFIER_FIELD, METRIC_QUERIES_FIELD, START_TIME_FIELD, END_TIME_FIELD, PERIOD_IN_SECONDS_FIELD, MAX_RESULTS_FIELD,
NEXT_TOKEN_FIELD, PERIOD_ALIGNMENT_FIELD));
private final String serviceType;
private final String identifier;
private final List metricQueries;
private final Instant startTime;
private final Instant endTime;
private final Integer periodInSeconds;
private final Integer maxResults;
private final String nextToken;
private final String periodAlignment;
private GetResourceMetricsRequest(BuilderImpl builder) {
super(builder);
this.serviceType = builder.serviceType;
this.identifier = builder.identifier;
this.metricQueries = builder.metricQueries;
this.startTime = builder.startTime;
this.endTime = builder.endTime;
this.periodInSeconds = builder.periodInSeconds;
this.maxResults = builder.maxResults;
this.nextToken = builder.nextToken;
this.periodAlignment = builder.periodAlignment;
}
/**
*
* The Amazon Web Services service for which Performance Insights returns metrics. Valid values are as follows:
*
*
* -
*
* RDS
*
*
* -
*
* DOCDB
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #serviceType} will
* return {@link ServiceType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #serviceTypeAsString}.
*
*
* @return The Amazon Web Services service for which Performance Insights returns metrics. Valid values are as
* follows:
*
* -
*
* RDS
*
*
* -
*
* DOCDB
*
*
* @see ServiceType
*/
public final ServiceType serviceType() {
return ServiceType.fromValue(serviceType);
}
/**
*
* The Amazon Web Services service for which Performance Insights returns metrics. Valid values are as follows:
*
*
* -
*
* RDS
*
*
* -
*
* DOCDB
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #serviceType} will
* return {@link ServiceType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #serviceTypeAsString}.
*
*
* @return The Amazon Web Services service for which Performance Insights returns metrics. Valid values are as
* follows:
*
* -
*
* RDS
*
*
* -
*
* DOCDB
*
*
* @see ServiceType
*/
public final String serviceTypeAsString() {
return serviceType;
}
/**
*
* An immutable identifier for a data source that is unique for an Amazon Web Services Region. Performance Insights
* gathers metrics from this data source. In the console, the identifier is shown as ResourceID. When you
* call DescribeDBInstances
, the identifier is returned as DbiResourceId
.
*
*
* To use a DB instance as a data source, specify its DbiResourceId
value. For example, specify
* db-ABCDEFGHIJKLMNOPQRSTU1VW2X
.
*
*
* @return An immutable identifier for a data source that is unique for an Amazon Web Services Region. Performance
* Insights gathers metrics from this data source. In the console, the identifier is shown as
* ResourceID. When you call DescribeDBInstances
, the identifier is returned as
* DbiResourceId
.
*
* To use a DB instance as a data source, specify its DbiResourceId
value. For example, specify
* db-ABCDEFGHIJKLMNOPQRSTU1VW2X
.
*/
public final String identifier() {
return identifier;
}
/**
* For responses, this returns true if the service returned a value for the MetricQueries 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 hasMetricQueries() {
return metricQueries != null && !(metricQueries instanceof SdkAutoConstructList);
}
/**
*
* An array of one or more queries to perform. Each query must specify a Performance Insights metric and specify an
* aggregate function, and you can provide filtering criteria. You must append the aggregate function to the metric.
* For example, to find the average for the metric db.load
you must use db.load.avg
. Valid
* values for aggregate functions include .avg
, .min
, .max
, and
* .sum
.
*
*
* 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 #hasMetricQueries} method.
*
*
* @return An array of one or more queries to perform. Each query must specify a Performance Insights metric and
* specify an aggregate function, and you can provide filtering criteria. You must append the aggregate
* function to the metric. For example, to find the average for the metric db.load
you must use
* db.load.avg
. Valid values for aggregate functions include .avg
,
* .min
, .max
, and .sum
.
*/
public final List metricQueries() {
return metricQueries;
}
/**
*
* The date and time specifying the beginning of the requested time series query range. You can't specify a
* StartTime
that is earlier than 7 days ago. By default, Performance Insights has 7 days of retention,
* but you can extend this range up to 2 years. The value specified is inclusive. Thus, the command returns
* data points equal to or greater than StartTime
.
*
*
* The value for StartTime
must be earlier than the value for EndTime
.
*
*
* @return The date and time specifying the beginning of the requested time series query range. You can't specify a
* StartTime
that is earlier than 7 days ago. By default, Performance Insights has 7 days of
* retention, but you can extend this range up to 2 years. The value specified is inclusive. Thus,
* the command returns data points equal to or greater than StartTime
.
*
* The value for StartTime
must be earlier than the value for EndTime
.
*/
public final Instant startTime() {
return startTime;
}
/**
*
* The date and time specifying the end of the requested time series query range. The value specified is
* exclusive. Thus, the command returns data points less than (but not equal to) EndTime
.
*
*
* The value for EndTime
must be later than the value for StartTime
.
*
*
* @return The date and time specifying the end of the requested time series query range. The value specified is
* exclusive. Thus, the command returns data points less than (but not equal to) EndTime
* .
*
* The value for EndTime
must be later than the value for StartTime
.
*/
public final Instant endTime() {
return endTime;
}
/**
*
* The granularity, in seconds, of the data points returned from Performance Insights. A period can be as short as
* one second, or as long as one day (86400 seconds). Valid values are:
*
*
* -
*
* 1
(one second)
*
*
* -
*
* 60
(one minute)
*
*
* -
*
* 300
(five minutes)
*
*
* -
*
* 3600
(one hour)
*
*
* -
*
* 86400
(twenty-four hours)
*
*
*
*
* If you don't specify PeriodInSeconds
, then Performance Insights will choose a value for you, with a
* goal of returning roughly 100-200 data points in the response.
*
*
* @return The granularity, in seconds, of the data points returned from Performance Insights. A period can be as
* short as one second, or as long as one day (86400 seconds). Valid values are:
*
* -
*
* 1
(one second)
*
*
* -
*
* 60
(one minute)
*
*
* -
*
* 300
(five minutes)
*
*
* -
*
* 3600
(one hour)
*
*
* -
*
* 86400
(twenty-four hours)
*
*
*
*
* If you don't specify PeriodInSeconds
, then Performance Insights will choose a value for you,
* with a goal of returning roughly 100-200 data points in the response.
*/
public final Integer periodInSeconds() {
return periodInSeconds;
}
/**
*
* The maximum number of items to return in the response. If more items exist than the specified
* MaxRecords
value, a pagination token is included in the response so that the remaining results can
* be retrieved.
*
*
* @return The maximum number of items to return in the response. If more items exist than the specified
* MaxRecords
value, a pagination token is included in the response so that the remaining
* results can be retrieved.
*/
public final Integer maxResults() {
return maxResults;
}
/**
*
* An optional pagination token provided by a previous request. If this parameter is specified, the response
* includes only records beyond the token, up to the value specified by MaxRecords
.
*
*
* @return An optional pagination token provided by a previous request. If this parameter is specified, the response
* includes only records beyond the token, up to the value specified by MaxRecords
.
*/
public final String nextToken() {
return nextToken;
}
/**
*
* The returned timestamp which is the start or end time of the time periods. The default value is
* END_TIME
.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #periodAlignment}
* will return {@link PeriodAlignment#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #periodAlignmentAsString}.
*
*
* @return The returned timestamp which is the start or end time of the time periods. The default value is
* END_TIME
.
* @see PeriodAlignment
*/
public final PeriodAlignment periodAlignment() {
return PeriodAlignment.fromValue(periodAlignment);
}
/**
*
* The returned timestamp which is the start or end time of the time periods. The default value is
* END_TIME
.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #periodAlignment}
* will return {@link PeriodAlignment#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #periodAlignmentAsString}.
*
*
* @return The returned timestamp which is the start or end time of the time periods. The default value is
* END_TIME
.
* @see PeriodAlignment
*/
public final String periodAlignmentAsString() {
return periodAlignment;
}
@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(serviceTypeAsString());
hashCode = 31 * hashCode + Objects.hashCode(identifier());
hashCode = 31 * hashCode + Objects.hashCode(hasMetricQueries() ? metricQueries() : null);
hashCode = 31 * hashCode + Objects.hashCode(startTime());
hashCode = 31 * hashCode + Objects.hashCode(endTime());
hashCode = 31 * hashCode + Objects.hashCode(periodInSeconds());
hashCode = 31 * hashCode + Objects.hashCode(maxResults());
hashCode = 31 * hashCode + Objects.hashCode(nextToken());
hashCode = 31 * hashCode + Objects.hashCode(periodAlignmentAsString());
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 GetResourceMetricsRequest)) {
return false;
}
GetResourceMetricsRequest other = (GetResourceMetricsRequest) obj;
return Objects.equals(serviceTypeAsString(), other.serviceTypeAsString())
&& Objects.equals(identifier(), other.identifier()) && hasMetricQueries() == other.hasMetricQueries()
&& Objects.equals(metricQueries(), other.metricQueries()) && Objects.equals(startTime(), other.startTime())
&& Objects.equals(endTime(), other.endTime()) && Objects.equals(periodInSeconds(), other.periodInSeconds())
&& Objects.equals(maxResults(), other.maxResults()) && Objects.equals(nextToken(), other.nextToken())
&& Objects.equals(periodAlignmentAsString(), other.periodAlignmentAsString());
}
/**
* 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("GetResourceMetricsRequest").add("ServiceType", serviceTypeAsString())
.add("Identifier", identifier()).add("MetricQueries", hasMetricQueries() ? metricQueries() : null)
.add("StartTime", startTime()).add("EndTime", endTime()).add("PeriodInSeconds", periodInSeconds())
.add("MaxResults", maxResults()).add("NextToken", nextToken()).add("PeriodAlignment", periodAlignmentAsString())
.build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "ServiceType":
return Optional.ofNullable(clazz.cast(serviceTypeAsString()));
case "Identifier":
return Optional.ofNullable(clazz.cast(identifier()));
case "MetricQueries":
return Optional.ofNullable(clazz.cast(metricQueries()));
case "StartTime":
return Optional.ofNullable(clazz.cast(startTime()));
case "EndTime":
return Optional.ofNullable(clazz.cast(endTime()));
case "PeriodInSeconds":
return Optional.ofNullable(clazz.cast(periodInSeconds()));
case "MaxResults":
return Optional.ofNullable(clazz.cast(maxResults()));
case "NextToken":
return Optional.ofNullable(clazz.cast(nextToken()));
case "PeriodAlignment":
return Optional.ofNullable(clazz.cast(periodAlignmentAsString()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function