object hostprototype.create(object/array hostPrototypes)
This method allows to create new host prototypes.
This method is only available to Admin and Super admin user types. Permissions to call the method can be revoked in user role settings. See User roles for more information.
(object/array)
Host prototypes to create.
Additionally to the standard host prototype properties, the method accepts the following parameters.
Parameter | Type | Description |
---|---|---|
groupLinks (required) |
array | Group links to be created for the host prototype. |
ruleid (required) |
string | ID of the LLD rule that the host prototype belongs to. |
groupPrototypes | array | Group prototypes to be created for the host prototype. |
macros | object/array | User macros to be created for the host prototype. |
tags | object/array | Host prototype tags. |
interfaces | object/array | Host prototype custom interfaces. |
templates | object/array | Templates to be linked to the host prototype. The templates must have the templateid property defined. |
(object)
Devuelve un objeto que contiene los ID del host creado prototipos bajo la propiedad hostids
. El orden de las identificaciones devueltas coincide con el orden de los prototipos de host aprobados.
Create a host prototype "{#VM.NAME}" on LLD rule "23542" with a group prototype "{#HV.NAME}", tag pair "Datacenter": "{#DATACENTER.NAME}" and custom SNMPv2 interface 127.0.0.1:161 with community {$SNMP_COMMUNITY}. Link it to host group "2".
Request:
{
"jsonrpc": "2.0",
"method": "hostprototype.create",
"params": {
"host": "{#VM.NAME}",
"ruleid": "23542",
"custom_interfaces": "1",
"groupLinks": [
{
"groupid": "2"
}
],
"groupPrototypes": [
{
"name": "{#HV.NAME}"
}
],
"tags": [
{
"tag": "Datacenter",
"value": "{#DATACENTER.NAME}"
}
],
"interfaces": [
{
"main": "1",
"type": "2",
"useip": "1",
"ip": "127.0.0.1",
"dns": "",
"port": "161",
"details": {
"version": "2",
"bulk": "1",
"community": "{$SNMP_COMMUNITY}"
}
}
]
},
"auth": "038e1d7b1735c6a5436ee9eae095879e",
"id": 1
}
Response:
CHostPrototype::create() en ui/include/classes/api/services/CHostPrototype.php.