[comment]: # translation:outdated

[comment]: # ({cd4a930c-cd4a930c})
# service.update

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

[comment]: # ({11440cc7-79afe9b7})
### 説明

`object service.update(object/array services)`

このメソッドで、既存のサービスを更新できます。

::: noteclassic
このメソッドはどのタイプのユーザーでも利用可能です。このメソッドを呼び出す権限は、ユーザーロール設定で取り消すことができます。詳しくは[ユーザーの役割](/manual/web_interface/frontend_sections/administration/user_roles)を参照してください。
:::

[comment]: # ({/11440cc7-79afe9b7})

[comment]: # ({new-5fb5ebb3})
### Parameters

`(object/array)` service properties to be updated.

The `serviceid` property must be defined for each service, all other
properties are optional. Only the passed properties will be updated, all
others will remain unchanged.

Additionally to the [standard service properties](object#service), the
method accepts the following parameters.

|Parameter|[Type](/manual/api/reference_commentary#data_types)|Description|
|---------|---------------------------------------------------|-----------|
|children|array|Child services to replace the current service children.<br><br>The children must have the `serviceid` property defined.|
|parents|array|Parent services to replace the current service parents.<br><br>The parents must have the `serviceid` property defined.|
|tags|array|Service [tags](/manual/api/reference/service/object#service_tag) to replace the current service tags.|
|times|array|Service [times](/manual/api/reference/service/object#service_time) to replace the current service times.|
|problem\_tags|array|[Problem tags](/manual/api/reference/service/object#problem_tag) to replace the current problem tags.|
|status\_rules|array|[Status rules](/manual/api/reference/service/object#status_rule) to replace the current status rules.|

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

[comment]: # ({9465ee4d-9465ee4d})
### 戻り値

`(object)` `serviceids`プロパティの下で更新されたサービスのIDを含むオブジェクトを返します。

[comment]: # ({/9465ee4d-9465ee4d})

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

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

[comment]: # ({3587c341-b9918036})
#### 親サービスを設定する

ID"3"のサービスをID"5"のサービスの親にします。

Request:

```json
{
    "jsonrpc": "2.0",
    "method": "service.update",
    "params": {
        "serviceid": "5",
        "parents": [
            {
                "serviceid": "3"
            }
        ]
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}
```

Response:

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

[comment]: # ({/3587c341-b9918036})

[comment]: # ({b89808c9-263b1baa})
#### スケジュールされたダウンタイムの追加

ID"4"のサービスに毎週月曜日22:00から火曜日10:00でスケジュールされたダウンタイムを追加します

Request:

```json
{
    "jsonrpc": "2.0",
    "method": "service.update",
    "params": {
        "serviceid": "4",
        "times": [
            {
                "type": "1",
                "ts_from": "165600",
                "ts_to": "201600"
            }
        ]
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}
```

Response:

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

[comment]: # ({/b89808c9-263b1baa})

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

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

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