Group management API
Updated at:2025-10-27
Create group
Create a group with the following code
Go
1 name := "test_group_sdk_go"
2 args := &api.CreateGroupArgs{
3 Name: name,
4 Description: name,
5 }
6 result, err := client.CreateGroup(args)
7 if err != nil {
8 fmt.Println("Create group failed", err)
9 } else {
10 fmt.Println("Create group success", result)
11 }
Prompt:
- For detailed parameter configuration and constraints, refer to the IAM API documentation Create Group
Query group
Query a group with the following code
Go
1 name := "test_group_sdk_go"
2 result, err := client.GetGroup(name)
3 if err != nil {
4 fmt.Println("Get group failed", err)
5 } else {
6 fmt.Println("Get group success", result)
7 }
Prompt:
- For detailed parameter configuration and constraints, refer to the IAM API documentation Query Group
Update group
Update a group with the following codes
Go
1 name := "test_group_sdk_go"
2 args := &api.UpdateGroupArgs{
3 Description: "newDes",
4 }
5 result, err := client.UpdateGroup(name, args)
6 if err != nil {
7 fmt.Println("Update group failed", err)
8 } else {
9 fmt.Println("Update group success", result)
10 }
Prompt:
- For detailed parameter configuration and constraints, refer to the IAM API documentation Update Group
Delete group
Delete a group with the following code
Go
1 name := "test_group_sdk_go"
2 err = client.DeleteGroup(name)
3 if err != nil {
4 fmt.Println("Delete group failed", err)
5 } else {
6 fmt.Println("Delete group success", name)
7 }
Prompt:
- For detailed parameter configuration and constraints, refer to the IAM API documentation Delete Group
List groups
Delete a group with the following code
Go
1 result, err := client.ListGroup()
2 if err != nil {
3 fmt.Println("Delete group failed", err)
4 } else {
5 fmt.Println("Delete group success", result)
6 }
Prompt:
- For detailed parameter configuration and constraints, refer to the IAM API documentation List Groups
Add user to group
Add a user to a group with the following codes
Go
1 userName := "test_user_sdk_go"
2 groupName := "test_user_sdk_go"
3 err = client.AddUserToGroup(userName, groupName)
4 if err != nil {
5 fmt.Println("Add user to group failed", err)
6 } else {
7 fmt.Println("Add user to group success", userName)
8 }
Prompt:
- For detailed parameter configuration and constraints, refer to the IAM API documentation Add a User to a Group
Remove user from group
Remove a user from a group with the following codes
Go
1 userName := "test_user_sdk_go"
2 groupName := "test_user_sdk_go"
3 err = client.DeleteUserFromGroup(userName, groupName)
4 if err != nil {
5 fmt.Println("Add user to group failed", err)
6 } else {
7 fmt.Println("Add user to group success", userName)
8 }
Prompt:
- For detailed parameter configuration and constraints, refer to the IAM API documentation Remove a User from a Group
List the group to which a user belongs
To list groups to which the users belong with the following codes
Go
1 userName := "test_user_sdk_go"
2 result, err := client.ListGroupsForUser(userName)
3 if err != nil {
4 fmt.Println("List groups for user failed", err)
5 } else {
6 fmt.Println("List groups for user success", result)
7 }
8
Prompt:
- For detailed parameter configuration and constraints, refer to the IAM API documentationList the Group to Which a User Belongs
List users within a group
List a user within a group with the following codes
Go
1 groupName := "test_user_sdk_go"
2 result, err := client.ListUsersInGroup(groupName)
3 if err != nil {
4 fmt.Println("List user in group failed", err)
5 } else {
6 fmt.Println("List user in group success", result)
7 }
Prompt:
- For detailed parameter configuration and constraints, refer to the IAM API documentation List a User Within a Group
