updateThing method
- required String thingName,
- AttributePayload? attributePayload,
- int? expectedVersion,
- bool? removeThingType,
- String? thingTypeName,
Updates the data for a thing.
May throw InvalidRequestException. May throw VersionConflictException. May throw ThrottlingException. May throw UnauthorizedException. May throw ServiceUnavailableException. May throw InternalFailureException. May throw ResourceNotFoundException.
Parameter 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.
Parameter 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.
Parameter 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
.
Parameter removeThingType
:
Remove a thing type association. If true, the association is
removed.
Parameter thingTypeName
:
The name of the thing type.
Implementation
Future<void> updateThing({
required String thingName,
AttributePayload? attributePayload,
int? expectedVersion,
bool? removeThingType,
String? thingTypeName,
}) async {
ArgumentError.checkNotNull(thingName, 'thingName');
_s.validateStringLength(
'thingName',
thingName,
1,
128,
isRequired: true,
);
_s.validateStringLength(
'thingTypeName',
thingTypeName,
1,
128,
);
final $payload = <String, dynamic>{
if (attributePayload != null) 'attributePayload': attributePayload,
if (expectedVersion != null) 'expectedVersion': expectedVersion,
if (removeThingType != null) 'removeThingType': removeThingType,
if (thingTypeName != null) 'thingTypeName': thingTypeName,
};
final response = await _protocol.send(
payload: $payload,
method: 'PATCH',
requestUri: '/things/${Uri.encodeComponent(thingName)}',
exceptionFnMap: _exceptionFns,
);
}