Creating Notifications

Last updated: 2018-08-21 16:24:26

1. API Description

This API (CreateScalingNotification) is used to create notification.
Domain for API request: scaling.api.qcloud.com

1) Each scaling group can create up to 20 notifications. For more information, refer to Service Limits.

2. Input Parameters

The following request parameter list only provides API request parameters. Common request parameters need to be added when the API is called. For more information, refer to Common Request Parameters. The Action field for this API is CreateScalingNotification.

Parameter Name Required Type Description
scalingGroupId Yes String Scaling group ID of the notification to be created. It can be queried by calling Query Scaling Group List (DescribeScalingGroup) API.
notificationTypes.n Yes int Notification types, which is a collection of notification types that need to be subscribed, ranging from 1 to 6. The specific mapping relationship is as follows:
1: Scale-up Succeeded
2: Scale-up Failed
3: Scale-down Succeeded
4: Scale-down Failed
5: Replacement of Unhealthy Sub-machines Succeeded
6: Replacement of Unhealthy Sub-machines Failed
receiversIds.n Yes String ID of the notification group, that is, the collection of user group ID (groupID). The array subscript is started with 0. You can call API Obtain User Group List (DescribeUserGroup) to query the parameter.

3. Output Parameters

Parameter Name Type Description
code Int Common error code; 0: Succeeded; other values: Failed. For more information, please refer to Common Error Codes on the Error Code page.
codeDesc String Error code at business side. If the task succeeds, it will return "Success"; if the task fails, the specific business error reason will be returned.
message String Module error message description depending on API.
data Array It contains the notification list information that was created successfully.

Parameter data is composed of the following parameters, and contains only one element notificationId.

Parameter Name Type Description
notificationId String Notification ID.

4. Error Codes

The following error codes only include the business logic error codes for this API. For additional common error codes, refer to AS Error Code.

Error Code Description
InvalidParameter.ScallingGroupId Cannot match to the corresponding scaling group ID
InvalidParameter.NotifyType Invalid notification type number

5. Example

https://scaling.api.qcloud.com/v2/index.php?
&<Common Request Parameters>
&scalingGroupId=asg-xxxx
&notificationTypes.0=1
&notificationTypes.1=2
&receiversIds.0=1832
&receiversIds.1=1833

Example of returned result is as below:

{
    "code":"0",
    "message":"",
    "codeDesc":"Success"
    "data":{
        "notificationId":"asn-xxxxx"
    }
}