All Products
Search
Document Center

CreateRule

Last Updated: Jan 15, 2021

CreateRule

Description

Creates a rule.

Method

POST

URI

openapi/instances/{instanceId}/rules

Request parameters

Parameter

Type

Required

Description

type

String

Yes

The type of the rule. Valid values: SelectionRule and OperationRule.

ruleMeta

Map

Yes

The specific information of the rule.

└sceneId

String

Yes

The ID of the scene.

selectionParams

List

Yes

The parameters specified for the item selection rule.

└selectType

Enum

Yes

The selection type. Valid values: QUERY_ITEM_TYPE, QUERY_CATEGORY, QUERY_PUB_TIME, and QUERY_CHANNEL.

└selectionOperation

Enum

Yes

The type of the operator. Valid values: OPERATOR_HIGHER, OPERATOR_LOWER, and QUERY_VALUE_IN.

└selectValue

String

Yes

The selected rule, which is transmitted in the JSON format.

operationParams

└operationType

Enum

Yes

The operations rule type. Valid values: MIX, DIVERSIFY, and EXPOSURE. This parameter can be set to EXPOSURE only for global rules.

└settings

MixSetting

Yes

└name

String

Yes

The mixed sorting type.

└value

Int

Yes

The percentage of the mixed sorting type.

└diversifyType

Enum

Yes

The discretization type. Valid values: TYPE_SHOP, TYPE_AUTHOR, and TYPE_CATEGORY.

└categoryIndex

Int

Yes

The category level. Set this parameter to 0 if no category is specified.

└window

Int

Yes

The window.

└status

Boolean

Yes

Specifies whether the rule is enabled.

└exposureSettings

List

Yes

The list of exposure settings.

└durationSeconds

Long

Yes

The exposure duration, in seconds.

└exposureType

String

Yes

The exposure type. Valid values: TYPE_EXPOSE and TYPE_CLICK.

└status

Boolean

Yes

Specifies whether the rule is enabled.

└scenarioBased

Boolean

Yes

Specifies whether the rule is a scene-specific rule.

Response parameters

Parameter

Type

Description

RequestId

String

The ID of the request.

Result

Map

The result that is returned.

└RuleId

String

The ID of the rule.

Examples

Sample requests

POST openapi/instances/{instanceId}/rules
/// Create an item selection rule.
{      "type":"SelectionRule",
    "ruleMeta":{
        "sceneId":"123",
        "ruleMetaType":"SELECTION",
        "selectionParams":[
            {
                "selectType":"QUERY_ITEM_TYPE",
                "selectionOperation":"QUERY_VALUE_IN",
                "selectValue":"[\"atrical\",\"image\"]"
            }
        ]
    }
}
// Create an operations rule.
{
    "type":"OperationRule",
    "ruleMeta":{
        "ruleMetaType":"OPERATION",
        "sceneId":"123",
        "operationParams":[
            {
                "operationType":"MIX",
                "settings":[
                    {
                        "name":"image",
                        "value":10
                    }
                ]
            },
            {
                "operationType":"DIVERSIFY",
                "status":true,
                "diversifyType":"TYPE_SHOP",
                "categoryIndex":1,
                "window":2
            },
            {
                "operationType":"EXPOSURE",
                "exposureSettings":[
                    {
                        "durationSeconds":1234000,
                        "status":true,
                        "exposureType":"TYPE_EXPOSE",
                        "scenarioBased":true
                    },
                    {
                        "durationSeconds":123400,
                        "status":true,
                        "exposureType":"TYPE_CLICK",
                        "scenarioBased":true
                    }
                ]
            }
        ]
    }
}

Sample responses

JSON format

// Item selection rule
{
    "Result":{
        "Status":"DRAFT",
        "GmtCreate":"2020-04-27T06:38:28.000Z",
        "GmtModified":"2020-04-27T06:38:28.000Z",
        "RuleId":"98493A14-D619-4E88-9F8D-108939817F9F",
        "RuleMeta":{
            "RuleMetaType":"SELECTION",
            "SceneId":"123",
            "PubState":"PUBLISHING",
            "SelectionParams":[
                {
                    "SelectType":"QUERY_ITEM_TYPE",
                    "SelectionOperation":"OPERATOR_EQUAL",
                    "SelectValue":"atrical,image"
                }
            ]
        }
    },
    "RequestId":"76E2C51D-A2D7-4775-9FD8-2AB84B2A0CEF"
}


// Operations rule
{
    "Result":{
        "Status":"DRAFT",
        "GmtCreate":"2020-04-27T03:17:21.000Z",
        "GmtModified":"2020-04-27T03:17:21.000Z",
        "RuleId":"123456789001122",
        "RuleMeta":{
            "RuleMetaType":"OPERATION",
            "SceneId":"123",
            "PubState":"PUBLISHING",
            "OperationParams":[
                {
                    "OperationType":"MIX",
                    "Settings":[
                        {
                            "Name":"image",
                            "Value":10
                        }
                    ]
                },
                {
                    "OperationType":"DIVERSIFY",
                    "CategoryIndex":1,
                    "Window":2,
                    "Status":true,
                    "DiversifyType":"TYPE_SHOP"
                },
                {
                    "OperationType":"EXPOSURE",
                    "ExposureSettings":[
                        {
                            "DurationSeconds":12340,
                            "Status":true,
                            "ExposureType":"TYPE_EXPOSE",
                            "ScenarioBased":true
                        },
                        {
                            "DurationSeconds":12340000,
                            "Status":true,
                            "ExposureType":"TYPE_CLICK",
                            "ScenarioBased":true
                        }
                    ]
                }
            ]
        }
    },
    "RequestId":"76E2C51D-A2D7-4775-9FD8-2AB84B2A0CEF"
}

Sample error responses

JSON format

{
    "Code": "InstanceNotFound",
    "Message": "The specified instance does not exist. Check the instanceId please.",
    "RequestId": "829F38F6-E2D6-4109-90A6-888160BD16C2"
}