[comment]: # ({c0df6427-c0df6427})
# hostprototype.update

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

[comment]: # ({7da22d8d-796670ab})
### Descrizione

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

Questo metodo consente di aggiornare i prototipi di host esistenti.

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

[comment]: # ({/7da22d8d-796670ab})

[comment]: # ({0881900c-50727275})
### Parametri

`(object/array)` Proprietà del prototipo di host da aggiornare.

La proprietà `hostid` deve essere definita per ciascun prototipo di host, tutte le altre
proprietà sono facoltative. Verranno aggiornate solo le proprietà passate, tutte
le altre rimarranno invariate.

Oltre alle [proprietà standard del prototipo di host](object#host-prototype), il metodo accetta i seguenti
parametri.

|Parametro|[Tipo](/manual/api/reference_commentary#data-types)|Descrizione|
|--|--|------|
|groupLinks|array|[Collegamenti ai gruppi](/manual/api/reference/hostprototype/object#group-link) per sostituire i collegamenti ai gruppi correnti nel prototipo di host.<br><br>[Comportamento del parametro](/manual/api/reference_commentary#parameter-behavior):<br>- *sola lettura* per gli oggetti ereditati|
|groupPrototypes|array|[Prototipi di gruppo](/manual/api/reference/hostprototype/object#group-prototype) per sostituire i prototipi di gruppo esistenti nel prototipo di host.<br><br>Tutti i prototipi di gruppo non elencati nella richiesta verranno rimossi.<br><br>[Comportamento del parametro](/manual/api/reference_commentary#parameter-behavior):<br>- *sola lettura* per gli oggetti ereditati|
|macros|object/array|[Macro utente](/manual/api/reference/usermacro/object) per sostituire le macro utente correnti.<br>Tutte le macro non elencate nella richiesta verranno rimosse.|
|tags|object/array|[Tag del prototipo di host](/manual/api/reference/hostprototype/object#host-prototype-tag) per sostituire i tag correnti.<br>Tutti i tag non elencati nella richiesta verranno rimossi.<br><br>[Comportamento del parametro](/manual/api/reference_commentary#parameter-behavior):<br>- *sola lettura* per gli oggetti ereditati|
|interfaces|object/array|[Interfacce personalizzate](/manual/api/reference/hostprototype/object#custom-interface) del prototipo di host per sostituire le interfacce correnti.<br>L'oggetto interfaccia personalizzata deve contenere tutti i suoi parametri.<br>Tutte le interfacce non elencate nella richiesta verranno rimosse.<br><br>[Comportamento del parametro](/manual/api/reference_commentary#parameter-behavior):<br>- *supportato* se `custom_interfaces` di [Host prototype object](/manual/api/reference/usermacro/object#host-prototype) è impostato su "use host prototypes custom interfaces"<br>- *sola lettura* per gli oggetti ereditati|
|templates|object/array|[Template](/manual/api/reference/template/object) per sostituire i template attualmente collegati.<br><br>I template devono avere definita solo la proprietà `templateid`.|

[comment]: # ({/0881900c-50727275})

[comment]: # ({c97defa2-c97defa2})
### Valori di ritorno

`(object)` Restituisce un oggetto contenente gli ID dei prototipi host aggiornati
sotto la proprietà `hostids`.

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

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

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

[comment]: # ({b9437ec2-9e34a671})
#### Disabilitazione di un prototipo di host

Disabilita un prototipo di host, cioè imposta il suo stato su "1".

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

```json
{
    "jsonrpc": "2.0",
    "method": "hostprototype.update",
    "params": {
        "hostid": "10092",
        "status": 1
    },
    "id": 1
}
```

Risposta:

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

[comment]: # ({/b9437ec2-9e34a671})

[comment]: # ({4592dcdd-440003e2})
#### Aggiornamento dei tag del prototipo di host

Sostituisci i tag del prototipo di host con nuovi tag.

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

```json
{
    "jsonrpc": "2.0",
    "method": "hostprototype.update",
    "params": {
        "hostid": "10092",
        "tags": [
            {
                "tag": "datacenter",
                "value": "{#DATACENTER.NAME}"
            },
            {
                "tag": "instance-type",
                "value": "{#INSTANCE_TYPE}"
            }
        ]
    },
    "id": 1
}
```

Risposta:

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

[comment]: # ({/4592dcdd-440003e2})

[comment]: # ({5195d3ed-7a7b18a4})
#### Aggiornamento delle interfacce personalizzate del prototipo di host

Sostituisce le interfacce ereditate con le interfacce personalizzate del prototipo di host.

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

```json
{
    "jsonrpc": "2.0",
    "method": "hostprototype.update",
    "params": {
        "hostid": "10092",
        "custom_interfaces": "1",
        "interfaces": [
            {
                "main": "1",
                "type": "2",
                "useip": "1",
                "ip": "127.0.0.1",
                "dns": "",
                "port": "161",
                "details": {
                    "version": "2",
                    "bulk": "1",
                    "community": "{$SNMP_COMMUNITY}"
                }
            }
        ]
    },
    "id": 1
}
```

Risposta:

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

[comment]: # ({/5195d3ed-7a7b18a4})

[comment]: # ({508c69b6-c4a38bf3})
### Vedi anche

-   [Collegamento del gruppo](object#group-link)
-   [Prototipo di gruppo](object#group-prototype)
-   [Tag del prototipo di host](object#host-prototype-tag)
-   [Interfaccia personalizzata](object#custom-interface)
-   [Macro
    utente](/manual/api/reference/usermacro/object#hosttemplate-level-macro)

[comment]: # ({/508c69b6-c4a38bf3})

[comment]: # ({a380e3fb-a380e3fb})
### Fonte

CHostPrototype::update() in
*ui/include/classes/api/services/CHostPrototype.php*.

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