All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.iot.model.CancelJobExecutionRequest Maven / Gradle / Ivy

Go to download

The AWS Java SDK for AWS Iot Service module holds the client classes that are used for communicating with AWS IoT Service

There is a newer version: 2.30.1
Show newest version
/*
 * 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.iot.model;

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.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.core.traits.MapTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructMap;
import software.amazon.awssdk.core.util.SdkAutoConstructMap;
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 CancelJobExecutionRequest extends IotRequest implements
        ToCopyableBuilder {
    private static final SdkField JOB_ID_FIELD = SdkField. builder(MarshallingType.STRING).memberName("jobId")
            .getter(getter(CancelJobExecutionRequest::jobId)).setter(setter(Builder::jobId))
            .traits(LocationTrait.builder().location(MarshallLocation.PATH).locationName("jobId").build()).build();

    private static final SdkField THING_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("thingName").getter(getter(CancelJobExecutionRequest::thingName)).setter(setter(Builder::thingName))
            .traits(LocationTrait.builder().location(MarshallLocation.PATH).locationName("thingName").build()).build();

    private static final SdkField FORCE_FIELD = SdkField. builder(MarshallingType.BOOLEAN).memberName("force")
            .getter(getter(CancelJobExecutionRequest::force)).setter(setter(Builder::force))
            .traits(LocationTrait.builder().location(MarshallLocation.QUERY_PARAM).locationName("force").build()).build();

    private static final SdkField EXPECTED_VERSION_FIELD = SdkField. builder(MarshallingType.LONG)
            .memberName("expectedVersion").getter(getter(CancelJobExecutionRequest::expectedVersion))
            .setter(setter(Builder::expectedVersion))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("expectedVersion").build()).build();

    private static final SdkField> STATUS_DETAILS_FIELD = SdkField
            .> builder(MarshallingType.MAP)
            .memberName("statusDetails")
            .getter(getter(CancelJobExecutionRequest::statusDetails))
            .setter(setter(Builder::statusDetails))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("statusDetails").build(),
                    MapTrait.builder()
                            .keyLocationName("key")
                            .valueLocationName("value")
                            .valueFieldInfo(
                                    SdkField. builder(MarshallingType.STRING)
                                            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
                                                    .locationName("value").build()).build()).build()).build();

    private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(JOB_ID_FIELD,
            THING_NAME_FIELD, FORCE_FIELD, EXPECTED_VERSION_FIELD, STATUS_DETAILS_FIELD));

    private static final Map> SDK_NAME_TO_FIELD = memberNameToFieldInitializer();

    private final String jobId;

    private final String thingName;

    private final Boolean force;

    private final Long expectedVersion;

    private final Map statusDetails;

    private CancelJobExecutionRequest(BuilderImpl builder) {
        super(builder);
        this.jobId = builder.jobId;
        this.thingName = builder.thingName;
        this.force = builder.force;
        this.expectedVersion = builder.expectedVersion;
        this.statusDetails = builder.statusDetails;
    }

    /**
     * 

* The ID of the job to be canceled. *

* * @return The ID of the job to be canceled. */ public final String jobId() { return jobId; } /** *

* The name of the thing whose execution of the job will be canceled. *

* * @return The name of the thing whose execution of the job will be canceled. */ public final String thingName() { return thingName; } /** *

* (Optional) If true the job execution will be canceled if it has status IN_PROGRESS or QUEUED, * otherwise the job execution will be canceled only if it has status QUEUED. If you attempt to cancel a job * execution that is IN_PROGRESS, and you do not set force to true, then an * InvalidStateTransitionException will be thrown. The default is false. *

*

* Canceling a job execution which is "IN_PROGRESS", will cause the device to be unable to update the job execution * status. Use caution and ensure that the device is able to recover to a valid state. *

* * @return (Optional) If true the job execution will be canceled if it has status IN_PROGRESS or * QUEUED, otherwise the job execution will be canceled only if it has status QUEUED. If you attempt to * cancel a job execution that is IN_PROGRESS, and you do not set force to true, * then an InvalidStateTransitionException will be thrown. The default is false * .

*

* Canceling a job execution which is "IN_PROGRESS", will cause the device to be unable to update the job * execution status. Use caution and ensure that the device is able to recover to a valid state. */ public final Boolean force() { return force; } /** *

* (Optional) The expected current version of the job execution. Each time you update the job execution, its version * is incremented. If the version of the job execution stored in Jobs does not match, the update is rejected with a * VersionMismatch error, and an ErrorResponse that contains the current job execution status data is returned. * (This makes it unnecessary to perform a separate DescribeJobExecution request in order to obtain the job * execution status data.) *

* * @return (Optional) The expected current version of the job execution. Each time you update the job execution, its * version is incremented. If the version of the job execution stored in Jobs does not match, the update is * rejected with a VersionMismatch error, and an ErrorResponse that contains the current job execution * status data is returned. (This makes it unnecessary to perform a separate DescribeJobExecution request in * order to obtain the job execution status data.) */ public final Long expectedVersion() { return expectedVersion; } /** * For responses, this returns true if the service returned a value for the StatusDetails 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 hasStatusDetails() { return statusDetails != null && !(statusDetails instanceof SdkAutoConstructMap); } /** *

* A collection of name/value pairs that describe the status of the job execution. If not specified, the * statusDetails are unchanged. You can specify at most 10 name/value pairs. *

*

* 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 #hasStatusDetails} method. *

* * @return A collection of name/value pairs that describe the status of the job execution. If not specified, the * statusDetails are unchanged. You can specify at most 10 name/value pairs. */ public final Map statusDetails() { return statusDetails; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + super.hashCode(); hashCode = 31 * hashCode + Objects.hashCode(jobId()); hashCode = 31 * hashCode + Objects.hashCode(thingName()); hashCode = 31 * hashCode + Objects.hashCode(force()); hashCode = 31 * hashCode + Objects.hashCode(expectedVersion()); hashCode = 31 * hashCode + Objects.hashCode(hasStatusDetails() ? statusDetails() : 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 CancelJobExecutionRequest)) { return false; } CancelJobExecutionRequest other = (CancelJobExecutionRequest) obj; return Objects.equals(jobId(), other.jobId()) && Objects.equals(thingName(), other.thingName()) && Objects.equals(force(), other.force()) && Objects.equals(expectedVersion(), other.expectedVersion()) && hasStatusDetails() == other.hasStatusDetails() && Objects.equals(statusDetails(), other.statusDetails()); } /** * 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("CancelJobExecutionRequest").add("JobId", jobId()).add("ThingName", thingName()) .add("Force", force()).add("ExpectedVersion", expectedVersion()) .add("StatusDetails", hasStatusDetails() ? statusDetails() : null).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "jobId": return Optional.ofNullable(clazz.cast(jobId())); case "thingName": return Optional.ofNullable(clazz.cast(thingName())); case "force": return Optional.ofNullable(clazz.cast(force())); case "expectedVersion": return Optional.ofNullable(clazz.cast(expectedVersion())); case "statusDetails": return Optional.ofNullable(clazz.cast(statusDetails())); 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("jobId", JOB_ID_FIELD); map.put("thingName", THING_NAME_FIELD); map.put("force", FORCE_FIELD); map.put("expectedVersion", EXPECTED_VERSION_FIELD); map.put("statusDetails", STATUS_DETAILS_FIELD); return Collections.unmodifiableMap(map); } private static Function getter(Function g) { return obj -> g.apply((CancelJobExecutionRequest) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends IotRequest.Builder, SdkPojo, CopyableBuilder { /** *

* The ID of the job to be canceled. *

* * @param jobId * The ID of the job to be canceled. * @return Returns a reference to this object so that method calls can be chained together. */ Builder jobId(String jobId); /** *

* The name of the thing whose execution of the job will be canceled. *

* * @param thingName * The name of the thing whose execution of the job will be canceled. * @return Returns a reference to this object so that method calls can be chained together. */ Builder thingName(String thingName); /** *

* (Optional) If true the job execution will be canceled if it has status IN_PROGRESS or QUEUED, * otherwise the job execution will be canceled only if it has status QUEUED. If you attempt to cancel a job * execution that is IN_PROGRESS, and you do not set force to true, then an * InvalidStateTransitionException will be thrown. The default is false. *

*

* Canceling a job execution which is "IN_PROGRESS", will cause the device to be unable to update the job * execution status. Use caution and ensure that the device is able to recover to a valid state. *

* * @param force * (Optional) If true the job execution will be canceled if it has status IN_PROGRESS or * QUEUED, otherwise the job execution will be canceled only if it has status QUEUED. If you attempt to * cancel a job execution that is IN_PROGRESS, and you do not set force to true * , then an InvalidStateTransitionException will be thrown. The default is * false.

*

* Canceling a job execution which is "IN_PROGRESS", will cause the device to be unable to update the job * execution status. Use caution and ensure that the device is able to recover to a valid state. * @return Returns a reference to this object so that method calls can be chained together. */ Builder force(Boolean force); /** *

* (Optional) The expected current version of the job execution. Each time you update the job execution, its * version is incremented. If the version of the job execution stored in Jobs does not match, the update is * rejected with a VersionMismatch error, and an ErrorResponse that contains the current job execution status * data is returned. (This makes it unnecessary to perform a separate DescribeJobExecution request in order to * obtain the job execution status data.) *

* * @param expectedVersion * (Optional) The expected current version of the job execution. Each time you update the job execution, * its version is incremented. If the version of the job execution stored in Jobs does not match, the * update is rejected with a VersionMismatch error, and an ErrorResponse that contains the current job * execution status data is returned. (This makes it unnecessary to perform a separate * DescribeJobExecution request in order to obtain the job execution status data.) * @return Returns a reference to this object so that method calls can be chained together. */ Builder expectedVersion(Long expectedVersion); /** *

* A collection of name/value pairs that describe the status of the job execution. If not specified, the * statusDetails are unchanged. You can specify at most 10 name/value pairs. *

* * @param statusDetails * A collection of name/value pairs that describe the status of the job execution. If not specified, the * statusDetails are unchanged. You can specify at most 10 name/value pairs. * @return Returns a reference to this object so that method calls can be chained together. */ Builder statusDetails(Map statusDetails); @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @Override Builder overrideConfiguration(Consumer builderConsumer); } static final class BuilderImpl extends IotRequest.BuilderImpl implements Builder { private String jobId; private String thingName; private Boolean force; private Long expectedVersion; private Map statusDetails = DefaultSdkAutoConstructMap.getInstance(); private BuilderImpl() { } private BuilderImpl(CancelJobExecutionRequest model) { super(model); jobId(model.jobId); thingName(model.thingName); force(model.force); expectedVersion(model.expectedVersion); statusDetails(model.statusDetails); } public final String getJobId() { return jobId; } public final void setJobId(String jobId) { this.jobId = jobId; } @Override public final Builder jobId(String jobId) { this.jobId = jobId; return this; } public final String getThingName() { return thingName; } public final void setThingName(String thingName) { this.thingName = thingName; } @Override public final Builder thingName(String thingName) { this.thingName = thingName; return this; } public final Boolean getForce() { return force; } public final void setForce(Boolean force) { this.force = force; } @Override public final Builder force(Boolean force) { this.force = force; return this; } public final Long getExpectedVersion() { return expectedVersion; } public final void setExpectedVersion(Long expectedVersion) { this.expectedVersion = expectedVersion; } @Override public final Builder expectedVersion(Long expectedVersion) { this.expectedVersion = expectedVersion; return this; } public final Map getStatusDetails() { if (statusDetails instanceof SdkAutoConstructMap) { return null; } return statusDetails; } public final void setStatusDetails(Map statusDetails) { this.statusDetails = DetailsMapCopier.copy(statusDetails); } @Override public final Builder statusDetails(Map statusDetails) { this.statusDetails = DetailsMapCopier.copy(statusDetails); return this; } @Override public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) { super.overrideConfiguration(overrideConfiguration); return this; } @Override public Builder overrideConfiguration(Consumer builderConsumer) { super.overrideConfiguration(builderConsumer); return this; } @Override public CancelJobExecutionRequest build() { return new CancelJobExecutionRequest(this); } @Override public List> sdkFields() { return SDK_FIELDS; } @Override public Map> sdkFieldNameToField() { return SDK_NAME_TO_FIELD; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy