[comment]: # translation:outdated

[comment]: # ({3f9b711d-3f9b711d})
# hostgroup.massadd

[comment]: # ({/3f9b711d-3f9b711d})

[comment]: # ({91abdc31-30b8c9f4})
### 説明

`object hostgroup.massadd(object parameters)`

この方法では、与えられたすべての host group に、複数の関連オブジェクトを同時に追加することができます。

::: noteclassic
このメソッドは、*Admin* および *Super admin* ユーザータイプにのみ使用できます。このメソッドを呼び出す許可は、<br>
ユーザーロール設定で取り消すことができます。詳細については、[User roles](/manual/web_interface/frontend_sections/administration/user_roles) を参照してください。
:::

[comment]: # ({/91abdc31-30b8c9f4})

[comment]: # ({f1d5c11f-b8ff6430})
### パラメータ

`(object)` 更新する host groups のIDと、全ての host groups に追加するオブジェクトを含むパラメータ。

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

|パラメータ|[Type](/manual/api/reference_commentary#data_types)|説明|
|--|--|------|
|**groups**<br>(required)|object/array|Host groups to be updated.<br><br>The host groups must have the `groupid` property defined.|
|hosts|object/array|Hosts to add to all host groups.<br><br>The hosts must have the `hostid` property defined.|
|templates|object/array|Templates to add to all host groups.<br><br>The templates must have the `templateid` property defined.|

[comment]: # ({/f1d5c11f-b8ff6430})

[comment]: # ({736f3b05-736f3b05})
### 戻り値

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

[comment]: # ({/736f3b05-736f3b05})

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

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

[comment]: # ({29ed5bf1-7698103b})
#### host group への host の追加

IDが5と6の  host group に2台の host を追加します。

Request:

``` {.java}
{
    "jsonrpc": "2.0",
    "method": "hostgroup.massadd",
    "params": {
        "groups": [
            {
                "groupid": "5"
            },
            {
                "groupid": "6"
            }
        ],
        "hosts": [
            {
                "hostid": "30050"
            },
            {
                "hostid": "30001"
            }
        ]
    },
    "auth": "f223adf833b2bf2ff38574a67bba6372",
    "id": 1
}
```

Response:

``` {.java}
{
    "jsonrpc": "2.0",
    "result": {
        "groupids": [
            "5",
            "6"
        ]
    },
    "id": 1
}
```

[comment]: # ({/29ed5bf1-7698103b})

[comment]: # ({cb21f40e-e5f0abe1})
### 参照

-   [Host](/manual/api/reference/host/object#host)
-   [Template](/manual/api/reference/template/object#template)

[comment]: # ({/cb21f40e-e5f0abe1})

[comment]: # ({19273fb6-19273fb6})
### ソース

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

[comment]: # ({/19273fb6-19273fb6})
