Creating an AS Policy (V2)
Function
This API is used to create an AS policy for an AS group or bandwidth.
The difference between the V2 and V1 APIs for creating an AS policy is that V2 supports creating an AS policy for adjusting bandwidth and differentiating scaling resources by their types.
URI
POST /autoscaling-api/v2/{project_id}/scaling_policy
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Specifies the project ID. |
Request
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
scaling_policy_name |
Yes |
String |
Specifies the AS policy name. The name contains only letters, digits, underscores (_), and hyphens (-), and cannot exceed 64 characters. |
scaling_resource_id |
Yes |
String |
Specifies the scaling resource ID, which is the unique ID of an AS group or bandwidth.
|
scaling_resource_type |
Yes |
String |
Specifies the scaling resource type.
|
scaling_policy_type |
Yes |
String |
Specifies the AS policy type.
|
alarm_id |
No |
String |
Specifies the alarm rule ID. This parameter is mandatory when scaling_policy_type is set to ALARM. After this parameter is specified, the value of scheduled_policy does not take effect. After you create an alarm policy, the system automatically adds an alarm triggering activity of the autoscaling type to the alarm_actions field in the alarm rule specified by the parameter value. You can obtain the parameter value by querying Cloud Eye alarm rules. For details, see Querying the Alarm Rule List in Cloud Eye API Reference. |
scheduled_policy |
No |
scheduled_policy object |
Specifies the periodic or scheduled AS policy. This parameter is mandatory when scaling_policy_type is set to SCHEDULED or RECURRENCE. After this parameter is specified, the value of alarm_id does not take effect. For details, see Table 3. |
scaling_policy_action |
No |
scaling_policy_action object |
Specifies the scaling action of the AS policy. For details, see Table 4. |
interval_alarm_actions |
No |
Array of interval_alarm_actions objects |
Specifies the value range of an alarm policy. This parameter is valid and mandatory when scaling_policy_type is set to INTERVAL_ALARM. For details, see Table 5. |
cool_down_time |
No |
Integer |
Specifies the cooldown period (in seconds). The value ranges from 0 to 86400 and is 300 by default. |
description |
No |
String |
Specifies the description of the AS policy. The value can contain 1 to 256 characters. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
launch_time |
Yes |
String |
Specifies the time when the scaling action is triggered. The time format complies with UTC.
|
recurrence_type |
No |
String |
Specifies the periodic triggering type. This parameter is mandatory when scaling_policy_type is set to RECURRENCE.
|
recurrence_value |
No |
String |
Specifies the day when a periodic scaling action is triggered. This parameter is mandatory when scaling_policy_type is set to RECURRENCE.
|
start_time |
No |
String |
Specifies the start time of the scaling action triggered periodically. The time format complies with UTC. The default value is the local time. The time format is YYYY-MM-DDThh:mmZ. |
end_time |
No |
String |
Specifies the end time of the scaling action triggered periodically. The time format complies with UTC. This parameter is mandatory when scaling_policy_type is set to RECURRENCE. When the scaling action is triggered periodically, the end time cannot be earlier than the current and start time. The time format is YYYY-MM-DDThh:mmZ. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
operation |
No |
String |
Specifies the operation to be performed. The default operation is ADD.
|
size |
No |
Integer |
Specifies the operation size. The value is an integer from 0 to 300. The default value is 1. This parameter can be set to 0 only when operation is set to SET.
|
percentage |
No |
Integer |
Specifies the percentage of instances to be operated. If operation is set to ADD, REMOVE, or REDUCE, the value of this parameter is an integer from 1 to 20000. If operation is set to SET, the value is an integer from 0 to 20000.
|
limits |
No |
Integer |
Specifies the operation restrictions. If scaling_resource_type is set to BANDWIDTH and operation is not SET, this parameter takes effect and the unit is Mbit/s.
|
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
lower_bound |
No |
double |
Specifies the lower limit of the value range. The value is null by default. If the lower limit of the value range is null, the upper limit must be less than or equal to 0. The minimum lower limit allowed is -1.174271E108. |
upper_bound |
No |
double |
Specifies the upper limit of the value range. The value is null by default. If the upper limit of the range is null, the lower limit must be greater than or equal to 0. The maximum upper limit allowed is 1.174271E108. |
operation |
No |
String |
Specifies the operation to be performed. The default operation is ADD.
|
size |
No |
Integer |
Specifies the operation size. The value is an integer from 0 to 300. The default value is 1. This parameter can be set to 0 only when operation is set to SET.
|
percentage |
No |
Integer |
Specifies the percentage of instances to be operated. When the operation is ADD, REMOVE, or REDUCE, the value is an integer from 1 to 20000. When the operation is SET, the value is an integer from 0 to 20000.
|
limits |
No |
Integer |
Specifies the operation restrictions. If scaling_resource_type is set to BANDWIDTH and operation is not SET, this parameter takes effect and the unit is Mbit/s.
|
- The alarm value range of a refined scaling policy is the threshold of the alarm rule plus the upper and lower limits of the value range.
- If the lower limit of a value range is null, the minimum lower limit is -1.174271E108. If the upper limit of the range is null, the maximum upper limit is 1.174271E108.
For example:
You set the alarm rule for an AS policy to CPU usage ≥ 30% and add the following two value ranges:
Scaling Action is set to 30% ≤ CPU usage < 60%, add 1 instance. Then lower_bound should be set to 0 and upper_bound to 30.
Scaling Action is set to 60% ≤ CPU usage < positive infinite, add 2 instances. Then lower_bound should be set to 30 and upper_bound to 1.174271E108 or null.
- If neither the upper nor lower limit of a value range is null, they must be both greater than or equal to, or less than or equal to 0.
- If multiple refined scaling policies are added, their value ranges cannot overlap.
- If the operator of an alarm rule is =, no range can be added.
Example Request
POST https://{Endpoint}/autoscaling-api/v2/{project_id}/scaling_policy { "alarm_id": "al1513822380493GvlJKZwA8", "cool_down_time": 900, "scaling_resource_id": "8ade64b5-d685-40b8-8582-4ce306ea37a6", "scaling_resource_type": "BANDWIDTH", "scaling_policy_action": { "size": 1, "operation": "ADD", "limits": 10 }, "scaling_policy_name": "hth_aspolicy_1", "scaling_policy_type": "ALARM" }
Response
Parameter |
Type |
Description |
---|---|---|
scaling_policy_id |
String |
Specifies the AS policy ID. |
Example Response
{ "scaling_policy_id": "0h327883-324n-4dzd-9c61-68d03ee191dd" }
Returned Values
- Normal
- Abnormal
Returned Value
Description
400 Bad Request
The server failed to process the request.
401 Unauthorized
You must enter the username and password to access the requested page.
403 Forbidden
You are forbidden to access the requested page.
404 Not Found
The server could not find the requested page.
405 Method Not Allowed
You are not allowed to use the method specified in the request.
406 Not Acceptable
The response generated by the server could not be accepted by the client.
407 Proxy Authentication Required
You must use the proxy server for authentication to process the request.
408 Request Timeout
The request timed out.
409 Conflict
The request could not be processed due to a conflict.
500 Internal Server Error
Failed to complete the request because of an internal service error.
501 Not Implemented
Failed to complete the request because the server does not support the requested function.
502 Bad Gateway
Failed to complete the request because the request is invalid.
503 Service Unavailable
Failed to complete the request because the system is unavailable.
504 Gateway Timeout
A gateway timeout error occurred.
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot