新增服务
接口功能介绍
接口约束
无
URI
/cgw/v1/upstream/create
请求方式: POST
Content-Type: application/json
路径参数
无
Query参数
无
请求参数
请求头header参数
参数 | 是否必填 | 参数类型 | 说明 | 示例 | 下级对象 |
---|---|---|---|---|---|
regionId | 是 | String | 资源池编码 | 7a2828074ef6e32e041a2ef124b19e63 |
请求体body参数
参数 | 是否必填 | 参数类型 | 说明 | 示例 | 下级对象 |
---|---|---|---|---|---|
instId | 是 | String | 实例Id | 7a2828074ef6e32e041a2ef124123456 | |
serviceList | 是 | Array of Objects | 服务列表 | UpstreamService | |
sourceType | 是 | String | 服务来源,VIP:固定地址;nacos:Nacos;kubernetes:Kubernetes | VIP | |
used | 否 | Boolean | 已使用标志,传入的话可以避免重复检测 | false |
表 UpstreamService
参数 | 是否必填 | 参数类型 | 说明 | 示例 | 下级对象 |
---|---|---|---|---|---|
balancerType | 否 | String | 服务负载均衡策略 | routerobin | |
enableMtls | 否 | Boolean | 是否开启mTLS,默认为false,只有当schema为https时才可选 | false | |
enableWebsocket | 否 | Boolean | 是否开启webSocket, 默认关闭 | false | |
fileCacheKeyVO | 否 | Object | 证书文件的缓存key | FileCacheKeyVO | |
keyFileCacheKeyVO | 否 | Object | 密钥证书文件的缓存key | KeyFileCacheKeyVO | |
groupName | 否 | String | 组名 | default | |
ips | 否 | Array of Objects | 服务ip地址列表,服务来源为VIP时生效 | String | |
name | 是 | String | 服务名称 | book_review | |
namespace | 否 | String | 命名空间ID | prod | |
scheme | 否 | String | 请求协议 | http | |
serviceInstId | 否 | String | 导入服务所在实例的id,只有nacos、kubernetes服务来源需要传入此参数 | 7a2828074ef6e32e041a2ef124753951 | |
servicePortMapping | 否 | Object | kubernetes服务的endpoint信息 | ServicePortMappingDTO |
表 FileCacheKeyVO
参数 | 是否必填 | 参数类型 | 说明 | 示例 | 下级对象 |
---|---|---|---|---|---|
certFileKey | 否 | String | 证书文件的缓存key | cert file key | |
certFileName | 否 | String | 证书文件名 | cert file name |
表 ServicePortMappingDTO
参数 | 是否必填 | 参数类型 | 说明 | 示例 | 下级对象 |
---|---|---|---|---|---|
clusterAccessUrl | 否 | String | 3.3.3.3 | ||
containerPort | 否 | Integer | 6443 | ||
enableMtls | 否 | Boolean | 是否开启mTLS,默认为false,只有当schema为https时才可选 | false | |
enableWebsocket | 否 | Boolean | 是否开启webSocket, 默认关闭 | false | |
fileCacheKeyVO | 否 | Object | 证书文件的缓存key | FileCacheKeyVO | |
keyFileCacheKeyVO | 否 | Object | 密钥证书文件的缓存key | KeyFileCacheKeyVO | |
masterExternalVip | 否 | String | 2.2.2.2 | ||
masterInnerVip | 否 | String | 1.1.1.1 | ||
nodePort | 否 | Integer | 80 | ||
portName | 否 | String | http | ||
protocol | 否 | String | http | ||
serviceName | 否 | String | test | ||
servicePort | 否 | Integer | 80 | ||
used | 否 | Boolean | 服务是否已添加的标志,传入的话可以避免重复检测 | false |
表 FileCacheKeyVO
参数 | 是否必填 | 参数类型 | 说明 | 示例 | 下级对象 |
---|---|---|---|---|---|
certFileKey | 否 | String | 证书文件的缓存key | cert file key | |
certFileName | 否 | String | 证书文件名 | cert file name |
响应参数
参数 | 参数类型 | 说明 | 示例 | 下级对象 |
---|---|---|---|---|
statusCode | Integer | 接口状态码 | 2000 | |
code | String | 错误码,异常时非空 | CGW_1001 | |
returnObj | Object | 返回数据 | {} | |
message | String | 异常描述 | success |
请求示例
请求url
https://127.0.0.1:8080/cgw/v1/upstream/create
请求头header
{
"regionId": "1234567890"
}
请求体body
{
"instId": "878da73f7dba36ff0ae80e004a4f28f9",
"sourceType": "nacos",
"serviceList": [
{
"name": "msap.nacos.provider",
"namespace": "40cacbb7-321e-4ce0-8ece-da44e14dcd02",
"scheme": "http"
}
]
}
响应示例
{
"message": "String",
"returnObj": {},
"statusCode": 2000
}
状态码
请参考 状态码说明。
错误码
请参考 错误码说明。