hostprototype.get

説明

integer/array hostprototype.get(object parameters)

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

このメソッドは、すべてのタイプのユーザーが利用できます。メソッドを呼び出す権限は、ユーザーロール設定で取り消すことができます。詳細は、ユーザーロール を参照してください。

パラメータ

(object) 必要な出力を定義するパラメータです。

このメソッドは以下のパラメータをサポートしています。

パラメータ 説明
hostids ID/array 指定したIDを持つホストプロトタイプのみを返します。
discoveryids ID/array 指定したLLDルールに属するホストプロトタイプのみを返します。
inherited boolean true に設定した場合、テンプレートから継承されたアイテムのみを返します。
selectDiscoveryRule query ホストプロトタイプが属するLLDルールを含む discoveryRule プロパティを返します。
selectInterfaces query ホストプロトタイプのカスタムインターフェースを含む interfaces プロパティを返します。
selectGroupLinks query ホストプロトタイプのグループリンクを含む groupLinks プロパティを返します。
selectGroupPrototypes query ホストプロトタイプのグループプロトタイプを含む groupPrototypes プロパティを返します。
selectMacros query ホストプロトタイプのマクロを含む macros プロパティを返します。
selectParentHost query ホストプロトタイプが属するホストを含む parentHost プロパティを返します。
selectTags query ホストプロトタイプのタグを含む tags プロパティを返します。
selectTemplates query ホストプロトタイプにリンクされたテンプレートを含む templates プロパティを返します。

count をサポートします。
sortfield string/array 指定したプロパティで結果をソートします。

指定可能な値: hostid, host, name, status, discovered
countOutput boolean これらのパラメータについては、リファレンスコメント で説明されています。
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) 次のいずれかを返します:

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

LLDルールからホストプロトタイプを取得する

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

リクエスト:

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

レスポンス:

{
    "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}",
                        "max_repetitions": "10"
                    }
                }
            ]
        }
    ],
    "id": 1
}

関連項目

ソース

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