software.amazon.awssdk.services.costexplorer.model.GetReservationUtilizationRequest 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;
/**
*/
@Generated("software.amazon.awssdk:codegen")
public final class GetReservationUtilizationRequest extends CostExplorerRequest implements
ToCopyableBuilder {
private static final SdkField TIME_PERIOD_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("TimePeriod").getter(getter(GetReservationUtilizationRequest::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(GetReservationUtilizationRequest::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(GetReservationUtilizationRequest::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(GetReservationUtilizationRequest::filter)).setter(setter(Builder::filter))
.constructor(Expression::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Filter").build()).build();
private static final SdkField NEXT_PAGE_TOKEN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("NextPageToken").getter(getter(GetReservationUtilizationRequest::nextPageToken))
.setter(setter(Builder::nextPageToken))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NextPageToken").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(TIME_PERIOD_FIELD,
GROUP_BY_FIELD, GRANULARITY_FIELD, FILTER_FIELD, NEXT_PAGE_TOKEN_FIELD));
private final DateInterval timePeriod;
private final List groupBy;
private final String granularity;
private final Expression filter;
private final String nextPageToken;
private GetReservationUtilizationRequest(BuilderImpl builder) {
super(builder);
this.timePeriod = builder.timePeriod;
this.groupBy = builder.groupBy;
this.granularity = builder.granularity;
this.filter = builder.filter;
this.nextPageToken = builder.nextPageToken;
}
/**
*
* Sets the start and end dates for retrieving RI utilization. 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 Sets the start and end dates for retrieving RI utilization. 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 DateInterval timePeriod() {
return timePeriod;
}
/**
* Returns true if the GroupBy 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 hasGroupBy() {
return groupBy != null && !(groupBy instanceof SdkAutoConstructList);
}
/**
*
* Groups only by SUBSCRIPTION_ID
. Metadata is included.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasGroupBy()} to see if a value was sent in this field.
*
*
* @return Groups only by SUBSCRIPTION_ID
. Metadata is included.
*/
public List groupBy() {
return groupBy;
}
/**
*
* 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
. If
* both GroupBy
and Granularity
aren't set, GetReservationUtilization
* defaults to DAILY
.
*
*
* The GetReservationUtilization
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 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
. If both GroupBy
and Granularity
aren't set,
* GetReservationUtilization
defaults to DAILY
.
*
* The GetReservationUtilization
operation supports only DAILY
and
* MONTHLY
granularities.
* @see Granularity
*/
public Granularity granularity() {
return Granularity.fromValue(granularity);
}
/**
*
* 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
. If
* both GroupBy
and Granularity
aren't set, GetReservationUtilization
* defaults to DAILY
.
*
*
* The GetReservationUtilization
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 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
. If both GroupBy
and Granularity
aren't set,
* GetReservationUtilization
defaults to DAILY
.
*
* The GetReservationUtilization
operation supports only DAILY
and
* MONTHLY
granularities.
* @see Granularity
*/
public String granularityAsString() {
return granularity;
}
/**
*
* Filters utilization data by dimensions. You can filter by the following dimensions:
*
*
* -
*
* AZ
*
*
* -
*
* CACHE_ENGINE
*
*
* -
*
* DEPLOYMENT_OPTION
*
*
* -
*
* INSTANCE_TYPE
*
*
* -
*
* LINKED_ACCOUNT
*
*
* -
*
* OPERATING_SYSTEM
*
*
* -
*
* PLATFORM
*
*
* -
*
* REGION
*
*
* -
*
* SERVICE
*
*
* -
*
* SCOPE
*
*
* -
*
* TENANCY
*
*
*
*
* GetReservationUtilization
uses the same Expression
* object as the other operations, but only AND
is supported among each dimension, and nesting is
* supported up to only one level deep. If there are multiple values for a dimension, they are OR'd together.
*
*
* @return Filters utilization data by dimensions. You can filter by the following dimensions:
*
* -
*
* AZ
*
*
* -
*
* CACHE_ENGINE
*
*
* -
*
* DEPLOYMENT_OPTION
*
*
* -
*
* INSTANCE_TYPE
*
*
* -
*
* LINKED_ACCOUNT
*
*
* -
*
* OPERATING_SYSTEM
*
*
* -
*
* PLATFORM
*
*
* -
*
* REGION
*
*
* -
*
* SERVICE
*
*
* -
*
* SCOPE
*
*
* -
*
* TENANCY
*
*
*
*
* GetReservationUtilization
uses the same Expression object as the other operations, but only AND
is supported among each
* dimension, and nesting is supported up to only one level deep. If there are multiple values for a
* dimension, they are OR'd together.
*/
public Expression filter() {
return filter;
}
/**
*
* The token to retrieve the next set of results. AWS 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. AWS provides the token when the response from a previous
* call has more results than the maximum page size.
*/
public String nextPageToken() {
return nextPageToken;
}
@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(timePeriod());
hashCode = 31 * hashCode + Objects.hashCode(groupBy());
hashCode = 31 * hashCode + Objects.hashCode(granularityAsString());
hashCode = 31 * hashCode + Objects.hashCode(filter());
hashCode = 31 * hashCode + Objects.hashCode(nextPageToken());
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 GetReservationUtilizationRequest)) {
return false;
}
GetReservationUtilizationRequest other = (GetReservationUtilizationRequest) obj;
return Objects.equals(timePeriod(), other.timePeriod()) && Objects.equals(groupBy(), other.groupBy())
&& Objects.equals(granularityAsString(), other.granularityAsString()) && Objects.equals(filter(), other.filter())
&& Objects.equals(nextPageToken(), other.nextPageToken());
}
/**
* 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("GetReservationUtilizationRequest").add("TimePeriod", timePeriod()).add("GroupBy", groupBy())
.add("Granularity", granularityAsString()).add("Filter", filter()).add("NextPageToken", nextPageToken()).build();
}
public 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 "NextPageToken":
return Optional.ofNullable(clazz.cast(nextPageToken()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function