updateThing method

Future<void> updateThing({
  1. required String thingName,
  2. AttributePayload? attributePayload,
  3. int? expectedVersion,
  4. bool? removeThingType,
  5. String? thingTypeName,
})

Updates the data for a thing.

Requires permission to access the UpdateThing action.

May throw InternalFailureException. May throw InvalidRequestException. May throw ResourceNotFoundException. May throw ServiceUnavailableException. May throw ThrottlingException. May throw UnauthorizedException. May throw VersionConflictException.

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 {
  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,
  );
}