[comment]: # translation:outdated

[comment]: # ({66c5a546-66c5a546})
# host.massadd

[comment]: # ({/66c5a546-66c5a546})

[comment]: # ({d60cc608-55030171})
### Apraksts

`object host.massadd(object parameters)`

Šī metode ļauj vienlaikus pievienot vairākus saistītus objektus visiem
norādītajiem hostiem.

::: noteclassic
Šī metode ir pieejama tikai *Admin* un *Super admin*
lietotāju tipiem. Atļaujas izsaukt šo metodi var tikt atsauktas lietotāja lomas
iestatījumos. Plašāku informāciju skatiet sadaļā [Lietotāju
lomas](/manual/web_interface/frontend_sections/users/user_roles).
:::

[comment]: # ({/d60cc608-55030171})

[comment]: # ({10a236c0-c25e2be4})
### Parametri

`(object)` Parametri, kas satur atjaunināmo hostu ID un
objektus, ko pievienot visiem hostiem.

Metode pieņem šādus parametrus.

|Parametrs|[Tips](/manual/api/reference_commentary#data-types)|Apraksts|
|--|--|------|
|hosts|object/array|[Hosti](/manual/api/reference/host/object), kas jāatjaunina.<br><br>Hostiem jābūt definētai tikai `hostid` īpašībai.<br><br>[Parametra darbība](/manual/api/reference_commentary#parameter-behavior):<br>- *obligāts*|
|groups|object/array|[Hostu grupas](/manual/api/reference/hostgroup/object), ko pievienot norādītajiem hostiem.<br><br>Hostu grupām jābūt definētai tikai `groupid` īpašībai.|
|interfaces|object/array|[Hostu saskarnes](/manual/api/reference/hostinterface/object), kas jāizveido norādītajiem hostiem.|
|macros|object/array|[Lietotāja makrosi](/manual/api/reference/usermacro/object), kas jāizveido norādītajiem hostiem.|
|templates|object/array|[Veidnes](/manual/api/reference/template/object), ko piesaistīt norādītajiem hostiem.<br><br>Veidnēm jābūt definētai tikai `templateid` īpašībai.|

[comment]: # ({/10a236c0-c25e2be4})

[comment]: # ({d166b99b-d166b99b})
### Atgrieztās vērtības

`(object)` Atgriež objektu, kas satur atjaunināto hostu ID
zem `hostids` īpašības.

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

[comment]: # ({b41637d2-b41637d2})
### Piemēri

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

[comment]: # ({b2ef6e4f-453a1298})
#### Makrosu pievienošana

Pievienojiet divus jaunus makrosus diviem hostiem.

[Pieprasījums](/manual/api#performing-requests):

```json
{
    "jsonrpc": "2.0",
    "method": "host.massadd",
    "params": {
        "hosts": [
            {
                "hostid": "10160"
            },
            {
                "hostid": "10167"
            }
        ],
        "macros": [
            {
                "macro": "{$TEST1}",
                "value": "MACROTEST1"
            },
            {
                "macro": "{$TEST2}",
                "value": "MACROTEST2",
                "description": "Testa apraksts"
            }
        ]
    },
    "id": 1
}
```

Atbilde:

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

[comment]: # ({/b2ef6e4f-453a1298})

[comment]: # ({ee23c6c9-ae4115e5})
### Skatiet arī

-   [host.update](update)
-   [Hostu grupa](/manual/api/reference/hostgroup/object#host-group)
-   [Veidne](/manual/api/reference/template/object#template)
-   [Lietotāja
    makross](/manual/api/reference/usermacro/object#hosttemplate-level-macro)
-   [Hosta
    saskarne](/manual/api/reference/hostinterface/object#host-interface)

[comment]: # ({/ee23c6c9-ae4115e5})

[comment]: # ({d5e419cc-d5e419cc})
### Avots

CHost::massAdd() failā *ui/include/classes/api/services/CHost.php*.

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