websoft9/appmanage/docs/developer.md

293 lines
7.7 KiB
Markdown
Raw Normal View History

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:44:16 +08:00
#### 请求方式
支持如下两种调用方式:
* get
* post
#### 请求头(公共参数)
2023-04-11 09:11:28 +08:00
2023-04-10 13:54:34 +08:00
| 参数名称 | 用途 |类型 |必要性 |
| ------ | --------------------------------------------- | ------ |------ |
2023-04-11 09:41:48 +08:00
| Version | 接口版本 | string |可选 |
| Language | 接口显示语言 | string |可选 |
2023-04-10 13:54:34 +08:00
2023-04-11 09:44:16 +08:00
#### 安全验证
2023-04-11 09:42:38 +08:00
本微服务没有安全验证模块,需通过 API 网关实现
2023-04-10 14:02:26 +08:00
2023-04-11 09:44:16 +08:00
#### 请求主体
2023-04-10 14:02:26 +08:00
2023-04-11 09:47:21 +08:00
[业务接口详情](#业务接口详情)
2023-04-10 14:02:26 +08:00
### 响应结果
2023-04-11 09:40:16 +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:40:16 +08:00
#### 响应主体
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-13 16:38:09 +08:00
"ResponseData": {
app_id: "xxxx",
StatusReason: {
Code: "Requirement.NotEnough",
Message: "Insufficient system resources (cpu, memory, disk space).",
Detail: "Error detail information"
}
},
2023-04-10 14:13:40 +08:00
"Error": {
2023-04-13 16:38:09 +08:00
Code: "Requirement.NotEnough",
Message: "Insufficient system resources (cpu, memory, disk space).",
Detail: "Error detail information"
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-13 15:53:05 +08:00
#### 错误代码设计
2023-04-13 16:02:08 +08:00
错误代码参考 [AWS API](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/errors-overview.html) 的分类方式:
2023-04-13 15:53:05 +08:00
2023-04-13 16:02:08 +08:00
* Client errors: These errors are usually caused by something the client did, such as specifying an incorrect or invalid parameter in the request, or using an action or resource on behalf of a user that doesn't have permission to use the action or resource. These errors are accompanied by a 400-series HTTP response code.
2023-04-13 15:53:05 +08:00
2023-04-13 16:02:08 +08:00
* Server errors: These errors are usually caused by an AWS server-side issue. These errors are accompanied by a 500-series HTTP response code.
##### Client errors
2023-04-13 15:53:05 +08:00
| code |message | detail |
| --------------------------------------------- | ------ | ------ |
2023-04-13 16:19:57 +08:00
| Client.Parameter.Blank.Error | p 必填参数为空 |null |
| Client.Parameter.Format.Error | p 参数语法不符 |null |
| Client.Parameter.Value.NotExist.Error | p 参数值错误 |null |
| Client.Parameter.Value.Repeat.Error | p 参数值重复 |null |
2023-04-13 15:53:05 +08:00
2023-04-13 16:02:08 +08:00
##### Server errors
2023-04-11 09:40:16 +08:00
| code |message | detail |
| --------------------------------------------- | ------ | ------ |
2023-04-13 16:11:31 +08:00
| Server.Container.Error | Docker 返回原始错误 |错误详细信息 |
2023-04-13 16:11:55 +08:00
| Server.SystemError | 系统原始错误 | 错误详细信息 |
2023-04-13 16:13:48 +08:00
| Server.*** | 其他可以友好提示的错误 | 错误详细信息 |
2023-04-11 09:40:16 +08:00
2023-04-11 09:47:21 +08:00
## 业务接口详情
2023-04-10 14:24:13 +08:00
2023-04-10 14:31:01 +08:00
各个业务接口的详细说明,公共参数不在这里继续说明。
2023-04-11 09:49:00 +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
2023-04-11 09:49:00 +08:00
### App 卸载
2023-04-10 16:10:42 +08:00
2023-04-11 09:40:16 +08:00
#### Action
2023-04-10 16:10:42 +08:00
2023-04-11 09:40:16 +08:00
AppUninstall
2023-04-10 16:10:42 +08:00
#### 请求参数
2023-04-11 09:40:16 +08:00
2023-04-10 16:10:42 +08:00
| 参数名称 | 用途 |类型 |必要性 |
| ------ | --------------------------------------------- | ------ |------ |
| app_id | 卸载该app | string |必须 |
#### 返回结果
2023-04-11 09:40:16 +08:00
2023-04-10 16:10:42 +08:00
| 返回值 |类型 |必要性 |
| ------ | ------ |------ |
| ResponseData | String(AppID) |必须 |
| error | ErrorInfo |非必须 |
2023-04-11 09:40:16 +08:00
### App 重启
#### Action
2023-04-10 16:39:45 +08:00
2023-04-11 09:40:16 +08:00
AppRestart
2023-04-10 16:39:45 +08:00
#### 请求参数
2023-04-11 09:40:16 +08:00
2023-04-10 16:39:45 +08:00
| 参数名称 | 用途 |类型 |必要性 |
| ------ | --------------------------------------------- | ------ |------ |
| app_id | 重启该app | string |必须 |
#### 返回结果
2023-04-11 09:40:16 +08:00
2023-04-10 16:39:45 +08:00
| 返回值 |类型 |必要性 |
| ------ | ------ |------ |
| ResponseData | String(AppID) |必须 |
| error | ErrorInfo |非必须 |
2023-04-11 09:40:16 +08:00
### App 启动
#### Action
2023-04-10 16:39:45 +08:00
2023-04-11 09:40:16 +08:00
AppStart
2023-04-10 16:39:45 +08:00
#### 请求参数
2023-04-11 09:40:16 +08:00
2023-04-10 16:39:45 +08:00
| 参数名称 | 用途 |类型 |必要性 |
| ------ | --------------------------------------------- | ------ |------ |
| app_id | 启动该app | string |必须 |
#### 返回结果
2023-04-11 09:40:16 +08:00
2023-04-10 16:39:45 +08:00
| 返回值 |类型 |必要性 |
| ------ | ------ |------ |
| ResponseData | String(AppID) |必须 |
| error | ErrorInfo |非必须 |
2023-04-11 09:40:16 +08:00
### App 停止
#### Action
2023-04-10 16:39:45 +08:00
2023-04-11 09:40:16 +08:00
AppStop
2023-04-10 16:39:45 +08:00
#### 请求参数
2023-04-11 09:40:16 +08:00
2023-04-10 16:39:45 +08:00
| 参数名称 | 用途 |类型 |必要性 |
| ------ | --------------------------------------------- | ------ |------ |
| app_id | 停止该app | string |必须 |
#### 返回结果
2023-04-11 09:40:16 +08:00
2023-04-10 16:39:45 +08:00
| 返回值 |类型 |必要性 |
| ------ | ------ |------ |
| ResponseData | String(AppID) |必须 |
| error | ErrorInfo |非必须 |
2023-04-11 09:49:00 +08:00
### App 状态查询
2023-04-10 15:28:23 +08:00
2023-04-11 09:40:16 +08:00
#### Action
2023-04-10 15:28:23 +08:00
2023-04-11 09:40:16 +08:00
AppStatus
2023-04-10 15:28:23 +08:00
#### 请求参数
2023-04-11 09:40:16 +08:00
2023-04-10 15:28:23 +08:00
| 参数名称 | 用途 |类型 |必要性 |
| ------ | --------------------------------------------- | ------ |------ |
| app_id | 查询该app的信息 | string |必须 |
#### 返回结果
2023-04-11 09:40:16 +08:00
2023-04-10 15:49:07 +08:00
| 返回值 |类型 |必要性 |
| ------ | ------ |------ |
| ResponseData | AppStatusInfo |必须 |
| error | ErrorInfo |非必须 |
2023-04-10 15:28:23 +08:00
AppStatusInfo 说明:
```
{
app_id应用ID,
2023-04-14 11:29:44 +08:00
status应用运行状态,[installing(创建中)running(运行中)exited(停止)restarting(反复重启)failed(失败)]
2023-04-10 15:28:23 +08:00
2023-04-14 11:30:54 +08:00
status_reason{ // 只有failed时才有内容
Code错误代码
Message错误提示信息
Detail错误真实信息
}
2023-04-10 15:28:23 +08:00
}
```
2023-04-11 09:49:00 +08:00
### App 列表查询
2023-04-10 14:31:01 +08:00
2023-04-11 09:40:16 +08:00
#### Action
2023-04-10 14:51:42 +08:00
2023-04-11 09:40:16 +08:00
AppList
2023-04-10 14:51:42 +08:00
2023-04-10 14:31:01 +08:00
#### 请求参数
2023-04-11 09:40:16 +08:00
2023-04-10 14:27:39 +08:00
| 参数名称 | 用途 |类型 |必要性 |
| ------ | --------------------------------------------- | ------ |------ |
2023-04-14 16:49:03 +08:00
| app_id | 查询指定的 app | string | 非必须 |
2023-04-10 14:31:01 +08:00
#### 返回结果
2023-04-11 09:40:16 +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-14 11:29:44 +08:00
status应用运行状态,[installing(创建中)running(运行中)exited(停止)restarting(反复重启)failed(失败)]
status_reason{ // 只有failed时才有内容
Code错误代码
Message错误提示信息
Detail错误真实信息
2023-04-14 11:30:54 +08:00
},
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_filedocker 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
}
}
```