[comment]: # translation:outdated

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

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

[comment]: # ({8cedc1b8-30b8c9f4})
### Descrizione

`object hostgroup.massadd(object parameters)`

Questo metodo consente di aggiungere simultaneamente più oggetti correlati a tutti
i gruppi di host specificati.

::: noteclassic
Questo metodo è disponibile solo per gli utenti di tipo *Admin* e *Super admin*.
I permessi per chiamare il metodo possono essere revocati nelle impostazioni del ruolo
utente. Consultare [Ruoli
utente](/manual/web_interface/frontend_sections/users/user_roles)
per ulteriori informazioni.
:::

[comment]: # ({/8cedc1b8-30b8c9f4})

[comment]: # ({19dffe69-b8ff6430})
### Parametri

`(object)` Parametri contenenti gli ID dei gruppi host da aggiornare
e gli oggetti da aggiungere a tutti i gruppi host.

Il metodo accetta i seguenti parametri.

|Parametro|[Tipo](/manual/api/reference_commentary#data-types)|Descrizione|
|--|--|------|
|groups|object/array|[Gruppi host](/manual/api/reference/hostgroup/object) da aggiornare.<br><br>I gruppi host devono avere definita solo la proprietà `groupid`.<br><br>[Comportamento dei parametri](/manual/api/reference_commentary#parameter-behavior):<br>- *obbligatorio*|
|hosts|object/array|[Host](/manual/api/reference/host/object) da aggiungere a tutti i gruppi host.<br><br>Gli host devono avere definita solo la proprietà `hostid`.|

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

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

`(object)` Restituisce un oggetto contenente gli ID dei gruppi di host
aggiornati nella proprietà `groupids`.

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

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

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

[comment]: # ({893ecf7b-7698103b})
#### Aggiungere host ai gruppi di host

Aggiunge due host ai gruppi host con ID 5 e 6.

[Richiesta](/manual/api#performing-requests):

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

Risposta:

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

[comment]: # ({/893ecf7b-7698103b})

[comment]: # ({6a994b89-e5f0abe1})
### Vedi anche

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

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

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

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

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