Delete a person from a group
Updated at:
Removes a custom person from a specified group using the Go SDK. This operation unlinks the person from the group — the person's information and images are not deleted.
Prerequisites
Before you begin, ensure that you have:
Go dependencies installed using the required Go version. Using a different version causes subsequent operation calls to fail. For details, see Installation.
The AI Guardrails API endpoint configured. For details, see Endpoint.
Parameters
Both parameters are required.
| Parameter | Type | Description |
|---|---|---|
personId | string | The ID of the custom person to remove |
groupIds | string array | The IDs of the custom groups to remove the person from |
Remove a person from a group
The following example removes a custom person from a specified group by calling the DeleteGroups API operation.
package main
import (
"encoding/json"
"fmt"
"github.com/aliyun/alibaba-cloud-sdk-go/services/green"
"strconv"
)
func main() {
/**
* Reuse the instantiated client as much as possible. This improves moderation performance and avoids repeated client connections.
* Get credentials from environment variables:
* AccessKey ID of your RAM user: os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_ID")
* AccessKey secret of your RAM user: os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET")
*/
client, _err := green.NewClientWithAccessKey(
"cn-shanghai",
"We recommend that you obtain the AccessKey ID of your RAM user from environment variables",
"We recommend that you obtain the AccessKey secret of your RAM user from environment variables");
if err != nil {
fmt.Println(err.Error())
return
}
/**
* personId: the ID of the custom person. This parameter is required.
* groupIds: the IDs of custom groups. This parameter is required.
*/
content, _ := json.Marshal(
map[string]interface{}{
"personId": "Person ID", "groupIds": [...]string{"Group ID_1"},
},
)
request := green.CreateDeleteGroupsRequest()
request.SetContent(content)
response, _err := client.DeleteGroups(request)
if _err != nil {
fmt.Println(_err.Error())
return
}
if response.GetHttpStatus() != 200 {
fmt.Println("response not success. status:" + strconv.Itoa(response.GetHttpStatus()))
}
fmt.Println(response.GetHttpContentString())
}What's next
API operation for deleting a person from a group — full parameter reference and response schema
Is this page helpful?