software.amazon.awssdk.services.ec2.model.CreateCapacityReservationFleetResponse Maven / Gradle / Ivy
Show all versions of ec2 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.ec2.model;
import java.time.Instant;
import java.util.Arrays;
import java.util.Collection;
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.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;
/**
*/
@Generated("software.amazon.awssdk:codegen")
public final class CreateCapacityReservationFleetResponse extends Ec2Response implements
ToCopyableBuilder {
private static final SdkField CAPACITY_RESERVATION_FLEET_ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("CapacityReservationFleetId")
.getter(getter(CreateCapacityReservationFleetResponse::capacityReservationFleetId))
.setter(setter(Builder::capacityReservationFleetId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CapacityReservationFleetId")
.unmarshallLocationName("capacityReservationFleetId").build()).build();
private static final SdkField STATE_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("State")
.getter(getter(CreateCapacityReservationFleetResponse::stateAsString))
.setter(setter(Builder::state))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("State")
.unmarshallLocationName("state").build()).build();
private static final SdkField TOTAL_TARGET_CAPACITY_FIELD = SdkField
. builder(MarshallingType.INTEGER)
.memberName("TotalTargetCapacity")
.getter(getter(CreateCapacityReservationFleetResponse::totalTargetCapacity))
.setter(setter(Builder::totalTargetCapacity))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TotalTargetCapacity")
.unmarshallLocationName("totalTargetCapacity").build()).build();
private static final SdkField TOTAL_FULFILLED_CAPACITY_FIELD = SdkField
. builder(MarshallingType.DOUBLE)
.memberName("TotalFulfilledCapacity")
.getter(getter(CreateCapacityReservationFleetResponse::totalFulfilledCapacity))
.setter(setter(Builder::totalFulfilledCapacity))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TotalFulfilledCapacity")
.unmarshallLocationName("totalFulfilledCapacity").build()).build();
private static final SdkField INSTANCE_MATCH_CRITERIA_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("InstanceMatchCriteria")
.getter(getter(CreateCapacityReservationFleetResponse::instanceMatchCriteriaAsString))
.setter(setter(Builder::instanceMatchCriteria))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("InstanceMatchCriteria")
.unmarshallLocationName("instanceMatchCriteria").build()).build();
private static final SdkField ALLOCATION_STRATEGY_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("AllocationStrategy")
.getter(getter(CreateCapacityReservationFleetResponse::allocationStrategy))
.setter(setter(Builder::allocationStrategy))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AllocationStrategy")
.unmarshallLocationName("allocationStrategy").build()).build();
private static final SdkField CREATE_TIME_FIELD = SdkField
. builder(MarshallingType.INSTANT)
.memberName("CreateTime")
.getter(getter(CreateCapacityReservationFleetResponse::createTime))
.setter(setter(Builder::createTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CreateTime")
.unmarshallLocationName("createTime").build()).build();
private static final SdkField END_DATE_FIELD = SdkField
. builder(MarshallingType.INSTANT)
.memberName("EndDate")
.getter(getter(CreateCapacityReservationFleetResponse::endDate))
.setter(setter(Builder::endDate))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EndDate")
.unmarshallLocationName("endDate").build()).build();
private static final SdkField TENANCY_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("Tenancy")
.getter(getter(CreateCapacityReservationFleetResponse::tenancyAsString))
.setter(setter(Builder::tenancy))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Tenancy")
.unmarshallLocationName("tenancy").build()).build();
private static final SdkField> FLEET_CAPACITY_RESERVATIONS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("FleetCapacityReservations")
.getter(getter(CreateCapacityReservationFleetResponse::fleetCapacityReservations))
.setter(setter(Builder::fleetCapacityReservations))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("FleetCapacityReservationSet")
.unmarshallLocationName("fleetCapacityReservationSet").build(),
ListTrait
.builder()
.memberLocationName("item")
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(FleetCapacityReservation::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("Item").unmarshallLocationName("item").build()).build())
.build()).build();
private static final SdkField> TAGS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Tags")
.getter(getter(CreateCapacityReservationFleetResponse::tags))
.setter(setter(Builder::tags))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TagSet")
.unmarshallLocationName("tagSet").build(),
ListTrait
.builder()
.memberLocationName("item")
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(Tag::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("Item").unmarshallLocationName("item").build()).build())
.build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(
CAPACITY_RESERVATION_FLEET_ID_FIELD, STATE_FIELD, TOTAL_TARGET_CAPACITY_FIELD, TOTAL_FULFILLED_CAPACITY_FIELD,
INSTANCE_MATCH_CRITERIA_FIELD, ALLOCATION_STRATEGY_FIELD, CREATE_TIME_FIELD, END_DATE_FIELD, TENANCY_FIELD,
FLEET_CAPACITY_RESERVATIONS_FIELD, TAGS_FIELD));
private static final Map> SDK_NAME_TO_FIELD = Collections
.unmodifiableMap(new HashMap>() {
{
put("CapacityReservationFleetId", CAPACITY_RESERVATION_FLEET_ID_FIELD);
put("State", STATE_FIELD);
put("TotalTargetCapacity", TOTAL_TARGET_CAPACITY_FIELD);
put("TotalFulfilledCapacity", TOTAL_FULFILLED_CAPACITY_FIELD);
put("InstanceMatchCriteria", INSTANCE_MATCH_CRITERIA_FIELD);
put("AllocationStrategy", ALLOCATION_STRATEGY_FIELD);
put("CreateTime", CREATE_TIME_FIELD);
put("EndDate", END_DATE_FIELD);
put("Tenancy", TENANCY_FIELD);
put("FleetCapacityReservationSet", FLEET_CAPACITY_RESERVATIONS_FIELD);
put("TagSet", TAGS_FIELD);
}
});
private final String capacityReservationFleetId;
private final String state;
private final Integer totalTargetCapacity;
private final Double totalFulfilledCapacity;
private final String instanceMatchCriteria;
private final String allocationStrategy;
private final Instant createTime;
private final Instant endDate;
private final String tenancy;
private final List fleetCapacityReservations;
private final List tags;
private CreateCapacityReservationFleetResponse(BuilderImpl builder) {
super(builder);
this.capacityReservationFleetId = builder.capacityReservationFleetId;
this.state = builder.state;
this.totalTargetCapacity = builder.totalTargetCapacity;
this.totalFulfilledCapacity = builder.totalFulfilledCapacity;
this.instanceMatchCriteria = builder.instanceMatchCriteria;
this.allocationStrategy = builder.allocationStrategy;
this.createTime = builder.createTime;
this.endDate = builder.endDate;
this.tenancy = builder.tenancy;
this.fleetCapacityReservations = builder.fleetCapacityReservations;
this.tags = builder.tags;
}
/**
*
* The ID of the Capacity Reservation Fleet.
*
*
* @return The ID of the Capacity Reservation Fleet.
*/
public final String capacityReservationFleetId() {
return capacityReservationFleetId;
}
/**
*
* The status of the Capacity Reservation Fleet.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link CapacityReservationFleetState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #stateAsString}.
*
*
* @return The status of the Capacity Reservation Fleet.
* @see CapacityReservationFleetState
*/
public final CapacityReservationFleetState state() {
return CapacityReservationFleetState.fromValue(state);
}
/**
*
* The status of the Capacity Reservation Fleet.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link CapacityReservationFleetState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #stateAsString}.
*
*
* @return The status of the Capacity Reservation Fleet.
* @see CapacityReservationFleetState
*/
public final String stateAsString() {
return state;
}
/**
*
* The total number of capacity units for which the Capacity Reservation Fleet reserves capacity.
*
*
* @return The total number of capacity units for which the Capacity Reservation Fleet reserves capacity.
*/
public final Integer totalTargetCapacity() {
return totalTargetCapacity;
}
/**
*
* The requested capacity units that have been successfully reserved.
*
*
* @return The requested capacity units that have been successfully reserved.
*/
public final Double totalFulfilledCapacity() {
return totalFulfilledCapacity;
}
/**
*
* The instance matching criteria for the Capacity Reservation Fleet.
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #instanceMatchCriteria} will return {@link FleetInstanceMatchCriteria#UNKNOWN_TO_SDK_VERSION}. The raw
* value returned by the service is available from {@link #instanceMatchCriteriaAsString}.
*
*
* @return The instance matching criteria for the Capacity Reservation Fleet.
* @see FleetInstanceMatchCriteria
*/
public final FleetInstanceMatchCriteria instanceMatchCriteria() {
return FleetInstanceMatchCriteria.fromValue(instanceMatchCriteria);
}
/**
*
* The instance matching criteria for the Capacity Reservation Fleet.
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #instanceMatchCriteria} will return {@link FleetInstanceMatchCriteria#UNKNOWN_TO_SDK_VERSION}. The raw
* value returned by the service is available from {@link #instanceMatchCriteriaAsString}.
*
*
* @return The instance matching criteria for the Capacity Reservation Fleet.
* @see FleetInstanceMatchCriteria
*/
public final String instanceMatchCriteriaAsString() {
return instanceMatchCriteria;
}
/**
*
* The allocation strategy used by the Capacity Reservation Fleet.
*
*
* @return The allocation strategy used by the Capacity Reservation Fleet.
*/
public final String allocationStrategy() {
return allocationStrategy;
}
/**
*
* The date and time at which the Capacity Reservation Fleet was created.
*
*
* @return The date and time at which the Capacity Reservation Fleet was created.
*/
public final Instant createTime() {
return createTime;
}
/**
*
* The date and time at which the Capacity Reservation Fleet expires.
*
*
* @return The date and time at which the Capacity Reservation Fleet expires.
*/
public final Instant endDate() {
return endDate;
}
/**
*
* Indicates the tenancy of Capacity Reservation Fleet.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #tenancy} will
* return {@link FleetCapacityReservationTenancy#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is
* available from {@link #tenancyAsString}.
*
*
* @return Indicates the tenancy of Capacity Reservation Fleet.
* @see FleetCapacityReservationTenancy
*/
public final FleetCapacityReservationTenancy tenancy() {
return FleetCapacityReservationTenancy.fromValue(tenancy);
}
/**
*
* Indicates the tenancy of Capacity Reservation Fleet.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #tenancy} will
* return {@link FleetCapacityReservationTenancy#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is
* available from {@link #tenancyAsString}.
*
*
* @return Indicates the tenancy of Capacity Reservation Fleet.
* @see FleetCapacityReservationTenancy
*/
public final String tenancyAsString() {
return tenancy;
}
/**
* For responses, this returns true if the service returned a value for the FleetCapacityReservations 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 hasFleetCapacityReservations() {
return fleetCapacityReservations != null && !(fleetCapacityReservations instanceof SdkAutoConstructList);
}
/**
*
* Information about the individual Capacity Reservations in the Capacity Reservation Fleet.
*
*
* 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 #hasFleetCapacityReservations} method.
*
*
* @return Information about the individual Capacity Reservations in the Capacity Reservation Fleet.
*/
public final List fleetCapacityReservations() {
return fleetCapacityReservations;
}
/**
* 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);
}
/**
*
* The tags assigned to the Capacity Reservation Fleet.
*
*
* 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 The tags assigned to the Capacity Reservation Fleet.
*/
public final List tags() {
return tags;
}
@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(capacityReservationFleetId());
hashCode = 31 * hashCode + Objects.hashCode(stateAsString());
hashCode = 31 * hashCode + Objects.hashCode(totalTargetCapacity());
hashCode = 31 * hashCode + Objects.hashCode(totalFulfilledCapacity());
hashCode = 31 * hashCode + Objects.hashCode(instanceMatchCriteriaAsString());
hashCode = 31 * hashCode + Objects.hashCode(allocationStrategy());
hashCode = 31 * hashCode + Objects.hashCode(createTime());
hashCode = 31 * hashCode + Objects.hashCode(endDate());
hashCode = 31 * hashCode + Objects.hashCode(tenancyAsString());
hashCode = 31 * hashCode + Objects.hashCode(hasFleetCapacityReservations() ? fleetCapacityReservations() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasTags() ? tags() : null);
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 CreateCapacityReservationFleetResponse)) {
return false;
}
CreateCapacityReservationFleetResponse other = (CreateCapacityReservationFleetResponse) obj;
return Objects.equals(capacityReservationFleetId(), other.capacityReservationFleetId())
&& Objects.equals(stateAsString(), other.stateAsString())
&& Objects.equals(totalTargetCapacity(), other.totalTargetCapacity())
&& Objects.equals(totalFulfilledCapacity(), other.totalFulfilledCapacity())
&& Objects.equals(instanceMatchCriteriaAsString(), other.instanceMatchCriteriaAsString())
&& Objects.equals(allocationStrategy(), other.allocationStrategy())
&& Objects.equals(createTime(), other.createTime()) && Objects.equals(endDate(), other.endDate())
&& Objects.equals(tenancyAsString(), other.tenancyAsString())
&& hasFleetCapacityReservations() == other.hasFleetCapacityReservations()
&& Objects.equals(fleetCapacityReservations(), other.fleetCapacityReservations()) && hasTags() == other.hasTags()
&& Objects.equals(tags(), other.tags());
}
/**
* 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("CreateCapacityReservationFleetResponse")
.add("CapacityReservationFleetId", capacityReservationFleetId()).add("State", stateAsString())
.add("TotalTargetCapacity", totalTargetCapacity()).add("TotalFulfilledCapacity", totalFulfilledCapacity())
.add("InstanceMatchCriteria", instanceMatchCriteriaAsString()).add("AllocationStrategy", allocationStrategy())
.add("CreateTime", createTime()).add("EndDate", endDate()).add("Tenancy", tenancyAsString())
.add("FleetCapacityReservations", hasFleetCapacityReservations() ? fleetCapacityReservations() : null)
.add("Tags", hasTags() ? tags() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "CapacityReservationFleetId":
return Optional.ofNullable(clazz.cast(capacityReservationFleetId()));
case "State":
return Optional.ofNullable(clazz.cast(stateAsString()));
case "TotalTargetCapacity":
return Optional.ofNullable(clazz.cast(totalTargetCapacity()));
case "TotalFulfilledCapacity":
return Optional.ofNullable(clazz.cast(totalFulfilledCapacity()));
case "InstanceMatchCriteria":
return Optional.ofNullable(clazz.cast(instanceMatchCriteriaAsString()));
case "AllocationStrategy":
return Optional.ofNullable(clazz.cast(allocationStrategy()));
case "CreateTime":
return Optional.ofNullable(clazz.cast(createTime()));
case "EndDate":
return Optional.ofNullable(clazz.cast(endDate()));
case "Tenancy":
return Optional.ofNullable(clazz.cast(tenancyAsString()));
case "FleetCapacityReservations":
return Optional.ofNullable(clazz.cast(fleetCapacityReservations()));
case "Tags":
return Optional.ofNullable(clazz.cast(tags()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
@Override
public final Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
private static Function