CreateNotificationConfiguration

Last updated: 2022-01-18 11:13:35

1. API Description

Domain name for API request: as.tencentcloudapi.com.

This API is used to create a notification policy.
When the notification is sent to a CMQ topic or queue, the following contents are included:

{
    "Service": "Tencent Cloud Auto Scaling",
    "CreatedTime": "2021-10-11T10:15:11Z", // Activity creation time
    "AppId": "100000000",
    "ActivityId": "asa-fznnvrja", // Scaling activity ID
    "AutoScalingGroupId": "asg-pc2oqu2z", // Scaling group ID
    "ActivityType": "SCALE_OUT",  // Scaling activity type
    "StatusCode": "SUCCESSFUL",   // Scaling activity result
    "Description": "Activity was launched in response to a difference between desired capacity and actual capacity,
    scale out 1 instance(s).", // Scaling activity description
    "StartTime": "2021-10-11T10:15:11Z",  // Activity starting time
    "EndTime": "2021-10-11T10:15:32Z",    // Activity ending time
    "DetailedStatusMessageSet": [ // A collection of failed attempts during the scaling process (Failed attempts are allowed in a successful scaling activity)
        {
            "Code": "InvalidInstanceType",
            "Zone": "ap-guangzhou-2",
            "InstanceId": "",
            "InstanceChargeType": "POSTPAID_BY_HOUR",
            "SubnetId": "subnet-4t5mgeuu",
            "Message": "The specified instance type `S5.LARGE8` is invalid in `subnet-4t5mgeuu`, `ap-guangzhou-2`.",
            "InstanceType": "S5.LARGE8",
        }
    ]
}

A maximum of 20 requests can be initiated per second for this API.

We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

2. Input Parameters

The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.
This document describes the parameters for Signature V1. It's recommended to use the V3 signature, which provides higher security. Note that for Signature V3, the common parameters need to be placed in the HTTP Header. See details.

Parameter Name Required Type Description
Action Yes String Common parameter. The value used for this API: CreateNotificationConfiguration.
Version Yes String Common parameter. The value used for this API: 2018-04-19.
Region Yes String Common parameter. For more information, please see the list of regions supported by the product.
AutoScalingGroupId Yes String Auto scaling group ID.
NotificationTypes.N Yes Array of String Notification type, i.e., the set of types of notifications to be subscribed to. Value range:
  • SCALE_OUT_SUCCESSFUL: scale-out succeeded
  • SCALE_OUT_FAILED: scale-out failed
  • SCALE_IN_SUCCESSFUL: scale-in succeeded
  • SCALE_IN_FAILED: scale-in failed
  • REPLACE_UNHEALTHY_INSTANCE_SUCCESSFUL: unhealthy instance replacement succeeded
  • REPLACE_UNHEALTHY_INSTANCE_FAILED: unhealthy instance replacement failed
  • NotificationUserGroupIds.N No Array of String Notification group ID, which is the set of user group IDs. You can query the user group IDs through the ListGroups API.
    TargetType No String Notification receiver type. Valid values:

  • USER_GROUP:User group

  • CMQ_QUEUE:CMQ queue

  • CMQ_TOPIC:CMQ topic

  • TDMQ_CMQ_TOPIC:TDMQ CMQ topic

  • TDMQ_CMQ_QUEUE:TDMQ CMQ queue

    Default value: USER_GROUP.
  • QueueName No String CMQ queue name. This parameter is required when TargetType is CMQ_QUEUE or TDMQ_CMQ_QUEUE.
    TopicName No String CMQ topic name. This parameter is required when TargetType is CMQ_TOPIC or TDMQ_CMQ_TOPIC.

    3. Output Parameters

    Parameter Name Type Description
    AutoScalingNotificationId String Notification ID.
    RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

    4. Example

    Example1 Creating the notification policy for scale-out results

    Input Example

    https://as.tencentcloudapi.com/?Action=CreateNotificationConfiguration
    &AutoScalingGroupId=asg-12wjuh0s
    &NotificationTypes.0=SCALE_OUT_SUCCESSFUL
    &NotificationTypes.1=SCALE_OUT_FAILED
    &NotificationUserGroupIds.0=1678
    &<Common request parameters>
    

    Output Example

    {
      "Response": {
        "AutoScalingNotificationId": "asn-2sestqbr",
        "RequestId": "fb02c8bd-5f38-4786-91b6-0c6e06a88832"
      }
    }
    

    Example2 Creating a policy to send notifications to the specified message queue for scale-out failures

    Input Example

    POST / HTTP/1.1
    Host: as.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: CreateNotificationConfiguration
    <Common request parameters>
    
    {
        "AutoScalingGroupId": "asg-pc2oqu2z",
        "NotificationTypes": [
            "SCALE_OUT_FAILED"
        ],
        "TargetType": "CMQ_QUEUE",
        "QueueName": "test-queue"
    }
    

    Output Example

    {
      "Response": {
        "AutoScalingNotificationId": "asn-03kyokwk",
        "RequestId": "8565bcc0-7b02-4e9c-ae9f-27e3d3d73e12"
      }
    }
    

    5. Developer Resources

    SDK

    TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

    Command Line Interface

    6. Error Code

    The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

    Error Code Description
    InvalidParameterValue.ConflictNotificationTarget Conflicting notification receiver type.
    InvalidParameterValue.InvalidAutoScalingGroupId Invalid scaling group ID.
    InvalidParameterValue.InvalidNotificationUserGroupId The notification group ID should be a numeric string.
    InvalidParameterValue.UserGroupIdNotFound The user group does not exist.
    LimitExceeded The quota limit is exceeded.
    LimitExceeded.QuotaNotEnough You are short of the quota.
    MissingParameter Parameter missing.
    ResourceNotFound.AutoScalingGroupNotFound The scaling group does not exist.
    ResourceNotFound.CmqQueueNotFound The specified CMQ queue does not exist.
    ResourceNotFound.TDMQCMQQueueNotFound The TDMQ-CMQ queue doesn't exist.
    ResourceNotFound.TDMQCMQTopicNotFound The TDMQ-CMQ topic doesn't exist.
    ResourceUnavailable.CmqTopicHasNoSubscriber There are no subscribers for the specified CMQ topic.
    ResourceUnavailable.TDMQCMQTopicHasNoSubscriber The TDMQ-CMQ topic is not subscribed.