获取

描述

integer/array sla.get(object parameters)

该方法允许根据给定的参数检索 SLA 对象。

这个方法所有用户类型都可以是用。在用户角色设置中可以撤销调用该方法的权限。 查看 用户角色 roles获取更多信息。

参数

(object) 定义所需输出的参数。

该方法支持以下参数。

参数 类型 描述
slaids ID/数组 仅返回具有指定ID的SLA。
serviceids ID/数组 仅返回与特定服务匹配的SLA。
selectSchedule 查询 返回一个schedules属性,包含SLA时间表。

支持count
selectExcludedDowntimes 查询 返回一个excluded_downtimes属性,包含SLA排除的停机时间。

支持count
selectServiceTags 查询 返回一个service_tags属性,包含SLA服务标签。

支持count
sortfield 字符串/数组 根据给定属性对结果进行排序。

可能的值:slaidnameperiodsloeffective_datetimezonestatusdescription
countOutput 布尔值 这些参数在参考说明中描述。
editable 布尔值
excludeSearch 布尔值
filter 对象
limit 整数
output 查询
preservekeys 布尔值
search 对象
searchByAny 布尔值
searchWildcardsEnabled 布尔值
sortorder 字符串/数组
startSearch 布尔值

返回值

(integer/array) 返回条目:

  • 一个数组对象;
  • 如果使用了 countOutput 参数,则返回检索到的对象数量。

示例

获取所有 SLA

检索所有有关所有 SLA 及其属性的数据。

请求:

{
           "jsonrpc": "2.0",
           "method": "sla.get",
           "params": {
               "output": "extend",
               "selectSchedule": ["period_from", "period_to"],
               "selectExcludedDowntimes": ["name", "period_from", "period_to"],
               "selectServiceTags": ["tag", "operator", "value"],
               "preservekeys": true
           },
           "id": 1
       }

响应:

{
           "jsonrpc": "2.0",
           "result": {
               "1": {
                   "slaid": "1",
                   "name": "数据库运行时间",
                   "period": "1",
                   "slo": "99.9995",
                   "effective_date": "1672444800",
                   "timezone": "America/Toronto",
                   "status": "1",
                   "description": "为主 SQL 数据库引擎提供卓越的运行时间。",
                   "service_tags": [
                       {
                           "tag": "数据库",
                           "operator": "0",
                           "value": "mysql"
                       },
                       {
                           "tag": "数据库",
                           "operator": "0",
                           "value": "postgresql"
                       }
                   ],
                   "schedule": [
                       {
                           "period_from": "0",
                           "period_to": "601200"
                       }
                   ],
                   "excluded_downtimes": [
                       {
                           "name": "软件版本升级推广",
                           "period_from": "1648760400",
                           "period_to": "1648764900"
                       }
                   ]
               }
           },
           "id": 1
       }

来源

CSla:get() 在 ui/include/classes/api/services/CSla.php