Associates a device with a concrete thing that is in the user's registry.
A thing can be associated with only one device at a time. If you associate a thing with a new device id, its previous association will be removed.
Parameters:
-
thing_name
(ThingName)
–
The name of the thing to which the entity is to be associated.
-
entity_id
(Urn)
–
The ID of the device to be associated with the thing.
The ID should be in the following format.
urn:tdm:REGION/ACCOUNT ID/default:device:DEVICENAME
-
namespace_version
(Optional[Version], default:
None
)
–
The version of the user's namespace. Defaults to the latest version of the user's namespace.
Raises:
Source code in docs_src/capo_iotthingsgraph/_services/io_t_things_graph.py
| def associate_entity_to_thing(
self,
thing_name: "capo_iotthingsgraph.types.thing_name.ThingName",
entity_id: "capo_iotthingsgraph.types.urn.Urn",
*,
config_overrides: Optional[IoTThingsGraphClientConfig] = None,
namespace_version: Optional["capo_iotthingsgraph.types.version.Version"] = None,
) -> "capo_iotthingsgraph.types.associate_entity_to_thing_response.AssociateEntityToThingResponse":
"""<p>Associates a device with a concrete thing that is in the user's registry.</p> <p>A thing can be associated with only one device at a time. If you associate a thing with a new device id, its previous association will be removed.</p>
Args:
thing_name: <p>The name of the thing to which the entity is to be associated.</p>
entity_id: <p>The ID of the device to be associated with the thing.</p> <p>The ID should be in the following format.</p> <p> <code>urn:tdm:REGION/ACCOUNT ID/default:device:DEVICENAME</code> </p>
namespace_version: <p>The version of the user's namespace. Defaults to the latest version of the user's namespace.</p>
Raises:
capo_iotthingsgraph.errors.internal_failure_exception.InternalFailureException: <p></p>
capo_iotthingsgraph.errors.invalid_request_exception.InvalidRequestException: <p></p>
capo_iotthingsgraph.errors.resource_not_found_exception.ResourceNotFoundException: <p></p>
capo_iotthingsgraph.errors.throttling_exception.ThrottlingException: <p></p>
capo_iotthingsgraph.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
def _handler(
req: "OperationRequest[capo_iotthingsgraph.types.associate_entity_to_thing_request.AssociateEntityToThingRequest]",
) -> OperationResponse[
"capo_iotthingsgraph.types.associate_entity_to_thing_response.AssociateEntityToThingResponse"
]:
import capo_iotthingsgraph._operations.iot_things_graph_front_end_service.associate_entity_to_thing
output, http_response = (
capo_iotthingsgraph._operations.iot_things_graph_front_end_service.associate_entity_to_thing.associate_entity_to_thing(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("AssociateEntityToThing")
)
input_: capo_iotthingsgraph.types.associate_entity_to_thing_request.AssociateEntityToThingRequest = {
"thing_name": thing_name,
"entity_id": entity_id,
}
if namespace_version is not None:
input_["namespace_version"] = namespace_version
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|