maintenance.create

Description 说明

object maintenance.create(object/array maintenances)

This method allows to create new maintenances.这种方法允许创建新的维护。

Parameters 参数

(object/array) Maintenances to create.要创建的Maintenances。

Additionally to the standard maintenance properties, the method accepts the following parameters.除标准维护属性外,该方法还接受以下参数。

属性 类 说明
groupids
(required)
array IDs of the host groups that will undergo maintenance.
hostids
(required)
array IDs of the hosts that will undergo maintenance.
timeperiods
(required)
array Maintenance time 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 created maintenances under the maintenanceids property. The order of the returned IDs matches the order of the passed maintenances.返回一个包含“维护”属性下的创建维护ID的对象。 返回的ID的顺序与通过的维护的顺序相匹配。

Examples 示例

Creating a maintenance

Create a maintenance with data collection for host group "2". It must be active from 22.01.2013 till 22.01.2014, come in effect each Sunday at 18:00 and last for one hour.

Request:

{
           "jsonrpc": "2.0",
           "method": "maintenance.create",
           "params": {
               "name": "Sunday maintenance",
               "active_since": 1358844540,
               "active_till": 1390466940,
               "groupids": [
                   "2"
               ],
               "timeperiods": [
                   {
                       "timeperiod_type": 3,
                       "every": 1,
                       "dayofweek": 64,
                       "start_time": 64800,
                       "period": 3600
                   }
               ]
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

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

See also参见

Source 来源

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