IOT: group names can now contain special characters (#6701)
This commit is contained in:
parent
5e1b166f25
commit
e11ba21b83
@ -581,14 +581,14 @@ class IoTResponse(BaseResponse):
|
|||||||
return json.dumps(dict(principals=principals))
|
return json.dumps(dict(principals=principals))
|
||||||
|
|
||||||
def describe_thing_group(self) -> str:
|
def describe_thing_group(self) -> str:
|
||||||
thing_group_name = self._get_param("thingGroupName")
|
thing_group_name = unquote(self.path.split("/thing-groups/")[-1])
|
||||||
thing_group = self.iot_backend.describe_thing_group(
|
thing_group = self.iot_backend.describe_thing_group(
|
||||||
thing_group_name=thing_group_name
|
thing_group_name=thing_group_name
|
||||||
)
|
)
|
||||||
return json.dumps(thing_group.to_dict())
|
return json.dumps(thing_group.to_dict())
|
||||||
|
|
||||||
def create_thing_group(self) -> str:
|
def create_thing_group(self) -> str:
|
||||||
thing_group_name = self._get_param("thingGroupName")
|
thing_group_name = unquote(self.path.split("/thing-groups/")[-1])
|
||||||
parent_group_name = self._get_param("parentGroupName")
|
parent_group_name = self._get_param("parentGroupName")
|
||||||
thing_group_properties = self._get_param("thingGroupProperties")
|
thing_group_properties = self._get_param("thingGroupProperties")
|
||||||
(
|
(
|
||||||
@ -609,7 +609,7 @@ class IoTResponse(BaseResponse):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def delete_thing_group(self) -> str:
|
def delete_thing_group(self) -> str:
|
||||||
thing_group_name = self._get_param("thingGroupName")
|
thing_group_name = unquote(self.path.split("/thing-groups/")[-1])
|
||||||
self.iot_backend.delete_thing_group(thing_group_name=thing_group_name)
|
self.iot_backend.delete_thing_group(thing_group_name=thing_group_name)
|
||||||
return json.dumps(dict())
|
return json.dumps(dict())
|
||||||
|
|
||||||
@ -632,7 +632,7 @@ class IoTResponse(BaseResponse):
|
|||||||
return json.dumps(dict(thingGroups=rets, nextToken=next_token))
|
return json.dumps(dict(thingGroups=rets, nextToken=next_token))
|
||||||
|
|
||||||
def update_thing_group(self) -> str:
|
def update_thing_group(self) -> str:
|
||||||
thing_group_name = self._get_param("thingGroupName")
|
thing_group_name = unquote(self.path.split("/thing-groups/")[-1])
|
||||||
thing_group_properties = self._get_param("thingGroupProperties")
|
thing_group_properties = self._get_param("thingGroupProperties")
|
||||||
expected_version = self._get_param("expectedVersion")
|
expected_version = self._get_param("expectedVersion")
|
||||||
version = self.iot_backend.update_thing_group(
|
version = self.iot_backend.update_thing_group(
|
||||||
|
@ -38,8 +38,8 @@ def generate_thing_group_tree(iot_client, tree_dict, _parent=None):
|
|||||||
|
|
||||||
|
|
||||||
class TestListThingGroup:
|
class TestListThingGroup:
|
||||||
group_name_1a = "my-group-name-1a"
|
group_name_1a = "my-group:name-1a"
|
||||||
group_name_1b = "my-group-name-1b"
|
group_name_1b = "my-group:name-1b"
|
||||||
group_name_2a = "my-group-name-2a"
|
group_name_2a = "my-group-name-2a"
|
||||||
group_name_2b = "my-group-name-2b"
|
group_name_2b = "my-group-name-2b"
|
||||||
group_name_3a = "my-group-name-3a"
|
group_name_3a = "my-group-name-3a"
|
||||||
@ -112,7 +112,7 @@ class TestListThingGroup:
|
|||||||
client = boto3.client("iot", region_name="ap-northeast-1")
|
client = boto3.client("iot", region_name="ap-northeast-1")
|
||||||
generate_thing_group_tree(client, self.tree_dict)
|
generate_thing_group_tree(client, self.tree_dict)
|
||||||
# test
|
# test
|
||||||
resp = client.list_thing_groups(namePrefixFilter="my-group-name-1")
|
resp = client.list_thing_groups(namePrefixFilter="my-group:name-1")
|
||||||
assert "thingGroups" in resp
|
assert "thingGroups" in resp
|
||||||
assert len(resp["thingGroups"]) == 2
|
assert len(resp["thingGroups"]) == 2
|
||||||
resp = client.list_thing_groups(namePrefixFilter="my-group-name-3")
|
resp = client.list_thing_groups(namePrefixFilter="my-group-name-3")
|
||||||
@ -129,7 +129,7 @@ class TestListThingGroup:
|
|||||||
generate_thing_group_tree(client, self.tree_dict)
|
generate_thing_group_tree(client, self.tree_dict)
|
||||||
# test
|
# test
|
||||||
resp = client.list_thing_groups(
|
resp = client.list_thing_groups(
|
||||||
namePrefixFilter="my-group-name-1", recursive=False
|
namePrefixFilter="my-group:name-1", recursive=False
|
||||||
)
|
)
|
||||||
assert "thingGroups" in resp
|
assert "thingGroups" in resp
|
||||||
assert len(resp["thingGroups"]) == 2
|
assert len(resp["thingGroups"]) == 2
|
||||||
@ -166,7 +166,7 @@ class TestListThingGroup:
|
|||||||
@mock_iot
|
@mock_iot
|
||||||
def test_delete_thing_group():
|
def test_delete_thing_group():
|
||||||
client = boto3.client("iot", region_name="ap-northeast-1")
|
client = boto3.client("iot", region_name="ap-northeast-1")
|
||||||
group_name_1a = "my-group-name-1a"
|
group_name_1a = "my-group:name-1a"
|
||||||
group_name_2a = "my-group-name-2a"
|
group_name_2a = "my-group-name-2a"
|
||||||
tree_dict = {group_name_1a: {group_name_2a: {}}}
|
tree_dict = {group_name_1a: {group_name_2a: {}}}
|
||||||
generate_thing_group_tree(client, tree_dict)
|
generate_thing_group_tree(client, tree_dict)
|
||||||
@ -199,8 +199,8 @@ def test_delete_thing_group():
|
|||||||
@mock_iot
|
@mock_iot
|
||||||
def test_describe_thing_group_metadata_hierarchy():
|
def test_describe_thing_group_metadata_hierarchy():
|
||||||
client = boto3.client("iot", region_name="ap-northeast-1")
|
client = boto3.client("iot", region_name="ap-northeast-1")
|
||||||
group_name_1a = "my-group-name-1a"
|
group_name_1a = "my-group:name-1a"
|
||||||
group_name_1b = "my-group-name-1b"
|
group_name_1b = "my-group:name-1b"
|
||||||
group_name_2a = "my-group-name-2a"
|
group_name_2a = "my-group-name-2a"
|
||||||
group_name_2b = "my-group-name-2b"
|
group_name_2b = "my-group-name-2b"
|
||||||
group_name_3a = "my-group-name-3a"
|
group_name_3a = "my-group-name-3a"
|
||||||
@ -313,7 +313,7 @@ def test_describe_thing_group_metadata_hierarchy():
|
|||||||
@mock_iot
|
@mock_iot
|
||||||
def test_thing_groups():
|
def test_thing_groups():
|
||||||
client = boto3.client("iot", region_name="ap-northeast-1")
|
client = boto3.client("iot", region_name="ap-northeast-1")
|
||||||
group_name = "my-group-name"
|
group_name = "my-group:name"
|
||||||
|
|
||||||
# thing group
|
# thing group
|
||||||
thing_group = client.create_thing_group(thingGroupName=group_name)
|
thing_group = client.create_thing_group(thingGroupName=group_name)
|
||||||
|
Loading…
Reference in New Issue
Block a user