Help Center/ Auto Scaling/ API Reference/ APIs/ AS Policies/ Modifying an AS Policy (V2)
Updated on 2026-10-13 GMT+08:00

Modifying an AS Policy (V2)

Function

This API is used to modify a specified AS policy.

The difference between the V2 and V1 APIs for modifying an AS policy is that V2 supports modifying a scaling resource type.

URI

PUT /autoscaling-api/v2/{project_id}/scaling_policy/{scaling_policy_id}

Table 1 Parameter description

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition

Specifies the project ID. For details, see Obtaining a Project ID.

Constraints

N/A

Range

N/A

Default Value

N/A

scaling_policy_id

Yes

String

Definition

Specifies an AS policy ID. For details, see Querying AS Policies Bound to a Scaling Resource (V2).

Constraints

N/A

Range

N/A

Default Value

N/A

Request

Table 2 Request parameters

Parameter

Mandatory

Type

Description

scaling_policy_name

No

String

Definition

Specifies the AS policy name.

Constraints

N/A

Range

The value can contain 1 to 64 characters. Only letters, digits, underscores (_), and hyphens (-) are allowed.

Default Value

N/A

scaling_policy_type

No

String

Definition

Specifies the AS policy type.

Constraints

N/A

Range

  • ALARM (corresponding to alarm_id): indicates that the scaling action is triggered by an alarm.
  • SCHEDULED (corresponding to scheduled_policy): indicates that the scaling action is triggered as scheduled.
  • RECURRENCE (corresponding to scheduled_policy): indicates that the scaling action is triggered periodically.
  • INTERVAL_ALARM (corresponding to alarm_id): indicates that the scaling action is triggered by a refined scaling policy.

Default Value

N/A

scaling_resource_id

No

String

Definition

Specifies the scaling resource ID, which is the ID of a unique AS group or bandwidth. To obtain an AS group ID, see Querying AS Groups. To obtain a bandwidth ID, see Querying Bandwidths.

  • If scaling_resource_type is set to SCALING_GROUP, this parameter indicates a unique AS group ID.
  • If scaling_resource_type is set to BANDWIDTH, this parameter indicates a unique bandwidth ID.

Constraints

AS cannot scale yearly/monthly bandwidths.

Range

N/A

Default Value

N/A

scaling_resource_type

No

String

Definition

Specifies the scaling resource type.

Constraints

N/A

Range

  • SCALING_GROUP: AS group
  • BANDWIDTH: bandwidth

Default Value

N/A

alarm_id

No

String

Definition

Specifies the alarm rule ID. After you modify 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 Alarm Rules in Cloud Eye API Reference.

Constraints

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.

Range

N/A

Default Value

N/A

scheduled_policy

No

scheduled_policy object

Definition

Specifies the periodic or scheduled AS policy. For details, see Table 3.

Constraints

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.

Range

N/A

Default Value

N/A

scaling_policy_action

No

scaling_policy_action object

Definition

Specifies the scaling action of the AS policy. For details, see Table 4.

Constraints

N/A

interval_alarm_actions

No

Array of interval_alarm_actions objects

Definition

Specifies the value range of an alarm policy. For details, see Table 5.

Constraints

This parameter is valid and mandatory when scaling_policy_type is set to INTERVAL_ALARM.

cool_down_time

No

Integer

Definition

Specifies the cooldown period, in seconds.

Constraints

During the cooldown period, AS denies all scaling requests triggered by alarm-based policies. Scaling requests triggered manually or by scheduled or periodic policies are not affected.

Range

0s to 86,400s

Default Value

300

description

No

String

Definition

Specifies the AS policy description.

Constraints

N/A

Range

1 to 256 characters

Default Value

N/A

Table 3 scheduled_policy field description

Parameter

Mandatory

Type

Description

launch_time

Yes

String

Definition

Specifies the time when the scaling action is triggered. The time format complies with UTC.

Constraints

  • If scaling_policy_type is set to SCHEDULED, the time format is YYYY-MM-DDThh:mmZ.
  • If scaling_policy_type is set to RECURRENCE, the time format is hh:mm.

Range

N/A

Default Value

N/A

recurrence_type

No

String

Definition

Specifies the type of a periodically triggered scaling action.

Constraints

This parameter is mandatory when scaling_policy_type is set to RECURRENCE.

Range

  • Daily: The scaling action is triggered once a day.
  • Weekly: The scaling action is triggered once a week.
  • Monthly: The scaling action is triggered once a month.

Default Value

N/A

recurrence_value

No

String

Definition

Specifies the day when a periodic scaling action is triggered.

Constraints

This parameter is mandatory when scaling_policy_type is set to RECURRENCE.

Range

  • If recurrence_type is set to Daily, the value is null, indicating that the scaling action is triggered once a day.
  • If recurrence_type is set to Weekly, the value ranges from 1 (Sunday) to 7 (Saturday). The digits refer to dates in each week and separated by a comma, such as 1,3,5.
  • If recurrence_type is set to Monthly, the value ranges from 1 to 31. The digits refer to the dates in each month and separated by a comma, such as 1,10,13,28.

Default Value

N/A

start_time

No

String

Definition

Specifies the start time of the scaling action triggered periodically. The time format complies with UTC.

The time format is YYYY-MM-DDThh:mmZ.

Constraints

N/A

Range

N/A

Default Value

The default value is the current time.

end_time

No

String

Definition

Specifies the end time of the scaling action triggered periodically. The time format complies with UTC.

The time format is YYYY-MM-DDThh:mmZ.

Constraints

  • 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 or the start time.

Range

N/A

Default Value

N/A

Table 4 scaling_policy_action field description

Parameter

Mandatory

Type

Description

operation

No

String

Definition

Specifies the operation to be performed.

Constraints

N/A

Range

  • If scaling_resource_type is set to SCALING_GROUP, the following operations are supported:
    • ADD: adds instances to the AS group.
    • REMOVE/REDUCE: removes or reduces instances from the AS group.
    • SET: sets the number of instances in the AS group.
  • If scaling_resource_type is set to BANDWIDTH, the following operations are supported:
    • ADD: increases the bandwidth.
    • REDUCE: decreases the bandwidth.
    • SET: sets the bandwidth to a fixed value.

Default Value

ADD

size

No

Integer

Definition

Specifies the operation size.

Constraints

  • This parameter can be set to 0 only when operation is set to SET.
  • If scaling_resource_type is set to SCALING_GROUP, either size or percentage can be set.

Range

  • If scaling_resource_type is set to SCALING_GROUP, this parameter indicates the number of instances. The value is an integer ranging from 0 to 300 and the default value is 1.
  • If scaling_resource_type is set to BANDWIDTH, this parameter indicates the bandwidth (Mbit/s). The value is an integer ranging from 1 to 300 and the default value is 1.

Default Value

1

percentage

No

Integer

Definition

Specifies the percentage of instances to be operated.

Constraints

  • If scaling_resource_type is set to SCALING_GROUP, either size or percentage can be set. If neither size nor percentage is set, the default value of size is 1.
  • If scaling_resource_type is set to BANDWIDTH, percentage is unavailable.

Range

  • If operation is set to ADD, REMOVE, or REDUCE, the value is an integer ranging from 1 to 20000.
  • If operation is set to SET, the value is an integer ranging from 0 to 20000.

Default Value

1

limits

No

Integer

Definition

Specifies the operation restrictions.

  • If operation is set to ADD, this parameter indicates the maximum bandwidth allowed.
  • If operation is set to REDUCE, this parameter indicates the minimum bandwidth allowed.

Constraints

If scaling_resource_type is set to BANDWIDTH and operation is not SET, this parameter takes effect and the unit is Mbit/s.

Range

N/A

Default Value

N/A

Table 5 interval_alarm_actions field description

Parameter

Mandatory

Type

Description

lower_bound

No

double

Definition

Specifies the lower limit of the value range.

Constraints

  • 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.

Range

N/A

Default Value

null

upper_bound

No

double

Definition

Specifies the upper limit of the value range.

Constraints

  • 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.

Range

N/A

Default Value

null

operation

No

String

Definition

Specifies the operation to be performed.

Constraints

N/A

Range

  • If scaling_resource_type is set to SCALING_GROUP, the following operations are supported:
    • ADD: adds instances to the AS group.
    • REMOVE/REDUCE: removes or reduces instances from the AS group.
    • SET: sets the number of instances in the AS group.
  • If scaling_resource_type is set to BANDWIDTH, the following operations are supported:
    • ADD: increases the bandwidth.
    • REDUCE: decreases the bandwidth.
    • SET: sets the bandwidth to a fixed value.

Default Value

ADD

size

No

Integer

Definition

Specifies the operation size.

Constraints

  • This parameter can be set to 0 only when operation is set to SET.
  • If scaling_resource_type is set to SCALING_GROUP, either size or percentage can be set.

Range

  • If scaling_resource_type is set to SCALING_GROUP, this parameter indicates the number of instances. The value is an integer ranging from 0 to 300 and the default value is 1.
  • If scaling_resource_type is set to BANDWIDTH, this parameter indicates the bandwidth (Mbit/s). The value is an integer ranging from 1 to 300 and the default value is 1.

Default Value

1

percentage

No

Integer

Definition

Specifies the percentage of instances to be operated.

Constraints

  • If scaling_resource_type is set to SCALING_GROUP, either size or percentage can be set. If neither size nor percentage is set, the default value of size is 1.
  • If scaling_resource_type is set to BANDWIDTH, percentage is unavailable.

Range

  • If operation is set to ADD, REMOVE, or REDUCE, the value is an integer ranging from 1 to 20000.
  • If operation is set to SET, the value is an integer ranging from 0 to 20000.

Default Value

N/A

limits

No

Integer

Definition

Specifies the operation restrictions.

  • If operation is set to ADD, this parameter indicates the maximum bandwidth allowed.
  • If operation is set to REDUCE, this parameter indicates the minimum bandwidth allowed.

Constraints

If scaling_resource_type is set to BANDWIDTH and operation is not SET, this parameter takes effect and the unit is Mbit/s.

Range

N/A

Default Value

N/A

  • 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

This example modifies an AS policy with ID 0h327883-324n-4dzd-9c61-68d03ee191dd. The AS policy name is changed to hth_aspolicy_1, the alarm rule ID is changed to al1513822380493GvlJKZwA8, the cooldown period is changed to 900 seconds, and the scaling action is changed to increase the bandwidth by 1 Mbit/s until the bandwidth reaches 10 Mbit/s.

PUT https://{Endpoint}/autoscaling-api/v2/{project_id}/scaling_policy/0h327883-324n-4dzd-9c61-68d03ee191dd

{
    "alarm_id": "al1513822380493GvlJKZwA8",
    "cool_down_time": 900,
    "scaling_policy_action": {
           "size": 1,
           "operation": "ADD",
           "limits": 10
    },
    "scaling_policy_name": "hth_aspolicy_1",
    "scaling_policy_type": "ALARM"
}

Response

Table 6 Response parameters

Parameter

Type

Description

scaling_policy_id

String

Definition

Specifies the AS policy ID.

Range

N/A

Example Response

{ 
     "scaling_policy_id": "0h327883-324n-4dzd-9c61-68d03ee191dd"  
}

Returned Values

  • Normal

    200

  • 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.