[comment]: # translation:outdated

[comment]: # ({2ed6e81f-2ed6e81f})
# usermacro.update

[comment]: # ({/2ed6e81f-2ed6e81f})

[comment]: # ({418ab7e0-23e3a148})
### Descrizione

`object usermacro.update(object/array hostMacros)`

Questo metodo consente di aggiornare le macro del host esistenti.

::: noteclassic
Questo metodo è disponibile solo per i tipi di utente *Admin* e *Super admin*.
Le autorizzazioni per chiamare 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]: # ({/418ab7e0-23e3a148})

[comment]: # ({495251b4-f8ce947c})
### Parametri

`(object/array)` [Proprietà della macro del host](object#host-macro) da
aggiornare.

La proprietà `hostmacroid` deve essere definita per ciascuna macro del host, tutte
le altre proprietà sono facoltative. Verranno aggiornate solo le proprietà passate,
tutte le altre rimarranno invariate.

[comment]: # ({/495251b4-f8ce947c})

[comment]: # ({5e19fc38-5e19fc38})
### Valori restituiti

"(object)" Restituisce un oggetto contenente gli ID delle macro host aggiornate
sotto la proprietà "hostmacroids".

[comment]: # ({/5e19fc38-5e19fc38})

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

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

[comment]: # ({985ee438-bc8ce678})
#### Modifica del valore di una macro host

Modificare il valore di una macro host in "public".

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

```json
{
    "jsonrpc": "2.0",
    "method": "usermacro.update",
    "params": {
        "hostmacroid": "1",
        "value": "public"
    },
    "id": 1
}
```

Risposta:

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

[comment]: # ({/985ee438-bc8ce678})

[comment]: # ({6948283e-129f453e})
#### Modificare il valore della macro creata da una regola di discovery

Convertire la macro "automatica" creata dalla regola di discovery in "manuale" e modificarne il valore in "new-value".

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

```json
{
    "jsonrpc": "2.0",
    "method": "usermacro.update",
    "params": {
        "hostmacroid": "1",
        "value": "new-value",
        "automatic": "0"
    },
    "id": 1
}
```

Risposta:

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

[comment]: # ({/6948283e-129f453e})

[comment]: # ({2eddd7d2-2eddd7d2})
### Fonte

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

[comment]: # ({/2eddd7d2-2eddd7d2})
