software.amazon.awssdk.services.codedeploy.model.CreateDeploymentRequest Maven / Gradle / Ivy
Show all versions of codedeploy 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.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 CreateDeployment
operation.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class CreateDeploymentRequest extends CodeDeployRequest implements
ToCopyableBuilder {
private static final SdkField APPLICATION_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("applicationName").getter(getter(CreateDeploymentRequest::applicationName))
.setter(setter(Builder::applicationName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("applicationName").build()).build();
private static final SdkField DEPLOYMENT_GROUP_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("deploymentGroupName").getter(getter(CreateDeploymentRequest::deploymentGroupName))
.setter(setter(Builder::deploymentGroupName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("deploymentGroupName").build())
.build();
private static final SdkField REVISION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("revision")
.getter(getter(CreateDeploymentRequest::revision)).setter(setter(Builder::revision))
.constructor(RevisionLocation::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("revision").build()).build();
private static final SdkField DEPLOYMENT_CONFIG_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("deploymentConfigName").getter(getter(CreateDeploymentRequest::deploymentConfigName))
.setter(setter(Builder::deploymentConfigName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("deploymentConfigName").build())
.build();
private static final SdkField DESCRIPTION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("description").getter(getter(CreateDeploymentRequest::description)).setter(setter(Builder::description))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("description").build()).build();
private static final SdkField IGNORE_APPLICATION_STOP_FAILURES_FIELD = SdkField
. builder(MarshallingType.BOOLEAN)
.memberName("ignoreApplicationStopFailures")
.getter(getter(CreateDeploymentRequest::ignoreApplicationStopFailures))
.setter(setter(Builder::ignoreApplicationStopFailures))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ignoreApplicationStopFailures")
.build()).build();
private static final SdkField TARGET_INSTANCES_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("targetInstances")
.getter(getter(CreateDeploymentRequest::targetInstances)).setter(setter(Builder::targetInstances))
.constructor(TargetInstances::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("targetInstances").build()).build();
private static final SdkField AUTO_ROLLBACK_CONFIGURATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("autoRollbackConfiguration")
.getter(getter(CreateDeploymentRequest::autoRollbackConfiguration))
.setter(setter(Builder::autoRollbackConfiguration)).constructor(AutoRollbackConfiguration::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("autoRollbackConfiguration").build())
.build();
private static final SdkField UPDATE_OUTDATED_INSTANCES_ONLY_FIELD = SdkField
. builder(MarshallingType.BOOLEAN)
.memberName("updateOutdatedInstancesOnly")
.getter(getter(CreateDeploymentRequest::updateOutdatedInstancesOnly))
.setter(setter(Builder::updateOutdatedInstancesOnly))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("updateOutdatedInstancesOnly")
.build()).build();
private static final SdkField FILE_EXISTS_BEHAVIOR_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("fileExistsBehavior").getter(getter(CreateDeploymentRequest::fileExistsBehaviorAsString))
.setter(setter(Builder::fileExistsBehavior))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("fileExistsBehavior").build())
.build();
private static final SdkField OVERRIDE_ALARM_CONFIGURATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.memberName("overrideAlarmConfiguration")
.getter(getter(CreateDeploymentRequest::overrideAlarmConfiguration))
.setter(setter(Builder::overrideAlarmConfiguration))
.constructor(AlarmConfiguration::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("overrideAlarmConfiguration").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(APPLICATION_NAME_FIELD,
DEPLOYMENT_GROUP_NAME_FIELD, REVISION_FIELD, DEPLOYMENT_CONFIG_NAME_FIELD, DESCRIPTION_FIELD,
IGNORE_APPLICATION_STOP_FAILURES_FIELD, TARGET_INSTANCES_FIELD, AUTO_ROLLBACK_CONFIGURATION_FIELD,
UPDATE_OUTDATED_INSTANCES_ONLY_FIELD, FILE_EXISTS_BEHAVIOR_FIELD, OVERRIDE_ALARM_CONFIGURATION_FIELD));
private final String applicationName;
private final String deploymentGroupName;
private final RevisionLocation revision;
private final String deploymentConfigName;
private final String description;
private final Boolean ignoreApplicationStopFailures;
private final TargetInstances targetInstances;
private final AutoRollbackConfiguration autoRollbackConfiguration;
private final Boolean updateOutdatedInstancesOnly;
private final String fileExistsBehavior;
private final AlarmConfiguration overrideAlarmConfiguration;
private CreateDeploymentRequest(BuilderImpl builder) {
super(builder);
this.applicationName = builder.applicationName;
this.deploymentGroupName = builder.deploymentGroupName;
this.revision = builder.revision;
this.deploymentConfigName = builder.deploymentConfigName;
this.description = builder.description;
this.ignoreApplicationStopFailures = builder.ignoreApplicationStopFailures;
this.targetInstances = builder.targetInstances;
this.autoRollbackConfiguration = builder.autoRollbackConfiguration;
this.updateOutdatedInstancesOnly = builder.updateOutdatedInstancesOnly;
this.fileExistsBehavior = builder.fileExistsBehavior;
this.overrideAlarmConfiguration = builder.overrideAlarmConfiguration;
}
/**
*
* The name of an CodeDeploy application associated with the user or Amazon Web Services account.
*
*
* @return The name of an CodeDeploy application associated with the user or Amazon Web Services account.
*/
public final String applicationName() {
return applicationName;
}
/**
*
* The name of the deployment group.
*
*
* @return The name of the deployment group.
*/
public final String deploymentGroupName() {
return deploymentGroupName;
}
/**
*
* The type and location of the revision to deploy.
*
*
* @return The type and location of the revision to deploy.
*/
public final RevisionLocation revision() {
return revision;
}
/**
*
* The name of a deployment configuration associated with the user or Amazon Web Services account.
*
*
* If not specified, the value configured in the deployment group is used as the default. If the deployment group
* does not have a deployment configuration associated with it, CodeDeployDefault
.
* OneAtATime
is used by default.
*
*
* @return The name of a deployment configuration associated with the user or Amazon Web Services account.
*
* If not specified, the value configured in the deployment group is used as the default. If the deployment
* group does not have a deployment configuration associated with it, CodeDeployDefault
.
* OneAtATime
is used by default.
*/
public final String deploymentConfigName() {
return deploymentConfigName;
}
/**
*
* A comment about the deployment.
*
*
* @return A comment about the deployment.
*/
public final String description() {
return description;
}
/**
*
* If true, then if an ApplicationStop
, BeforeBlockTraffic
, or
* AfterBlockTraffic
deployment lifecycle event to an instance fails, then the deployment continues to
* the next deployment lifecycle event. For example, if ApplicationStop
fails, the deployment continues
* with DownloadBundle
. If BeforeBlockTraffic
fails, the deployment continues with
* BlockTraffic
. If AfterBlockTraffic
fails, the deployment continues with
* ApplicationStop
.
*
*
* If false or not specified, then if a lifecycle event fails during a deployment to an instance, that deployment
* fails. If deployment to that instance is part of an overall deployment and the number of healthy hosts is not
* less than the minimum number of healthy hosts, then a deployment to the next instance is attempted.
*
*
* During a deployment, the CodeDeploy agent runs the scripts specified for ApplicationStop
,
* BeforeBlockTraffic
, and AfterBlockTraffic
in the AppSpec file from the previous
* successful deployment. (All other scripts are run from the AppSpec file in the current deployment.) If one of
* these scripts contains an error and does not run successfully, the deployment can fail.
*
*
* If the cause of the failure is a script from the last successful deployment that will never run successfully,
* create a new deployment and use ignoreApplicationStopFailures
to specify that the
* ApplicationStop
, BeforeBlockTraffic
, and AfterBlockTraffic
failures should
* be ignored.
*
*
* @return If true, then if an ApplicationStop
, BeforeBlockTraffic
, or
* AfterBlockTraffic
deployment lifecycle event to an instance fails, then the deployment
* continues to the next deployment lifecycle event. For example, if ApplicationStop
fails, the
* deployment continues with DownloadBundle
. If BeforeBlockTraffic
fails, the
* deployment continues with BlockTraffic
. If AfterBlockTraffic
fails, the
* deployment continues with ApplicationStop
.
*
* If false or not specified, then if a lifecycle event fails during a deployment to an instance, that
* deployment fails. If deployment to that instance is part of an overall deployment and the number of
* healthy hosts is not less than the minimum number of healthy hosts, then a deployment to the next
* instance is attempted.
*
*
* During a deployment, the CodeDeploy agent runs the scripts specified for ApplicationStop
,
* BeforeBlockTraffic
, and AfterBlockTraffic
in the AppSpec file from the previous
* successful deployment. (All other scripts are run from the AppSpec file in the current deployment.) If
* one of these scripts contains an error and does not run successfully, the deployment can fail.
*
*
* If the cause of the failure is a script from the last successful deployment that will never run
* successfully, create a new deployment and use ignoreApplicationStopFailures
to specify that
* the ApplicationStop
, BeforeBlockTraffic
, and AfterBlockTraffic
* failures should be ignored.
*/
public final Boolean ignoreApplicationStopFailures() {
return ignoreApplicationStopFailures;
}
/**
*
* Information about the instances that belong to the replacement environment in a blue/green deployment.
*
*
* @return Information about the instances that belong to the replacement environment in a blue/green deployment.
*/
public final TargetInstances targetInstances() {
return targetInstances;
}
/**
*
* Configuration information for an automatic rollback that is added when a deployment is created.
*
*
* @return Configuration information for an automatic rollback that is added when a deployment is created.
*/
public final AutoRollbackConfiguration autoRollbackConfiguration() {
return autoRollbackConfiguration;
}
/**
*
* Indicates whether to deploy to all instances or only to instances that are not running the latest application
* revision.
*
*
* @return Indicates whether to deploy to all instances or only to instances that are not running the latest
* application revision.
*/
public final Boolean updateOutdatedInstancesOnly() {
return updateOutdatedInstancesOnly;
}
/**
*
* Information about how CodeDeploy handles files that already exist in a deployment target location but weren't
* part of the previous successful deployment.
*
*
* The fileExistsBehavior
parameter takes any of the following values:
*
*
* -
*
* DISALLOW: The deployment fails. This is also the default behavior if no option is specified.
*
*
* -
*
* OVERWRITE: The version of the file from the application revision currently being deployed replaces the version
* already on the instance.
*
*
* -
*
* RETAIN: The version of the file already on the instance is kept and used as part of the new deployment.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #fileExistsBehavior} will return {@link FileExistsBehavior#UNKNOWN_TO_SDK_VERSION}. The raw value returned
* by the service is available from {@link #fileExistsBehaviorAsString}.
*
*
* @return Information about how CodeDeploy handles files that already exist in a deployment target location but
* weren't part of the previous successful deployment.
*
* The fileExistsBehavior
parameter takes any of the following values:
*
*
* -
*
* DISALLOW: The deployment fails. This is also the default behavior if no option is specified.
*
*
* -
*
* OVERWRITE: The version of the file from the application revision currently being deployed replaces the
* version already on the instance.
*
*
* -
*
* RETAIN: The version of the file already on the instance is kept and used as part of the new deployment.
*
*
* @see FileExistsBehavior
*/
public final FileExistsBehavior fileExistsBehavior() {
return FileExistsBehavior.fromValue(fileExistsBehavior);
}
/**
*
* Information about how CodeDeploy handles files that already exist in a deployment target location but weren't
* part of the previous successful deployment.
*
*
* The fileExistsBehavior
parameter takes any of the following values:
*
*
* -
*
* DISALLOW: The deployment fails. This is also the default behavior if no option is specified.
*
*
* -
*
* OVERWRITE: The version of the file from the application revision currently being deployed replaces the version
* already on the instance.
*
*
* -
*
* RETAIN: The version of the file already on the instance is kept and used as part of the new deployment.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #fileExistsBehavior} will return {@link FileExistsBehavior#UNKNOWN_TO_SDK_VERSION}. The raw value returned
* by the service is available from {@link #fileExistsBehaviorAsString}.
*
*
* @return Information about how CodeDeploy handles files that already exist in a deployment target location but
* weren't part of the previous successful deployment.
*
* The fileExistsBehavior
parameter takes any of the following values:
*
*
* -
*
* DISALLOW: The deployment fails. This is also the default behavior if no option is specified.
*
*
* -
*
* OVERWRITE: The version of the file from the application revision currently being deployed replaces the
* version already on the instance.
*
*
* -
*
* RETAIN: The version of the file already on the instance is kept and used as part of the new deployment.
*
*
* @see FileExistsBehavior
*/
public final String fileExistsBehaviorAsString() {
return fileExistsBehavior;
}
/**
*
* Allows you to specify information about alarms associated with a deployment. The alarm configuration that you
* specify here will override the alarm configuration at the deployment group level. Consider overriding the alarm
* configuration if you have set up alarms at the deployment group level that are causing deployment failures. In
* this case, you would call CreateDeployment
to create a new deployment that uses a previous
* application revision that is known to work, and set its alarm configuration to turn off alarm polling. Turning
* off alarm polling ensures that the new deployment proceeds without being blocked by the alarm that was generated
* by the previous, failed, deployment.
*
*
*
* If you specify an overrideAlarmConfiguration
, you need the UpdateDeploymentGroup
IAM
* permission when calling CreateDeployment
.
*
*
*
* @return Allows you to specify information about alarms associated with a deployment. The alarm configuration that
* you specify here will override the alarm configuration at the deployment group level. Consider overriding
* the alarm configuration if you have set up alarms at the deployment group level that are causing
* deployment failures. In this case, you would call CreateDeployment
to create a new
* deployment that uses a previous application revision that is known to work, and set its alarm
* configuration to turn off alarm polling. Turning off alarm polling ensures that the new deployment
* proceeds without being blocked by the alarm that was generated by the previous, failed, deployment.
*
*
* If you specify an overrideAlarmConfiguration
, you need the
* UpdateDeploymentGroup
IAM permission when calling CreateDeployment
.
*
*/
public final AlarmConfiguration overrideAlarmConfiguration() {
return overrideAlarmConfiguration;
}
@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(applicationName());
hashCode = 31 * hashCode + Objects.hashCode(deploymentGroupName());
hashCode = 31 * hashCode + Objects.hashCode(revision());
hashCode = 31 * hashCode + Objects.hashCode(deploymentConfigName());
hashCode = 31 * hashCode + Objects.hashCode(description());
hashCode = 31 * hashCode + Objects.hashCode(ignoreApplicationStopFailures());
hashCode = 31 * hashCode + Objects.hashCode(targetInstances());
hashCode = 31 * hashCode + Objects.hashCode(autoRollbackConfiguration());
hashCode = 31 * hashCode + Objects.hashCode(updateOutdatedInstancesOnly());
hashCode = 31 * hashCode + Objects.hashCode(fileExistsBehaviorAsString());
hashCode = 31 * hashCode + Objects.hashCode(overrideAlarmConfiguration());
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 CreateDeploymentRequest)) {
return false;
}
CreateDeploymentRequest other = (CreateDeploymentRequest) obj;
return Objects.equals(applicationName(), other.applicationName())
&& Objects.equals(deploymentGroupName(), other.deploymentGroupName())
&& Objects.equals(revision(), other.revision())
&& Objects.equals(deploymentConfigName(), other.deploymentConfigName())
&& Objects.equals(description(), other.description())
&& Objects.equals(ignoreApplicationStopFailures(), other.ignoreApplicationStopFailures())
&& Objects.equals(targetInstances(), other.targetInstances())
&& Objects.equals(autoRollbackConfiguration(), other.autoRollbackConfiguration())
&& Objects.equals(updateOutdatedInstancesOnly(), other.updateOutdatedInstancesOnly())
&& Objects.equals(fileExistsBehaviorAsString(), other.fileExistsBehaviorAsString())
&& Objects.equals(overrideAlarmConfiguration(), other.overrideAlarmConfiguration());
}
/**
* 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("CreateDeploymentRequest").add("ApplicationName", applicationName())
.add("DeploymentGroupName", deploymentGroupName()).add("Revision", revision())
.add("DeploymentConfigName", deploymentConfigName()).add("Description", description())
.add("IgnoreApplicationStopFailures", ignoreApplicationStopFailures()).add("TargetInstances", targetInstances())
.add("AutoRollbackConfiguration", autoRollbackConfiguration())
.add("UpdateOutdatedInstancesOnly", updateOutdatedInstancesOnly())
.add("FileExistsBehavior", fileExistsBehaviorAsString())
.add("OverrideAlarmConfiguration", overrideAlarmConfiguration()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "applicationName":
return Optional.ofNullable(clazz.cast(applicationName()));
case "deploymentGroupName":
return Optional.ofNullable(clazz.cast(deploymentGroupName()));
case "revision":
return Optional.ofNullable(clazz.cast(revision()));
case "deploymentConfigName":
return Optional.ofNullable(clazz.cast(deploymentConfigName()));
case "description":
return Optional.ofNullable(clazz.cast(description()));
case "ignoreApplicationStopFailures":
return Optional.ofNullable(clazz.cast(ignoreApplicationStopFailures()));
case "targetInstances":
return Optional.ofNullable(clazz.cast(targetInstances()));
case "autoRollbackConfiguration":
return Optional.ofNullable(clazz.cast(autoRollbackConfiguration()));
case "updateOutdatedInstancesOnly":
return Optional.ofNullable(clazz.cast(updateOutdatedInstancesOnly()));
case "fileExistsBehavior":
return Optional.ofNullable(clazz.cast(fileExistsBehaviorAsString()));
case "overrideAlarmConfiguration":
return Optional.ofNullable(clazz.cast(overrideAlarmConfiguration()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function