software.amazon.awssdk.services.costexplorer.model.GetSavingsPlansUtilizationRequest 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.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.LocationTrait;
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 GetSavingsPlansUtilizationRequest extends CostExplorerRequest implements
ToCopyableBuilder {
private static final SdkField TIME_PERIOD_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("TimePeriod").getter(getter(GetSavingsPlansUtilizationRequest::timePeriod))
.setter(setter(Builder::timePeriod)).constructor(DateInterval::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TimePeriod").build()).build();
private static final SdkField GRANULARITY_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Granularity").getter(getter(GetSavingsPlansUtilizationRequest::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(GetSavingsPlansUtilizationRequest::filter)).setter(setter(Builder::filter))
.constructor(Expression::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Filter").build()).build();
private static final SdkField SORT_BY_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("SortBy").getter(getter(GetSavingsPlansUtilizationRequest::sortBy)).setter(setter(Builder::sortBy))
.constructor(SortDefinition::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SortBy").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(TIME_PERIOD_FIELD,
GRANULARITY_FIELD, FILTER_FIELD, SORT_BY_FIELD));
private final DateInterval timePeriod;
private final String granularity;
private final Expression filter;
private final SortDefinition sortBy;
private GetSavingsPlansUtilizationRequest(BuilderImpl builder) {
super(builder);
this.timePeriod = builder.timePeriod;
this.granularity = builder.granularity;
this.filter = builder.filter;
this.sortBy = builder.sortBy;
}
/**
*
* The time period that you want the usage and costs for. The Start
date must be within 13 months. The
* End
date must be after the Start
date, and before the current date. Future dates can't
* be used as an End
date.
*
*
* @return The time period that you want the usage and costs for. The Start
date must be within 13
* months. The End
date must be after the Start
date, and before the current date.
* Future dates can't be used as an End
date.
*/
public final DateInterval timePeriod() {
return timePeriod;
}
/**
*
* The granularity of the Amazon Web Services utillization data for your Savings Plans.
*
*
* The GetSavingsPlansUtilization
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 utillization data for your Savings Plans.
*
* The GetSavingsPlansUtilization
operation supports only DAILY
and
* MONTHLY
granularities.
* @see Granularity
*/
public final Granularity granularity() {
return Granularity.fromValue(granularity);
}
/**
*
* The granularity of the Amazon Web Services utillization data for your Savings Plans.
*
*
* The GetSavingsPlansUtilization
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 utillization data for your Savings Plans.
*
* The GetSavingsPlansUtilization
operation supports only DAILY
and
* MONTHLY
granularities.
* @see Granularity
*/
public final String granularityAsString() {
return granularity;
}
/**
*
* Filters Savings Plans utilization coverage data for active Savings Plans dimensions. You can filter data with the
* following dimensions:
*
*
* -
*
* LINKED_ACCOUNT
*
*
* -
*
* SAVINGS_PLAN_ARN
*
*
* -
*
* SAVINGS_PLANS_TYPE
*
*
* -
*
* REGION
*
*
* -
*
* PAYMENT_OPTION
*
*
* -
*
* INSTANCE_TYPE_FAMILY
*
*
*
*
* GetSavingsPlansUtilization
uses the same Expression
* object as the other operations, but only AND
is supported among each dimension.
*
*
* @return Filters Savings Plans utilization coverage data for active Savings Plans dimensions. You can filter data
* with the following dimensions:
*
* -
*
* LINKED_ACCOUNT
*
*
* -
*
* SAVINGS_PLAN_ARN
*
*
* -
*
* SAVINGS_PLANS_TYPE
*
*
* -
*
* REGION
*
*
* -
*
* PAYMENT_OPTION
*
*
* -
*
* INSTANCE_TYPE_FAMILY
*
*
*
*
* GetSavingsPlansUtilization
uses the same Expression object as the other operations, but only AND
is supported among each
* dimension.
*/
public final Expression filter() {
return filter;
}
/**
*
* The value that you want to sort the data by.
*
*
* The following values are supported for Key
:
*
*
* -
*
* UtilizationPercentage
*
*
* -
*
* TotalCommitment
*
*
* -
*
* UsedCommitment
*
*
* -
*
* UnusedCommitment
*
*
* -
*
* NetSavings
*
*
*
*
* The supported values for SortOrder
are ASCENDING
and DESCENDING
.
*
*
* @return The value that you want to sort the data by.
*
* The following values are supported for Key
:
*
*
* -
*
* UtilizationPercentage
*
*
* -
*
* TotalCommitment
*
*
* -
*
* UsedCommitment
*
*
* -
*
* UnusedCommitment
*
*
* -
*
* NetSavings
*
*
*
*
* The supported values for SortOrder
are ASCENDING
and DESCENDING
.
*/
public final SortDefinition sortBy() {
return sortBy;
}
@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(granularityAsString());
hashCode = 31 * hashCode + Objects.hashCode(filter());
hashCode = 31 * hashCode + Objects.hashCode(sortBy());
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 GetSavingsPlansUtilizationRequest)) {
return false;
}
GetSavingsPlansUtilizationRequest other = (GetSavingsPlansUtilizationRequest) obj;
return Objects.equals(timePeriod(), other.timePeriod())
&& Objects.equals(granularityAsString(), other.granularityAsString()) && Objects.equals(filter(), other.filter())
&& Objects.equals(sortBy(), other.sortBy());
}
/**
* 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("GetSavingsPlansUtilizationRequest").add("TimePeriod", timePeriod())
.add("Granularity", granularityAsString()).add("Filter", filter()).add("SortBy", sortBy()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "TimePeriod":
return Optional.ofNullable(clazz.cast(timePeriod()));
case "Granularity":
return Optional.ofNullable(clazz.cast(granularityAsString()));
case "Filter":
return Optional.ofNullable(clazz.cast(filter()));
case "SortBy":
return Optional.ofNullable(clazz.cast(sortBy()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function
*
* The GetSavingsPlansUtilization
operation supports only DAILY
and
* MONTHLY
granularities.
* @see Granularity
* @return Returns a reference to this object so that method calls can be chained together.
* @see Granularity
*/
Builder granularity(Granularity granularity);
/**
*
* Filters Savings Plans utilization coverage data for active Savings Plans dimensions. You can filter data with
* the following dimensions:
*
*
* -
*
* LINKED_ACCOUNT
*
*
* -
*
* SAVINGS_PLAN_ARN
*
*
* -
*
* SAVINGS_PLANS_TYPE
*
*
* -
*
* REGION
*
*
* -
*
* PAYMENT_OPTION
*
*
* -
*
* INSTANCE_TYPE_FAMILY
*
*
*
*
* GetSavingsPlansUtilization
uses the same Expression
* object as the other operations, but only AND
is supported among each dimension.
*
*
* @param filter
* Filters Savings Plans utilization coverage data for active Savings Plans dimensions. You can filter
* data with the following dimensions:
*
* -
*
* LINKED_ACCOUNT
*
*
* -
*
* SAVINGS_PLAN_ARN
*
*
* -
*
* SAVINGS_PLANS_TYPE
*
*
* -
*
* REGION
*
*
* -
*
* PAYMENT_OPTION
*
*
* -
*
* INSTANCE_TYPE_FAMILY
*
*
*
*
* GetSavingsPlansUtilization
uses the same Expression object as the other operations, but only AND
is supported among each
* dimension.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder filter(Expression filter);
/**
*
* Filters Savings Plans utilization coverage data for active Savings Plans dimensions. You can filter data with
* the following dimensions:
*
*
* -
*
* LINKED_ACCOUNT
*
*
* -
*
* SAVINGS_PLAN_ARN
*
*
* -
*
* SAVINGS_PLANS_TYPE
*
*
* -
*
* REGION
*
*
* -
*
* PAYMENT_OPTION
*
*
* -
*
* INSTANCE_TYPE_FAMILY
*
*
*
*
* GetSavingsPlansUtilization
uses the same Expression
* object as the other operations, but only AND
is supported among each dimension.
*
* This is a convenience method that creates an instance of the {@link Expression.Builder} avoiding the need to
* create one manually via {@link Expression#builder()}.
*
*
* When the {@link Consumer} completes, {@link Expression.Builder#build()} is called immediately and its result
* is passed to {@link #filter(Expression)}.
*
* @param filter
* a consumer that will call methods on {@link Expression.Builder}
* @return Returns a reference to this object so that method calls can be chained together.
* @see #filter(Expression)
*/
default Builder filter(Consumer filter) {
return filter(Expression.builder().applyMutation(filter).build());
}
/**
*
* The value that you want to sort the data by.
*
*
* The following values are supported for Key
:
*
*
* -
*
* UtilizationPercentage
*
*
* -
*
* TotalCommitment
*
*
* -
*
* UsedCommitment
*
*
* -
*
* UnusedCommitment
*
*
* -
*
* NetSavings
*
*
*
*
* The supported values for SortOrder
are ASCENDING
and DESCENDING
.
*
*
* @param sortBy
* The value that you want to sort the data by.
*
* The following values are supported for Key
:
*
*
* -
*
* UtilizationPercentage
*
*
* -
*
* TotalCommitment
*
*
* -
*
* UsedCommitment
*
*
* -
*
* UnusedCommitment
*
*
* -
*
* NetSavings
*
*
*
*
* The supported values for SortOrder
are ASCENDING
and DESCENDING
.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder sortBy(SortDefinition sortBy);
/**
*
* The value that you want to sort the data by.
*
*
* The following values are supported for Key
:
*
*
* -
*
* UtilizationPercentage
*
*
* -
*
* TotalCommitment
*
*
* -
*
* UsedCommitment
*
*
* -
*
* UnusedCommitment
*
*
* -
*
* NetSavings
*
*
*
*
* The supported values for SortOrder
are ASCENDING
and DESCENDING
.
*
* This is a convenience method that creates an instance of the {@link SortDefinition.Builder} avoiding the need
* to create one manually via {@link SortDefinition#builder()}.
*
*
* When the {@link Consumer} completes, {@link SortDefinition.Builder#build()} is called immediately and its
* result is passed to {@link #sortBy(SortDefinition)}.
*
* @param sortBy
* a consumer that will call methods on {@link SortDefinition.Builder}
* @return Returns a reference to this object so that method calls can be chained together.
* @see #sortBy(SortDefinition)
*/
default Builder sortBy(Consumer sortBy) {
return sortBy(SortDefinition.builder().applyMutation(sortBy).build());
}
@Override
Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration);
@Override
Builder overrideConfiguration(Consumer builderConsumer);
}
static final class BuilderImpl extends CostExplorerRequest.BuilderImpl implements Builder {
private DateInterval timePeriod;
private String granularity;
private Expression filter;
private SortDefinition sortBy;
private BuilderImpl() {
}
private BuilderImpl(GetSavingsPlansUtilizationRequest model) {
super(model);
timePeriod(model.timePeriod);
granularity(model.granularity);
filter(model.filter);
sortBy(model.sortBy);
}
public final DateInterval.Builder getTimePeriod() {
return timePeriod != null ? timePeriod.toBuilder() : null;
}
public final void setTimePeriod(DateInterval.BuilderImpl timePeriod) {
this.timePeriod = timePeriod != null ? timePeriod.build() : null;
}
@Override
public final Builder timePeriod(DateInterval timePeriod) {
this.timePeriod = timePeriod;
return this;
}
public final String getGranularity() {
return granularity;
}
public final void setGranularity(String granularity) {
this.granularity = granularity;
}
@Override
public final Builder granularity(String granularity) {
this.granularity = granularity;
return this;
}
@Override
public final Builder granularity(Granularity granularity) {
this.granularity(granularity == null ? null : granularity.toString());
return this;
}
public final Expression.Builder getFilter() {
return filter != null ? filter.toBuilder() : null;
}
public final void setFilter(Expression.BuilderImpl filter) {
this.filter = filter != null ? filter.build() : null;
}
@Override
public final Builder filter(Expression filter) {
this.filter = filter;
return this;
}
public final SortDefinition.Builder getSortBy() {
return sortBy != null ? sortBy.toBuilder() : null;
}
public final void setSortBy(SortDefinition.BuilderImpl sortBy) {
this.sortBy = sortBy != null ? sortBy.build() : null;
}
@Override
public final Builder sortBy(SortDefinition sortBy) {
this.sortBy = sortBy;
return this;
}
@Override
public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) {
super.overrideConfiguration(overrideConfiguration);
return this;
}
@Override
public Builder overrideConfiguration(Consumer builderConsumer) {
super.overrideConfiguration(builderConsumer);
return this;
}
@Override
public GetSavingsPlansUtilizationRequest build() {
return new GetSavingsPlansUtilizationRequest(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
}
}