Skip to content

update_thing_groups_for_thing

update_thing_groups_for_thing(
    *,
    config_overrides: Optional[IoTClientConfig] = None,
    thing_name: Optional[ThingName] = None,
    thing_groups_to_add: Optional[ThingGroupList] = None,
    thing_groups_to_remove: Optional[ThingGroupList] = None,
    override_dynamic_groups: Optional[OverrideDynamicGroups] = None,
) -> UpdateThingGroupsForThingResponse

Updates the groups to which the thing belongs.

Requires permission to access the UpdateThingGroupsForThing action.

Parameters:

  • thing_name (Optional[ThingName], default: None ) –

    The thing whose group memberships will be updated.

  • thing_groups_to_add (Optional[ThingGroupList], default: None ) –

    The groups to which the thing will be added.

  • thing_groups_to_remove (Optional[ThingGroupList], default: None ) –

    The groups from which the thing will be removed.

  • override_dynamic_groups (Optional[OverrideDynamicGroups], default: None ) –

    Override dynamic thing groups with static thing groups when 10-group limit is reached. If a thing belongs to 10 thing groups, and one or more of those groups are dynamic thing groups, adding a thing to a static group removes the thing from the last dynamic group.

Raises:

Source code in docs_src/capo_iot/_services/io_t.py
def update_thing_groups_for_thing(
    self,
    *,
    config_overrides: Optional[IoTClientConfig] = None,
    thing_name: Optional["capo_iot.types.thing_name.ThingName"] = None,
    thing_groups_to_add: Optional[
        "capo_iot.types.thing_group_list.ThingGroupList"
    ] = None,
    thing_groups_to_remove: Optional[
        "capo_iot.types.thing_group_list.ThingGroupList"
    ] = None,
    override_dynamic_groups: Optional[
        "capo_iot.types.override_dynamic_groups.OverrideDynamicGroups"
    ] = None,
) -> "capo_iot.types.update_thing_groups_for_thing_response.UpdateThingGroupsForThingResponse":
    """<p>Updates the groups to which the thing belongs.</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">UpdateThingGroupsForThing</a> action.</p>

    Args:
        thing_name: <p>The thing whose group memberships will be updated.</p>
        thing_groups_to_add: <p>The groups to which the thing will be added.</p>
        thing_groups_to_remove: <p>The groups from which the thing will be removed.</p>
        override_dynamic_groups: <p>Override dynamic thing groups with static thing groups when 10-group limit is reached. If a thing belongs to 10 thing groups, and one or more of those groups are dynamic thing groups, adding a thing to a static group removes the thing from the last dynamic group.</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.throttling_exception.ThrottlingException: <p>The rate exceeds the limit.</p>
        capo_iot.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_iot.types.update_thing_groups_for_thing_request.UpdateThingGroupsForThingRequest]",
    ) -> OperationResponse[
        "capo_iot.types.update_thing_groups_for_thing_response.UpdateThingGroupsForThingResponse"
    ]:
        import capo_iot._operations.aws_iot_service.update_thing_groups_for_thing

        output, http_response = (
            capo_iot._operations.aws_iot_service.update_thing_groups_for_thing.update_thing_groups_for_thing(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateThingGroupsForThing")
    )
    input_: capo_iot.types.update_thing_groups_for_thing_request.UpdateThingGroupsForThingRequest = {}
    if thing_name is not None:
        input_["thing_name"] = thing_name
    if thing_groups_to_add is not None:
        input_["thing_groups_to_add"] = thing_groups_to_add
    if thing_groups_to_remove is not None:
        input_["thing_groups_to_remove"] = thing_groups_to_remove
    if override_dynamic_groups is not None:
        input_["override_dynamic_groups"] = override_dynamic_groups

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output