[comment]: # ({2898fc4b-2898fc4b})
# hostinterface.replacehostinterfaces

[comment]: # ({/2898fc4b-2898fc4b})

[comment]: # ({e440e997-f14e7778})
### Descrizione

`object hostinterface.replacehostinterfaces(object parameters)`

Questo metodo consente di sostituire tutte le interfacce host su un determinato host.

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

[comment]: # ({/e440e997-f14e7778})

[comment]: # ({233510b8-f5cf0b40})
### Parametri

`(object)` Parametri contenenti l'ID dell'host da aggiornare e le nuove interfacce dell'host.

|Parametro|[Tipo](/manual/api/reference_commentary#data_types)|Descrizione|
|--|--|------|
|interfaces|object/array|[Interfacce dell'host](/manual/api/reference/hostinterface/object) da usare per sostituire le interfacce dell'host correnti.<br><br>[Comportamento del parametro](/manual/api/reference_commentary#parameter-behavior):<br>- *required*|
|hostid|ID|ID dell'host da aggiornare.<br><br>[Comportamento del parametro](/manual/api/reference_commentary#parameter-behavior):<br>- *required*|

[comment]: # ({/233510b8-f5cf0b40})

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

`(object)` Restituisce un oggetto contenente gli ID delle interfacce dell'host create
sotto la proprietà `interfaceids`.

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

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

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

[comment]: # ({01fd5e38-98e67db1})
#### Sostituzione delle interfacce dell'host

Sostituisce tutte le interfacce dell'host con una singola interfaccia agent.

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

```json
{
    "jsonrpc": "2.0",
    "method": "hostinterface.replacehostinterfaces",
    "params": {
        "hostid": "30052",
        "interfaces": {
            "dns": "",
            "ip": "127.0.0.1",
            "main": 1,
            "port": "10050",
            "type": 1,
            "useip": 1
        }
    },
    "id": 1
}
```

Response:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "interfaceids": [
            "30081"
        ]
    },
    "id": 1
}
```

[comment]: # ({/01fd5e38-98e67db1})

[comment]: # ({272c42ef-272c42ef})
### Guarda anche

- [host.update](/manual/api/reference/host/update)
- [host.massupdate](/manual/api/reference/host/massupdate)

[comment]: # ({/272c42ef-272c42ef})

[comment]: # ({9d1e0b55-9d1e0b55})
### Fonte

CHostInterface::replaceHostInterfaces() in
*ui/include/classes/api/services/CHostInterface.php*.

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