# hostprototype.create

### Description 说明

`object hostprototype.create(object/array hostPrototypes)`

This method allows to create new host
prototypes.这种方法允许创建新的主机原型。

### Parameters 参数

`(object/array)` Host prototypes to create.主机原型创建。

Additionally to the [standard host prototype
properties](object#host_prototype), the method accepts the following
parameters.除标准主机原型属性之外，该方法接受以下参数。

|参数              类|描述|<|
|-----------------------|------|-|
|**groupLinks**<br>(required)|array|Group links to be created for the host prototype. 要为主机原型创建的组链接。|
|**ruleid**<br>(required)|string|ID of the LLD rule that the host prototype belongs to. 主机原型所属的LLD规则的ID。|
|groupPrototypes|array|Group prototypes to be created for the host prototype. 将为主机原型创建的组原型。|
|inventory|object|Host prototype inventory properties.主机原型库存属性。|
|templates|object/array|Templates to be linked to the host prototype. 与主机原型链接的模板。<br><br>The templates must have the `templateid` property defined.模板必须定义“templateid”属性。|

### Return values 返回值

`(object)` Returns an object containing the IDs of the created host
prototypes under the `hostids` property. The order of the returned IDs
matches the order of the passed host
prototypes.返回包含“hostid”属性下创建的主机原型的ID的对象。
返回的ID的顺序与传递的主机原型的顺序相匹配。

### Examples 示例

#### Creating a host prototype 创建主机原型

Create a host prototype "{\#VM.NAME}" on LLD rule "23542" with a group
prototype "{\#HV.NAME}". Link it to host group
"2".使用组原型“{＃HV.NAME}”为LLD规则“23542”创建主机原型“{＃VM.NAME}”。
将其链接到主机组“2”。

Request:

``` {.java}
{
    "jsonrpc": "2.0",
    "method": "hostprototype.create",
    "params": {
        "host": "{#VM.NAME}",
        "ruleid": "23542",
        "groupLinks": [
            {
                "groupid": "2"
            }
        ],
        "groupPrototypes": [
            {
                "name": "{#HV.NAME}"
            }
        ]
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}
```

Response:

``` {.java}
{
    "jsonrpc": "2.0",
    "result": {
        "hostids": [
            "10103"
        ]
    },
    "id": 1
}
```

### See also 参见

-   [Group link](object#group_link)
-   [Group prototype](object#group_prototype)
-   [Host prototype inventory](object#host_prototype_inventory)

### Source 来源

CHostPrototype::create() in
*frontends/php/include/classes/api/services/CHostPrototype.php*.
