• 返回
  • 最后更新
  • 2020-10-03 22:15:30 +0800 CST

ToughRADIUS 商业版 API — 策略管理

通过 API 来管理用户策略, 一个策略通常会被应用到多个用户,创建时为用户绑定策略, 即可让用户获得策略定义的各项配置

数据结构

id: 策略唯一id
name: 策略名,必须
domain: 认证域,可选
addr_pool: 地址池,可选
active_num: 同时在线数, 0表示不限制
up_rate:  上行速率 Mbps
down_rate: 下行速率 Mbps
bill_times: 授权的时长,创建用户时自动计算过期
bill_timeunit: 授权的时长单位,支持 'second', 'minute', 'hour','day','week','month','year'
up_limit_policy: 上行限速策略,可选
down_limit_policy: 下行限速策略,可选
limit_policy:  总体限速策略,可选
remark: 备注,可选
status: 状态 enabled/disabled,必选
tags:  标签,可选

- 查询策略

GET /bss/profile/list?tags=&keyword=

参数通过 url 传递, 通过tags 和 keyword 模糊匹配

请求Header

authorization: Bearer <Api Token>

响应结果

{ 
    "code": 0, 
    "msg": "Success"  
    "data": [{
          "id": "1",
          "tags": "N/A",
          "name": "default",
          "domain": "N/A",
          "addr_pool": "N/A",
          "active_num": 1,
          "up_rate": 0,
          "down_rate": 0,
          "limit_policy": "N/A",
          "up_limit_policy": "N/A",
          "down_limit_policy": "N/A",
          "bill_times": 1,
          "bill_timeunit": "day",
          "status": "enabled",
          "remark": "default",
          "create_time": "2020-09-01 00:00:00",
          "update_time": "2020-09-09 15:32:55"
        },...
     ]
 }

- 根据ID查询单个策略

GET /bss/profile/get?id=1

请求Header

authorization: Bearer <Api Token>

响应结果

{
  "code": 0,
  "msgtype": "info",
  "msg": "Operation Success",
  "data": {
    "id": "1",
    "tags": "N/A",
    "name": "default",
    "domain": "N/A",
    "addr_pool": "N/A",
    "active_num": 1,
    "up_rate": 10240,
    "down_rate": 10240,
    "limit_policy": "N/A",
    "up_limit_policy": "N/A",
    "down_limit_policy": "N/A",
    "bill_times": 86400,
    "bill_timeunit": "second",
    "status": "enabled",
    "remark": "default",
    "create_time": "2020-09-01 00:00:00",
    "update_time": "2020-09-01 00:00:00"
  }
}

- 创建策略

POST /bss/profile/add

请求Header

authorization: Bearer <Api Token>
content-type: application/x-www-form-urlencoded

请求参数

name=myprofile
domain=N/A
addr_pool=N/A
active_num=0 
up_rate=0
down_rate=0
bill_times=1
bill_timeunit=day
up_limit_policy=N/A
down_limit_policy=N/A
limit_policy=N/A
remark=N/A
status=enabled
tags=N/A

响应结果

{ "code":0, "msg": "Success", data: { "id": "..." } }

返回记录唯一ID

- 修改策略

POST /bss/profile/update

请求Header

authorization: Bearer <Api Token>
content-type: application/x-www-form-urlencoded

请求参数

id=1
name=myprofile
domain=N/A
addr_pool=N/A
active_num=0 
up_rate=0
down_rate=0
bill_times=1
bill_timeunit=day
up_limit_policy=N/A
down_limit_policy=N/A
limit_policy=N/A
remark=N/A
status=enabled
tags=N/A

响应结果

{ "code": 0, "msg": "Success" }

- 删除策略

GET /bss/profile/delete?ids=1303594346607874048

参数直接通过url参数ids传递,支持多个id,英文逗号分割

请求Header

authorization: Bearer <Api Token>

响应结果

{ "code": 0, "msg": "Success" }