software.amazon.awssdk.services.costexplorer.model.GetSavingsPlansUtilizationDetailsRequest 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 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 GetSavingsPlansUtilizationDetailsRequest extends CostExplorerRequest implements
ToCopyableBuilder {
private static final SdkField TIME_PERIOD_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("TimePeriod").getter(getter(GetSavingsPlansUtilizationDetailsRequest::timePeriod))
.setter(setter(Builder::timePeriod)).constructor(DateInterval::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TimePeriod").build()).build();
private static final SdkField FILTER_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("Filter").getter(getter(GetSavingsPlansUtilizationDetailsRequest::filter))
.setter(setter(Builder::filter)).constructor(Expression::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Filter").build()).build();
private static final SdkField> DATA_TYPE_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("DataType")
.getter(getter(GetSavingsPlansUtilizationDetailsRequest::dataTypeAsStrings))
.setter(setter(Builder::dataTypeWithStrings))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DataType").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_TOKEN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("NextToken").getter(getter(GetSavingsPlansUtilizationDetailsRequest::nextToken))
.setter(setter(Builder::nextToken))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NextToken").build()).build();
private static final SdkField MAX_RESULTS_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("MaxResults").getter(getter(GetSavingsPlansUtilizationDetailsRequest::maxResults))
.setter(setter(Builder::maxResults))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MaxResults").build()).build();
private static final SdkField SORT_BY_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("SortBy").getter(getter(GetSavingsPlansUtilizationDetailsRequest::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,
FILTER_FIELD, DATA_TYPE_FIELD, NEXT_TOKEN_FIELD, MAX_RESULTS_FIELD, SORT_BY_FIELD));
private final DateInterval timePeriod;
private final Expression filter;
private final List dataType;
private final String nextToken;
private final Integer maxResults;
private final SortDefinition sortBy;
private GetSavingsPlansUtilizationDetailsRequest(BuilderImpl builder) {
super(builder);
this.timePeriod = builder.timePeriod;
this.filter = builder.filter;
this.dataType = builder.dataType;
this.nextToken = builder.nextToken;
this.maxResults = builder.maxResults;
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;
}
/**
*
* Filters Savings Plans utilization coverage data for active Savings Plans dimensions. You can filter data with the
* following dimensions:
*
*
* -
*
* LINKED_ACCOUNT
*
*
* -
*
* SAVINGS_PLAN_ARN
*
*
* -
*
* REGION
*
*
* -
*
* PAYMENT_OPTION
*
*
* -
*
* INSTANCE_TYPE_FAMILY
*
*
*
*
* GetSavingsPlansUtilizationDetails
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
*
*
* -
*
* REGION
*
*
* -
*
* PAYMENT_OPTION
*
*
* -
*
* INSTANCE_TYPE_FAMILY
*
*
*
*
* GetSavingsPlansUtilizationDetails
uses the same Expression object as the other operations, but only AND
is supported among each
* dimension.
*/
public final Expression filter() {
return filter;
}
/**
*
* The data type.
*
*
* 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 #hasDataType} method.
*
*
* @return The data type.
*/
public final List dataType() {
return SavingsPlansDataTypesCopier.copyStringToEnum(dataType);
}
/**
* For responses, this returns true if the service returned a value for the DataType 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 hasDataType() {
return dataType != null && !(dataType instanceof SdkAutoConstructList);
}
/**
*
* The data type.
*
*
* 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 #hasDataType} method.
*
*
* @return The data type.
*/
public final List dataTypeAsStrings() {
return dataType;
}
/**
*
* 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 nextToken() {
return nextToken;
}
/**
*
* The number of items to be returned in a response. The default is 20
, with a minimum value of
* 1
.
*
*
* @return The number of items to be returned in a response. The default is 20
, with a minimum value of
* 1
.
*/
public final Integer maxResults() {
return maxResults;
}
/**
*
* The value that you want to sort the data by.
*
*
* The following values are supported for Key
:
*
*
* -
*
* UtilizationPercentage
*
*
* -
*
* TotalCommitment
*
*
* -
*
* UsedCommitment
*
*
* -
*
* UnusedCommitment
*
*
* -
*
* NetSavings
*
*
* -
*
* AmortizedRecurringCommitment
*
*
* -
*
* AmortizedUpfrontCommitment
*
*
*
*
* 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
*
*
* -
*
* AmortizedRecurringCommitment
*
*
* -
*
* AmortizedUpfrontCommitment
*
*
*
*
* 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(filter());
hashCode = 31 * hashCode + Objects.hashCode(hasDataType() ? dataTypeAsStrings() : null);
hashCode = 31 * hashCode + Objects.hashCode(nextToken());
hashCode = 31 * hashCode + Objects.hashCode(maxResults());
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 GetSavingsPlansUtilizationDetailsRequest)) {
return false;
}
GetSavingsPlansUtilizationDetailsRequest other = (GetSavingsPlansUtilizationDetailsRequest) obj;
return Objects.equals(timePeriod(), other.timePeriod()) && Objects.equals(filter(), other.filter())
&& hasDataType() == other.hasDataType() && Objects.equals(dataTypeAsStrings(), other.dataTypeAsStrings())
&& Objects.equals(nextToken(), other.nextToken()) && Objects.equals(maxResults(), other.maxResults())
&& 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("GetSavingsPlansUtilizationDetailsRequest").add("TimePeriod", timePeriod())
.add("Filter", filter()).add("DataType", hasDataType() ? dataTypeAsStrings() : null)
.add("NextToken", nextToken()).add("MaxResults", maxResults()).add("SortBy", sortBy()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "TimePeriod":
return Optional.ofNullable(clazz.cast(timePeriod()));
case "Filter":
return Optional.ofNullable(clazz.cast(filter()));
case "DataType":
return Optional.ofNullable(clazz.cast(dataTypeAsStrings()));
case "NextToken":
return Optional.ofNullable(clazz.cast(nextToken()));
case "MaxResults":
return Optional.ofNullable(clazz.cast(maxResults()));
case "SortBy":
return Optional.ofNullable(clazz.cast(sortBy()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function