software.amazon.awssdk.services.costexplorer.model.CurrentInstance 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.io.Serializable;
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.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;
/**
*
* Context about the current instance.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class CurrentInstance implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField RESOURCE_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ResourceId").getter(getter(CurrentInstance::resourceId)).setter(setter(Builder::resourceId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ResourceId").build()).build();
private static final SdkField INSTANCE_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("InstanceName").getter(getter(CurrentInstance::instanceName)).setter(setter(Builder::instanceName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("InstanceName").build()).build();
private static final SdkField> TAGS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Tags")
.getter(getter(CurrentInstance::tags))
.setter(setter(Builder::tags))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Tags").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(TagValues::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField RESOURCE_DETAILS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("ResourceDetails")
.getter(getter(CurrentInstance::resourceDetails)).setter(setter(Builder::resourceDetails))
.constructor(ResourceDetails::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ResourceDetails").build()).build();
private static final SdkField RESOURCE_UTILIZATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("ResourceUtilization")
.getter(getter(CurrentInstance::resourceUtilization)).setter(setter(Builder::resourceUtilization))
.constructor(ResourceUtilization::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ResourceUtilization").build())
.build();
private static final SdkField RESERVATION_COVERED_HOURS_IN_LOOKBACK_PERIOD_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("ReservationCoveredHoursInLookbackPeriod")
.getter(getter(CurrentInstance::reservationCoveredHoursInLookbackPeriod))
.setter(setter(Builder::reservationCoveredHoursInLookbackPeriod))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("ReservationCoveredHoursInLookbackPeriod").build()).build();
private static final SdkField SAVINGS_PLANS_COVERED_HOURS_IN_LOOKBACK_PERIOD_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("SavingsPlansCoveredHoursInLookbackPeriod")
.getter(getter(CurrentInstance::savingsPlansCoveredHoursInLookbackPeriod))
.setter(setter(Builder::savingsPlansCoveredHoursInLookbackPeriod))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("SavingsPlansCoveredHoursInLookbackPeriod").build()).build();
private static final SdkField ON_DEMAND_HOURS_IN_LOOKBACK_PERIOD_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("OnDemandHoursInLookbackPeriod")
.getter(getter(CurrentInstance::onDemandHoursInLookbackPeriod))
.setter(setter(Builder::onDemandHoursInLookbackPeriod))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("OnDemandHoursInLookbackPeriod")
.build()).build();
private static final SdkField TOTAL_RUNNING_HOURS_IN_LOOKBACK_PERIOD_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("TotalRunningHoursInLookbackPeriod")
.getter(getter(CurrentInstance::totalRunningHoursInLookbackPeriod))
.setter(setter(Builder::totalRunningHoursInLookbackPeriod))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TotalRunningHoursInLookbackPeriod")
.build()).build();
private static final SdkField MONTHLY_COST_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("MonthlyCost").getter(getter(CurrentInstance::monthlyCost)).setter(setter(Builder::monthlyCost))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MonthlyCost").build()).build();
private static final SdkField CURRENCY_CODE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("CurrencyCode").getter(getter(CurrentInstance::currencyCode)).setter(setter(Builder::currencyCode))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CurrencyCode").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(RESOURCE_ID_FIELD,
INSTANCE_NAME_FIELD, TAGS_FIELD, RESOURCE_DETAILS_FIELD, RESOURCE_UTILIZATION_FIELD,
RESERVATION_COVERED_HOURS_IN_LOOKBACK_PERIOD_FIELD, SAVINGS_PLANS_COVERED_HOURS_IN_LOOKBACK_PERIOD_FIELD,
ON_DEMAND_HOURS_IN_LOOKBACK_PERIOD_FIELD, TOTAL_RUNNING_HOURS_IN_LOOKBACK_PERIOD_FIELD, MONTHLY_COST_FIELD,
CURRENCY_CODE_FIELD));
private static final long serialVersionUID = 1L;
private final String resourceId;
private final String instanceName;
private final List tags;
private final ResourceDetails resourceDetails;
private final ResourceUtilization resourceUtilization;
private final String reservationCoveredHoursInLookbackPeriod;
private final String savingsPlansCoveredHoursInLookbackPeriod;
private final String onDemandHoursInLookbackPeriod;
private final String totalRunningHoursInLookbackPeriod;
private final String monthlyCost;
private final String currencyCode;
private CurrentInstance(BuilderImpl builder) {
this.resourceId = builder.resourceId;
this.instanceName = builder.instanceName;
this.tags = builder.tags;
this.resourceDetails = builder.resourceDetails;
this.resourceUtilization = builder.resourceUtilization;
this.reservationCoveredHoursInLookbackPeriod = builder.reservationCoveredHoursInLookbackPeriod;
this.savingsPlansCoveredHoursInLookbackPeriod = builder.savingsPlansCoveredHoursInLookbackPeriod;
this.onDemandHoursInLookbackPeriod = builder.onDemandHoursInLookbackPeriod;
this.totalRunningHoursInLookbackPeriod = builder.totalRunningHoursInLookbackPeriod;
this.monthlyCost = builder.monthlyCost;
this.currencyCode = builder.currencyCode;
}
/**
*
* Resource ID of the current instance.
*
*
* @return Resource ID of the current instance.
*/
public final String resourceId() {
return resourceId;
}
/**
*
* The name that you given an instance. This field shows as blank if you haven't given the instance a name.
*
*
* @return The name that you given an instance. This field shows as blank if you haven't given the instance a name.
*/
public final String instanceName() {
return instanceName;
}
/**
* For responses, this returns true if the service returned a value for the Tags 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 hasTags() {
return tags != null && !(tags instanceof SdkAutoConstructList);
}
/**
*
* Cost allocation resource tags that are applied to the instance.
*
*
* 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 #hasTags} method.
*
*
* @return Cost allocation resource tags that are applied to the instance.
*/
public final List tags() {
return tags;
}
/**
*
* Details about the resource and utilization.
*
*
* @return Details about the resource and utilization.
*/
public final ResourceDetails resourceDetails() {
return resourceDetails;
}
/**
*
* Utilization information of the current instance during the lookback period.
*
*
* @return Utilization information of the current instance during the lookback period.
*/
public final ResourceUtilization resourceUtilization() {
return resourceUtilization;
}
/**
*
* The number of hours during the lookback period that's covered by reservations.
*
*
* @return The number of hours during the lookback period that's covered by reservations.
*/
public final String reservationCoveredHoursInLookbackPeriod() {
return reservationCoveredHoursInLookbackPeriod;
}
/**
*
* The number of hours during the lookback period that's covered by Savings Plans.
*
*
* @return The number of hours during the lookback period that's covered by Savings Plans.
*/
public final String savingsPlansCoveredHoursInLookbackPeriod() {
return savingsPlansCoveredHoursInLookbackPeriod;
}
/**
*
* The number of hours during the lookback period that's billed at On-Demand rates.
*
*
* @return The number of hours during the lookback period that's billed at On-Demand rates.
*/
public final String onDemandHoursInLookbackPeriod() {
return onDemandHoursInLookbackPeriod;
}
/**
*
* The total number of hours that the instance ran during the lookback period.
*
*
* @return The total number of hours that the instance ran during the lookback period.
*/
public final String totalRunningHoursInLookbackPeriod() {
return totalRunningHoursInLookbackPeriod;
}
/**
*
* The current On-Demand cost of operating this instance on a monthly basis.
*
*
* @return The current On-Demand cost of operating this instance on a monthly basis.
*/
public final String monthlyCost() {
return monthlyCost;
}
/**
*
* The currency code that Amazon Web Services used to calculate the costs for this instance.
*
*
* @return The currency code that Amazon Web Services used to calculate the costs for this instance.
*/
public final String currencyCode() {
return currencyCode;
}
@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 + Objects.hashCode(resourceId());
hashCode = 31 * hashCode + Objects.hashCode(instanceName());
hashCode = 31 * hashCode + Objects.hashCode(hasTags() ? tags() : null);
hashCode = 31 * hashCode + Objects.hashCode(resourceDetails());
hashCode = 31 * hashCode + Objects.hashCode(resourceUtilization());
hashCode = 31 * hashCode + Objects.hashCode(reservationCoveredHoursInLookbackPeriod());
hashCode = 31 * hashCode + Objects.hashCode(savingsPlansCoveredHoursInLookbackPeriod());
hashCode = 31 * hashCode + Objects.hashCode(onDemandHoursInLookbackPeriod());
hashCode = 31 * hashCode + Objects.hashCode(totalRunningHoursInLookbackPeriod());
hashCode = 31 * hashCode + Objects.hashCode(monthlyCost());
hashCode = 31 * hashCode + Objects.hashCode(currencyCode());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof CurrentInstance)) {
return false;
}
CurrentInstance other = (CurrentInstance) obj;
return Objects.equals(resourceId(), other.resourceId()) && Objects.equals(instanceName(), other.instanceName())
&& hasTags() == other.hasTags() && Objects.equals(tags(), other.tags())
&& Objects.equals(resourceDetails(), other.resourceDetails())
&& Objects.equals(resourceUtilization(), other.resourceUtilization())
&& Objects.equals(reservationCoveredHoursInLookbackPeriod(), other.reservationCoveredHoursInLookbackPeriod())
&& Objects.equals(savingsPlansCoveredHoursInLookbackPeriod(), other.savingsPlansCoveredHoursInLookbackPeriod())
&& Objects.equals(onDemandHoursInLookbackPeriod(), other.onDemandHoursInLookbackPeriod())
&& Objects.equals(totalRunningHoursInLookbackPeriod(), other.totalRunningHoursInLookbackPeriod())
&& Objects.equals(monthlyCost(), other.monthlyCost()) && Objects.equals(currencyCode(), other.currencyCode());
}
/**
* 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("CurrentInstance").add("ResourceId", resourceId()).add("InstanceName", instanceName())
.add("Tags", hasTags() ? tags() : null).add("ResourceDetails", resourceDetails())
.add("ResourceUtilization", resourceUtilization())
.add("ReservationCoveredHoursInLookbackPeriod", reservationCoveredHoursInLookbackPeriod())
.add("SavingsPlansCoveredHoursInLookbackPeriod", savingsPlansCoveredHoursInLookbackPeriod())
.add("OnDemandHoursInLookbackPeriod", onDemandHoursInLookbackPeriod())
.add("TotalRunningHoursInLookbackPeriod", totalRunningHoursInLookbackPeriod()).add("MonthlyCost", monthlyCost())
.add("CurrencyCode", currencyCode()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "ResourceId":
return Optional.ofNullable(clazz.cast(resourceId()));
case "InstanceName":
return Optional.ofNullable(clazz.cast(instanceName()));
case "Tags":
return Optional.ofNullable(clazz.cast(tags()));
case "ResourceDetails":
return Optional.ofNullable(clazz.cast(resourceDetails()));
case "ResourceUtilization":
return Optional.ofNullable(clazz.cast(resourceUtilization()));
case "ReservationCoveredHoursInLookbackPeriod":
return Optional.ofNullable(clazz.cast(reservationCoveredHoursInLookbackPeriod()));
case "SavingsPlansCoveredHoursInLookbackPeriod":
return Optional.ofNullable(clazz.cast(savingsPlansCoveredHoursInLookbackPeriod()));
case "OnDemandHoursInLookbackPeriod":
return Optional.ofNullable(clazz.cast(onDemandHoursInLookbackPeriod()));
case "TotalRunningHoursInLookbackPeriod":
return Optional.ofNullable(clazz.cast(totalRunningHoursInLookbackPeriod()));
case "MonthlyCost":
return Optional.ofNullable(clazz.cast(monthlyCost()));
case "CurrencyCode":
return Optional.ofNullable(clazz.cast(currencyCode()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function