Updated on 2023-06-29 GMT+08:00

Binding a Request Throttling Policy

Function

The request throttling policy bound to an API will control access of all users to the API.

If the number of API calls within a specified period reaches the limit, subsequent access will be rejected, protecting the backend API from abnormal traffic and ensuring stable service running.

This API is used to bind a request throttling policy to an API that has been published in an environment. You can bind different request throttling policies to an API in different environments, but can bind only one request throttling policy to the API in each environment.

URI

POST /v2/{project_id}/apic/instances/{instance_id}/throttle-bindings

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details about how to obtain the project ID, see Appendix > Obtaining a Project ID in the ROMA Connect API Reference.

instance_id

Yes

String

Instance ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token, which can be obtained by calling the IAM API (value of X-Subject-Token in the response header).

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

strategy_id

Yes

String

Request throttling policy ID.

Minimum: 1

Maximum: 65

publish_ids

Yes

Array of strings

API publication record ID.

Response Parameters

Status code: 201

Table 4 Response body parameters

Parameter

Type

Description

throttle_applys

Array of ThrottleApiBinding objects

List of binding relationships between APIs and request throttling policies.

Table 5 ThrottleApiBinding

Parameter

Type

Description

publish_id

String

API publication record ID.

scope

Integer

Scope of the request throttling policy.

  • 1: the entire API

  • 2: a user

  • 3: an app

Currently, only 1 is supported.

strategy_id

String

Request throttling policy ID.

apply_time

String

Time when the policy is bound to the API.

id

String

Binding record ID.

Status code: 401

Table 6 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error description.

Status code: 403

Table 7 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error description.

Status code: 404

Table 8 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error description.

Status code: 500

Table 9 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error description.

Example Requests

{
  "publish_ids" : [ "40e7162dc6b94bbbbb1a60d2a24b1b0c" ],
  "strategy_id" : "3437448ad06f4e0c91a224183116e965"
}

Example Responses

Status code: 201

Created

{
  "throttle_applys" : [ {
    "publish_id" : "40e7162dc6b94bbbbb1a60d2a24b1b0c",
    "scope" : 1,
    "strategy_id" : "3437448ad06f4e0c91a224183116e965",
    "apply_time" : "2020-08-03T12:25:52.257613934Z",
    "id" : "3e06ac135e18477e918060d3c59d6f6a"
  } ]
}

Status code: 401

Unauthorized

{
  "error_code" : "APIG.1002",
  "error_msg" : "Incorrect token or token resolution failed"
}

Status code: 403

Forbidden

{
  "error_code" : "APIG.1005",
  "error_msg" : "No permissions to request this method"
}

Status code: 404

Not Found

{
  "error_code" : "APIG.3005",
  "error_msg" : "Request throttling policy 3437448ad06f4e0c91a224183116e965 does not exist"
}

Status code: 500

Internal Server Error

{
  "error_code" : "APIG.9999",
  "error_msg" : "System error"
}

Status Codes

Status Code

Description

201

Created

401

Unauthorized

403

Forbidden

404

Not Found

500

Internal Server Error

Error Codes

See Error Codes.