[comment]: # translation:outdated

[comment]: # ({f47b150e-f47b150e})
# maintenance.create

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

[comment]: # ({e8498ebc-e8498ebc})
### 説明

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

このメソッドで、新しいメンテナンスを作成できます。

::: noteclassic
このメソッドは*Admin*および*Super admin*ユーザータイプでのみ使用できます。 メソッドを呼び出す権限は、ユーザーロール設定で取り消すことができます。 詳細については[ユーザーの役割](/manual/web_interface/frontend_sections/administration/user_roles)を参照してください。
:::

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

[comment]: # ({01d00bcb-6c14daac})
### パラメータ

`(object/array)` メンテナンスの作成

このメソッドは[標準のメンテナンスプロパティ](object#maintenance)に加えて、次のパラメーターを受け入れます。

|パラメータ|[タイプ](/manual/api/reference_commentary#data_types)|説明|
|--|--|------|
|groups|object/array|メンテナンスが行われるホスト[groups](/manual/api/reference/hostgroup/object)<br> <br>ホストグループには`groupid`プロパティが定義されている必要があります。<br><br>`groups`または`hosts`のオブジェクトを少なくとも1つ指定する必要があります。|
|hosts|object/array|メンテナンスが行われる[ホスト](/manual/api/reference/host/object)<br><br>ホストには`hostid`プロパティが定義されている必要があります。<br><br>`groups`または`hosts`のオブジェクトを少なくとも1つ指定する必要があります。|
|**timeperiods**<br>(必須)|object/array|メンテナンス[期間](/manual/api/reference/maintenance/object#time_period)|
|tags|object/array|[障害タグ](/manual/api/reference/maintenance/object#problem_tag)<br><br>どの障害を抑制するかを定義します。<br>タグが指定されていない場合、すべてのアクティブなメンテナンスホストの障害が抑制されます。|

[comment]: # ({/01d00bcb-6c14daac})

[comment]: # ({48c4869c-48c4869c})
### 戻り値

`(object)` `maintenanceids`プロパティの下で作成されたメンテナンスのIDを含むオブジェクトを返します。 返されるIDの順序は、渡されたメンテナンスの順序と一致します。

[comment]: # ({/48c4869c-48c4869c})

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

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

[comment]: # ({642cb053-bb812c67})
#### メンテナンスの作成

ID"2"のホストグループのデータ収集と、障害タグ**service:mysqld**および**error**を使用してメンテナンスを作成します。 2013年1月22日から2014年1月22日までアクティブで、毎週日曜日の18:00に有効になり1時間持続します。

Request:

```json
{
    "jsonrpc": "2.0",
    "method": "maintenance.create",
    "params": {
        "name": "Sunday maintenance",
        "active_since": 1358844540,
        "active_till": 1390466940,
        "tags_evaltype": 0,
        "groups": [
            {"groupid": "2"}
        ],
        "timeperiods": [
            {
                "period": 3600,
                "timeperiod_type": 3,
                "start_time": 64800,
                "every": 1,
                "dayofweek": 64
            }
        ],
        "tags": [
            {
                "tag": "service",
                "operator": "0",
                "value": "mysqld"
            },
            {
                "tag": "error",
                "operator": "2",
                "value": ""
            }
        ]
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}
```

Response:

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

[comment]: # ({/642cb053-bb812c67})

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

-   [Time period](object#time_period)

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

[comment]: # ({3e3a556f-3e3a556f})
### ソース

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

[comment]: # ({/3e3a556f-3e3a556f})
