Skip to content

create_thing async

create_thing(
    thing_name: ThingName,
    *,
    config_overrides: Optional[AsyncIoTClientConfig] = None,
    thing_type_name: Optional[ThingTypeName] = None,
    attribute_payload: Optional[AttributePayload] = None,
    billing_group_name: Optional[BillingGroupName] = None,
) -> CreateThingResponse

Creates a thing record in the registry. If this call is made multiple times using the same thing name and configuration, the call will succeed. If this call is made with the same thing name but different configuration a ResourceAlreadyExistsException is thrown.

This is a control plane operation. See Authorization for information about authorizing control plane actions.

Requires permission to access the CreateThing action.

Parameters:

  • thing_name (ThingName) –

    The name of the thing to create.

    You can't change a thing's name after you create it. 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 associated with the new thing.

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

    The attribute payload, which consists of up to three name/value pairs in a JSON document. For example:

    {\"attributes\":{\"string1\":\"string2\"}}

  • billing_group_name (Optional[BillingGroupName], default: None ) –

    The name of the billing group the thing will be added to.

Raises:

Source code in docs_src/capo_iot/_services/async_io_t.py
async def create_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,
    billing_group_name: Optional[
        "capo_iot.types.billing_group_name.BillingGroupName"
    ] = None,
) -> "capo_iot.types.create_thing_response.CreateThingResponse":
    r"""<p>Creates a thing record in the registry. If this call is made multiple times using the same thing name and configuration, the call will succeed. If this call is made with the same thing name but different configuration a <code>ResourceAlreadyExistsException</code> is thrown.</p> <note> <p>This is a control plane operation. See <a href="https://docs.aws.amazon.com/iot/latest/developerguide/iot-authorization.html">Authorization</a> for information about authorizing control plane actions.</p> </note> <p>Requires permission to access the <a href="https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions">CreateThing</a> action.</p>

    Args:
        thing_name: <p>The name of the thing to create.</p> <p>You can't change a thing's name after you create it. 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 associated with the new thing.</p>
        attribute_payload: <p>The attribute payload, which consists of up to three name/value pairs in a JSON document. For example:</p> <p> <code>{\"attributes\":{\"string1\":\"string2\"}}</code> </p>
        billing_group_name: <p>The name of the billing group the thing will be added to.</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_already_exists_exception.ResourceAlreadyExistsException: <p>The resource already exists.</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.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_iot.types.create_thing_request.CreateThingRequest]",
    ) -> AsyncOperationResponse[
        "capo_iot.types.create_thing_response.CreateThingResponse"
    ]:
        import capo_iot._operations.aws_iot_service.create_thing

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateThing")
    )
    input_: capo_iot.types.create_thing_request.CreateThingRequest = {
        "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 billing_group_name is not None:
        input_["billing_group_name"] = billing_group_name

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