All Products
Search
Document Center

Content Moderation:Query business scenarios

Last Updated:Jul 31, 2023

This topic describes how to use Content Moderation SDK for Python to query existing and custom business scenarios. This helps you manage business scenarios.

Prerequisites

  • Python dependencies are installed. For more information, see Installation.

    Note

    You must use the required Python version described in the Installation topic to install the dependencies. Otherwise, subsequent operation calls fail.

  • The Extension.Uploader utility class is downloaded and imported into your project.

Submit a task to query business scenarios

Operation

Description

Supported region

DescribeUserBizTypes

Queries business scenarios.

  • cn-shanghai: China (Shanghai)

  • cn-beijing: China (Beijing)

  • cn-shenzhen: China (Shenzhen)

  • ap-southeast-1: Singapore

Sample code

# coding=utf-8

from aliyunsdkcore import client
from aliyunsdkcore.profile import region_provider
from aliyunsdkgreen.request.v20170823 import DescribeUserBizTypesRequest

# Note: We recommend that you reuse the instantiated client as much as possible. This improves moderation performance and avoids repeated client connections. 
# Common ways to obtain environment variables:
# Obtain the AccessKey ID of your RAM user: os.environ['ALIBABA_CLOUD_ACCESS_KEY_ID']
# Obtain the AccessKey secret of your RAM user: os.environ['ALIBABA_CLOUD_ACCESS_KEY_SECRET']
clt = client.AcsClient("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", "cn-shanghai")
region_provider.modify_point('Green', "cn-shanghai", 'green.cn-shanghai.aliyuncs.com')
request = DescribeUserBizTypesRequest.DescribeUserBizTypesRequest()

request.set_accept_format('JSON')

response = clt.do_action_with_exception(request)

'''
Response:
{
    # The list of all business scenarios. 
    "BizTypeList":[
        {
            # Indicates whether an industry template was imported. 
            "CiteTemplate":false,
            # The name of the business scenario. 
            "BizType":"mohongtest2",
            # The source of the business scenario. A value of custom indicates a custom business scenario. A value of system indicates the default business scenario of Content Moderation. 
            "Source":"custom",
            # The industry information. 
            "IndustryInfo":""
        }
    ],
    "RequestId":"ADDBDECA-E1B2-4988-AE3B-956BF51573EC",
    # When you create a business scenario, you can import the configuration of an existing business scenario in the list of queried business scenarios. 
    "BizTypeListImport":[
        {
            "CiteTemplate":false,
            "BizType":"mohongtest2",
            "Source":"custom",
            "IndustryInfo":""
        }
    ]
}

'''

print(response)