[comment]: # translation:outdated

[comment]: # ({31d5554a-31d5554a})
# hostprototype.get

[comment]: # ({/31d5554a-31d5554a})

[comment]: # ({d1534f8a-d1534f8a})
### 説明

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

このメソッドでは、指定されたパラメーターを基にホストプロトタイプを取得できます。

::: noteclassic
このメソッドはどのタイプのユーザーでも利用可能です。このメソッドを呼び出す権限は、ユーザーロール設定で
取り消すことができます。詳しくは[ユーザーの役割](/manual/web_interface/frontend_sections/administration/user_roles)を参照してください。
:::

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

[comment]: # ({1e6186e6-0d6ab1f2})
### パラメータ

`(object)` 目的の出力を定義するパラメーター。

このメソッドは、次のパラメーターをサポートします。

|パラメータ|[タイプ](/manual/api/reference_commentary#data_types)|説明|
|--|--|------|
|hostids|string/array|指定されたIDを持つホストプロトタイプのみを返します|
|discoveryids|string/array|指定されたLLDルールに属するホストプロトタイプのみを返します|
|inherited|boolean|`true`に設定すると、テンプレートから継承されたアイテムのみが返されます|
|selectDiscoveryRule|query|ホストプロトタイプが属するLLDルールを使用して[discoveryRule](/manual/api/reference/discoveryrule/object#lld_rule)プロパティを返します|
|selectInterfaces|query|[interfaces](/manual/api/reference/hostprototype/object#custom_interface)プロパティをホストプロトタイプカスタムインターフェイスとともに返します|
|selectGroupLinks|query|ホストプロトタイプのグループリンクを含む[groupLinks](/manual/api/reference/hostprototype/object#group_link)プロパティを返します|
|selectGroupPrototypes|query|[groupPrototypes](/manual/api/reference/hostprototype/object#group_prototype)プロパティを、ホストプロトタイプのグループプロトタイプとともに返します|
|selectMacros|query|ホストプロトタイプマクロを使用して[macros](/manual/api/reference/usermacro/object)プロパティを返します|
|selectParentHost|query|ホストプロトタイプが属するホストの[parent Host](/manual/api/reference/host/object)プロパティを返します|
|selectTags|query|[tags](/manual/api/reference/hostprototype/object#host_prototype_tag)プロパティをホストプロトタイプタグとともに返します|
|selectTemplates|query|ホストプロトタイプにリンクされたテンプレートを含む[templates](/manual/api/reference/template/object)プロパティを返します<br><br>`count`をサポートします|
|sortfield|string/array|指定されたプロパティで結果を並べ替えます。<br><br>値は`hostid`,` host`,`name`および`status`です|
|countOutput|boolean|すべての`get`メソッドに共通するこれらのパラメーターについては[Generic Zabbix API information](/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|^|

[comment]: # ({/1e6186e6-0d6ab1f2})

[comment]: # ({7223bab1-7223bab1})
### 戻り値

`(integer/array)` 次のいずれかを返します:

-   オブジェクトの配列
-   `countOutput`パラメーターが使用されている場合、取得したオブジェクトの数

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

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

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

[comment]: # ({bebba1b3-a91c8b17})
#### LLDルールからホストプロトタイプの取得

LLDルールから、すべてのホストプロトタイプ、グループリンク、グループプロトタイプ、およびタグを取得します。

Request:

```json
{
    "jsonrpc": "2.0",
    "method": "hostprototype.get",
    "params": {
        "output": "extend",
        "selectInterfaces": "extend",
        "selectGroupLinks": "extend",
        "selectGroupPrototypes": "extend",
        "selectTags": "extend",
        "discoveryids": "23554"
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}
```

Response:

```json
{
    "jsonrpc": "2.0",
    "result": [
        {
            "hostid": "10092",
            "host": "{#HV.UUID}",
            "name": "{#HV.UUID}",
            "status": "0",
            "templateid": "0",
            "discover": "0",
            "custom_interfaces": "1",
            "inventory_mode": "-1",
            "groupLinks": [
                {
                    "group_prototypeid": "4",
                    "hostid": "10092",
                    "groupid": "7",
                    "templateid": "0"
                }
            ],
            "groupPrototypes": [
                {
                    "group_prototypeid": "7",
                    "hostid": "10092",
                    "name": "{#CLUSTER.NAME}",
                    "templateid": "0"
                }
            ],
            "tags": [
                {
                    "tag": "Datacenter",
                    "value": "{#DATACENTER.NAME}"
                },
                {
                    "tag": "Instance type",
                    "value": "{#INSTANCE_TYPE}"
                }
            ],
            "interfaces": [
                {
                    "main": "1",
                    "type": "2",
                    "useip": "1",
                    "ip": "127.0.0.1",
                    "dns": "",
                    "port": "161",
                    "details": {
                        "version": "2",
                        "bulk": "1",
                        "community": "{$SNMP_COMMUNITY}"
                    }
                }
            ]
        }
    ],
    "id": 1
}
```

[comment]: # ({/bebba1b3-a91c8b17})

[comment]: # ({749ec170-749ec170})
### 参照

-   [Group link](object#group_link)
-   [Group prototype](object#group_prototype)
-   [User macro](/manual/api/reference/usermacro/object#hosttemplate_level_macro)

[comment]: # ({/749ec170-749ec170})

[comment]: # ({437ab274-437ab274})
### ソース

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

[comment]: # ({/437ab274-437ab274})
