获取

描述

integer/array sla.get(object parameters)

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

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

参数

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

这个方法支持下列参数。

参数类型描述
slaidsID/array仅返回 SLA 给定的 ID。
serviceidsID/array仅返回与特定服务匹配的 SLA。
selectSchedulequery返回一个带有 SLA 时间表的 schedule 属性。

支持 count
selectExcludedDowntimesquery返回一个带有 SLA 排除停机时间的excluded_downtimes 属性。

支持 count
selectServiceTagsquery返回一个带有 SLA 服务标签的 service_tags 属性。

支持 count
sortfieldstring/array按照给定的属性对结果进行排序。

可能的值: slaid, name, period, slo, effective_date, timezone, status, description
countOutputboolean这些参数在所有 get 方法中都是通用的,详细描述在 [参考说明](/manual/api/reference_commentary#常用的-get-方法参数。
editableboolean
excludeSearchboolean
filterobject
limitinteger
outputquery
preservekeysboolean
searchobject
searchByAnyboolean
searchWildcardsEnabledboolean
sortorderstring/array
startSearchboolean

返回值

(integer/array) 返回条目:

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

示例

检索所有SLA

检索所有数据,包括 SLA 和它的属性。

请求:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "sla.get",
  4. "params": {
  5. "output": "extend",
  6. "selectSchedule": ["period_from", "period_to"],
  7. "selectExcludedDowntimes": ["name", "period_from", "period_to"],
  8. "selectServiceTags": ["tag", "operator", "value"],
  9. "preservekeys": true
  10. },
  11. "id": 1
  12. }

响应:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "1": {
  5. "slaid": "1",
  6. "name": "Database Uptime",
  7. "period": "1",
  8. "slo": "99.9995",
  9. "effective_date": "1672444800",
  10. "timezone": "America/Toronto",
  11. "status": "1",
  12. "description": "Provide excellent uptime for main SQL database engines.",
  13. "service_tags": [
  14. {
  15. "tag": "Database",
  16. "operator": "0",
  17. "value": "MySQL"
  18. },
  19. {
  20. "tag": "Database",
  21. "operator": "0",
  22. "value": "PostgreSQL"
  23. }
  24. ],
  25. "schedule": [
  26. {
  27. "period_from": "0",
  28. "period_to": "601200"
  29. }
  30. ],
  31. "excluded_downtimes": [
  32. {
  33. "name": "Software version upgrade rollout",
  34. "period_from": "1648760400",
  35. "period_to": "1648764900"
  36. }
  37. ]
  38. }
  39. },
  40. "id": 1
  41. }

来源

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