Help Center/
Content Moderation/
SDK Reference/
Using the Go SDK/
SDK Calling Example/
Moderation (Image)/
Image Moderation (Asynchronous Batch) (V2)/
Querying a Task
Updated on 2023-07-17 GMT+08:00
Querying a Task
- This section describes how to use the Image Moderation (Asynchronous Batch) SDK for querying a task by AK/SK authentication.
Replace the AK/SK in the sample code with the actual AK/SK. Use JobId of RunCheckResultRequest to configure the ID of the moderation task, and then execute the code.
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" moderation "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/moderation/v2" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/moderation/v2/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/moderation/v2/region" ) func main() { //Enter your AK/SK. ak := "<YOUR AK>" sk := "<YOUR SK>" auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). Build() client := moderation.NewModerationClient( moderation.ModerationClientBuilder(). WithRegion(region.ValueOf("cn-north-4")). WithCredential(auth). Build()) request := &model.RunCheckResultRequest{} request.JobId = "70e952b5-5fa3-4d18-9ce4-75bba7226d7c" response, err := client.RunCheckResult(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
- If the moderation result is displayed on the console, the code is successfully executed.
RunCheckResultResponse {"result":{"job_id":"xxx","status":"finish","create_time":"2021-08-05T03:44:37Z","update_time":"2021-08-05T03:44:37Z","items":[{"url":"https://sdk-obs-source-save.obs.cn-north-4.myhuaweicloud.com/terrorism.jpg","suggestion":"pass","detail":{"porn":[{"confidence":0.9883,"label":"normal"},{"confidence":0.0039,"label":"porn"},{"confidence":0.0078,"label":"sexy"}]},"category_suggestions":{"porn":"pass",}}]}} Process exiting with code: 0
Parent topic: Image Moderation (Asynchronous Batch) (V2)
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot