software.amazon.awssdk.services.devopsguru.model.ServiceResourceCost Maven / Gradle / Ivy
Show all versions of devopsguru 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.devopsguru.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Function;
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.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* An object that contains information about the estimated monthly cost to analyze an Amazon Web Services resource. For
* more information, see Estimate
* your Amazon DevOps Guru costs and Amazon DevOps Guru
* pricing.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ServiceResourceCost implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField TYPE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Type")
.getter(getter(ServiceResourceCost::type)).setter(setter(Builder::type))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Type").build()).build();
private static final SdkField STATE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("State")
.getter(getter(ServiceResourceCost::stateAsString)).setter(setter(Builder::state))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("State").build()).build();
private static final SdkField COUNT_FIELD = SdkField. builder(MarshallingType.INTEGER).memberName("Count")
.getter(getter(ServiceResourceCost::count)).setter(setter(Builder::count))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Count").build()).build();
private static final SdkField UNIT_COST_FIELD = SdkField. builder(MarshallingType.DOUBLE)
.memberName("UnitCost").getter(getter(ServiceResourceCost::unitCost)).setter(setter(Builder::unitCost))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("UnitCost").build()).build();
private static final SdkField COST_FIELD = SdkField. builder(MarshallingType.DOUBLE).memberName("Cost")
.getter(getter(ServiceResourceCost::cost)).setter(setter(Builder::cost))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Cost").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(TYPE_FIELD, STATE_FIELD,
COUNT_FIELD, UNIT_COST_FIELD, COST_FIELD));
private static final Map> SDK_NAME_TO_FIELD = memberNameToFieldInitializer();
private static final long serialVersionUID = 1L;
private final String type;
private final String state;
private final Integer count;
private final Double unitCost;
private final Double cost;
private ServiceResourceCost(BuilderImpl builder) {
this.type = builder.type;
this.state = builder.state;
this.count = builder.count;
this.unitCost = builder.unitCost;
this.cost = builder.cost;
}
/**
*
* The type of the Amazon Web Services resource.
*
*
* @return The type of the Amazon Web Services resource.
*/
public final String type() {
return type;
}
/**
*
* The state of the resource. The resource is ACTIVE
if it produces metrics, events, or logs within an
* hour, otherwise it is INACTIVE
. You pay for the number of active Amazon Web Services resource hours
* analyzed for each resource. Inactive resources are not charged.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link CostEstimationServiceResourceState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is
* available from {@link #stateAsString}.
*
*
* @return The state of the resource. The resource is ACTIVE
if it produces metrics, events, or logs
* within an hour, otherwise it is INACTIVE
. You pay for the number of active Amazon Web
* Services resource hours analyzed for each resource. Inactive resources are not charged.
* @see CostEstimationServiceResourceState
*/
public final CostEstimationServiceResourceState state() {
return CostEstimationServiceResourceState.fromValue(state);
}
/**
*
* The state of the resource. The resource is ACTIVE
if it produces metrics, events, or logs within an
* hour, otherwise it is INACTIVE
. You pay for the number of active Amazon Web Services resource hours
* analyzed for each resource. Inactive resources are not charged.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link CostEstimationServiceResourceState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is
* available from {@link #stateAsString}.
*
*
* @return The state of the resource. The resource is ACTIVE
if it produces metrics, events, or logs
* within an hour, otherwise it is INACTIVE
. You pay for the number of active Amazon Web
* Services resource hours analyzed for each resource. Inactive resources are not charged.
* @see CostEstimationServiceResourceState
*/
public final String stateAsString() {
return state;
}
/**
*
* The number of active resources analyzed for this service to create a monthly cost estimate.
*
*
* @return The number of active resources analyzed for this service to create a monthly cost estimate.
*/
public final Integer count() {
return count;
}
/**
*
* The price per hour to analyze the resources in the service. For more information, see Estimate your Amazon DevOps
* Guru costs and Amazon DevOps Guru pricing.
*
*
* @return The price per hour to analyze the resources in the service. For more information, see Estimate your Amazon
* DevOps Guru costs and Amazon DevOps Guru
* pricing.
*/
public final Double unitCost() {
return unitCost;
}
/**
*
* The total estimated monthly cost to analyze the active resources for this resource.
*
*
* @return The total estimated monthly cost to analyze the active resources for this resource.
*/
public final Double cost() {
return cost;
}
@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(type());
hashCode = 31 * hashCode + Objects.hashCode(stateAsString());
hashCode = 31 * hashCode + Objects.hashCode(count());
hashCode = 31 * hashCode + Objects.hashCode(unitCost());
hashCode = 31 * hashCode + Objects.hashCode(cost());
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 ServiceResourceCost)) {
return false;
}
ServiceResourceCost other = (ServiceResourceCost) obj;
return Objects.equals(type(), other.type()) && Objects.equals(stateAsString(), other.stateAsString())
&& Objects.equals(count(), other.count()) && Objects.equals(unitCost(), other.unitCost())
&& Objects.equals(cost(), other.cost());
}
/**
* 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("ServiceResourceCost").add("Type", type()).add("State", stateAsString()).add("Count", count())
.add("UnitCost", unitCost()).add("Cost", cost()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Type":
return Optional.ofNullable(clazz.cast(type()));
case "State":
return Optional.ofNullable(clazz.cast(stateAsString()));
case "Count":
return Optional.ofNullable(clazz.cast(count()));
case "UnitCost":
return Optional.ofNullable(clazz.cast(unitCost()));
case "Cost":
return Optional.ofNullable(clazz.cast(cost()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
@Override
public final Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
private static Map> memberNameToFieldInitializer() {
Map> map = new HashMap<>();
map.put("Type", TYPE_FIELD);
map.put("State", STATE_FIELD);
map.put("Count", COUNT_FIELD);
map.put("UnitCost", UNIT_COST_FIELD);
map.put("Cost", COST_FIELD);
return Collections.unmodifiableMap(map);
}
private static Function