AgileConfig - RESTful API 介紹
阿新 • • 發佈:2021-01-18
## AgileConfig
AgileConfig是一個基於.net core開發的輕量級配置中心。
AgileConfig秉承輕量化的特點,部署簡單、配置簡單、使用簡單、學習簡單,它只提取了必要的一些功能,並沒有像Apollo那樣複雜且龐大。但是它的功能也已經足夠你替換webconfig,appsettings.json這些檔案了。如果你不想用微服務全家桶,不想為了部署一個配置中心而需要看N篇教程跟幾臺伺服器那麼你可以試試AgileConfig :)
## RESTful Api
為了更加方便的跟業務系統整合最新版的AgileConfig已支援json格式的 restful api來維護配置 。
本API入參跟出參為json格式,所以請求的時候需設定Content-Type頭部為application/json 。
使用basic簡單認證,設定Authorization頭部為Basic base64(userName:password) 。
當操作節點、應用api的時候basic認證的userName固定設定為admin,password為當前密碼 。
當操作配置api的時候basic認證的userName為應用的appid,password為應用的祕鑰 。
### 節點
因為本系統登入的時候沒有使用者名稱所以basic認證的時候使用者名稱固定使用admin密碼為當前設定的密碼
#### model
```
{
"address": "http://localhost:5000",
"remark": "this",
"status": 0, // 1=online 0=offile
"lastEchoTime": null
}
```
#### 獲取所有節點
| 引數名 | 值 |
| ---- | ---- |
| url | /api/node |
| method | GET |
| status code| 200 |
| response content | [model] |
#### 新增節點
| 引數名 | 值 |
| ---- | ---- |
| url | /api/node |
| method | POST |
| status code | 201 |
| request body | model |
| response content | 空 |
#### 刪除節點
| 引數名 | 值 |
| ---- | ---- |
| url | /api/node?address={address} |
| method | DELETE |
| status code | 204 |
| response content | 空 |
### 應用
因為本系統登入的時候沒有使用者名稱所以basic認證的時候使用者名稱固定使用admin密碼為當前設定的密碼
#### model
```
{
"id": "xxx",
"name": "測試程式3",
"secret": "",
"enabled": true, //是否啟用
"inheritanced": true, //是否可以繼承
"inheritancedApps": null //繼承的app列表
}
```
#### 獲取所有應用
| 引數名 | 值 |
| ---- | ---- |
| url | /api/app |
| method | GET |
| status code | 200 |
| response content | [model] |
#### 獲取單一應用
| 引數名 | 值 |
| ---- | ---- |
| url | /api/app/{appid} |
| method | GET |
| status code | 200 |
| response content | model |
#### 新增應用
| 引數名 | 值 |
| ---- | ---- |
| url | /api/app |
| method | POST |
| status code | 201 |
| request body | model |
| response content | 空 |
#### 修改應用
| 引數名 | 值 |
| ---- | ---- |
| url | /api/app |
| method | PUT |
| status code | 200 |
| request body | model |
| response content | 空 |
### 配置
配置的basic認證使用者名稱使用appId密碼使用secret
#### model
```
{
"id": "0986e7ed33c447618f28e92360394cea",
"appId": "xxx",
"group": "", //組
"key": "key1",
"value": "3333",
"description": null, //描述
"onlineStatus": 0, //是否線上 0=等待上線 1=線上
"status": 1 // 0=刪除 1=正常
}
```
#### 獲取所有app的配置
| 引數名 | 值 |
| ---- | ---- |
| url | /api/config |
| method | GET |
| status code | 200 |
| response content | [model] |
#### 獲取單一配置
| 引數名 | 值 |
| ---- | ---- |
| url | /api/config/{id} |
| method | GET |
| status code | 200 |
| response content | model |
#### 新建配置
| 引數名 | 值 |
| ---- | ---- |
| url | /api/config |
| method | POST |
| status code | 201 |
| request body | model |
| response content | 空 |
#### 修改配置
| 引數名 | 值 |
| ---- | ---- |
| url | /api/config |
| method | PUT |
| status code | 200 |
| request body | model |
| response content | 空 |
#### 刪除配置
| 引數名 | 值 |
| ---- | ---- |
| url | /api/config/{id} |
| method | DELETE |
| status code | 204 |
| response content | 空 |
#### 上線配置
| 引數名 | 值 |
| ---- | ---- |
| url | /api/config/publish/{id} |
| method | POST |
| status code | 200 |
| response content | 空 |
#### 下線配置
| 引數名 | 值 |
| ---- | ---- |
| url | /api/config/offline/{id} |
| method | POST |
| status code | 200 |
| response content | 空 |
相關內容:
[AgileConfig-如何使用AgileConfig.Client讀取配置](https://www.cnblogs.com/kklldog/p/how-to-use-agileconfigclient.html)
[AgileConfig-輕量級配置中心 1.1.0 釋出,支援應用間配置繼承](https://www.cnblogs.com/kklldog/p/agileconfig_110_publish.html)
[造輪子-AgileConfig基於.NetCore的一個輕量級配置中心](https://github.com/kklldog/AgileConfig)
gihub地址:
[AgileConfig](https://github.com/kklldog/AgileConfig)
[AgileConfig.Client](https://github.com/kklldog/AgileConfig_Cli