Help Center/ Auto Scaling/ API Reference/ Application Examples/ Example 3: Enabling an AS Group
Updated on 2022-09-22 GMT+08:00

Example 3: Enabling an AS Group

Scenarios

This section describes how to enable an AS group by calling APIs. For details, see Calling APIs.

An AS group consists of a collection of instances that apply to the same scenario. It is the basis for enabling or disabling AS policies and performing scaling actions.

Only enabled AS groups support scaling actions.

Involved APIs

Procedure

  1. Determine the user token that can be used to authenticate the calling of other APIs.

    1. View the user token. For details, see Obtaining a User Token.
    1. Obtain the value of X-Subject-Token in the response header.

  1. Determine the AS group.

    1. View AS groups.
      • API

        URI format: GET /autoscaling-api/v1/{project_id}/scaling_group

        For details, see Querying AS Groups.

      • Example request

        This example shows how to query AS groups with AS configuration ID 1d281494-6085-4579-b817-c1f813be835f.

        GET https://{Endpoint}/autoscaling-api/v1/0605767c2e80d5762fd0c0146a10aaf2/scaling_group?scaling_configuration_id=1d281494-6085-4579-b817-c1f813be835f

        Obtain {endpoint} from Regions and Endpoint.

      • Example response
        {
          "limit": 20,
          "scaling_groups": [
              {
                  "networks": [
                      {
                          "id": "a8327883-6b07-4497-9c61-68d03ee193a",
                          "ipv6_enable": true,
                          "ipv6_bandwidth": 
                          {
                              "id": "076ee2ff-f23e-4338-b8ac-1bc7278532d5"
                          }
                      }
                  ],
                  "available_zones": [
                      "XXXa",
                      "XXXb"
                  ],
                  "detail": null,
                  "scaling_group_name": "as-group-test",
                  "scaling_group_id": "77a7a397-7d2f-4e79-9da9-6a35e2709150",
                  "scaling_group_status": "INSERVICE",
                  "scaling_configuration_id": "1d281494-6085-4579-b817-c1f813be835f",
                  "scaling_configuration_name": "healthCheck",
                  "current_instance_number": 0,
                  "desire_instance_number": 1,
                  "min_instance_number": 0,
                  "max_instance_number": 500,
                  "cool_down_time": 300,
                  "lb_listener_id": "f06c0112570743b51c0e8fbe1f235bab",
                  "security_groups": [
                      {
                          "id": "8a4b1d5b-0054-419f-84b1-5c8a59ebc829"
                      }
                  ],
                  "create_time": "2015-07-23T02:46:29Z",
                  "vpc_id": "863ccae2-ee85-4d27-bc5b-3ba2a198a9e2",
                  "health_periodic_audit_method": "ELB_AUDIT",
                  "health_periodic_audit_time": 5,
                  "health_periodic_audit_grace_period": 600,
                  "instance_terminate_policy": "OLD_CONFIG_OLD_INSTANCE",
                  "is_scaling": false,
                  "delete_publicip": false,
                  "enterprise_project_id": "c92b1a5d-6f20-43f2-b1b7-7ce35e58e413",
                  "multi_az_priority_policy": "PICK_FIRST"
              }
          ],
          "total_number": 1,
          "start_number": 0
        }

    1. Select an AS group and record the AS group ID.

  1. Enable the specified AS group.

    • API

      URI format: POST /autoscaling-api/v1/{project_id}/scaling_group/{scaling_group_id}/action

      For details, see Enabling or Disabling an AS Group.

    • Example request

      POST: https://{Endpoint}/autoscaling-api/v1/0605767c2e80d5762fd0c0146a10aaf2/scaling_group/77a7a397-7d2f-4e79-9da9-6a35e2709150/action

      Obtain {endpoint} from Regions and Endpoint.

      Body:

      {
          "action": "resume"
      }

    • Example response

    The HTTP status code 204 is returned.