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

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 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 getter(Function g) { return obj -> g.apply((GetResourceMetricsRequest) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends PiRequest.Builder, SdkPojo, CopyableBuilder { /** *

* The AWS service for which Performance Insights will return metrics. The only valid value for * ServiceType is: RDS *

* * @param serviceType * The AWS service for which Performance Insights will return metrics. The only valid value for * ServiceType is: RDS * @see ServiceType * @return Returns a reference to this object so that method calls can be chained together. * @see ServiceType */ Builder serviceType(String serviceType); /** *

* The AWS service for which Performance Insights will return metrics. The only valid value for * ServiceType is: RDS *

* * @param serviceType * The AWS service for which Performance Insights will return metrics. The only valid value for * ServiceType is: RDS * @see ServiceType * @return Returns a reference to this object so that method calls can be chained together. * @see ServiceType */ Builder serviceType(ServiceType 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 *

* * @param identifier * 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 Returns a reference to this object so that method calls can be chained together. */ Builder identifier(String identifier); /** *

* 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. *

* * @param metricQueries * 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. * @return Returns a reference to this object so that method calls can be chained together. */ Builder metricQueries(Collection metricQueries); /** *

* 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. *

* * @param metricQueries * 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. * @return Returns a reference to this object so that method calls can be chained together. */ Builder metricQueries(MetricQuery... metricQueries); /** *

* 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. *

* This is a convenience that creates an instance of the {@link List.Builder} avoiding the need to * create one manually via {@link List#builder()}. * * When the {@link Consumer} completes, {@link List.Builder#build()} is called immediately and its * result is passed to {@link #metricQueries(List)}. * * @param metricQueries * a consumer that will call methods on {@link List.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #metricQueries(List) */ Builder metricQueries(Consumer... 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. *

* * @param startTime * 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 Returns a reference to this object so that method calls can be chained together. */ Builder startTime(Instant 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. *

* * @param endTime * 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 Returns a reference to this object so that method calls can be chained together. */ Builder endTime(Instant 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. *

* * @param periodInSeconds * 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 Returns a reference to this object so that method calls can be chained together. */ Builder periodInSeconds(Integer 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. *

* * @param maxResults * 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 Returns a reference to this object so that method calls can be chained together. */ Builder maxResults(Integer 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. *

* * @param nextToken * 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 Returns a reference to this object so that method calls can be chained together. */ Builder nextToken(String nextToken); @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @Override Builder overrideConfiguration(Consumer builderConsumer); } static final class BuilderImpl extends PiRequest.BuilderImpl implements Builder { private String serviceType; private String identifier; private List metricQueries = DefaultSdkAutoConstructList.getInstance(); private Instant startTime; private Instant endTime; private Integer periodInSeconds; private Integer maxResults; private String nextToken; private BuilderImpl() { } private BuilderImpl(GetResourceMetricsRequest model) { super(model); serviceType(model.serviceType); identifier(model.identifier); metricQueries(model.metricQueries); startTime(model.startTime); endTime(model.endTime); periodInSeconds(model.periodInSeconds); maxResults(model.maxResults); nextToken(model.nextToken); } public final String getServiceType() { return serviceType; } @Override public final Builder serviceType(String serviceType) { this.serviceType = serviceType; return this; } @Override public final Builder serviceType(ServiceType serviceType) { this.serviceType(serviceType == null ? null : serviceType.toString()); return this; } public final void setServiceType(String serviceType) { this.serviceType = serviceType; } public final String getIdentifier() { return identifier; } @Override public final Builder identifier(String identifier) { this.identifier = identifier; return this; } public final void setIdentifier(String identifier) { this.identifier = identifier; } public final Collection getMetricQueries() { return metricQueries != null ? metricQueries.stream().map(MetricQuery::toBuilder).collect(Collectors.toList()) : null; } @Override public final Builder metricQueries(Collection metricQueries) { this.metricQueries = MetricQueryListCopier.copy(metricQueries); return this; } @Override @SafeVarargs public final Builder metricQueries(MetricQuery... metricQueries) { metricQueries(Arrays.asList(metricQueries)); return this; } @Override @SafeVarargs public final Builder metricQueries(Consumer... metricQueries) { metricQueries(Stream.of(metricQueries).map(c -> MetricQuery.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final void setMetricQueries(Collection metricQueries) { this.metricQueries = MetricQueryListCopier.copyFromBuilder(metricQueries); } public final Instant getStartTime() { return startTime; } @Override public final Builder startTime(Instant startTime) { this.startTime = startTime; return this; } public final void setStartTime(Instant startTime) { this.startTime = startTime; } public final Instant getEndTime() { return endTime; } @Override public final Builder endTime(Instant endTime) { this.endTime = endTime; return this; } public final void setEndTime(Instant endTime) { this.endTime = endTime; } public final Integer getPeriodInSeconds() { return periodInSeconds; } @Override public final Builder periodInSeconds(Integer periodInSeconds) { this.periodInSeconds = periodInSeconds; return this; } public final void setPeriodInSeconds(Integer periodInSeconds) { this.periodInSeconds = periodInSeconds; } public final Integer getMaxResults() { return maxResults; } @Override public final Builder maxResults(Integer maxResults) { this.maxResults = maxResults; return this; } public final void setMaxResults(Integer maxResults) { this.maxResults = maxResults; } public final String getNextToken() { return nextToken; } @Override public final Builder nextToken(String nextToken) { this.nextToken = nextToken; return this; } public final void setNextToken(String nextToken) { this.nextToken = nextToken; } @Override public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) { super.overrideConfiguration(overrideConfiguration); return this; } @Override public Builder overrideConfiguration(Consumer builderConsumer) { super.overrideConfiguration(builderConsumer); return this; } @Override public GetResourceMetricsRequest build() { return new GetResourceMetricsRequest(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy