software.amazon.awssdk.services.iot.model.UpdateThingRequest Maven / Gradle / Ivy
Show all versions of iot 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.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 extends Builder> 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