Introduction

IBM Cloud provides the capability to automatically optimize the resource allocation of your application through Auto-Scaling service. You can use the Auto-Scaling service to automatically increase or decrease the compute capacity of your Cloud Foundry applications. The number of application instances is adjusted dynamically based on the Auto-Scaling policy you defined.

The Auto-Scaling service provides common APIs to control this behavior by create/update/delete/get/enable/disable Auto-Scaling policy. Also common APIs like get scaling history can be used to retrieve the scaling action by Auto-Scaling service.

Error handling

This API uses standard HTTP response codes to indicate whether a method completed successfully. A 200 or 201 response always indicates success. A 400 type response is some sort of error in the parameters provided, A 401 type response is some sort of unauthorized Error, and a 404 type response usually indicates some resource related to this request is not found.

Pagination

Some API requests might return a large number of results. To avoid performance issues, these results are returned one page at a time, with a limited number of results on each page. GET requests for the following resources use pagination:

  • /apps/{app_id}/scalinghistory

The default page and max size is 300 records. When not all the record is returned, the timestamp in the response indicated the timestamp in the latest record, and user can use this timestamp to initiate another request to fetch more data. When all record per request is returned, timestamp in the response is set to 0

Rate limiting

There is no Rate limits for API currently in Auto-Scaling RESTful API, but due to the implementation, response to certain RESTful API might not return immediately when back-end server load is high.

Methods

Get an existing Policy information by application ID

You can use this API endpoint to get existing Auto-scaling policy data.

GET /apps/{app_id}/policy
Request

Custom Headers

  • The user must login CloudFoundry and provide a valid access token. The AccessToken can be obtained by command cf oauth-token.

Path Parameters

  • ID of application that assocated with this operation

Response

Status Code

  • Policy information has been retrieved successfully

  • Invalid parameters supplied

  • Unauthorized for this operation

  • Can not find the application by app_id, or no policy has been not found that has been assocated with this application

Example responses

Add a new Policy to the application, when policy exists, it just been updated

You can use this API endpoint to attach your application with Auto-scaling policy.

PUT /apps/{app_id}/policy
Request

Custom Headers

  • The user must login CloudFoundry and provide a valid access token. The AccessToken can be obtained by command cf oauth-token.

Path Parameters

  • ID of application that assocated with this operation

calendar-based scaling settings in this policy

Response

Status Code

  • Policy has been updated successfully

  • Policy has been created and bound with application successfully

  • Invalid parameters supplied

  • Unauthorized for this operation

  • Can not find the application by app_id, or application does not bind with Auto-scaling service

Example responses

Delete an existing Policy, and detach it with application

You can use this API endpoint to delete existing Auto-scaling policy.

DELETE /apps/{app_id}/policy
Request

Custom Headers

  • The user must login CloudFoundry and provide a valid access token. The AccessToken can be obtained by command cf oauth-token.

Path Parameters

  • ID of application that assocated with this operation

Response

Status Code

  • successful operation and policy deleted

  • Invalid parameters supplied

  • Unauthorized for this operation

  • Can not find the application by app_id, or no policy has been not found that has been assocated with this application

Example responses

Find current policy status

Find current policy status of this application, or return error if no policy is found with this application or other error happened

GET /apps/{app_id}/policy/status
Request

Custom Headers

  • The user must login CloudFoundry and provide a valid access token. The AccessToken can be obtained by command cf oauth-token.

Path Parameters

  • ID of application that assocated with this operation

Response

Status Code

  • successful operation

  • Invalid parameters provided

  • Unauthorized for this operation

  • Can not find the application by app_id, or no policy has been not found that has been assocated with this application

Example responses

Set current policy status

In this endpoint, it will try to find the policy assocated with this application and return its current status or error if no policy is found with this application or other error happened

PUT /apps/{app_id}/policy/status
Request

Custom Headers

  • The user must login CloudFoundry and provide a valid access token. The AccessToken can be obtained by command cf oauth-token.

Path Parameters

  • ID of application that assocated with this operation

to enable or disable the policy

Response

Status Code

  • successful operation

  • Invalid parameters provided

  • Unauthorized for this operation

  • Can not find the application by app_id, or no policy has been not found that has been assocated with this application

Example responses

Returns scaling history data

Returns a map of timestamp and an array of scaling history data

GET /apps/{app_id}/scalinghistory
Request

Custom Headers

  • The user must login CloudFoundry and provide a valid access token. The AccessToken can be obtained by command cf oauth-token.

Path Parameters

  • ID of application that assocated with this operation

Query Parameters

  • timestamp in millisecond of start time that to narrow down the scaling history data

  • timestamp in millisecond of end time that to narrow down the scaling history data

Response

Status Code

  • successful operation and scaling history returned

  • Invalid parameters provided

  • Unauthorized for this operation

  • Can not find the application by app_id, or no policy has been not found that has been assocated with this application

Example responses