Routing rules
This topic lists the OpenAPI operations for contact methods and their corresponding request and response parameters.
Create a routing rule
Use sofa.apigateway.router.create to create a routing rule.
Request parameters
Name | Type | Required | Example | Description |
param | RouterInfoVO | Yes | - | parameter |
tenant_id | STRING | Yes | TSCPDICNT | The tenant identity. |
workspace_id | STRING | Yes | default | Workspace Identity |
Response parameters
Name | Type | Example | Description |
data | RouterInfoVO | The data. |
Code examples
Request example
{
"param":{
"router_name":"router1",
"router_type":"HEADER",
"upstream_protocol":"HTTP",
"router_configs":[
{
"arg_key":"param1",
"match_type":"IN",
"arg_value":"value1",
"sys_id":"cBfmcHFVNMXmTrEWFH4FsZf9wDPLndt8"
}
]
},
"tenant_id":"JADDGOCN",
"workspace_id":"antdemo"
}Response Example
{
"data":{
"router_configs":[
{
"sysId":"cBfmcHFVNMXmTrEWFH4FsZf9wDPLndt8",
"argKey":"param1",
"matchType":"IN",
"routerType":"HEADER",
"argValue":"value1"
}
],
"upstream_protocol":"HTTP",
"router_id":"7SpBBxXzQp8UzRVZ",
"router_name":"router1",
"router_type":"HEADER",
"operator":""
},
"result_code":"OK"
}Delete a routing rule
You can use sofa.apigateway.router.delete to delete a specified routing rule.
Request parameters
Name | Type | Required | Example | Description |
router_id | STRING | Yes | 8Amfi67dmE9wpY46 | The routing rule identity. |
tenant_id | STRING | Yes | TSCPDICNT | The tenant identity. |
workspace_id | STRING | Yes | default | The workspace identity. |
Response parameters
Name | Type | Example | Description |
data | BOOLEAN | true, false | Data |
Code examples
Example request
{
"router_id":"uY2fA0kL9qf1lbqy",
"tenan_id":"JADDGOCN",
"workspace_id":"antdemo"
}Example response
{
"data":true,
"result_code":"OK"
}Update a routing rule
Use sofa.apigateway.router.update to update a routing rule.
Request parameters
Name | Type | Required | Example | Description |
param | RouterInfoVO | No | - | parameter |
tenant_id | STRING | Yes | TSCPDICNT | The tenant identity. |
workspace_id | STRING | Yes | default | The workspace identity. |
Response parameters
Name | Type | Example | Description |
data | BOOLEAN | true, false | data |
Code examples
Sample Request
{
"param":{
"router_name":"router3",
"router_type":"HEADER",
"upstream_protocol":"HTTP",
"router_id":"uY2fA0kL9qf1lbqy",
"router_configs":[
{
"arg_key":"param1",
"weight":null,
"match_type":"IN",
"arg_value":"value1",
"sys_id":"cBfmcHFVNMXmTrEWFH4FsZf9wDPLndt8"
}
]
},
"tenant_id":"JADDGOCN",
"workspace_id":"antdemo"
}Sample Response
{
"data":true,
"result_code":"OK"
}Query a routing rule by ID
You can use sofa.apigateway.router.get to query the configuration of a specified routing rule.
Request parameters
Name | Type | Required | Example | Description |
router_id | STRING | Yes | 8Amfi67dmE9wpY46 | The routing rule identity. |
tenant_id | STRING | Yes | TSCPDICNT | The tenant identity. |
workspace_id | STRING | Yes | default | The workspace identity. |
Response Parameters
Name | Type | Example | Description |
data | RouterInfoVO | - | Data |
Code examples
Example request
{
"router_id":"7SpBBxXzQp8UzRVZ",
"tenant_id":"JADDGOCN",
"workspace_id":"antdemo"
}Sample response
{
"data":{
"gmt_create":"2020-03-27 02:14:18",
"router_configs":[
{
"systemCluster":{
"gmtModified":"2020-03-25 15:14:27",
"sysType":"URL",
"sysId":"cBfmcHFVNMXmTrEWFH4FsZf9wDPLndt8",
"host":[
"123.4.2:80"
],
"sysName":"ffff",
"tenantId":"JADDGOCN",
"upstreamProtocol":"HTTP",
"apiCount":1,
"gmtCreate":"2020-03-25 15:14:18",
"operator":"",
"workspaceId":"antdemo"
},
"sysId":"cBfmcHFVNMXmTrEWFH4FsZf9wDPLndt8",
"argKey":"param1",
"matchType":"IN",
"routerType":"HEADER",
"argValue":"value1"
}
],
"upstream_protocol":"HTTP",
"router_id":"7SpBBxXzQp8UzRVZ",
"router_name":"router2",
"gmt_modified":"2020-03-27 02:14:18",
"router_type":"HEADER",
"operator":""
},
"result_code":"OK"
}Query a list of routing rules
You can use sofa.apigateway.router.all to query all routing rules.
Request parameters
Name | Type | Required | Example | Description |
param | RouterInfoQueryVO | No | - | parameter |
tenant_id | STRING | Yes | TSCPDICNT | The tenant identity. |
workspace_id | STRING | Yes | default | The workspace identity. |
Response parameters
Name | Type | Example | Description |
data | ARRAY[RouterInfoVO] | - | Data |
Code examples
Example request
{
"param":{
"page_info":{
"page_index":1,
"page_size":10
},
"query":{
"router_name":null
}
},
"tenant_id":"JADDGOCN",
"workspace_id":"antdemo"
}Example response
{
"data":[
{
"gmtModified":"2020-03-27 02:14:18",
"routerName":"router2",
"routerId":"7SpBBxXzQp8UzRVZ",
"routerType":"HEADER",
"upstreamProtocol":"HTTP",
"gmtCreate":"2020-03-27 02:14:18",
"operator":""
},
{
"gmtModified":"2020-03-26 11:58:29",
"routerName":"rrrr",
"routerId":"aPdifmIr852vfqE4",
"routerType":"HEADER",
"upstreamProtocol":"HTTP",
"apiCount":1,
"gmtCreate":"2020-03-25 15:15:08",
"operator":""
}
],
"result_code":"OK"
}Query a paginated list of routing rules
You can use sofa.apigateway.router.list to query a paginated list of routing rules.
Request parameters
Name | Type | Required | Example | Description |
param | RouterInfoQueryVO | No | - | Parameter |
tenant_id | STRING | Yes | TSCPDICNT | The tenant identity. |
workspace_id | STRING | Yes | default | The workspace identity. |
Response parameters
Name | Type | Example | Description |
data | RouterInfoPagedListVO | - | data |
Code examples
Sample request
{
"param":{
"page_info":{
"page_index":1,
"page_size":10
},
"query":{
"router_name":null
}
},
"tenant_id":"JADDGOCN",
"workspace_id":"antdemo"
}Response example
{
"data":{
"page_info":{
"total":2,
"page_index":1,
"page_size":10
},
"list":[
{
"gmtModified":"2020-03-27 02:14:18",
"routerName":"router2",
"routerId":"7SpBBxXzQp8UzRVZ",
"routerType":"HEADER",
"upstreamProtocol":"HTTP",
"gmtCreate":"2020-03-27 02:14:18",
"operator":""
},
{
"gmtModified":"2020-03-26 11:58:29",
"routerName":"rrrr",
"routerId":"aPdifmIr852vfqE4",
"routerType":"HEADER",
"upstreamProtocol":"HTTP",
"apiCount":1,
"gmtCreate":"2020-03-25 15:15:08",
"operator":""
}
]
},
"result_code":"OK"
}Query a list of APIs by routing rule ID
You can use sofa.apigateway.router.api.all to query all APIs that use a specific routing rule.
Request parameters
Name | Type | Required | Example | Description |
param | ApiInfoQueryVO | No | - | parameter |
router_id | STRING | Yes | 8Amfi67dmE9wpY46 | The routing rule ID. |
tenant_id | STRING | Yes | TSCPDICNT | The tenant identity. |
workspace_id | STRING | Yes | default | Workspace Identity |
Response parameters
Name | Type | Example | Description |
data | ARRAY[ApiInfoVO] | - | Data |
Code examples
Example request
{
"param":{
"page_info":{
"page_size":10,
"page_index":1
},
"query":{
"api_name":null
}
},
"router_id":"aPdifmIr852vfqE4"
}Response Example
{
"data":{
"page_info":{
"total":1,
"page_index":1,
"page_size":10
},
"list":[
{
"charset":"UTF-8",
"apiName":"rrrwe",
"gmtModified":"2020-03-26 11:58:29",
"method":"GET",
"upstreamPath":"/werwer",
"routerType":"HEADER",
"upstreamProtocol":"HTTP",
"gmtCreate":"2020-03-25 15:15:12",
"timeout":3000,
"operator":"",
"path":"/werwer",
"apiGroupId":"dumebnn9gbnyy02y",
"appType":"STANDARD_AND_MPAAS",
"routerId":"aPdifmIr852vfqE4",
"downstreamProtocol":"HTTP",
"domainName":"dumebnn9gbnyy02y.apigateway.inc.alipay.net",
"apiGroupName":"test_aalq",
"tenantId":"JADDGOCN",
"operationType":"wer.wer",
"contentType":"application/json",
"upstreamType":"SYSTEM_CLUSTER",
"apiId":"1h3WttiKTeTUtZpWn5Xg5P5bu2UBGjrP",
"apiStatus":"CLOSED",
"workspaceId":"antdemo"
}
]
},
"result_code":"OK"
}Query a paginated list of APIs by routing rule ID
You can use sofa.apigateway.router.api.list to query for a paginated list of APIs that use a specific routing rule.
Request Parameters
Name | Type | Required | Example | Description |
param | ApiInfoQueryVO | No | - | Parameter |
router_id | STRING | Yes | 8Amfi67dmE9wpY46 | The routing rule ID. |
tenant_id | STRING | Yes | TSCPDICNT | The tenant identity. |
workspace_id | STRING | Yes | default | Workspace Identity |
Response parameters
Name | Type | Example | Description |
data | ApiInfoPagedListVO | - | Data |
Code examples
Example request
{
"param":{
"page_info":{
"page_size":10,
"page_index":1
},
"query":{
"api_name":null
}
},
"router_id":"aPdifmIr852vfqE4"
}Sample response
{
"data":[
{
"charset":"UTF-8",
"apiName":"rrrwe",
"gmtModified":"2020-03-26 11:58:29",
"method":"GET",
"upstreamPath":"/werwer",
"routerType":"HEADER",
"upstreamProtocol":"HTTP",
"gmtCreate":"2020-03-25 15:15:12",
"timeout":3000,
"operator":"",
"path":"/werwer",
"apiGroupId":"dumebnn9gbnyy02y",
"appType":"STANDARD_AND_MPAAS",
"routerId":"aPdifmIr852vfqE4",
"downstreamProtocol":"HTTP",
"tenantId":"JADDGOCN",
"operationType":"wer.wer",
"contentType":"application/json",
"upstreamType":"SYSTEM_CLUSTER",
"apiId":"1h3WttiKTeTUtZpWn5Xg5P5bu2UBGjrP",
"apiStatus":"CLOSED",
"workspaceId":"antdemo"
}
],
"result_code":"OK"
}