
software.amazon.awssdk.services.pi.model.GetResourceMetricsRequest Maven / Gradle / Ivy
/*
* 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)
.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)
.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)
.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)
.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)
.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)
.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)
.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)
.getter(getter(GetResourceMetricsRequest::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(SERVICE_TYPE_FIELD,
IDENTIFIER_FIELD, METRIC_QUERIES_FIELD, START_TIME_FIELD, END_TIME_FIELD, PERIOD_IN_SECONDS_FIELD, MAX_RESULTS_FIELD,
NEXT_TOKEN_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 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;
}
/**
*
* The AWS service for which Performance Insights will return metrics. The only valid value for ServiceType
* is: RDS
*
*
* 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 AWS service for which Performance Insights will return metrics. The only valid value for
* ServiceType is: RDS
* @see ServiceType
*/
public ServiceType serviceType() {
return ServiceType.fromValue(serviceType);
}
/**
*
* The AWS service for which Performance Insights will return metrics. The only valid value for ServiceType
* is: RDS
*
*
* 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 AWS service for which Performance Insights will return metrics. The only valid value for
* ServiceType is: RDS
* @see ServiceType
*/
public String serviceTypeAsString() {
return serviceType;
}
/**
*
* An immutable, AWS Region-unique identifier for a data source. Performance Insights gathers metrics from this data
* source.
*
*
* To use an Amazon RDS instance as a data source, you specify its DbiResourceId
value - for example:
* db-FAIHNTYBKTGAUSUZQYPDS2GW4A
*
*
* @return An immutable, AWS Region-unique identifier for a data source. Performance Insights gathers metrics from
* this data source.
*
* To use an Amazon RDS instance as a data source, you specify its DbiResourceId
value - for
* example: db-FAIHNTYBKTGAUSUZQYPDS2GW4A
*/
public String identifier() {
return identifier;
}
/**
* Returns true if the MetricQueries 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 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 can
* optionally specify aggregation and filtering criteria.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasMetricQueries()} to see if a value was sent in this field.
*
*
* @return An array of one or more queries to perform. Each query must specify a Performance Insights metric, and
* can optionally specify aggregation and filtering criteria.
*/
public List metricQueries() {
return metricQueries;
}
/**
*
* The date and time specifying the beginning of the requested time series data. You can't specify a
* StartTime
that's earlier than 7 days ago. The value specified is inclusive - data points
* equal to or greater than StartTime
will be returned.
*
*
* 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 data. You can't specify a
* StartTime
that's earlier than 7 days ago. The value specified is inclusive - data
* points equal to or greater than StartTime
will be returned.
*
* The value for StartTime
must be earlier than the value for EndTime
.
*/
public Instant startTime() {
return startTime;
}
/**
*
* The date and time specifiying the end of the requested time series data. The value specified is exclusive
* - data points less than (but not equal to) EndTime
will be returned.
*
*
* The value for EndTime
must be later than the value for StartTime
.
*
*
* @return The date and time specifiying the end of the requested time series data. The value specified is
* exclusive - data points less than (but not equal to) EndTime
will be returned.
*
* The value for EndTime
must be later than the value for StartTime
.
*/
public 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 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 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 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 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(metricQueries());
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());
return hashCode;
}
@Override
public boolean equals(Object obj) {
return super.equals(obj) && equalsBySdkFields(obj);
}
@Override
public 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()) && 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());
}
/**
* 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 String toString() {
return ToString.builder("GetResourceMetricsRequest").add("ServiceType", serviceTypeAsString())
.add("Identifier", identifier()).add("MetricQueries", metricQueries()).add("StartTime", startTime())
.add("EndTime", endTime()).add("PeriodInSeconds", periodInSeconds()).add("MaxResults", maxResults())
.add("NextToken", nextToken()).build();
}
public 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()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function