software.amazon.awssdk.services.costexplorer.model.GetReservationCoverageRequest Maven / Gradle / Ivy
Show all versions of costexplorer 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.costexplorer.model;
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;
/**
*
* You can use the following request parameters to query for how much of your instance usage a reservation covered.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class GetReservationCoverageRequest extends CostExplorerRequest implements
ToCopyableBuilder {
private static final SdkField TIME_PERIOD_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("TimePeriod").getter(getter(GetReservationCoverageRequest::timePeriod))
.setter(setter(Builder::timePeriod)).constructor(DateInterval::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TimePeriod").build()).build();
private static final SdkField> GROUP_BY_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("GroupBy")
.getter(getter(GetReservationCoverageRequest::groupBy))
.setter(setter(Builder::groupBy))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("GroupBy").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(GroupDefinition::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField GRANULARITY_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Granularity").getter(getter(GetReservationCoverageRequest::granularityAsString))
.setter(setter(Builder::granularity))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Granularity").build()).build();
private static final SdkField FILTER_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("Filter").getter(getter(GetReservationCoverageRequest::filter)).setter(setter(Builder::filter))
.constructor(Expression::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Filter").build()).build();
private static final SdkField> METRICS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Metrics")
.getter(getter(GetReservationCoverageRequest::metrics))
.setter(setter(Builder::metrics))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Metrics").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 NEXT_PAGE_TOKEN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("NextPageToken").getter(getter(GetReservationCoverageRequest::nextPageToken))
.setter(setter(Builder::nextPageToken))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NextPageToken").build()).build();
private static final SdkField SORT_BY_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("SortBy").getter(getter(GetReservationCoverageRequest::sortBy)).setter(setter(Builder::sortBy))
.constructor(SortDefinition::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SortBy").build()).build();
private static final SdkField MAX_RESULTS_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("MaxResults").getter(getter(GetReservationCoverageRequest::maxResults))
.setter(setter(Builder::maxResults))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MaxResults").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(TIME_PERIOD_FIELD,
GROUP_BY_FIELD, GRANULARITY_FIELD, FILTER_FIELD, METRICS_FIELD, NEXT_PAGE_TOKEN_FIELD, SORT_BY_FIELD,
MAX_RESULTS_FIELD));
private final DateInterval timePeriod;
private final List groupBy;
private final String granularity;
private final Expression filter;
private final List metrics;
private final String nextPageToken;
private final SortDefinition sortBy;
private final Integer maxResults;
private GetReservationCoverageRequest(BuilderImpl builder) {
super(builder);
this.timePeriod = builder.timePeriod;
this.groupBy = builder.groupBy;
this.granularity = builder.granularity;
this.filter = builder.filter;
this.metrics = builder.metrics;
this.nextPageToken = builder.nextPageToken;
this.sortBy = builder.sortBy;
this.maxResults = builder.maxResults;
}
/**
*
* The start and end dates of the period that you want to retrieve data about reservation coverage for. You can
* retrieve data for a maximum of 13 months: the last 12 months and the current month. The start date is inclusive,
* but the end date is exclusive. For example, if start
is 2017-01-01
and end
* is 2017-05-01
, then the cost and usage data is retrieved from 2017-01-01
up to and
* including 2017-04-30
but not including 2017-05-01
.
*
*
* @return The start and end dates of the period that you want to retrieve data about reservation coverage for. You
* can retrieve data for a maximum of 13 months: the last 12 months and the current month. The start date is
* inclusive, but the end date is exclusive. For example, if start
is 2017-01-01
* and end
is 2017-05-01
, then the cost and usage data is retrieved from
* 2017-01-01
up to and including 2017-04-30
but not including
* 2017-05-01
.
*/
public final DateInterval timePeriod() {
return timePeriod;
}
/**
* For responses, this returns true if the service returned a value for the GroupBy 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 hasGroupBy() {
return groupBy != null && !(groupBy instanceof SdkAutoConstructList);
}
/**
*
* You can group the data by the following attributes:
*
*
* -
*
* AZ
*
*
* -
*
* CACHE_ENGINE
*
*
* -
*
* DATABASE_ENGINE
*
*
* -
*
* DEPLOYMENT_OPTION
*
*
* -
*
* INSTANCE_TYPE
*
*
* -
*
* INVOICING_ENTITY
*
*
* -
*
* LINKED_ACCOUNT
*
*
* -
*
* OPERATING_SYSTEM
*
*
* -
*
* PLATFORM
*
*
* -
*
* REGION
*
*
* -
*
* TENANCY
*
*
*
*
* 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 #hasGroupBy} method.
*
*
* @return You can group the data by the following attributes:
*
* -
*
* AZ
*
*
* -
*
* CACHE_ENGINE
*
*
* -
*
* DATABASE_ENGINE
*
*
* -
*
* DEPLOYMENT_OPTION
*
*
* -
*
* INSTANCE_TYPE
*
*
* -
*
* INVOICING_ENTITY
*
*
* -
*
* LINKED_ACCOUNT
*
*
* -
*
* OPERATING_SYSTEM
*
*
* -
*
* PLATFORM
*
*
* -
*
* REGION
*
*
* -
*
* TENANCY
*
*
*/
public final List groupBy() {
return groupBy;
}
/**
*
* The granularity of the Amazon Web Services cost data for the reservation. Valid values are MONTHLY
* and DAILY
.
*
*
* If GroupBy
is set, Granularity
can't be set. If Granularity
isn't set, the
* response object doesn't include Granularity
, either MONTHLY
or DAILY
.
*
*
* The GetReservationCoverage
operation supports only DAILY
and MONTHLY
* granularities.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #granularity} will
* return {@link Granularity#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #granularityAsString}.
*
*
* @return The granularity of the Amazon Web Services cost data for the reservation. Valid values are
* MONTHLY
and DAILY
.
*
* If GroupBy
is set, Granularity
can't be set. If Granularity
isn't
* set, the response object doesn't include Granularity
, either MONTHLY
or
* DAILY
.
*
*
* The GetReservationCoverage
operation supports only DAILY
and
* MONTHLY
granularities.
* @see Granularity
*/
public final Granularity granularity() {
return Granularity.fromValue(granularity);
}
/**
*
* The granularity of the Amazon Web Services cost data for the reservation. Valid values are MONTHLY
* and DAILY
.
*
*
* If GroupBy
is set, Granularity
can't be set. If Granularity
isn't set, the
* response object doesn't include Granularity
, either MONTHLY
or DAILY
.
*
*
* The GetReservationCoverage
operation supports only DAILY
and MONTHLY
* granularities.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #granularity} will
* return {@link Granularity#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #granularityAsString}.
*
*
* @return The granularity of the Amazon Web Services cost data for the reservation. Valid values are
* MONTHLY
and DAILY
.
*
* If GroupBy
is set, Granularity
can't be set. If Granularity
isn't
* set, the response object doesn't include Granularity
, either MONTHLY
or
* DAILY
.
*
*
* The GetReservationCoverage
operation supports only DAILY
and
* MONTHLY
granularities.
* @see Granularity
*/
public final String granularityAsString() {
return granularity;
}
/**
*
* Filters utilization data by dimensions. You can filter by the following dimensions:
*
*
* -
*
* AZ
*
*
* -
*
* CACHE_ENGINE
*
*
* -
*
* DATABASE_ENGINE
*
*
* -
*
* DEPLOYMENT_OPTION
*
*
* -
*
* INSTANCE_TYPE
*
*
* -
*
* LINKED_ACCOUNT
*
*
* -
*
* OPERATING_SYSTEM
*
*
* -
*
* PLATFORM
*
*
* -
*
* REGION
*
*
* -
*
* SERVICE
*
*
* -
*
* TAG
*
*
* -
*
* TENANCY
*
*
*
*
* GetReservationCoverage
uses the same Expression
* object as the other operations, but only AND
is supported among each dimension. You can nest only
* one level deep. If there are multiple values for a dimension, they are OR'd together.
*
*
* If you don't provide a SERVICE
filter, Cost Explorer defaults to EC2.
*
*
* Cost category is also supported.
*
*
* @return Filters utilization data by dimensions. You can filter by the following dimensions:
*
* -
*
* AZ
*
*
* -
*
* CACHE_ENGINE
*
*
* -
*
* DATABASE_ENGINE
*
*
* -
*
* DEPLOYMENT_OPTION
*
*
* -
*
* INSTANCE_TYPE
*
*
* -
*
* LINKED_ACCOUNT
*
*
* -
*
* OPERATING_SYSTEM
*
*
* -
*
* PLATFORM
*
*
* -
*
* REGION
*
*
* -
*
* SERVICE
*
*
* -
*
* TAG
*
*
* -
*
* TENANCY
*
*
*
*
* GetReservationCoverage
uses the same Expression object as the other operations, but only AND
is supported among each
* dimension. You can nest only one level deep. If there are multiple values for a dimension, they are OR'd
* together.
*
*
* If you don't provide a SERVICE
filter, Cost Explorer defaults to EC2.
*
*
* Cost category is also supported.
*/
public final Expression filter() {
return filter;
}
/**
* For responses, this returns true if the service returned a value for the Metrics 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 hasMetrics() {
return metrics != null && !(metrics instanceof SdkAutoConstructList);
}
/**
*
* The measurement that you want your reservation coverage reported in.
*
*
* Valid values are Hour
, Unit
, and Cost
. You can use multiple values in a
* request.
*
*
* 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 #hasMetrics} method.
*
*
* @return The measurement that you want your reservation coverage reported in.
*
* Valid values are Hour
, Unit
, and Cost
. You can use multiple values
* in a request.
*/
public final List metrics() {
return metrics;
}
/**
*
* The token to retrieve the next set of results. Amazon Web Services provides the token when the response from a
* previous call has more results than the maximum page size.
*
*
* @return The token to retrieve the next set of results. Amazon Web Services provides the token when the response
* from a previous call has more results than the maximum page size.
*/
public final String nextPageToken() {
return nextPageToken;
}
/**
*
* The value by which you want to sort the data.
*
*
* The following values are supported for Key
:
*
*
* -
*
* OnDemandCost
*
*
* -
*
* CoverageHoursPercentage
*
*
* -
*
* OnDemandHours
*
*
* -
*
* ReservedHours
*
*
* -
*
* TotalRunningHours
*
*
* -
*
* CoverageNormalizedUnitsPercentage
*
*
* -
*
* OnDemandNormalizedUnits
*
*
* -
*
* ReservedNormalizedUnits
*
*
* -
*
* TotalRunningNormalizedUnits
*
*
* -
*
* Time
*
*
*
*
* Supported values for SortOrder
are ASCENDING
or DESCENDING
.
*
*
* @return The value by which you want to sort the data.
*
* The following values are supported for Key
:
*
*
* -
*
* OnDemandCost
*
*
* -
*
* CoverageHoursPercentage
*
*
* -
*
* OnDemandHours
*
*
* -
*
* ReservedHours
*
*
* -
*
* TotalRunningHours
*
*
* -
*
* CoverageNormalizedUnitsPercentage
*
*
* -
*
* OnDemandNormalizedUnits
*
*
* -
*
* ReservedNormalizedUnits
*
*
* -
*
* TotalRunningNormalizedUnits
*
*
* -
*
* Time
*
*
*
*
* Supported values for SortOrder
are ASCENDING
or DESCENDING
.
*/
public final SortDefinition sortBy() {
return sortBy;
}
/**
*
* The maximum number of objects that you returned for this request. If more objects are available, in the response,
* Amazon Web Services provides a NextPageToken value that you can use in a subsequent call to get the next batch of
* objects.
*
*
* @return The maximum number of objects that you returned for this request. If more objects are available, in the
* response, Amazon Web Services provides a NextPageToken value that you can use in a subsequent call to get
* the next batch of objects.
*/
public final Integer maxResults() {
return maxResults;
}
@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(timePeriod());
hashCode = 31 * hashCode + Objects.hashCode(hasGroupBy() ? groupBy() : null);
hashCode = 31 * hashCode + Objects.hashCode(granularityAsString());
hashCode = 31 * hashCode + Objects.hashCode(filter());
hashCode = 31 * hashCode + Objects.hashCode(hasMetrics() ? metrics() : null);
hashCode = 31 * hashCode + Objects.hashCode(nextPageToken());
hashCode = 31 * hashCode + Objects.hashCode(sortBy());
hashCode = 31 * hashCode + Objects.hashCode(maxResults());
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 GetReservationCoverageRequest)) {
return false;
}
GetReservationCoverageRequest other = (GetReservationCoverageRequest) obj;
return Objects.equals(timePeriod(), other.timePeriod()) && hasGroupBy() == other.hasGroupBy()
&& Objects.equals(groupBy(), other.groupBy())
&& Objects.equals(granularityAsString(), other.granularityAsString()) && Objects.equals(filter(), other.filter())
&& hasMetrics() == other.hasMetrics() && Objects.equals(metrics(), other.metrics())
&& Objects.equals(nextPageToken(), other.nextPageToken()) && Objects.equals(sortBy(), other.sortBy())
&& Objects.equals(maxResults(), other.maxResults());
}
/**
* 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("GetReservationCoverageRequest").add("TimePeriod", timePeriod())
.add("GroupBy", hasGroupBy() ? groupBy() : null).add("Granularity", granularityAsString())
.add("Filter", filter()).add("Metrics", hasMetrics() ? metrics() : null).add("NextPageToken", nextPageToken())
.add("SortBy", sortBy()).add("MaxResults", maxResults()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "TimePeriod":
return Optional.ofNullable(clazz.cast(timePeriod()));
case "GroupBy":
return Optional.ofNullable(clazz.cast(groupBy()));
case "Granularity":
return Optional.ofNullable(clazz.cast(granularityAsString()));
case "Filter":
return Optional.ofNullable(clazz.cast(filter()));
case "Metrics":
return Optional.ofNullable(clazz.cast(metrics()));
case "NextPageToken":
return Optional.ofNullable(clazz.cast(nextPageToken()));
case "SortBy":
return Optional.ofNullable(clazz.cast(sortBy()));
case "MaxResults":
return Optional.ofNullable(clazz.cast(maxResults()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function