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

software.amazon.awssdk.services.iot.model.UpdateThingRequest 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.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 * 

* The input for the UpdateThing operation. *

*/ @Generated("software.amazon.awssdk:codegen") public final class UpdateThingRequest extends IotRequest implements ToCopyableBuilder { private static final SdkField THING_NAME_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("thingName").getter(getter(UpdateThingRequest::thingName)).setter(setter(Builder::thingName)) .traits(LocationTrait.builder().location(MarshallLocation.PATH).locationName("thingName").build()).build(); private static final SdkField THING_TYPE_NAME_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("thingTypeName").getter(getter(UpdateThingRequest::thingTypeName)).setter(setter(Builder::thingTypeName)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("thingTypeName").build()).build(); private static final SdkField ATTRIBUTE_PAYLOAD_FIELD = SdkField . builder(MarshallingType.SDK_POJO).memberName("attributePayload") .getter(getter(UpdateThingRequest::attributePayload)).setter(setter(Builder::attributePayload)) .constructor(AttributePayload::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("attributePayload").build()).build(); private static final SdkField EXPECTED_VERSION_FIELD = SdkField. builder(MarshallingType.LONG) .memberName("expectedVersion").getter(getter(UpdateThingRequest::expectedVersion)) .setter(setter(Builder::expectedVersion)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("expectedVersion").build()).build(); private static final SdkField REMOVE_THING_TYPE_FIELD = SdkField. builder(MarshallingType.BOOLEAN) .memberName("removeThingType").getter(getter(UpdateThingRequest::removeThingType)) .setter(setter(Builder::removeThingType)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("removeThingType").build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(THING_NAME_FIELD, THING_TYPE_NAME_FIELD, ATTRIBUTE_PAYLOAD_FIELD, EXPECTED_VERSION_FIELD, REMOVE_THING_TYPE_FIELD)); private static final Map> SDK_NAME_TO_FIELD = memberNameToFieldInitializer(); private final String thingName; private final String thingTypeName; private final AttributePayload attributePayload; private final Long expectedVersion; private final Boolean removeThingType; private UpdateThingRequest(BuilderImpl builder) { super(builder); this.thingName = builder.thingName; this.thingTypeName = builder.thingTypeName; this.attributePayload = builder.attributePayload; this.expectedVersion = builder.expectedVersion; this.removeThingType = builder.removeThingType; } /** *

* The name of the thing to update. *

*

* You can't change a thing's name. To change a thing's name, you must create a new thing, give it the new name, and * then delete the old thing. *

* * @return The name of the thing to update.

*

* You can't change a thing's name. To change a thing's name, you must create a new thing, give it the new * name, and then delete the old thing. */ public final String thingName() { return thingName; } /** *

* The name of the thing type. *

* * @return The name of the thing type. */ public final String thingTypeName() { return thingTypeName; } /** *

* A list of thing attributes, a JSON string containing name-value pairs. For example: *

*

* {\"attributes\":{\"name1\":\"value2\"}} *

*

* This data is used to add new attributes or update existing attributes. *

* * @return A list of thing attributes, a JSON string containing name-value pairs. For example:

*

* {\"attributes\":{\"name1\":\"value2\"}} *

*

* This data is used to add new attributes or update existing attributes. */ public final AttributePayload attributePayload() { return attributePayload; } /** *

* The expected version of the thing record in the registry. If the version of the record in the registry does not * match the expected version specified in the request, the UpdateThing request is rejected with a * VersionConflictException. *

* * @return The expected version of the thing record in the registry. If the version of the record in the registry * does not match the expected version specified in the request, the UpdateThing request is * rejected with a VersionConflictException. */ public final Long expectedVersion() { return expectedVersion; } /** *

* Remove a thing type association. If true, the association is removed. *

* * @return Remove a thing type association. If true, the association is removed. */ public final Boolean removeThingType() { return removeThingType; } @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(thingName()); hashCode = 31 * hashCode + Objects.hashCode(thingTypeName()); hashCode = 31 * hashCode + Objects.hashCode(attributePayload()); hashCode = 31 * hashCode + Objects.hashCode(expectedVersion()); hashCode = 31 * hashCode + Objects.hashCode(removeThingType()); 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 UpdateThingRequest)) { return false; } UpdateThingRequest other = (UpdateThingRequest) obj; return Objects.equals(thingName(), other.thingName()) && Objects.equals(thingTypeName(), other.thingTypeName()) && Objects.equals(attributePayload(), other.attributePayload()) && Objects.equals(expectedVersion(), other.expectedVersion()) && Objects.equals(removeThingType(), other.removeThingType()); } /** * 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("UpdateThingRequest").add("ThingName", thingName()).add("ThingTypeName", thingTypeName()) .add("AttributePayload", attributePayload()).add("ExpectedVersion", expectedVersion()) .add("RemoveThingType", removeThingType()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "thingName": return Optional.ofNullable(clazz.cast(thingName())); case "thingTypeName": return Optional.ofNullable(clazz.cast(thingTypeName())); case "attributePayload": return Optional.ofNullable(clazz.cast(attributePayload())); case "expectedVersion": return Optional.ofNullable(clazz.cast(expectedVersion())); case "removeThingType": return Optional.ofNullable(clazz.cast(removeThingType())); 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("thingName", THING_NAME_FIELD); map.put("thingTypeName", THING_TYPE_NAME_FIELD); map.put("attributePayload", ATTRIBUTE_PAYLOAD_FIELD); map.put("expectedVersion", EXPECTED_VERSION_FIELD); map.put("removeThingType", REMOVE_THING_TYPE_FIELD); return Collections.unmodifiableMap(map); } private static Function getter(Function g) { return obj -> g.apply((UpdateThingRequest) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends IotRequest.Builder, SdkPojo, CopyableBuilder { /** *

* The name of the thing to update. *

*

* You can't change a thing's name. To change a thing's name, you must create a new thing, give it the new name, * and then delete the old thing. *

* * @param thingName * The name of the thing to update.

*

* You can't change a thing's name. To change a thing's name, you must create a new thing, give it the * new name, and then delete the old thing. * @return Returns a reference to this object so that method calls can be chained together. */ Builder thingName(String thingName); /** *

* The name of the thing type. *

* * @param thingTypeName * The name of the thing type. * @return Returns a reference to this object so that method calls can be chained together. */ Builder thingTypeName(String thingTypeName); /** *

* A list of thing attributes, a JSON string containing name-value pairs. For example: *

*

* {\"attributes\":{\"name1\":\"value2\"}} *

*

* This data is used to add new attributes or update existing attributes. *

* * @param attributePayload * A list of thing attributes, a JSON string containing name-value pairs. For example:

*

* {\"attributes\":{\"name1\":\"value2\"}} *

*

* This data is used to add new attributes or update existing attributes. * @return Returns a reference to this object so that method calls can be chained together. */ Builder attributePayload(AttributePayload attributePayload); /** *

* A list of thing attributes, a JSON string containing name-value pairs. For example: *

*

* {\"attributes\":{\"name1\":\"value2\"}} *

*

* This data is used to add new attributes or update existing attributes. *

* This is a convenience method that creates an instance of the {@link AttributePayload.Builder} avoiding the * need to create one manually via {@link AttributePayload#builder()}. * *

* When the {@link Consumer} completes, {@link AttributePayload.Builder#build()} is called immediately and its * result is passed to {@link #attributePayload(AttributePayload)}. * * @param attributePayload * a consumer that will call methods on {@link AttributePayload.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #attributePayload(AttributePayload) */ default Builder attributePayload(Consumer attributePayload) { return attributePayload(AttributePayload.builder().applyMutation(attributePayload).build()); } /** *

* The expected version of the thing record in the registry. If the version of the record in the registry does * not match the expected version specified in the request, the UpdateThing request is rejected * with a VersionConflictException. *

* * @param expectedVersion * The expected version of the thing record in the registry. If the version of the record in the registry * does not match the expected version specified in the request, the UpdateThing request is * rejected with a VersionConflictException. * @return Returns a reference to this object so that method calls can be chained together. */ Builder expectedVersion(Long expectedVersion); /** *

* Remove a thing type association. If true, the association is removed. *

* * @param removeThingType * Remove a thing type association. If true, the association is removed. * @return Returns a reference to this object so that method calls can be chained together. */ Builder removeThingType(Boolean removeThingType); @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @Override Builder overrideConfiguration(Consumer builderConsumer); } static final class BuilderImpl extends IotRequest.BuilderImpl implements Builder { private String thingName; private String thingTypeName; private AttributePayload attributePayload; private Long expectedVersion; private Boolean removeThingType; private BuilderImpl() { } private BuilderImpl(UpdateThingRequest model) { super(model); thingName(model.thingName); thingTypeName(model.thingTypeName); attributePayload(model.attributePayload); expectedVersion(model.expectedVersion); removeThingType(model.removeThingType); } 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 String getThingTypeName() { return thingTypeName; } public final void setThingTypeName(String thingTypeName) { this.thingTypeName = thingTypeName; } @Override public final Builder thingTypeName(String thingTypeName) { this.thingTypeName = thingTypeName; return this; } public final AttributePayload.Builder getAttributePayload() { return attributePayload != null ? attributePayload.toBuilder() : null; } public final void setAttributePayload(AttributePayload.BuilderImpl attributePayload) { this.attributePayload = attributePayload != null ? attributePayload.build() : null; } @Override public final Builder attributePayload(AttributePayload attributePayload) { this.attributePayload = attributePayload; 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 Boolean getRemoveThingType() { return removeThingType; } public final void setRemoveThingType(Boolean removeThingType) { this.removeThingType = removeThingType; } @Override public final Builder removeThingType(Boolean removeThingType) { this.removeThingType = removeThingType; 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 UpdateThingRequest build() { return new UpdateThingRequest(this); } @Override public List> sdkFields() { return SDK_FIELDS; } @Override public Map> sdkFieldNameToField() { return SDK_NAME_TO_FIELD; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy