[comment]: # translation:outdated

[comment]: # ({6a93039d-6a93039d})
# 获取

[comment]: # ({/6a93039d-6a93039d})

[comment]: # ({aeecab61-27b69e53})
### 描述

`integer/array graphprototype.get(object parameters)`

该方法允许根据指定的参数来检索图形原型。

::: noteclassic
这种方法对任何类型的用户都适用。调用该方法的权限可以在用户角色设置中被撤销。 前往[用户角色](/manual/web_interface/frontend_sections/users/user_roles)以了解更多信息。
:::

[comment]: # ({/aeecab61-27b69e53})

[comment]: # ({20b09c9f-de0f74af})
### 参数

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

该方法支持以下参数。

|参数|[类型](/manual/api/reference_commentary#data-types)|描述|
|--|--|------|
|discoveryids|ID/array|仅返回属于给定发现规则的图形原型。|
|graphids|ID/array|仅返回具有给定 ID 的图形原型。|
|groupids|ID/array|仅返回属于给定主机组或模板组中的主机或模板的图形原型。|
|hostids|ID/array|仅返回属于给定主机的图形原型。|
|inherited|boolean|如果设置为 `true`，则仅返回从模板继承的图形原型。|
|itemids|ID/array|仅返回包含给定监控项原型的图形原型。|
|templated|boolean|如果设置为 `true`，则仅返回属于模板的图形原型。|
|templateids|ID/array|仅返回属于给定模板的图形原型。|
|selectDiscoveryData|query|返回一个 `discoveryData` 属性，其中包含图形原型发现对象数据。图形原型发现对象将已发现的图形原型链接到发现它的图形原型。<br><br>它具有以下属性：<br>`parent_graphid` - `(ID)` 创建该图形所依据的图形原型的 ID；<br>`status` - `(int)` 图形发现状态：<br>0 - *(默认)* 图形原型已发现，<br>1 - 图形原型不再被发现；<br>`ts_delete` - `(timestamp)` 不再被发现的图形原型将被删除的时间。|
|selectDiscoveryRule|query|返回一个 [`discoveryRule`](/manual/api/reference/discoveryrule/object#lld-rule) 属性，其中包含该图形原型所属的 LLD 规则。|
|selectDiscoveryRulePrototype|query|返回一个 [`discoveryRulePrototype`](/manual/api/reference/discoveryruleprototype/object) 属性，其中包含该图形原型所属的父 LLD 规则原型。|
|selectGraphItems|query|返回一个 [`gitems`](/manual/api/reference/graphitem/object) 属性，其中包含图形原型中使用的图形项。|
|selectHostGroups|query|返回一个 [`hostgroups`](/manual/api/reference/hostgroup/object) 属性，其中包含该图形原型所属的主机组。|
|selectHosts|query|返回一个 [`hosts`](/manual/api/reference/host/object) 属性，其中包含该图形原型所属的主机。|
|selectItems|query|返回一个 `items` 属性，其中包含图形原型中使用的[监控项](/manual/api/reference/item/object)和[监控项原型](/manual/api/reference/itemprototype/object)。|
|selectTemplateGroups|query|返回一个 [`templategroups`](/manual/api/reference/templategroup/object) 属性，其中包含该图形原型所属的模板组。|
|selectTemplates|query|返回一个 [`templates`](/manual/api/reference/template/object) 属性，其中包含该图形原型所属的模板。|
|filter|object|仅返回与给定过滤条件完全匹配的结果。<br><br>接受一个对象，其中键为属性名称，值为单个值或用于匹配的值数组。<br><br>不支持 `text` [数据类型](/manual/api/reference_commentary#data-types) 的属性。<br><br>支持附加属性：<br>`host` - 该图形原型所属主机的技术名称；<br>`hostid` - 该图形原型所属主机的 ID。|
|sortfield|string/array|按给定属性对结果进行排序。<br><br>可能的值：`graphid`、`name`、`graphtype`、`discovered`。|
|countOutput|boolean|这些参数在[参考说明](/manual/api/reference_commentary#common-get-method-parameters)中进行了描述。|
|editable|boolean|^|
|excludeSearch|boolean|^|
|limit|integer|^|
|output|query|^|
|preservekeys|boolean|^|
|search|object|^|
|searchByAny|boolean|^|
|searchWildcardsEnabled|boolean|^|
|sortorder|string/array|^|
|startSearch|boolean|^|

[comment]: # ({/20b09c9f-de0f74af})

[comment]: # ({7223bab1-7223bab1})
### 返回值

返回 `(integer/array)` 其中之一:

-   一个对象的数组;
-   如果使用了 `countOutput` 参数，则为检索到的对象的数量。

[comment]: # ({/7223bab1-7223bab1})

[comment]: # ({b41637d2-b41637d2})
### 示例

[comment]: # ({/b41637d2-b41637d2})

[comment]: # ({117a4fa9-62edff03})
#### 从 LLD 规则中检索图形原型

检索某个 LLD 规则中的所有图形原型。

[请求](/manual/api#performing-requests)：

```json
{
    "jsonrpc": "2.0",
    "method": "graphprototype.get",
    "params": {
        "output": "extend",
        "discoveryids": "27426"
    },
    "id": 1
}
```

响应：

```json
{
    "jsonrpc": "2.0",
    "result": [
        {
            "graphid": "1017",
            "name": "Disk space usage {#FSNAME}",
            "width": "600",
            "height": "340",
            "yaxismin": "0.0000",
            "yaxismax": "0.0000",
            "templateid": "442",
            "show_work_period": "0",
            "show_triggers": "0",
            "graphtype": "2",
            "show_legend": "1",
            "show_3d": "1",
            "percent_left": "0.0000",
            "percent_right": "0.0000",
            "ymin_type": "0",
            "ymax_type": "0",
            "ymin_itemid": "0",
            "ymax_itemid": "0",
            "flags": "2"
            "discover": "0"
        }
    ],
    "id": 1
}
```

[comment]: # ({/117a4fa9-62edff03})

[comment]: # ({7b8d40e8-e4f96e80})
### 另请参见

-   [发现规则](/manual/api/reference/discoveryrule/object#discovery-rule)
-   [图形监控项](/manual/api/reference/graphitem/object#graph-item)
-   [监控项](/manual/api/reference/item/object#item)
-   [主机](/manual/api/reference/host/object#host)
-   [主机组](/manual/api/reference/hostgroup/object#host-group)
-   [模板](/manual/api/reference/template/object#template)
-   [模板组](/manual/api/reference/templategroup/object#template-group)

[comment]: # ({/7b8d40e8-e4f96e80})

[comment]: # ({fc80fda8-fc80fda8})
### 源码

CGraphPrototype::get() in
*ui/include/classes/api/services/CGraphPrototype.php*.

[comment]: # ({/fc80fda8-fc80fda8})
