integer/array service.get(object parameters)
The method allows to retrieve services according to the given parameters. 此方法允许根据给定的参数检索服务。 ::: noteclassic This method is available to users of any type. Permissions to call the method can be revoked in user role settings. See User roles for more information. ::: :::请注意 此方法允许任何用户使用。可以在用户角色设置中撤销调用此方法的权限。更多信息请查看 用户角色。 :::
(object)
Parameters defining the desired output. (object)
定义所需输出的参数。 The method supports the following parameters. 该方法支持以下参数。 |Parameter参数 |Type类型|Description说明| |--|--|------| |serviceids|ID/array|Return only services with the given IDs.仅返回拥有指定ID的服务。| |parentids|ID/array|Return only services that are linked to the given parent services.仅返回拥有指定硬依赖父服务的服务。| |deep_parentids|flag|Return all direct and indirect child services. Used together with parentids
.返回所有直接和间接的子服务,与父对象一起使用。| |childids|ID/array|Return only services that are linked to the given child services.仅返回在指定子服务上有硬依赖的服务。| |evaltype|integer|Rules for tag searching.标记搜索规则。
Possible values:
0 - (default默认) And/Or;
2 - Or.或| |tags|object/array|Return only services with given tags. Exact match by tag and case-sensitive or case-insensitive search by tag value depending on operator value.
Format: [{"tag": "<tag>", "value": "<value>", "operator": "<operator>"}, ...]
.
An empty array returns all services.仅返回具有给定标记的服务。按标记精确匹配,按标记值区分大小写或不区分大小写搜索,具体取决于运算符值。格式: [{"tag": "<tag>", "value": "<value>", "operator": "<operator>"}, ...]
.空数组返回所有服务。
Possible operator values:运算符
0 - (default默认) Contains包含;
1 - Equals等于;
2 - Does not contain;不包含
3 - Does not equal;不相等
4 - Exists;存在
5 - Does not exist.不存在| |problem_tags|object/array|Return only services with given problem tags. Exact match by tag and case-sensitive or case-insensitive search by tag value depending on operator value.
Format: [{"tag": "<tag>", "value": "<value>", "operator": "<operator>"}, ...]
.
An empty array returns all services.仅返回具有给定问题标记的服务。按标记精确匹配,按标记值区分大小写或不区分大小写搜索,具体取决于运算符值。格式:[{"tag": "<tag>", "value": "<value>", "operator": "<operator>"}, ...]
.空数组返回所有服务。
Possible operator values:运算符
0 - (default默认) Contains包含;
1 - Equals等于;
2 - Does not contain;不包含
3 - Does not equal;不相等
4 - Exists;存在
5 - Does not exist.不存在| |without_problem_tags|flag|Return only services without problem tags.只返回没有问题标签的服务。| |slaids|ID/array|Return only services that are linked to the specific SLA(s).仅返回链接到特定SLA的服务。| |selectChildren|query|Return a children
property with the child services.仅返回在指定子服务上有硬依赖的服务。
Supports count
.支持统计| |selectParents|query|Return a parents
property with the parent services.仅返回在指定父服务上有硬依赖的服务。
Supports count
.支持统计| |selectTags|query|Return a tags
property with service tags.返回制定服务标签
Supports count
.支持统计| |selectProblemEvents|query|Return a problem_events
property with an array of problem event objects.返回一个带有问题事件对象数组的problem_events属性。
The problem event object has the following properties:问题事件对象具有以下属性:eventid
- (ID)
Event ID;事件IDseverity
- (string)
Current event severity;严重性-(字符串)当前事件的严重性;name
- (string)
Resolved event name.
Supports count
.name-(字符串)已解析的事件名称。| |selectProblemTags|query|Return a problem_tags
property with problem tags.指定问题标签返回标签
Supports count
.支持统计| |selectStatusRules|query|Return a status_rules
property with status rules.返回一个状态规则
Supports count
.支持统计| |selectStatusTimeline|object/array|Return a status_timeline
property containing service state changes for given periods.返回包含给定时段的服务状态更改的status_timeline属性。
Format [{"period_from": "<period_from>", "period_to": "<period_to>"}, ...]
格式:[{"period_from": "<period_from>", "period_to": "<period_to>"}, ...]
- period_from
being a starting date (inclusive; integer timestamp) and period_to
being an ending date (exclusive; integer timestamp) for the period you're interested in.period_from
开始日期(包括;整数时间戳),period_to结束日期(不包括;整数时戳)。
Returns an array of entries containing a start_value
property and an alarms
array for the state changes within specified periods.返回一个数组,其中包含start_value属性和指定时段内状态更改的报警| |sortfield|string/array|Sort the result by the given properties.根据给定的属性对结果进行排序。
Possible values: serviceid
, name
, status
, sortorder
, created_at
.| |countOutput|boolean|These parameters being common for all get
methods are described in detail in the [reference commentary]这些参数对所有get方法都是通用的,参考注释中进行了详细描述。(/manual/api/reference_commentary#common_get_method_parameters).| |editable|boolean|^| |excludeSearch|boolean|^| |filter|object|^| |limit|integer|^| |output|query|^| |preservekeys|boolean|^| |search|object|^| |searchByAny|boolean|^| |searchWildcardsEnabled|boolean|^| |sortorder|string/array|^| |startSearch|boolean|^|
(integer/array)
Returns either: (整型/数组)
返回其中之一: - an array of objects;- 一个对象数组; - the count of retrieved objects, if the countOutput
parameter has been used.- 如果使用countOutput
参数,被检索对象的数量。
Retrieve all data about all services and their dependencies. 检索有关所有服务及其依赖关系的所有数据。 Request: 请求:
{
"jsonrpc": "2.0",
"method": "service.get",
"params": {
"output": "extend",
"selectChildren": "extend",
"selectParents": "extend"
},
"id": 1
}
Response: 响应:
{
"jsonrpc": "2.0",
"result": [
{
"serviceid": "1",
"name": "My Service - 0001",
"status": "-1",
"algorithm": "2",
"sortorder": "0",
"weight": "0",
"propagation_rule": "0",
"propagation_value": "0",
"description": "My Service Description 0001.",
"uuid": "dfa4daeaea754e3a95c04d6029182681",
"created_at": "946684800",
"readonly": false,
"parents": [],
"children": []
},
{
"serviceid": "2",
"name": "My Service - 0002",
"status": "-1",
"algorithm": "2",
"sortorder": "0",
"weight": "0",
"propagation_rule": "0",
"propagation_value": "0",
"description": "My Service Description 0002.",
"uuid": "20ea0d85212841219130abeaca28c065",
"created_at": "946684800",
"readonly": false,
"parents": [],
"children": []
}
],
"id": 1
}
CService::get() in ui/include/classes/api/services/CService.php.