Group management API
Updated at:2025-10-27
Create group
Create a group with reference to the following codes:
Python
1def create_group():
2 iam_client = IamClient(iam_sample_conf.config)
3
4# Group creation request as dict
5# Set group name
6# Set group description
7 create_group_request = {"name": "test_group", "description": "create test_group"}
8 response = iam_client.create_group(create_group_request)
9 print(response)
Query group
Query a group with reference to the following codes:
Python
1def get_group():
2 iam_client = IamClient(iam_sample_conf.config)
3
4# Group name
5 group_name = b"test_group"
6 response = iam_client.get_group(group_name)
7 print(response)
Update group
Update a group with reference to the following codes:
Python
1def update_group():
2 iam_client = IamClient(iam_sample_conf.config)
3# Current group name
4 group_name = b"test_group"
5
6# Group update request as dict
7# Set new group name
8# Set group description
9 update_group_request = {"name": "test_group_new", "description": "update test_group"}
10 response = iam_client.update_group(group_name, update_group_request)
11 print(response)
Delete group
Delete a group with reference to the following codes:
Python
1def delete_group():
2 iam_client = IamClient(iam_sample_conf.config)
3
4# Current group name
5 group_name = b"test_group"
6 response = iam_client.delete_group(group_name)
7 print(response)
List groups
List groups with reference to the following codes:
Python
1def list_group():
2 iam_client = IamClient(iam_sample_conf.config)
3 response = iam_client.list_group()
4 print(response)
Add user to group
Add a user to a group with reference to the following codes:
Python
1def add_user_to_group():
2 iam_client = IamClient(iam_sample_conf.config)
3
4# Group name
5 group_name = b"test_group"
6# User to be added to group
7 user_name = b"test_user"
8 response = iam_client.add_user_to_group(group_name, user_name)
9 print(response)
Remove user from group
Remove a user from a group with reference to the following codes:
Python
1def remove_user_from_group():
2 iam_client = IamClient(iam_sample_conf.config)
3
4# Group name
5 group_name = b"test_group"
6
7# User to be removed from group
8 user_name = b"test_user"
9 response = iam_client.remove_user_from_group(group_name, user_name)
10 print(response)
List the group to which a user belongs
List groups to which the users belong with reference to the following codes:
Python
1def list_user_group():
2 iam_client = IamClient(iam_sample_conf.config)
3# Username
4 user_name = b"test_user"
5 response = iam_client.list_user_group(user_name)
6 print(response)
List users within a group
List users within a group with reference to the following codes:
Python
1def list_group_user():
2 iam_client = IamClient(iam_sample_conf.config)
3 group_name = b"test_group"
4 response = iam_client.list_group_user(group_name)
5 print(response)
