[comment]: # ({6a93039d-6a93039d})
# graphprototype.get

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

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

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

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

::: noteclassic
该方法可供任何类型的用户使用。调用该方法的权限可以在用户角色设置中撤销。更多信息请参阅[User
roles](/manual/web_interface/frontend_sections/administration/user_roles)。

:::

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

[comment]: # ({0fb4a4f3-de0f74af})
### 参数

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

该方法支持以下参数。

| 参数 | [数据类型](/manual/api/reference_commentary#数据类型) | 描述 |
|--|--|------|
| discoveryids | string/array | 仅返回属于给定发现规则的图形原型。 |
| graphids | string/array | 仅返回具有给定ID的图形原型。 |
| groupids | string/array | 仅返回属于给定主机组中主机的图形原型。 |
| hostids | string/array | 仅返回属于给定主机的图形原型。 |
| inherited | boolean | 如果设置为`true`，则仅返回从模板继承的图形原型。 |
| itemids | string/array | 仅返回包含给定监控项原型的图形原型。 |
| templated | boolean | 如果设置为`true`，则仅返回属于模板的图形原型。 |
| templateids | string/array | 仅返回属于给定模板的图形原型。 |
| selectDiscoveryRule | query | 返回一个[lld规则](/manual/api/reference/discoveryrule/object#lld规则)属性，包含图形原型所属的LLD规则。 |
| selectGraphItems | query | 返回一个[gitems](/manual/api/reference/graphitem/object)属性，包含图形原型中使用的图形监控项。 |
| selectGroups | query | 返回一个[groups](/manual/api/reference/hostgroup/object)属性，包含图形原型所属的主机组。 |
| selectHosts | query | 返回一个[hosts](/manual/api/reference/host/object)属性，包含图形原型所属的主机。 |
| selectItems | query | 返回一个`items`属性，包含图形原型中使用的[items](/manual/api/reference/item/object)和[item prototypes](/manual/api/reference/itemprototype/object)。 |
| selectTemplates | query | 返回一个[templates](/manual/api/reference/template/object)属性，包含图形原型所属的模板。 |
| filter | object | 仅返回与给定过滤器完全匹配的结果。<br><br>接受一个array，其中键是属性名称，值是要匹配的单个值或array的值。<br><br>支持额外的过滤器：<br>`host` - 图形原型所属的主机的技术名称；<br>`hostid` - 图形原型所属的主机的ID。 |
| sortfield | string/array | 按给定属性对结果进行排序。<br><br>可能的值为：`graphid`、`name`和`graphtype`。 |
| countOutput | boolean | 这些参数在[通用get方法参数](/manual/api/reference_commentary#通用get方法参数)中有描述。 |
| editable | boolean | ^           |
| excludeSearch | boolean | ^           |
| limit | integer | ^           |
| output | query | ^           |
| preservekeys | boolean | ^           |
| search | object | ^           |
| searchByAny | boolean | ^           |
| searchWildcardsEnabled | boolean | ^           |
| sortorder | string/array | ^           |
| startSearch | boolean | ^           |

[comment]: # ({/0fb4a4f3-de0f74af})

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

`(integer/array)` 返回以下两种情况之一:

-   一个包含array的objects数组
-   检索到的objects数量（当使用了`countOutput`参数时）

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

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

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

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

从LLD规则中获取所有图形原型。

请求:

```json
{
    "jsonrpc": "2.0",
    "method": "graphprototype.get",
    "params": {
        "output": "extend",
        "discoveryids": "27426"
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "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",
            "discover": "0"
        }
    ],
    "id": 1
}
```

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

[comment]: # ({e4f96e80-e4f96e80})
### 另请参阅

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

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

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

CGraphPrototype::get() 位于
*ui/include/classes/api/services/CGraphPrototype.php* 文件中.

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