host.massadd

説明

object host.massadd(object parameters)

このメソッドでは、与えられたすべてのホストに、複数の関連オブジェクトを同時に追加することができます。

このメソッドは、Admin および Super admin ユーザータイプにのみ使用できます。このメソッドを呼び出す許可は、
ユーザーロール設定で取り消すことができます。詳細については、User roles を参照してください。

パラメータ

(object) 更新するホストのID、および全てのホストに追加するオブジェクトを含むパラメータ

このメソッドは、以下のパラメータを受け付けます。

パラメータ Type 説明
hosts
(required)
object/array Hosts to be updated.

The hosts must have the hostid property defined.
groups object/array Host groups to add to the given hosts.

The host groups must have the groupid property defined.
interfaces object/array Host interfaces to be created for the given hosts.
macros object/array User macros to be created for the given hosts.
templates object/array Templates to link to the given hosts.

The templates must have the templateid property defined.

戻り値

(object) hostids プロパティの下で更新されたホストの ID を含むオブジェクトを返します。

マクロの追加

2つのホストに2つの新しいマクロを追加します。

Request:

{
    "jsonrpc": "2.0",
    "method": "host.massadd",
    "params": {
        "hosts": [
            {
                "hostid": "10160"
            },
            {
                "hostid": "10167"
            }
        ],
        "macros": [
            {
                "macro": "{$TEST1}",
                "value": "MACROTEST1"
            },
            {
                "macro": "{$TEST2}",
                "value": "MACROTEST2",
                "description": "Test description"
            }
        ]
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}

Response:

{
    "jsonrpc": "2.0",
    "result": {
        "hostids": [
            "10160",
            "10167"
        ]
    },
    "id": 1
}

参照

ソース

CHost::massAdd() in ui/include/classes/api/services/CHost.php.