maintenance.update

Description 说明

object maintenance.update(object/array maintenances)

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

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, the method accepts the following parameters. 另外见standard maintenance properties,此方法接受如下参数。

ParameterTypeDescription
groupidsarrayIDs of the host groups to replace the current groups. 要替换的当前主机组的主机组IDs。
hostidsarrayIDs of the hosts to replace the current hosts. 要替换当前主机的主机IDs。
timeperiodsarrayMaintenance time periods to replace the current periods. 要替换当前维护模式时间周期的时间周期。

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

Return values 返回值

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

Examples 示例

Assigning different hosts 指定不同的主机

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

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "maintenance.update",
  4. "params": {
  5. "maintenanceid": "3",
  6. "hostids": [
  7. "10085",
  8. "10084"
  9. ]
  10. },
  11. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  12. "id": 1
  13. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "maintenanceids": [
  5. "3"
  6. ]
  7. },
  8. "id": 1
  9. }

See also

Source

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