Implemented parent_group, recursive and name_prefix_filter for function list_thing_groups()
This commit is contained in:
parent
323877c15d
commit
e1baca1569
@ -857,8 +857,30 @@ class IoTBackend(BaseBackend):
|
|||||||
del self.thing_groups[thing_group.arn]
|
del self.thing_groups[thing_group.arn]
|
||||||
|
|
||||||
def list_thing_groups(self, parent_group, name_prefix_filter, recursive):
|
def list_thing_groups(self, parent_group, name_prefix_filter, recursive):
|
||||||
thing_groups = self.thing_groups.values()
|
if recursive is None:
|
||||||
return thing_groups
|
recursive = True
|
||||||
|
if name_prefix_filter is None:
|
||||||
|
name_prefix_filter = ""
|
||||||
|
if parent_group and parent_group not in [
|
||||||
|
_.thing_group_name for _ in self.thing_groups.values()
|
||||||
|
]:
|
||||||
|
raise ResourceNotFoundException()
|
||||||
|
thing_groups = [
|
||||||
|
_ for _ in self.thing_groups.values() if _.parent_group_name == parent_group
|
||||||
|
]
|
||||||
|
if recursive:
|
||||||
|
for g in thing_groups:
|
||||||
|
thing_groups.extend(
|
||||||
|
self.list_thing_groups(
|
||||||
|
parent_group=g.thing_group_name,
|
||||||
|
name_prefix_filter=None,
|
||||||
|
recursive=False,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
# thing_groups = groups_to_process.values()
|
||||||
|
return [
|
||||||
|
_ for _ in thing_groups if _.thing_group_name.startswith(name_prefix_filter)
|
||||||
|
]
|
||||||
|
|
||||||
def update_thing_group(
|
def update_thing_group(
|
||||||
self, thing_group_name, thing_group_properties, expected_version
|
self, thing_group_name, thing_group_properties, expected_version
|
||||||
|
@ -535,7 +535,7 @@ class IoTResponse(BaseResponse):
|
|||||||
# max_results = self._get_int_param("maxResults")
|
# max_results = self._get_int_param("maxResults")
|
||||||
parent_group = self._get_param("parentGroup")
|
parent_group = self._get_param("parentGroup")
|
||||||
name_prefix_filter = self._get_param("namePrefixFilter")
|
name_prefix_filter = self._get_param("namePrefixFilter")
|
||||||
recursive = self._get_param("recursive")
|
recursive = self._get_bool_param("recursive")
|
||||||
thing_groups = self.iot_backend.list_thing_groups(
|
thing_groups = self.iot_backend.list_thing_groups(
|
||||||
parent_group=parent_group,
|
parent_group=parent_group,
|
||||||
name_prefix_filter=name_prefix_filter,
|
name_prefix_filter=name_prefix_filter,
|
||||||
|
Loading…
Reference in New Issue
Block a user