订阅事件

  • API: POST /api/{version}/event/subscribe/{bk_supplier_account}/{bk_biz_id}
  • API 名称: subscribe_event
  • 功能说明:

    • 中文:事件订阅
    • English:subscribe event
  • input body:

  1. {
  2. "subscription_name":"mysubscribe",
  3. "system_name":"SystemName",
  4. "callback_url":"http://127.0.0.1:8080/callback",
  5. "confirm_mode":"httpstatus",
  6. "confirm_pattern":"200",
  7. "subscription_form":"hostcreate",
  8. "timeout":10
  9. }
  • input 字段说明
字段 类型 是否必须 默认值 说明 Description
bk_biz_id int 业务id business id
bk_supplier_account string 开发商账号 supplier account code
subscription_name string 订阅的名字 the subscription name
system_name string 订阅事件的系统的名字 the subscriber’s name
callback_url string 回调函数 the callbacks of the subscribers
confirm_mode string 事件发送成功校验模式,可选 1-httpstatus,2-regular confirm success mode of send to callback success, could be 1-httpstatus,2-regular
confirm_pattern string callback的httpstatus或正则 the correct return httpstatus or regular
subscription_form string 订阅的事件,以逗号分隔 subcription event names, should split by comma
timeout int 发送事件超时时间 time out when send event message to callback
  • output:
  1. {
  2. "result":true,
  3. "bk_error_code":0,
  4. "bk_error_msg":"",
  5. "data":{
  6. "subscription_id": 1
  7. }
  8. }
  • output 字段说明
字段 类型 说明 Description
result bool ture:成功,false:失败 true:success, false: failure
bk_error_code int 错误编码。 0表示success,>0表示失败错误 error code. 0 represent success, >0 represent failure code
bk_error_msg string 请求失败返回的错误信息 error message from failed request
data object 操作结果 the result

data 字段说明

名称 类型 说明 Description
subscription_id int 新增订阅的订阅ID the id of the new subscription

退订事件

  • API: DELETE /api/{version}/event/subscribe/{supplier_account}/{bk_biz_id}/{subscription_id}
  • API 名称:unsubcribe_event
  • 功能说明:

    • 中文:退订
    • English:event unsubscribe
  • input body

  1. {}
  • input 字段说明
名称 类型 默认值 说明 Description
bk_biz_id int 业务id business id
bk_supplier_account string 开发商账号 supplier account code
subscription_id int 订阅ID subscription_id
  • output
    1. {
    2. "result":true,
    3. "bk_error_code":0,
    4. "bk_error_msg":"",
    5. "data":"success"
    6. }
  • output 字段说明
字段 类型 说明 Description
result bool ture:成功,false:失败 true:success, false: failure
bk_error_code int 错误编码。 0表示success,>0表示失败错误 error code. 0 represent success, >0 represent failure code
bk_error_msg string 请求失败返回的错误信息 error message from failed request
data string 操作结果 the result

修改订阅

  • API: PUT /api/{version}/event/subscribe/{bk_supplier_account}/{bk_biz_id}/{subscription_id}
  • API 名称:update_event_subscribe

    • 中文:修改订阅
    • English:update the event subscription
  • input body

  1. {
  2. "subscription_name":"mysubscribe",
  3. "system_name":"SystemName",
  4. "callback_url":"http://127.0.0.1:8080/callback",
  5. "confirm_mode":"httpstatus",
  6. "confirm_pattern":"200",
  7. "subscription_form":"hostcreate",
  8. "timeout":10
  9. }
  • input 字段说明
字段 类型 是否必须 默认值 说明 Description
bk_biz_id int 业务id business id
bk_supplier_account string 开发商账号 supplier account code
subscription_id int 订阅ID subscription_id
subscription_name string 订阅的名字 the subscription name
system_name string 订阅事件的系统的名字 the subscriber’s name
callback_url string 回调函数 the callbacks of the subscribers
confirm_mode string 事件发送成功校验模式,可选 1-httpstatus,2-regular confirm success mode of send to callback success, could be 1-httpstatus,2-regular
confirm_pattern string callback的httpstatus或正则 the correct return httpstatus or regular
subscription_form string 订阅的事件,以逗号分隔 subcription event names, should split by comma
timeout int 发送事件超时时间 time out when send event message to callback
  • output
  1. {
  2. "result":true,
  3. "bk_error_code":0,
  4. "bk_error_msg":"",
  5. "data":"success"
  6. }
  • output 字段说明
字段 类型 说明 Description
result bool ture:成功,false:失败 true:success, false: failure
bk_error_code int 错误编码。 0表示success,>0表示失败错误 error code. 0 represent success, >0 represent failure code
bk_error_msg string 请求失败返回的错误信息 error message from failed request
data object 数据对象,在操作成功后如果有返回值数据会在此字段设置 The result, it will include the data ,only the error code is zero.

查询订阅

  • API: POST /api/{version}/event/subscribe/search/{bk_supplier_account}/{bk_biz_id}
  • API 名称:search_subscription

    • 中文:查询订阅
    • English:search subscriptions
  • input body

  1. {
  2. "page":{
  3. "start":0,
  4. "limit":10,
  5. "sort":"HostName"
  6. }
  7. }
  • input 输入字段说明

  • output

  1. {
  2. "result":true,
  3. "bk_error_code":0,
  4. "bk_error_msg":"",
  5. "data":[
  6. {
  7. "subscription_id":1,
  8. "subscription_name":"mysubscribe",
  9. "system_name":"SystemName",
  10. "callback_url":"http://127.0.0.1:8080/callback",
  11. "confirm_mode":"httpstatus",
  12. "confirm_pattern":"200",
  13. "subscription_form":"hostcreate",
  14. "timeout":10,
  15. "last_time": "2017-09-19 16:57:07",
  16. "operator": "user",
  17. "statistics": {
  18. "total": 30,
  19. "failure": 2
  20. }
  21. }
  22. ]
  23. }
  • output 字段说明
字段 类型 说明 Description
result bool ture:成功,false:失败 true:success, false: failure
bk_error_code int 错误编码。 0表示success,>0表示失败错误 error code. 0 represent success, >0 represent failure code
bk_error_msg string 请求失败返回的错误信息 error message from failed request
data object 操作结果 the result

data 字段说明

名称 类型 说明 Description
subscription_id int 订阅ID the subscription id
subscription_name string 订阅名 the subscription
system_name string 系统名称 the subscriber’s name
callback_url string 回调地址 the callback of the subscription
confirm_mode string 回调成功确认模式,可选:httpstatus,regular the http status
confirm_pattern string 回调成功标志 the http result pattern
subscription_form string 订阅单,用”,”分隔 subscribed events,split by comma
timeout int 超时时间,单位:秒 time out
operator int 本条数据的最后更新人员 updator of this subscription
last_time int 更新时间 update time of this subscription
statistics.total int 推送总数 the total count one push
statistics.failure int 推送失败数 the failure total count

测试推送

  • API: POST /api/{version}/event/subscribe/ping
  • API 名称:ping_subscription

    • 中文:推送测试
    • English:push test
  • input body

  1. {
  2. "callback_url": "127.0.0.1:8080/callback",
  3. "data": {}
  4. }
  • input 字段说明
字段 类型 说明 Description
callback_url string 回调方法 the callback URL
data string 回调方法 data that would send to callback url
  • output
  1. {
  2. "result":true,
  3. "bk_error_code":0,
  4. "bk_error_msg":"",
  5. "data":[
  6. {
  7. "http_status": 200,
  8. "response_body": "xxxxx"
  9. }
  10. ]
  11. }
  • output 字段说明
名称 类型 说明 Description
http_status int 返回的HTTP STATUS the http status
response_body string 订阅者的callback返回体 the response data from subcription callback

测试推送(只测试连通性)

  • API: POST /api/{version}/event/subscribe/telnet
  • API 名称: testing_connection

    • 中文:连通性测试
    • English:connectivity testing
  • input body

  1. {
  2. "callback_url": "127.0.0.1:8080/callback"
  3. }
  • input 字段说明
字段 类型 说明 Description
callback_url string 回调方法 the callback URL
  • output
  1. {
  2. "result":true,
  3. "bk_error_code":0,
  4. "bk_error_msg":"",
  5. "data": "success"
  6. }
  • output 字段说明
字段 类型 说明 Description
result bool ture:成功,false:失败 true:success, false: failure
bk_error_code int 错误编码。 0表示success,>0表示失败错误 error code. 0 represent success, >0 represent failure code
bk_error_msg string 请求失败返回的错误信息 error message from failed request
data string 操作结果 the result