[comment]: # ({8c711e69-8c711e69})
# maintenance.update

[comment]: # ({/8c711e69-8c711e69})

[comment]: # ({714cb5fb-292dcffa})
### Description 说明

`object maintenance.update(object/array maintenances)`

This method allows to update existing maintenances.
此方法允许更新已存在的维护模式。

[comment]: # ({/714cb5fb-292dcffa})

[comment]: # ({f49a971b-dc6b3fa2})
### Parameters 参数

`(object/array)` Maintenance properties to be updated.
`(object/array)`要更新的维护模式的属性。

The `maintenanceid` property must be defined for each maintenance, all
other properties are optional. Only the passed properties will be
updated, all others will remain unchanged.
每一个维护模式的`maintenanceid`属性必须被定义，其他所有属性均为可选。只有被传递的属性才会被更新，所有它属性保持不变。

Additionally to the [standard maintenance
properties](object#maintenance), the method accepts the following
parameters. 另外见[standard maintenance
properties](/zh/object#maintenance),此方法接受如下参数。

|Parameter|Type|Description|
|---------|----|-----------|
|groupids|array|IDs of the host groups to replace the current groups. 要替换的当前主机组的主机组IDs。|
|hostids|array|IDs of the hosts to replace the current hosts. 要替换当前主机的主机IDs。|
|timeperiods|array|Maintenance time periods to replace the current periods. 要替换当前维护模式时间周期的时间周期。|

::: noteimportant
At least one host or host group must be defined
for each maintenance.
每一个维护模式至少一个主机或者一个主机组被定义。
:::

[comment]: # ({/f49a971b-dc6b3fa2})

[comment]: # ({03a1c374-b9ffa219})
### Return values 返回值

`(object)` Returns an object containing the IDs of the updated
maintenances under the `maintenanceids` property. `(object)`
在`maintenanceids`属性中返回一个包含已被更新的维护模式的IDs的对象。

[comment]: # ({/03a1c374-b9ffa219})

[comment]: # ({69594a0c-b41637d2})
### Examples 示例

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

[comment]: # ({0689e4b3-3f6d58a5})
#### Assigning different hosts 指定不同的主机

Replace the hosts currently assigned to maintenance "3" with two
different ones. 用两个不同的主机替换当前分配给维护“3”的主机。

Request:

``` {.java}
{
    "jsonrpc": "2.0",
    "method": "maintenance.update",
    "params": {
        "maintenanceid": "3",
        "hostids": [
            "10085",
            "10084"
        ]
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}
```

Response:

``` {.java}
{
    "jsonrpc": "2.0",
    "result": {
        "maintenanceids": [
            "3"
        ]
    },
    "id": 1
}
```

[comment]: # ({/0689e4b3-3f6d58a5})

[comment]: # ({82b3ef0e-82b3ef0e})
### See also

-   [Time period](object#time_period)

[comment]: # ({/82b3ef0e-82b3ef0e})

[comment]: # ({8f5ecc6f-63ad1661})
### Source

CMaintenance::update() in
*frontends/php/include/classes/api/services/CMaintenance.php*.

[comment]: # ({/8f5ecc6f-63ad1661})
