Skip to main content

How to use OpenAPI

How to call console OpenAPI

  1. Before calling the console OpenAPI, the user needs to click the personal center-access token-add in the upper right corner of the platform to create an access token for authorization
  2. Before calling the console OpenAPI, make sure you have obtained the access token required by the API and added it to the request header
  3. Only relative paths are displayed in the OpenAPI documentation, such as /openapi/v1/administrators, and the actual request path is not displayed.You need to piece together your console access address as a path to form the full

OpenAPI Documentation Convention Format

The console OpenAPI document format is mainly as:

Basic information: Introduce what the API does
Request method: Introduce the request methods required by the API (POST, PUT, DELETE, GET, etc.)
Request parameters: A brief description of the path parameters and query parameters used by the API
Request Body: This part of the parameters needs to be placed in the Body of the HTTP request, usually in JSON format
Request body example: Example of a successful request parameter corresponding to the API
Response body: After an API call, the body part of the HTTP response Content
Example Response Body: Example of API Successful Request Result

OpenAPI common parameter description

The following parameters are descriptions of the path parameters that are often used when calling the platform.

nameLocationtypeChinese nameillustrate
team_idpathstringTeam IDID that identifies a team, 32-bit string
app_idpathintApp IDIdentifies an application, integer
service_idpathstringcomponent IDID that identifies a component, 32-bit string
region_namepathstringCluster unique identifierA name that identifies a cluster, unique under the enterprise, user-defined value
user_idpathintUser IDID that identifies a user, integer

Parameter acquisition and interface example

Rainbond is mainly divided into four views:enterprise view, team view, application view, and component view, so Openapi documents are also organized according to this logic.

The following describes the specific request sample:

Get the list of teams under the enterprise

curl -X GET '' -H 'Authorization: <Please fill in the access token>obtained from the console here'

Example of response result

Here tenant_id corresponds to the value of team_id

"tenant_alias":"admin's team",
"is_active": true,
"role_id": "1",

Get a list of clusters

curl -X GET '' -H 'Authorization: <Please fill in the access token>obtained from the console here'

Example of response result

region_name here corresponds to the unique identifier of the cluster

"region_alias":"Self-built cluster",
"desc":"Provide host to install Kubernetes cluster and connect",
"key_file" :null

Get application list

team_id and region_name Please fill in the response values obtained from the above two interfaces

curl -X GET '{team_id}/regions/{region_name}/apps' -H 'Authorization: <Please fill in the access token>obtained from the console here'

Example of response result

Here ID corresponds to app_id

"group_name":"Test Application",
"order_index": 0,
"update_time":" 2022-06-15T15:37:51.020167",
" logo":"",

build components

According to the above interface request example, we can continue to find the corresponding service_id to operate the component.Here is an example of building a component

curl -X POST '{team_id}/regions/{region_name}/apps/{app_id}/services/{service_id}/build' -H 'Authorization: <here please fill in from the console Obtained access token>'

Example of response result

"event_id": "5821167607ec460b89b326084fb3d1e0"