配置系统API
1.创建一个配置模块(create module
在配置系统中生成一个模块
- 请求体
POST /v1/create/module
Content-Type:application/json
{
"module_name":"cos_cgi"
}
- 响应体
HTTP/1.1 200 OK
Content-Type:application/json
{
"code": 0,
"error": "success"
}
如果出现错误,会体现在code 和 error中。如果遇到http status非200,也认为是错误
2.创建配置的环境分类
在配置系统中生成一个模块配置的环境分类
- 请求体
POST /v1/create/env
Content-Type:application/json
{
"module_name":"cos_cgi",
"env_name":"test"
}
- 响应体
HTTP/1.1 200 OK
Content-Type:application/json
{
"code": 0,
"error": "success"
}
如果出现错误,会体现在code 和 error中。如果遇到http status非200,也认为是错误
3.创建配置所在模块及环境下的配置项分类
- 请求体
POST /v1/create/category
Content-Type:application/json
{
"module_name":"cos_cgi",
"env_name":"test",
"category": "ap-shanghai"
}
- 响应体
HTTP/1.1 200 OK
Content-Type:application/json
{
"code": 0,
"error": "success"
}
如果出现错误,会体现在code 和 error中。如果遇到http status非200,也认为是错误
4.批量创建配置项
在一个特定的模块、环境、分类下批量的创建配置项
- 请求体
POST /v1/create/batch/config
Content-Type:application/json
{
"module_name": "test_cgi",
"env_name": "dev",
"category": {
"category_name" : "common",
"ns" : [
{
"name": "file1",
"kv_pair":
{
"kvs": [
{
"key":"min_slice_size",
"value":"1024000"
},
{
"key":"max_slice_size",
"value":"20971520"
},
{
"key": "serial_upload",
"value": "1",
"comment": "顺序上传分片的标志 0:可以并发 1:必须顺序上传"
}
]
}
}
]
}
}
- 响应体
HTTP/1.1 200 OK
Content-Type:application/json
{
"code": 0,
"error": "success"
}
如果出现错误,会体现在code 和 error中。如果遇到http status非200,也认为是错误
5.通过module来获取module下所有的配置项
- 请求体
POST /v1/getconfig/module
Content-Type:application/json
{
"module_name":"cos-cgi"
}
- 响应体
HTTP/1.1 200 OK
Content-Type:application/json
{
"code": 0,
"error": "success",
"module_conf": {
"module_name": "cos-cgi",
"env_conf": [
{
"env_name": "prod",
"ctg": [
{
"category_name": "ap-shanghai",
"ns": [
{
"name": "accelerate",
"kv_pair": {
"kvs": [
{
"key": "dsa_server_domain",
"value": "openapi.dsa.tencentyun.com"
}
]
}
}
]
}
]
}
]
}
}
如果出现错误,会体现在code 和 error中。如果遇到http status非200,也认为是错误
6.通过module和env来获取配置
- 请求体
POST /v1/getconfig/env
Content-Type:application/json
{
"module_name":"cos-cgi",
"env_name":"prod"
}
- 响应体
HTTP/1.1 200 OK
Content-Type:application/json
{
"code": 0,
"error": "success",
"module_conf": {
"module_name": "cos-cgi",
"env_conf": [
{
"env_name": "prod",
"ctg": [
{
"category_name": "ap-shanghai",
"ns": [
{
"name": "accelerate",
"kv_pair": {
"kvs": [
{
"key": "dsa_server_domain",
"value": "openapi.dsa.tencentyun.com"
}
]
}
}
]
}
]
}
]
}
}
如果出现错误,会体现在code 和 error中。如果遇到http status非200,也认为是错误
7.通过module、env和category来获取配置项
- 请求体
POST /v1/getconfig/category
Content-Type:application/json
{
"module_name":"cos-cgi",
"env_name":"prod",
"category_name":"ap-shanghai"
}
- 响应体
HTTP/1.1 200 OK
Content-Type:application/json
{
"code": 0,
"error": "success",
"module_conf": {
"module_name": "cos-cgi",
"env_conf": [
{
"env_name": "prod",
"ctg": [
{
"category_name": "ap-shanghai",
"ns": [
{
"name": "accelerate",
"kv_pair": {
"kvs": [
{
"key": "dsa_server_domain",
"value": "openapi.dsa.tencentyun.com"
}
]
}
}
]
}
]
}
]
}
}
如果出现错误,会体现在code 和 error中。如果遇到http status非200,也认为是错误
8.获取在配置系统中管理的所有module名字
- 请求体
POST /v1/getconfig/modules
- 响应体
HTTP/1.1 200 OK
Content-Type:application/json
{
"code": 0,
"error": "success",
"modules": [
"cos-cgi"
]
}
9.删除一个module
删除一个module,其下面的所有配置项都删除
- 请求体
POST /v1/delete/module
Content-Type:application/json
{
"module_name":"cos_cgi"
}
- 响应体
HTTP/1.1 200 OK
Content-Type:application/json
{
"code": 0,
"error": "success"
}
10.删除一个module下的一个env
删除一个module下的一个env,其env下面的所有配置项都删除
- 请求体
POST /v1/delete/env
Content-Type:application/json
{
"module_name":"cos_cgi",
"env_name":"test"
}
- 响应体
HTTP/1.1 200 OK
Content-Type:application/json
{
"code": 0,
"error": "success"
}
11.删除一个module及env下的一个category分类
删除一个module及env下的category,其category下面的所有配置项都删除
- 请求体
POST /v1/delete/category
Content-Type:application/json
{
"module_name":"cos_cgi",
"env_name":"test",
"category":{
"category_name": "ap-shanghai"
}
}
- 响应体
HTTP/1.1 200 OK
Content-Type:application/json
{
"code": 0,
"error": "success"
}
删除删除一个module及env下的category,其category部分配置项
- 请求体
POST /v1/delete/category
Content-Type:application/json
{
"module_name":"cos_cgi",
"env_name":"test",
"category": {
"category_name" : "common",
"ns" : [
{
"name": "file1",
"kv_pair":
{
"kvs": [
{
"key":"min_slice_size",
"value":"1024000"
},
{
"key":"max_slice_size",
"value":"20971520"
},
{
"key": "serial_upload",
"value": "1",
"comment": "顺序上传分片的标志 0:可以并发 1:必须顺序上传"
}
]
}
}
]
}
}
- 响应体
HTTP/1.1 200 OK
Content-Type:application/json
{
"code": 0,
"error": "success"
}
12.提交配置的修改
提交配置仅仅是对配置上的修改生成一个版本。不做下发的操作
- 请求体
POST /v1/config/submit
Content-Type:application/json
{
"module_name": "cos-cgi",
"env_name" : "prod",
"category": "ap-shanghai",
"external_category":[
"common"
]
}
// 生成的配置以category指定的为主,但是可以附加上external_category上的配置项
- 响应体
HTTP/1.1 200 OK
Content-Type:application/json
{
"code": 0,
"error": "success",
"version": "1.2" // 返回的版本号
}
13.指定版本升级配置
下发指定版本的配置,并且通过灰度开关来指定下发策略
- 请求体
POST /v1/config/upgrade
Content-Type:application/json
{
"module_name": "cos-cgi",
"env_name" : "prod",
"category": "ap-shanghai",
"version":"1.2",
"upgrade_percent":0.8,
"pre_script": "",
"post_script": "",
"local_file_path":"/tmp/filecloud_coss3.ini"
}
// 生成的配置以category指定的为主,但是可以附加上external_category上的配置项
- 响应体
HTTP/1.1 200 OK
Content-Type:application/json
{
"code": 0,
"error": "success"
}
14.通过module来获取到配置的元数据信息
- 请求体
POST /v1/getconfig/meta/module"
Content-Type:application/json
{
"module_name":"cos-cgi"
}
- 响应体
HTTP/1.1 200 OK
Content-Type:application/json
{
"code": 0,
"error": "success",
"module_conf": {
"module_name": "cos-cgi",
"env_conf": [
{
"env_name": "prod",
"ctg": [
{
"category_name": "ap-shanghai",
"ns": [
{
"name": "1.1",
"kv_pair": {
"kvs": [
{
"key": "cos_file_md5",
"value": "78601ddf3c327fa4a2a2a595f5609f55"
},
{
"key": "cos_file_path",
"value": "cos-cgi/prod/ap-shanghai/1.1"
},
{
{
"key": "pre_script",
"value": ""
},
{
"key": "post_script",
"value": ""
},
{
"key": "local_file_path",
"value": "/tmp/filecloud_coss3.ini"
}
]
}
},
{
"name": "1.2",
"kv_pair": {
"kvs": [
{
"key": "cos_file_md5",
"value": "0015a32e4093fc82b387e61e7679f8b6"
},
{
"key": "cos_file_path",
"value": "cos-cgi/prod/ap-shanghai/1.2"
},
{
"key": "pre_script",
"value": ""
},
{
"key": "post_script",
"value": ""
},
{
"key": "local_file_path",
"value": "/tmp/filecloud_coss3.ini"
}
]
}
},
{
"name": "current_version",
"kv_pair": {
"kvs": [
{
"key": "last_version",
"value": "1.2"
},
{
"key": "local_file_path",
"value": "/tmp/filecloud_coss3.ini"
},
{
"key": "upgrade_percent",
"value": "0.8"
},
{
"key": "version_id",
"value": "1.2"
},
]
}
}
]
}
]
}
]
}
}
如果出现错误,会体现在code 和 error中。如果遇到http status非200,也认为是错误
15.获取在配置系统中管理的module下所有的env的名字
- 请求体
POST /v1/getconfig/envs
Content-Type:application/json
{
"module_name":"cos-cgi"
}
- 响应体
HTTP/1.1 200 OK
Content-Type:application/json
{
"code": 0,
"error": "success",
"envs": [
"prod"
]
}
16.获取在配置系统中管理的特定module和env下所有category的名字
- 请求体
POST /v1/getconfig/categories
Content-Type:application/json
{
"module_name":"cos-cgi",
"env_name":"prod"
}
- 响应体
HTTP/1.1 200 OK
Content-Type:application/json
{
"code": 0,
"error": "success",
"categories": [
"common", "ap-shanghai"
]
}
17.根据module获取当前园区下所有agent的状态信息
** According the module get the agentinfo
- 请求体
POST /v1/getagentinfo/module
Content-Type:application/json
{
"module_name":"cos_cgi",
"env_name":"test",
"category_name": "ap-shanghai"
}
+ 响应体
HTTP/1.1 200 OK
Content-Type:application/json
{
"code": 0,
"error": "success",
"agent_info" :[
{
"ip_addr" : "127.0.0.1",
"version": "1.2",
"last_alive": "0123456789",
"is_timeout": "true",
},
{
"ip_addr" : "127.0.0.1",
"version": "1.2",
"last_alive": "0123456789",
"is_timeout": "true",
},
]
}
18.通过request module来获取指定园区下配置的元数据信息
- 请求体
POST /v1/getconfig/meta/category
Content-Type:application/json
{
"module_name":"cos-cgi",
"env_name":"test",
"category": "ap-shanghai"
}
- 响应体
HTTP/1.1 200 OK
Content-Type:application/json
{
"code": 0,
"error": "success",
"ctg": {
"category_name": "ap-shanghai",
"ns": [
{
"name": "1.1",
"kv_pair": {
"kvs": [
{
"key": "cos_file_md5",
"value": "78601ddf3c327fa4a2a2a595f5609f55"
},
{
"key": "cos_file_path",
"value": "cos-cgi/prod/ap-shanghai/1.1"
},
{
{
"key": "pre_script",
"value": ""
},
{
"key": "post_script",
"value": ""
},
{
"key": "local_file_path",
"value": "/tmp/filecloud_coss3.ini"
}
]
},
{
"name": "1.2",
"kv_pair": {
"kvs": [
{
"key": "cos_file_md5",
"value": "0015a32e4093fc82b387e61e7679f8b6"
},
{
"key": "cos_file_path",
"value": "cos-cgi/prod/ap-shanghai/1.2"
},
{
"key": "pre_script",
"value": ""
},
{
"key": "post_script",
"value": ""
},
{
"key": "local_file_path",
"value": "/tmp/filecloud_coss3.ini"
}
]
}
},
{
"name": "current_version",
"kv_pair": {
"kvs": [
{
"key": "last_version",
"value": "1.2"
},
{
"key": "local_file_path",
"value": "/tmp/filecloud_coss3.ini"
},
{
"key": "upgrade_percent",
"value": "0.8"
},
{
"key": "version_id",
"value": "1.2"
},
]
}
}
]
}
19. ** TODO 需要从状态流转为事件流,下面结构将会修改
**根据module获取当前园区下版本下发的状态**
** agent_status: progress, fail,success
+ 请求体
POST /v1/getupgradeinfo/category
Content-Type:application/json
{
"module_name":"cos_cgi",
"env_name":"test",
"category": "ap-shanghai"
}
- 响应体
HTTP/1.1 200 OK
Content-Type:application/json
{
"code": 0,
"error": "success",
"upgrade_info" [
{
"version":"1.2",
"timestamp":"0123456789",
"node_info" : [
{
"node_ip":"127.0.0.1",
"agent_detials":[
{
"agent_ip":"127.0.1.12",
"agent_status":"progress",
"agent_msg":"pre script exec failed",
},
{
...other agent_details
},
]
},
{
...other node_info
},
]
},
{
...other_upgrade_info
},
]
}
网友评论