tencent cloud

文档反馈

CreateNotificationConfiguration

最后更新时间:2024-10-25 15:16:19

    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.

    Parameter Name Required Type Description
    Action Yes String Common Params. The value used for this API: CreateNotificationConfiguration.
    Version Yes String Common Params. The value used for this API: 2018-04-19.
    Region Yes String Common Params. 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, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem.

    4. Example

    Example1 Creating the notification policy for scale-out results

    Input Example

    POST / HTTP/1.1
    Host: as.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: CreateNotificationConfiguration
    <Common request parameters>
    
    {
        "AutoScalingGroupId": "asg-12wjuh0s",
        "NotificationUserGroupIds": [
            "1678"
        ],
        "NotificationTypes": [
            "SCALE_OUT_FAILED",
            "SCALE_OUT_SUCCESSFUL"
        ]
    }
    

    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
    InvalidParameter.ActionNotFound Invalid Action request.
    InvalidParameterValue.ConflictNotificationTarget Conflicting notification receiver type.
    InvalidParameterValue.InvalidAutoScalingGroupId Invalid scaling group ID.
    InvalidParameterValue.InvalidNotificationUserGroupId The notification group ID should be a numeric string.
    InvalidParameterValue.LimitExceeded The value exceeds the limit.
    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.
    联系我们

    联系我们,为您的业务提供专属服务。

    技术支持

    如果你想寻求进一步的帮助,通过工单与我们进行联络。我们提供7x24的工单服务。

    7x24 电话支持