software.amazon.awssdk.services.emr.model.Step 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.emr.model;
import java.io.Serializable;
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.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;
/**
*
* This represents a step in a cluster.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Step implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField ID_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Id")
.getter(getter(Step::id)).setter(setter(Builder::id))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Id").build()).build();
private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Name")
.getter(getter(Step::name)).setter(setter(Builder::name))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Name").build()).build();
private static final SdkField CONFIG_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("Config").getter(getter(Step::config)).setter(setter(Builder::config))
.constructor(HadoopStepConfig::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Config").build()).build();
private static final SdkField ACTION_ON_FAILURE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ActionOnFailure").getter(getter(Step::actionOnFailureAsString)).setter(setter(Builder::actionOnFailure))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ActionOnFailure").build()).build();
private static final SdkField STATUS_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("Status").getter(getter(Step::status)).setter(setter(Builder::status)).constructor(StepStatus::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Status").build()).build();
private static final SdkField EXECUTION_ROLE_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ExecutionRoleArn").getter(getter(Step::executionRoleArn)).setter(setter(Builder::executionRoleArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ExecutionRoleArn").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ID_FIELD, NAME_FIELD,
CONFIG_FIELD, ACTION_ON_FAILURE_FIELD, STATUS_FIELD, EXECUTION_ROLE_ARN_FIELD));
private static final long serialVersionUID = 1L;
private final String id;
private final String name;
private final HadoopStepConfig config;
private final String actionOnFailure;
private final StepStatus status;
private final String executionRoleArn;
private Step(BuilderImpl builder) {
this.id = builder.id;
this.name = builder.name;
this.config = builder.config;
this.actionOnFailure = builder.actionOnFailure;
this.status = builder.status;
this.executionRoleArn = builder.executionRoleArn;
}
/**
*
* The identifier of the cluster step.
*
*
* @return The identifier of the cluster step.
*/
public final String id() {
return id;
}
/**
*
* The name of the cluster step.
*
*
* @return The name of the cluster step.
*/
public final String name() {
return name;
}
/**
*
* The Hadoop job configuration of the cluster step.
*
*
* @return The Hadoop job configuration of the cluster step.
*/
public final HadoopStepConfig config() {
return config;
}
/**
*
* The action to take when the cluster step fails. Possible values are TERMINATE_CLUSTER
,
* CANCEL_AND_WAIT
, and CONTINUE
. TERMINATE_JOB_FLOW
is provided for backward
* compatibility. We recommend using TERMINATE_CLUSTER
instead.
*
*
* If a cluster's StepConcurrencyLevel
is greater than 1
, do not use
* AddJobFlowSteps
to submit a step with this parameter set to CANCEL_AND_WAIT
or
* TERMINATE_CLUSTER
. The step is not submitted and the action fails with a message that the
* ActionOnFailure
setting is not valid.
*
*
* If you change a cluster's StepConcurrencyLevel
to be greater than 1 while a step is running, the
* ActionOnFailure
parameter may not behave as you expect. In this case, for a step that fails with
* this parameter set to CANCEL_AND_WAIT
, pending steps and the running step are not canceled; for a
* step that fails with this parameter set to TERMINATE_CLUSTER
, the cluster does not terminate.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #actionOnFailure}
* will return {@link ActionOnFailure#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #actionOnFailureAsString}.
*
*
* @return The action to take when the cluster step fails. Possible values are TERMINATE_CLUSTER
,
* CANCEL_AND_WAIT
, and CONTINUE
. TERMINATE_JOB_FLOW
is provided for
* backward compatibility. We recommend using TERMINATE_CLUSTER
instead.
*
* If a cluster's StepConcurrencyLevel
is greater than 1
, do not use
* AddJobFlowSteps
to submit a step with this parameter set to CANCEL_AND_WAIT
or
* TERMINATE_CLUSTER
. The step is not submitted and the action fails with a message that the
* ActionOnFailure
setting is not valid.
*
*
* If you change a cluster's StepConcurrencyLevel
to be greater than 1 while a step is running,
* the ActionOnFailure
parameter may not behave as you expect. In this case, for a step that
* fails with this parameter set to CANCEL_AND_WAIT
, pending steps and the running step are not
* canceled; for a step that fails with this parameter set to TERMINATE_CLUSTER
, the cluster
* does not terminate.
* @see ActionOnFailure
*/
public final ActionOnFailure actionOnFailure() {
return ActionOnFailure.fromValue(actionOnFailure);
}
/**
*
* The action to take when the cluster step fails. Possible values are TERMINATE_CLUSTER
,
* CANCEL_AND_WAIT
, and CONTINUE
. TERMINATE_JOB_FLOW
is provided for backward
* compatibility. We recommend using TERMINATE_CLUSTER
instead.
*
*
* If a cluster's StepConcurrencyLevel
is greater than 1
, do not use
* AddJobFlowSteps
to submit a step with this parameter set to CANCEL_AND_WAIT
or
* TERMINATE_CLUSTER
. The step is not submitted and the action fails with a message that the
* ActionOnFailure
setting is not valid.
*
*
* If you change a cluster's StepConcurrencyLevel
to be greater than 1 while a step is running, the
* ActionOnFailure
parameter may not behave as you expect. In this case, for a step that fails with
* this parameter set to CANCEL_AND_WAIT
, pending steps and the running step are not canceled; for a
* step that fails with this parameter set to TERMINATE_CLUSTER
, the cluster does not terminate.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #actionOnFailure}
* will return {@link ActionOnFailure#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #actionOnFailureAsString}.
*
*
* @return The action to take when the cluster step fails. Possible values are TERMINATE_CLUSTER
,
* CANCEL_AND_WAIT
, and CONTINUE
. TERMINATE_JOB_FLOW
is provided for
* backward compatibility. We recommend using TERMINATE_CLUSTER
instead.
*
* If a cluster's StepConcurrencyLevel
is greater than 1
, do not use
* AddJobFlowSteps
to submit a step with this parameter set to CANCEL_AND_WAIT
or
* TERMINATE_CLUSTER
. The step is not submitted and the action fails with a message that the
* ActionOnFailure
setting is not valid.
*
*
* If you change a cluster's StepConcurrencyLevel
to be greater than 1 while a step is running,
* the ActionOnFailure
parameter may not behave as you expect. In this case, for a step that
* fails with this parameter set to CANCEL_AND_WAIT
, pending steps and the running step are not
* canceled; for a step that fails with this parameter set to TERMINATE_CLUSTER
, the cluster
* does not terminate.
* @see ActionOnFailure
*/
public final String actionOnFailureAsString() {
return actionOnFailure;
}
/**
*
* The current execution status details of the cluster step.
*
*
* @return The current execution status details of the cluster step.
*/
public final StepStatus status() {
return status;
}
/**
*
* The Amazon Resource Name (ARN) of the runtime role for a step on the cluster. The runtime role can be a
* cross-account IAM role. The runtime role ARN is a combination of account ID, role name, and role type using the
* following format: arn:partition:service:region:account:resource
.
*
*
* For example, arn:aws:IAM::1234567890:role/ReadOnly
is a correctly formatted runtime role ARN.
*
*
* @return The Amazon Resource Name (ARN) of the runtime role for a step on the cluster. The runtime role can be a
* cross-account IAM role. The runtime role ARN is a combination of account ID, role name, and role type
* using the following format: arn:partition:service:region:account:resource
.
*
* For example, arn:aws:IAM::1234567890:role/ReadOnly
is a correctly formatted runtime role
* ARN.
*/
public final String executionRoleArn() {
return executionRoleArn;
}
@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(id());
hashCode = 31 * hashCode + Objects.hashCode(name());
hashCode = 31 * hashCode + Objects.hashCode(config());
hashCode = 31 * hashCode + Objects.hashCode(actionOnFailureAsString());
hashCode = 31 * hashCode + Objects.hashCode(status());
hashCode = 31 * hashCode + Objects.hashCode(executionRoleArn());
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 Step)) {
return false;
}
Step other = (Step) obj;
return Objects.equals(id(), other.id()) && Objects.equals(name(), other.name())
&& Objects.equals(config(), other.config())
&& Objects.equals(actionOnFailureAsString(), other.actionOnFailureAsString())
&& Objects.equals(status(), other.status()) && Objects.equals(executionRoleArn(), other.executionRoleArn());
}
/**
* 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("Step").add("Id", id()).add("Name", name()).add("Config", config())
.add("ActionOnFailure", actionOnFailureAsString()).add("Status", status())
.add("ExecutionRoleArn", executionRoleArn()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Id":
return Optional.ofNullable(clazz.cast(id()));
case "Name":
return Optional.ofNullable(clazz.cast(name()));
case "Config":
return Optional.ofNullable(clazz.cast(config()));
case "ActionOnFailure":
return Optional.ofNullable(clazz.cast(actionOnFailureAsString()));
case "Status":
return Optional.ofNullable(clazz.cast(status()));
case "ExecutionRoleArn":
return Optional.ofNullable(clazz.cast(executionRoleArn()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function
*
* If a cluster's StepConcurrencyLevel
is greater than 1
, do not use
* AddJobFlowSteps
to submit a step with this parameter set to CANCEL_AND_WAIT
* or TERMINATE_CLUSTER
. The step is not submitted and the action fails with a message that
* the ActionOnFailure
setting is not valid.
*
*
* If you change a cluster's StepConcurrencyLevel
to be greater than 1 while a step is
* running, the ActionOnFailure
parameter may not behave as you expect. In this case, for a
* step that fails with this parameter set to CANCEL_AND_WAIT
, pending steps and the running
* step are not canceled; for a step that fails with this parameter set to TERMINATE_CLUSTER
* , the cluster does not terminate.
* @see ActionOnFailure
* @return Returns a reference to this object so that method calls can be chained together.
* @see ActionOnFailure
*/
Builder actionOnFailure(ActionOnFailure actionOnFailure);
/**
*
* The current execution status details of the cluster step.
*
*
* @param status
* The current execution status details of the cluster step.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder status(StepStatus status);
/**
*
* The current execution status details of the cluster step.
*
* This is a convenience method that creates an instance of the {@link StepStatus.Builder} avoiding the need to
* create one manually via {@link StepStatus#builder()}.
*
*
* When the {@link Consumer} completes, {@link StepStatus.Builder#build()} is called immediately and its result
* is passed to {@link #status(StepStatus)}.
*
* @param status
* a consumer that will call methods on {@link StepStatus.Builder}
* @return Returns a reference to this object so that method calls can be chained together.
* @see #status(StepStatus)
*/
default Builder status(Consumer status) {
return status(StepStatus.builder().applyMutation(status).build());
}
/**
*
* The Amazon Resource Name (ARN) of the runtime role for a step on the cluster. The runtime role can be a
* cross-account IAM role. The runtime role ARN is a combination of account ID, role name, and role type using
* the following format: arn:partition:service:region:account:resource
.
*
*
* For example, arn:aws:IAM::1234567890:role/ReadOnly
is a correctly formatted runtime role ARN.
*
*
* @param executionRoleArn
* The Amazon Resource Name (ARN) of the runtime role for a step on the cluster. The runtime role can be
* a cross-account IAM role. The runtime role ARN is a combination of account ID, role name, and role
* type using the following format: arn:partition:service:region:account:resource
.
*
* For example, arn:aws:IAM::1234567890:role/ReadOnly
is a correctly formatted runtime role
* ARN.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder executionRoleArn(String executionRoleArn);
}
static final class BuilderImpl implements Builder {
private String id;
private String name;
private HadoopStepConfig config;
private String actionOnFailure;
private StepStatus status;
private String executionRoleArn;
private BuilderImpl() {
}
private BuilderImpl(Step model) {
id(model.id);
name(model.name);
config(model.config);
actionOnFailure(model.actionOnFailure);
status(model.status);
executionRoleArn(model.executionRoleArn);
}
public final String getId() {
return id;
}
public final void setId(String id) {
this.id = id;
}
@Override
public final Builder id(String id) {
this.id = id;
return this;
}
public final String getName() {
return name;
}
public final void setName(String name) {
this.name = name;
}
@Override
public final Builder name(String name) {
this.name = name;
return this;
}
public final HadoopStepConfig.Builder getConfig() {
return config != null ? config.toBuilder() : null;
}
public final void setConfig(HadoopStepConfig.BuilderImpl config) {
this.config = config != null ? config.build() : null;
}
@Override
public final Builder config(HadoopStepConfig config) {
this.config = config;
return this;
}
public final String getActionOnFailure() {
return actionOnFailure;
}
public final void setActionOnFailure(String actionOnFailure) {
this.actionOnFailure = actionOnFailure;
}
@Override
public final Builder actionOnFailure(String actionOnFailure) {
this.actionOnFailure = actionOnFailure;
return this;
}
@Override
public final Builder actionOnFailure(ActionOnFailure actionOnFailure) {
this.actionOnFailure(actionOnFailure == null ? null : actionOnFailure.toString());
return this;
}
public final StepStatus.Builder getStatus() {
return status != null ? status.toBuilder() : null;
}
public final void setStatus(StepStatus.BuilderImpl status) {
this.status = status != null ? status.build() : null;
}
@Override
public final Builder status(StepStatus status) {
this.status = status;
return this;
}
public final String getExecutionRoleArn() {
return executionRoleArn;
}
public final void setExecutionRoleArn(String executionRoleArn) {
this.executionRoleArn = executionRoleArn;
}
@Override
public final Builder executionRoleArn(String executionRoleArn) {
this.executionRoleArn = executionRoleArn;
return this;
}
@Override
public Step build() {
return new Step(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
}
}