
software.amazon.awssdk.services.codedeploy.model.CreateDeploymentConfigRequest Maven / Gradle / Ivy
/*
* 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.codedeploy.model;
import java.util.Arrays;
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.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Represents the input of a CreateDeploymentConfig
operation.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class CreateDeploymentConfigRequest extends CodeDeployRequest implements
ToCopyableBuilder {
private static final SdkField DEPLOYMENT_CONFIG_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("deploymentConfigName").getter(getter(CreateDeploymentConfigRequest::deploymentConfigName))
.setter(setter(Builder::deploymentConfigName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("deploymentConfigName").build())
.build();
private static final SdkField MINIMUM_HEALTHY_HOSTS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("minimumHealthyHosts")
.getter(getter(CreateDeploymentConfigRequest::minimumHealthyHosts)).setter(setter(Builder::minimumHealthyHosts))
.constructor(MinimumHealthyHosts::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("minimumHealthyHosts").build())
.build();
private static final SdkField TRAFFIC_ROUTING_CONFIG_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("trafficRoutingConfig")
.getter(getter(CreateDeploymentConfigRequest::trafficRoutingConfig)).setter(setter(Builder::trafficRoutingConfig))
.constructor(TrafficRoutingConfig::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("trafficRoutingConfig").build())
.build();
private static final SdkField COMPUTE_PLATFORM_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("computePlatform").getter(getter(CreateDeploymentConfigRequest::computePlatformAsString))
.setter(setter(Builder::computePlatform))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("computePlatform").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(DEPLOYMENT_CONFIG_NAME_FIELD,
MINIMUM_HEALTHY_HOSTS_FIELD, TRAFFIC_ROUTING_CONFIG_FIELD, COMPUTE_PLATFORM_FIELD));
private final String deploymentConfigName;
private final MinimumHealthyHosts minimumHealthyHosts;
private final TrafficRoutingConfig trafficRoutingConfig;
private final String computePlatform;
private CreateDeploymentConfigRequest(BuilderImpl builder) {
super(builder);
this.deploymentConfigName = builder.deploymentConfigName;
this.minimumHealthyHosts = builder.minimumHealthyHosts;
this.trafficRoutingConfig = builder.trafficRoutingConfig;
this.computePlatform = builder.computePlatform;
}
/**
*
* The name of the deployment configuration to create.
*
*
* @return The name of the deployment configuration to create.
*/
public final String deploymentConfigName() {
return deploymentConfigName;
}
/**
*
* The minimum number of healthy instances that should be available at any time during the deployment. There are two
* parameters expected in the input: type and value.
*
*
* The type parameter takes either of the following values:
*
*
* -
*
* HOST_COUNT: The value parameter represents the minimum number of healthy instances as an absolute value.
*
*
* -
*
* FLEET_PERCENT: The value parameter represents the minimum number of healthy instances as a percentage of the
* total number of instances in the deployment. If you specify FLEET_PERCENT, at the start of the deployment, AWS
* CodeDeploy converts the percentage to the equivalent number of instances and rounds up fractional instances.
*
*
*
*
* The value parameter takes an integer.
*
*
* For example, to set a minimum of 95% healthy instance, specify a type of FLEET_PERCENT and a value of 95.
*
*
* @return The minimum number of healthy instances that should be available at any time during the deployment. There
* are two parameters expected in the input: type and value.
*
* The type parameter takes either of the following values:
*
*
* -
*
* HOST_COUNT: The value parameter represents the minimum number of healthy instances as an absolute value.
*
*
* -
*
* FLEET_PERCENT: The value parameter represents the minimum number of healthy instances as a percentage of
* the total number of instances in the deployment. If you specify FLEET_PERCENT, at the start of the
* deployment, AWS CodeDeploy converts the percentage to the equivalent number of instances and rounds up
* fractional instances.
*
*
*
*
* The value parameter takes an integer.
*
*
* For example, to set a minimum of 95% healthy instance, specify a type of FLEET_PERCENT and a value of 95.
*/
public final MinimumHealthyHosts minimumHealthyHosts() {
return minimumHealthyHosts;
}
/**
*
* The configuration that specifies how the deployment traffic is routed.
*
*
* @return The configuration that specifies how the deployment traffic is routed.
*/
public final TrafficRoutingConfig trafficRoutingConfig() {
return trafficRoutingConfig;
}
/**
*
* The destination platform type for the deployment (Lambda
, Server
, or ECS
).
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #computePlatform}
* will return {@link ComputePlatform#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #computePlatformAsString}.
*
*
* @return The destination platform type for the deployment (Lambda
, Server
, or
* ECS
).
* @see ComputePlatform
*/
public final ComputePlatform computePlatform() {
return ComputePlatform.fromValue(computePlatform);
}
/**
*
* The destination platform type for the deployment (Lambda
, Server
, or ECS
).
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #computePlatform}
* will return {@link ComputePlatform#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #computePlatformAsString}.
*
*
* @return The destination platform type for the deployment (Lambda
, Server
, or
* ECS
).
* @see ComputePlatform
*/
public final String computePlatformAsString() {
return computePlatform;
}
@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(deploymentConfigName());
hashCode = 31 * hashCode + Objects.hashCode(minimumHealthyHosts());
hashCode = 31 * hashCode + Objects.hashCode(trafficRoutingConfig());
hashCode = 31 * hashCode + Objects.hashCode(computePlatformAsString());
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 CreateDeploymentConfigRequest)) {
return false;
}
CreateDeploymentConfigRequest other = (CreateDeploymentConfigRequest) obj;
return Objects.equals(deploymentConfigName(), other.deploymentConfigName())
&& Objects.equals(minimumHealthyHosts(), other.minimumHealthyHosts())
&& Objects.equals(trafficRoutingConfig(), other.trafficRoutingConfig())
&& Objects.equals(computePlatformAsString(), other.computePlatformAsString());
}
/**
* 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("CreateDeploymentConfigRequest").add("DeploymentConfigName", deploymentConfigName())
.add("MinimumHealthyHosts", minimumHealthyHosts()).add("TrafficRoutingConfig", trafficRoutingConfig())
.add("ComputePlatform", computePlatformAsString()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "deploymentConfigName":
return Optional.ofNullable(clazz.cast(deploymentConfigName()));
case "minimumHealthyHosts":
return Optional.ofNullable(clazz.cast(minimumHealthyHosts()));
case "trafficRoutingConfig":
return Optional.ofNullable(clazz.cast(trafficRoutingConfig()));
case "computePlatform":
return Optional.ofNullable(clazz.cast(computePlatformAsString()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function