Skip to content

update_thing async

update_thing(
    thing_name: ThingName,
    *,
    config_overrides: Optional[AsyncIoTClientConfig] = None,
    thing_type_name: Optional[ThingTypeName] = None,
    attribute_payload: Optional[AttributePayload] = None,
    expected_version: Optional[OptionalVersion] = None,
    remove_thing_type: Optional[RemoveThingType] = None,
) -> UpdateThingResponse

Updates the data for a thing.

Requires permission to access the UpdateThing action.

Parameters:

  • thing_name (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.

  • thing_type_name (Optional[ThingTypeName], default: None ) –

    The name of the thing type.

  • attribute_payload (Optional[AttributePayload], default: None ) –

    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.

  • expected_version (Optional[OptionalVersion], default: None ) –

    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.

  • remove_thing_type (Optional[RemoveThingType], default: None ) –

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

Raises:

Source code in docs_src/capo_iot/_services/async_io_t.py
async def update_thing(
    self,
    thing_name: "capo_iot.types.thing_name.ThingName",
    *,
    config_overrides: Optional[AsyncIoTClientConfig] = None,
    thing_type_name: Optional[
        "capo_iot.types.thing_type_name.ThingTypeName"
    ] = None,
    attribute_payload: Optional[
        "capo_iot.types.attribute_payload.AttributePayload"
    ] = None,
    expected_version: Optional[
        "capo_iot.types.optional_version.OptionalVersion"
    ] = None,
    remove_thing_type: Optional[
        "capo_iot.types.remove_thing_type.RemoveThingType"
    ] = None,
) -> "capo_iot.types.update_thing_response.UpdateThingResponse":
    r"""<p>Updates the data for a thing.</p> <p>Requires permission to access the <a href="https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions">UpdateThing</a> action.</p>

    Args:
        thing_name: <p>The name of the thing to update.</p> <p>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.</p>
        thing_type_name: <p>The name of the thing type.</p>
        attribute_payload: <p>A list of thing attributes, a JSON string containing name-value pairs. For example:</p> <p> <code>{\"attributes\":{\"name1\":\"value2\"}}</code> </p> <p>This data is used to add new attributes or update existing attributes.</p>
        expected_version: <p>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 <code>UpdateThing</code> request is rejected with a <code>VersionConflictException</code>.</p>
        remove_thing_type: <p>Remove a thing type association. If <b>true</b>, the association is removed.</p>

    Raises:
        capo_iot.errors.internal_failure_exception.InternalFailureException: <p>An unexpected error has occurred.</p>
        capo_iot.errors.invalid_request_exception.InvalidRequestException: <p>The request is not valid.</p>
        capo_iot.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource does not exist.</p>
        capo_iot.errors.service_unavailable_exception.ServiceUnavailableException: <p>The service is temporarily unavailable.</p>
        capo_iot.errors.throttling_exception.ThrottlingException: <p>The rate exceeds the limit.</p>
        capo_iot.errors.unauthorized_exception.UnauthorizedException: <p>You are not authorized to perform this operation.</p>
        capo_iot.errors.version_conflict_exception.VersionConflictException: <p>An exception thrown when the version of an entity specified with the <code>expectedVersion</code> parameter does not match the latest version in the system.</p>
        capo_iot.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_iot.types.update_thing_request.UpdateThingRequest]",
    ) -> AsyncOperationResponse[
        "capo_iot.types.update_thing_response.UpdateThingResponse"
    ]:
        import capo_iot._operations.aws_iot_service.update_thing

        (
            output,
            http_response,
        ) = await capo_iot._operations.aws_iot_service.update_thing.async_update_thing(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateThing")
    )
    input_: capo_iot.types.update_thing_request.UpdateThingRequest = {
        "thing_name": thing_name
    }
    if thing_type_name is not None:
        input_["thing_type_name"] = thing_type_name
    if attribute_payload is not None:
        input_["attribute_payload"] = attribute_payload
    if expected_version is not None:
        input_["expected_version"] = expected_version
    if remove_thing_type is not None:
        input_["remove_thing_type"] = remove_thing_type

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output