Updated on 2025-10-22 GMT+08:00

Creating an Event Notification Rule

Function

This API is used to create an event notification rule.

URI

POST /v1/{project_id}/cae/notice-rules

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. See Obtaining a Project ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token.

  • Obtain the token. For details, see "Obtaining a User Token" in Identity and Access Management API Reference (https://support.huaweicloud.com/intl/en-us/api-iam/iam_30_0001.html).

  • The value of X-Subject-Token in the response header is the token value.

X-Enterprise-Project-ID

No

String

Enterprise project ID.

  • When an environment is created, it will be bound with an enterprise project ID.

  • Enter 0 or up to 36 characters in UUID format with hyphens (-).

  • If this parameter is not specified or set to 0, resources in the default enterprise project are queried.

NOTE:
For details about how to obtain enterprise project IDs and enterprise project features, see Enterprise Management User Guide.
Table 3 Request body parameters

Parameter

Mandatory

Type

Description

api_version

Yes

String

API version. Fixed value: v1.

kind

Yes

String

API type. Fixed value: NoticeRule.

spec

Yes

CreateNoticeRuleItem object

Request data.

Table 4 CreateNoticeRuleItem

Parameter

Mandatory

Type

Description

name

Yes

String

Notification name.

event_name

No

String

Name of the trigger event. Values: Instance scheduling successful, Instance scheduling failed, Health checked, Health check failed, Image pulled, Pull image failed, Container started up, Container startup failed, Volume mounted, Attach volume failed.

scope

Yes

NoticeRuleScope object

Scope of the notification rule that takes effect.

trigger_policy

Yes

TriggerPolicy object

Trigger policy.

notification

Yes

NoticeRuleNotification object

Notification mechanism.

enable

No

Boolean

Enable or not.

Table 5 NoticeRuleScope

Parameter

Mandatory

Type

Description

type

Yes

String

Type of the effective scope. including environments (for all components in a specified environment), applications (for all components of a specified application), and components (for specified components).

environments

No

Array of strings

List of valid environment IDs.

applications

No

Array of strings

List of valid application IDs.

components

No

Array of strings

List of valid component IDs.

Table 6 TriggerPolicy

Parameter

Mandatory

Type

Description

trigger_type

Yes

String

Trigger type. Options: accumulative or immediately.

period

No

Integer

Trigger period. This parameter needs to be set when accumulative is selected. The default unit is second. The value can be 5 minutes, 20 minutes, 1 hour, 4 hours, or 24 hours.

operator

No

String

Comparison operator. The value can be > or >=.

count

No

Integer

Number of trigger times. This parameter needs to be set when accumulative is selected.

Table 7 NoticeRuleNotification

Parameter

Mandatory

Type

Description

protocol

Yes

String

Definition

Notification protocol type.

Constraints

N/A.

Range

  • email

  • sms

  • wechat

  • dingding

Default Value

N/A.

extension

No

extension object

endpoint

Yes

String

Notification endpoint address.

For an email protocol, the endpoint must be an email address.

For an SMS protocol, the endpoint must be a phone number.

For the WeChat protocol and DingTalk chatbot, see Obtaining Subscription Endpoints.

WeCom and DingTalk chatbot are in OBT of SMN. Submit a service ticket to enable them.

template

No

String

Notification template language. Options:

ZH

EN

Table 8 extension

Parameter

Mandatory

Type

Description

sign_secret

No

String

In the DingTalk scenario, you can enter the key field.

Response Parameters

Status code: 200

Table 9 Response body parameters

Parameter

Type

Description

api_version

String

API version. Fixed value: v1.

kind

String

API type. Fixed value: NoticeRule.

spec

CreateNoticeRuleRespItem object

Request data.

Table 10 CreateNoticeRuleRespItem

Parameter

Type

Description

id

String

Unique ID of a notification rule.

name

String

Notification name.

event_name

String

Name of the triggered event.

scope

NoticeRuleScope object

Scope of the notification rule that takes effect.

trigger_policy

TriggerPolicy object

Trigger policy.

notification

NoticeRuleNotification object

Notification mechanism.

enable

Boolean

Enable or not.

Table 11 NoticeRuleScope

Parameter

Type

Description

type

String

Type of the effective scope. including environments (for all components in a specified environment), applications (for all components of a specified application), and components (for specified components).

environments

Array of strings

List of valid environment IDs.

applications

Array of strings

List of valid application IDs.

components

Array of strings

List of valid component IDs.

Table 12 TriggerPolicy

Parameter

Type

Description

trigger_type

String

Trigger type. Options: accumulative or immediately.

period

Integer

Trigger period. This parameter needs to be set when accumulative is selected. The default unit is second. The value can be 5 minutes, 20 minutes, 1 hour, 4 hours, or 24 hours.

operator

String

Comparison operator. The value can be > or >=.

count

Integer

Number of trigger times. This parameter needs to be set when accumulative is selected.

Table 13 NoticeRuleNotification

Parameter

Type

Description

protocol

String

Definition

Notification protocol type.

Constraints

N/A.

Range

  • email

  • sms

  • wechat

  • dingding

Default Value

N/A.

extension

extension object

endpoint

String

Notification endpoint address.

For an email protocol, the endpoint must be an email address.

For an SMS protocol, the endpoint must be a phone number.

For the WeChat protocol and DingTalk chatbot, see Obtaining Subscription Endpoints.

WeCom and DingTalk chatbot are in OBT of SMN. Submit a service ticket to enable them.

template

String

Notification template language. Options:

ZH

EN

Table 14 extension

Parameter

Type

Description

sign_secret

String

In the DingTalk scenario, you can enter the key field.

Example Requests

Create an event notification rule.

POST https://{endpoint}/v1/{project_id}/cae/notice-rules

{
  "api_version" : "v1",
  "kind" : "NoticeRule",
  "spec" : {
    "name" : "test",
    "event_name" : "Started",
    "scope" : {
      "type" : "environments",
      "environments" : [ "f3c12180-b34a-42d8-bb5a-12ba0a6b579e" ]
    },
    "trigger_policy" : {
      "trigger_type" : "immediately"
    },
    "notification" : {
      "protocol" : "email",
      "endpoint" : "123@example.com",
      "template" : "ZH"
    },
    "enable" : true
  }
}

Example Responses

Status code: 200

OK

{
  "api_version": "v1",
  "kind": "NoticeRule",
  "spec": {
    "id": "133da017-423c-4e1c-80be-8c8c71c9b84e",
    "name": "test",
    "event_name": "Started",
    "scope": {
      "type": "environments",
      "environments": [
        "f3c12180-b34a-42d8-bb5a-12ba0a6b579e"
      ]
    },
    "trigger_policy": {
      "trigger_type": "immediately"
    },
    "notification": {
      "protocol": "email",
      "endpoint": "123@example.com"
      "template": "ZH"
    },
    "enable": true
  }
}

Status Codes

Status Code

Description

200

OK

Error Codes

See Error Codes.