2023-04-10 14:52:59 +08:00
|
|
|
|
# API设计文档
|
|
|
|
|
|
2023-04-10 13:46:02 +08:00
|
|
|
|
## API结构
|
2023-04-10 13:36:02 +08:00
|
|
|
|
|
2023-04-10 13:46:02 +08:00
|
|
|
|
### 请求
|
2023-04-10 13:54:34 +08:00
|
|
|
|
|
|
|
|
|
### 请求头(公共参数)
|
2023-04-11 09:11:28 +08:00
|
|
|
|
|
2023-04-10 13:54:34 +08:00
|
|
|
|
| 参数名称 | 用途 |类型 |必要性 |
|
|
|
|
|
| ------ | --------------------------------------------- | ------ |------ |
|
2023-04-11 09:11:28 +08:00
|
|
|
|
| Version | 接口版本 | string |必须 |
|
2023-04-10 14:02:26 +08:00
|
|
|
|
| Language | 接口显示语言 | string |必须 |
|
2023-04-10 13:54:34 +08:00
|
|
|
|
|
2023-04-11 09:11:28 +08:00
|
|
|
|
> 接口调用安全验证:通过 API 网关
|
2023-04-10 14:02:26 +08:00
|
|
|
|
|
|
|
|
|
### 请求主体
|
|
|
|
|
|
2023-04-10 14:25:33 +08:00
|
|
|
|
[详细参照各个接口业务参数](#API接口说明)
|
2023-04-10 14:02:26 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### 响应结果
|
|
|
|
|
|
|
|
|
|
### 响应头(公共参数)
|
2023-04-11 09:11:28 +08:00
|
|
|
|
|
2023-04-10 14:02:26 +08:00
|
|
|
|
|返回参数 | 用途 |类型 |必要性 |
|
|
|
|
|
| ------ | --------------------------------------------- | ------ |------ |
|
|
|
|
|
| HTTP状态码 | 判断接口调用是否成功(200或404) | Integer |必须 |
|
|
|
|
|
|
|
|
|
|
### 响应主体
|
2023-04-11 09:11:28 +08:00
|
|
|
|
|
2023-04-10 14:02:26 +08:00
|
|
|
|
|返回参数 | 用途 |类型 |必要性 |
|
|
|
|
|
| ------ | --------------------------------------------- | ------ |------ |
|
2023-04-11 09:11:28 +08:00
|
|
|
|
| ResponseData | 各个接口的业务数据 | object(依据接口而异) |必须 |
|
|
|
|
|
| Error | 错误code和错误信息 | ErrorInfo | 非必须 ,无错误时不返回 |
|
2023-04-10 14:13:58 +08:00
|
|
|
|
|
2023-04-10 14:14:23 +08:00
|
|
|
|
```
|
2023-04-10 14:13:40 +08:00
|
|
|
|
{
|
2023-04-10 15:51:17 +08:00
|
|
|
|
"ResponseData": {app_id: "xxxx"},
|
2023-04-10 14:13:40 +08:00
|
|
|
|
"Error": {
|
2023-04-10 15:51:17 +08:00
|
|
|
|
"Code": "Requirement.NotEnough",
|
|
|
|
|
"Message": "Insufficient system resources (cpu, memory, disk space)."
|
2023-04-10 14:13:40 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-04-10 14:14:23 +08:00
|
|
|
|
```
|
2023-04-10 13:46:02 +08:00
|
|
|
|
|
2023-04-10 14:25:10 +08:00
|
|
|
|
## API接口说明
|
2023-04-10 14:24:13 +08:00
|
|
|
|
|
2023-04-10 14:31:01 +08:00
|
|
|
|
各个业务接口的详细说明,公共参数不在这里继续说明。
|
|
|
|
|
|
2023-04-11 09:11:28 +08:00
|
|
|
|
### app 安装
|
2023-04-10 15:45:41 +08:00
|
|
|
|
|
2023-04-11 09:11:28 +08:00
|
|
|
|
#### Action
|
2023-04-10 15:45:41 +08:00
|
|
|
|
|
2023-04-11 09:11:28 +08:00
|
|
|
|
AppInstall
|
2023-04-10 15:45:41 +08:00
|
|
|
|
|
|
|
|
|
#### 请求参数
|
2023-04-11 09:11:28 +08:00
|
|
|
|
|
2023-04-10 15:45:41 +08:00
|
|
|
|
| 参数名称 | 用途 |类型 |必要性 |
|
|
|
|
|
| ------ | --------------------------------------------- | ------ |------ |
|
|
|
|
|
| app_name | 应用名称 | string |必须 |
|
|
|
|
|
| customer_app_name | 用户自定义应用名称 | string |必须 |
|
|
|
|
|
| app_version | 应用版本 | string |必须 |
|
|
|
|
|
|
|
|
|
|
#### 返回结果
|
2023-04-11 09:11:28 +08:00
|
|
|
|
|
2023-04-10 15:49:52 +08:00
|
|
|
|
| 返回值 |类型 |必要性 |
|
|
|
|
|
| ------ | ------ |------ |
|
2023-04-10 15:52:21 +08:00
|
|
|
|
| ResponseData | String(AppID) |必须 |
|
2023-04-11 09:11:28 +08:00
|
|
|
|
| Error | ErrorInfo |非必须 |
|
2023-04-10 15:45:41 +08:00
|
|
|
|
|
|
|
|
|
ErrorInfo 说明:
|
2023-04-11 09:11:28 +08:00
|
|
|
|
|
2023-04-10 15:45:41 +08:00
|
|
|
|
| code |message |
|
|
|
|
|
| --------------------------------------------- | ------ |
|
2023-04-10 15:56:28 +08:00
|
|
|
|
| Param.AppName.Blank | APP名称为空 |
|
|
|
|
|
| Param.AppName.NotExis | 不支持安装指定的App |
|
2023-04-10 15:45:41 +08:00
|
|
|
|
| Param.CustomerAppName.Blank | 用户自定义APP名称为空 |
|
2023-04-10 16:39:45 +08:00
|
|
|
|
| Param.CustomerAppName.FormatError | 用户自定义APP名称只能是数字和小写字母组成 |
|
2023-04-10 15:45:41 +08:00
|
|
|
|
| Param.CustomerAppName.Repeat | 已经安装了此应用,请重新指定APP名称 |
|
|
|
|
|
| Param.CustomerAppName.Wait | 同名应用已经在安装等待中,请重新指定APP名称 |
|
2023-04-10 16:50:40 +08:00
|
|
|
|
| Param.AppVersion.Blank | 安装App的版本不能为空 |
|
2023-04-10 15:45:41 +08:00
|
|
|
|
| Requirement.NotEnough| 系统资源(cpu,内存,磁盘空间)不足 |
|
2023-04-10 15:49:07 +08:00
|
|
|
|
| Container.Command.Error | 操作容器指令发生错误 |
|
2023-04-10 15:45:41 +08:00
|
|
|
|
| SystemError |系统异常,请联系管理员(系统报错返回) |
|
|
|
|
|
|
|
|
|
|
|
2023-04-10 16:10:42 +08:00
|
|
|
|
### app 卸载接口
|
|
|
|
|
|
|
|
|
|
#### 请求URL
|
|
|
|
|
|
|
|
|
|
请求URL=FastAPI通用URL/AppUninstall
|
|
|
|
|
|
|
|
|
|
#### 请求参数
|
|
|
|
|
| 参数名称 | 用途 |类型 |必要性 |
|
|
|
|
|
| ------ | --------------------------------------------- | ------ |------ |
|
|
|
|
|
| app_id | 卸载该app | string |必须 |
|
|
|
|
|
| delete_image | 是否删除镜像 | boolean |非必须,默认为False |
|
|
|
|
|
| delete_data | 是否删除所有数据 | boolean |非必须,默认为True |
|
|
|
|
|
|
|
|
|
|
#### 返回结果
|
|
|
|
|
| 返回值 |类型 |必要性 |
|
|
|
|
|
| ------ | ------ |------ |
|
|
|
|
|
| ResponseData | String(AppID) |必须 |
|
|
|
|
|
| error | ErrorInfo |非必须 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ErrorInfo 说明:
|
2023-04-11 09:20:55 +08:00
|
|
|
|
|
2023-04-10 16:10:42 +08:00
|
|
|
|
| code |message |
|
|
|
|
|
| --------------------------------------------- | ------ |
|
2023-04-11 09:20:55 +08:00
|
|
|
|
| Param.APPID.Blank | APP_ID 不能为空 |
|
|
|
|
|
| Param.APPID.FormatError | APP_ID 只能是数字和小写字母组成 |
|
2023-04-10 16:39:45 +08:00
|
|
|
|
| Param.APPID.NotExist | APP不存在 |
|
2023-04-11 09:20:55 +08:00
|
|
|
|
| Container.Command.Error | Docker 返回错误 |
|
|
|
|
|
| SystemError | 系统异常,请联系管理员 |
|
2023-04-10 16:39:45 +08:00
|
|
|
|
|
|
|
|
|
### App 重启接口
|
|
|
|
|
|
|
|
|
|
#### 请求URL
|
|
|
|
|
|
|
|
|
|
请求URL=FastAPI通用URL/AppRestart
|
|
|
|
|
|
|
|
|
|
#### 请求参数
|
|
|
|
|
| 参数名称 | 用途 |类型 |必要性 |
|
|
|
|
|
| ------ | --------------------------------------------- | ------ |------ |
|
|
|
|
|
| app_id | 重启该app | string |必须 |
|
|
|
|
|
|
|
|
|
|
#### 返回结果
|
|
|
|
|
| 返回值 |类型 |必要性 |
|
|
|
|
|
| ------ | ------ |------ |
|
|
|
|
|
| ResponseData | String(AppID) |必须 |
|
|
|
|
|
| error | ErrorInfo |非必须 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ErrorInfo 说明:
|
|
|
|
|
| code |message |
|
|
|
|
|
| --------------------------------------------- | ------ |
|
|
|
|
|
| Param.APPID.Blank | APP_ID不能为空 |
|
|
|
|
|
| Param.APPID.FormatError | APP_ID只能是数字和小写字母组成 |
|
|
|
|
|
| Param.APPID.NotExist | APP不存在 |
|
|
|
|
|
| Container.Command.Error | 操作容器指令发生错误 |
|
|
|
|
|
| SystemError |系统异常,请联系管理员(系统报错返回) |
|
|
|
|
|
|
|
|
|
|
### App 启动接口
|
|
|
|
|
|
|
|
|
|
#### 请求URL
|
|
|
|
|
|
|
|
|
|
请求URL=FastAPI通用URL/AppStart
|
|
|
|
|
|
|
|
|
|
#### 请求参数
|
|
|
|
|
| 参数名称 | 用途 |类型 |必要性 |
|
|
|
|
|
| ------ | --------------------------------------------- | ------ |------ |
|
|
|
|
|
| app_id | 启动该app | string |必须 |
|
|
|
|
|
|
|
|
|
|
#### 返回结果
|
|
|
|
|
| 返回值 |类型 |必要性 |
|
|
|
|
|
| ------ | ------ |------ |
|
|
|
|
|
| ResponseData | String(AppID) |必须 |
|
|
|
|
|
| error | ErrorInfo |非必须 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ErrorInfo 说明:
|
|
|
|
|
| code |message |
|
|
|
|
|
| --------------------------------------------- | ------ |
|
|
|
|
|
| Param.APPID.Blank | APP_ID不能为空 |
|
|
|
|
|
| Param.APPID.FormatError | APP_ID只能是数字和小写字母组成 |
|
|
|
|
|
| Param.APPID.NotExist | APP不存在 |
|
|
|
|
|
| Container.Command.Error | 操作容器指令发生错误 |
|
|
|
|
|
| SystemError |系统异常,请联系管理员(系统报错返回) |
|
|
|
|
|
|
|
|
|
|
### App 停止接口
|
|
|
|
|
|
|
|
|
|
#### 请求URL
|
|
|
|
|
|
|
|
|
|
请求URL=FastAPI通用URL/AppStop
|
|
|
|
|
|
|
|
|
|
#### 请求参数
|
|
|
|
|
| 参数名称 | 用途 |类型 |必要性 |
|
|
|
|
|
| ------ | --------------------------------------------- | ------ |------ |
|
|
|
|
|
| app_id | 停止该app | string |必须 |
|
|
|
|
|
|
|
|
|
|
#### 返回结果
|
|
|
|
|
| 返回值 |类型 |必要性 |
|
|
|
|
|
| ------ | ------ |------ |
|
|
|
|
|
| ResponseData | String(AppID) |必须 |
|
|
|
|
|
| error | ErrorInfo |非必须 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ErrorInfo 说明:
|
|
|
|
|
| code |message |
|
|
|
|
|
| --------------------------------------------- | ------ |
|
|
|
|
|
| Param.APPID.Blank | APP_ID不能为空 |
|
|
|
|
|
| Param.APPID.FormatError | APP_ID只能是数字和小写字母组成 |
|
|
|
|
|
| Param.APPID.NotExist | APP不存在 |
|
2023-04-10 16:10:42 +08:00
|
|
|
|
| Container.Command.Error | 操作容器指令发生错误 |
|
|
|
|
|
| SystemError |系统异常,请联系管理员(系统报错返回) |
|
|
|
|
|
|
2023-04-10 15:28:23 +08:00
|
|
|
|
### app 状态查询接口
|
|
|
|
|
|
|
|
|
|
#### 请求URL
|
|
|
|
|
|
|
|
|
|
请求URL=FastAPI通用URL/AppStatus
|
|
|
|
|
|
|
|
|
|
#### 请求参数
|
|
|
|
|
| 参数名称 | 用途 |类型 |必要性 |
|
|
|
|
|
| ------ | --------------------------------------------- | ------ |------ |
|
|
|
|
|
| app_id | 查询该app的信息 | string |必须 |
|
|
|
|
|
|
|
|
|
|
#### 返回结果
|
2023-04-10 15:49:07 +08:00
|
|
|
|
| 返回值 |类型 |必要性 |
|
|
|
|
|
| ------ | ------ |------ |
|
|
|
|
|
| ResponseData | AppStatusInfo |必须 |
|
|
|
|
|
| error | ErrorInfo |非必须 |
|
2023-04-10 15:28:23 +08:00
|
|
|
|
|
|
|
|
|
AppStatusInfo 说明:
|
|
|
|
|
```
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
app_id:应用ID,
|
|
|
|
|
|
|
|
|
|
name:应用名,
|
|
|
|
|
|
|
|
|
|
customer_name:自定义应用名,
|
|
|
|
|
|
|
|
|
|
trade_mark:应用商标,
|
|
|
|
|
|
|
|
|
|
status_code:应用运行状态码,(queuing:'00',pulling:'10',creating:'11',initing:'12',running:'30',stop:'40',error:'50')
|
|
|
|
|
|
|
|
|
|
status:应用运行状态,(queuing:排队等待,pulling:镜像拉取中,creating:容器启动中,initing:初始化中,running:正常运行,stop:停止,error:错误)
|
|
|
|
|
|
|
|
|
|
official_app:是否为官方应用,
|
|
|
|
|
|
|
|
|
|
image_url:图片路径
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
ErrorInfo 说明:
|
|
|
|
|
| code |message |
|
|
|
|
|
| --------------------------------------------- | ------ |
|
2023-04-10 16:39:45 +08:00
|
|
|
|
| Param.APPID.Blank | APP_ID不能为空 |
|
|
|
|
|
| Param.APPID.FormatError | APP_ID只能是数字和小写字母组成 |
|
|
|
|
|
| Param.APPID.NotExist | APP不存在 |
|
2023-04-10 15:56:28 +08:00
|
|
|
|
| Container.CommandError | 操作容器指令发生错误 |
|
2023-04-10 15:31:03 +08:00
|
|
|
|
| SystemError |系统异常,请联系管理员(系统报错返回) |
|
2023-04-10 15:28:23 +08:00
|
|
|
|
|
|
|
|
|
|
2023-04-10 14:24:13 +08:00
|
|
|
|
### app 列表查询接口
|
2023-04-10 14:31:01 +08:00
|
|
|
|
|
2023-04-10 14:51:42 +08:00
|
|
|
|
#### 请求URL
|
|
|
|
|
|
2023-04-10 15:28:23 +08:00
|
|
|
|
请求URL=FastAPI通用URL/AppList
|
2023-04-10 14:51:42 +08:00
|
|
|
|
|
2023-04-10 14:31:01 +08:00
|
|
|
|
#### 请求参数
|
2023-04-10 14:27:39 +08:00
|
|
|
|
| 参数名称 | 用途 |类型 |必要性 |
|
|
|
|
|
| ------ | --------------------------------------------- | ------ |------ |
|
|
|
|
|
| app_name | 查询app列表信息,当app_name不为空时,查询该app的信息 | string |非必须 |
|
2023-04-10 14:31:01 +08:00
|
|
|
|
|
|
|
|
|
#### 返回结果
|
2023-04-10 15:49:07 +08:00
|
|
|
|
| 返回值 |类型 |必要性 |
|
|
|
|
|
| ------ | ------ |------ |
|
2023-04-10 17:08:56 +08:00
|
|
|
|
| ResponseData | Array of AppDetailInfo |必须 |
|
2023-04-10 15:49:07 +08:00
|
|
|
|
| error | ErrorInfo |非必须 |
|
2023-04-10 14:51:42 +08:00
|
|
|
|
|
|
|
|
|
AppDetailInfo 说明:
|
2023-04-10 15:01:45 +08:00
|
|
|
|
```
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
app_id:应用ID,
|
|
|
|
|
|
|
|
|
|
name:应用名,
|
|
|
|
|
|
|
|
|
|
customer_name:自定义应用名,
|
|
|
|
|
|
|
|
|
|
trade_mark:应用商标,
|
|
|
|
|
|
2023-04-10 15:20:07 +08:00
|
|
|
|
status_code:应用运行状态码,(queuing:'00',pulling:'10',creating:'11',initing:'12',running:'30',stop:'40',error:'50')
|
2023-04-10 15:01:45 +08:00
|
|
|
|
|
2023-04-10 15:20:07 +08:00
|
|
|
|
status:应用运行状态,(queuing:排队等待,pulling:镜像拉取中,creating:容器启动中,initing:初始化中,running:正常运行,stop:停止,error:错误)
|
2023-04-10 15:01:45 +08:00
|
|
|
|
|
|
|
|
|
official_app:是否为官方应用,
|
|
|
|
|
|
2023-04-10 15:28:23 +08:00
|
|
|
|
image_url:图片路径,
|
|
|
|
|
|
2023-04-10 15:20:07 +08:00
|
|
|
|
running_info: { // 只有status=running才有值,其他时候为空
|
2023-04-10 15:01:45 +08:00
|
|
|
|
|
|
|
|
|
port:应用端口,
|
|
|
|
|
|
2023-04-10 15:20:07 +08:00
|
|
|
|
compose_file:docker compose文件路径,
|
2023-04-10 15:01:45 +08:00
|
|
|
|
|
|
|
|
|
url:应用网址,
|
|
|
|
|
|
|
|
|
|
admin_url:管理员网址,
|
|
|
|
|
|
|
|
|
|
user_name:用户名,
|
|
|
|
|
|
|
|
|
|
password:密码,
|
2023-04-10 16:41:35 +08:00
|
|
|
|
|
|
|
|
|
default_domain: 默认域名,
|
|
|
|
|
|
|
|
|
|
set_domain: 用户自定义域名,
|
2023-04-10 15:01:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
```
|
2023-04-10 14:51:42 +08:00
|
|
|
|
|
|
|
|
|
ErrorInfo 说明:
|
2023-04-10 15:28:23 +08:00
|
|
|
|
| code |message |
|
|
|
|
|
| --------------------------------------------- | ------ |
|
2023-04-10 15:56:28 +08:00
|
|
|
|
| Container.CommandError | 操作容器指令发生错误 |
|
2023-04-10 15:31:03 +08:00
|
|
|
|
| SystemError |系统异常,请联系管理员(系统报错返回) |
|