[comment]: # ({2293b018-2293b018})
# action.get 

[comment]: # ({/2293b018-2293b018})

[comment]: # ({4ef8f0ed-42834e1b})
### 説明

`integer/array action.get(object parameters)`

このメソッドは、指定したパラメーターに応じたアクションを取得できます。

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

[comment]: # ({/4ef8f0ed-42834e1b})

[comment]: # ({5a2121c5-f6c19c90})
### パラメータ

`(object)` 必要な出力を定義するパラメータ。

このメソッドは以下のパラメータをサポートしています。

|パラメータ|[Type](/manual/api/reference_commentary#data-types)|説明|
|--|--|------|
|actionids|ID/array|指定したIDを持つアクションのみを返します。|
|groupids|ID/array|アクション条件で指定したホストグループを使用するアクションのみを返します。|
|hostids|ID/array|アクション条件で指定したホストを使用するアクションのみを返します。|
|triggerids|ID/array|アクション条件で指定したトリガーを使用するアクションのみを返します。|
|mediatypeids|ID/array|メッセージ送信に指定したメディアタイプを使用するアクションのみを返します。|
|usrgrpids|ID/array|指定したユーザーグループにメッセージを送信するよう設定されているアクションのみを返します。|
|userids|ID/array|指定したユーザーにメッセージを送信するよう設定されているアクションのみを返します。|
|scriptids|ID/array|指定したスクリプトを実行するよう設定されているアクションのみを返します。|
|selectFilter|query|アクション条件フィルターを含む [`filter`](/manual/api/reference/action/object#action-filter) プロパティを返します。|
|selectOperations|query|アクション操作を含む [`operations`](/manual/api/reference/action/object#action-operation) プロパティを返します。|
|selectRecoveryOperations|query|アクションのリカバリー操作を含む [`recovery_operations`](/manual/api/reference/action/object#action-recovery-operation) プロパティを返します。|
|selectUpdateOperations|query|アクションの更新操作を含む [`update_operations`](/manual/api/reference/action/object#action-update-operation) プロパティを返します。|
|sortfield|string/array|指定したプロパティで結果をソートします。<br><br>指定可能な値: `actionid`, `name`, `status`。|
|countOutput|boolean|これらのパラメータは [reference commentary](/manual/api/reference_commentary#common-get-method-parameters) で説明されています。|
|excludeSearch|boolean|^|
|filter|object|^|
|limit|integer|^|
|output|query|^|
|preservekeys|boolean|^|
|search|object|^|
|searchByAny|boolean|^|
|searchWildcardsEnabled|boolean|^|
|sortorder|string/array|^|
|startSearch|boolean|^|

[comment]: # ({/5a2121c5-f6c19c90})

[comment]: # ({7223bab1-7223bab1})
### 戻り値

`(integer/array)` 以下のどちらかを返します。

-   オブジェクトの配列
-   `countOutput`パラメーターが使用されている場合は、取得したオブジェクトの数

[comment]: # ({/7223bab1-7223bab1})

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

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

[comment]: # ({dabc835c-f7d2e806})
#### トリガーアクションの取得

アクション条件とオペレーションを含む、すべての設定済みトリガーアクションを取得します。

[リクエスト](/manual/api#performing-requests):

```json
{
    "jsonrpc": "2.0",
    "method": "action.get",
    "params": {
        "output": "extend",
        "selectOperations": "extend",
        "selectRecoveryOperations": "extend",
        "selectUpdateOperations": "extend",
        "selectFilter": "extend",
        "filter": {
            "eventsource": 0
        }
    },
    "id": 1
}
```

レスポンス:

```json
{
    "jsonrpc": "2.0",
    "result": [
        {
            "actionid": "3",
            "name": "Report problems to Zabbix administrators",
            "eventsource": "0",
            "status": "1",
            "esc_period": "1h",
            "pause_suppressed": "1",
            "filter": {
                "evaltype": "0",
                "formula": "",
                "conditions": [],
                "eval_formula": ""
            },
            "operations": [
                {
                    "operationid": "3",
                    "actionid": "3",
                    "operationtype": "0",
                    "esc_period": "0",
                    "esc_step_from": "1",
                    "esc_step_to": "1",
                    "evaltype": "0",
                    "opconditions": [],
                    "opmessage": [
                        {
                            "default_msg": "1",
                            "subject": "",
                            "message": "",
                            "mediatypeid" => "0"
                        }
                    ],
                    "opmessage_grp": [
                        {
                            "usrgrpid": "7"
                        }
                    ]
                }
            ],
            "recovery_operations": [
                {
                    "operationid": "7",
                    "actionid": "3",
                    "operationtype": "11",
                    "evaltype": "0",
                    "opconditions": [],
                    "opmessage": {
                        "default_msg": "0",
                        "subject": "{TRIGGER.STATUS}: {TRIGGER.NAME}",
                        "message": "Trigger: {TRIGGER.NAME}\r\nTrigger state: {TRIGGER.STATUS}\r\nTrigger severity: {TRIGGER.SEVERITY}\r\nTrigger URL: {TRIGGER.URL}\r\n\r\nItem values:\r\n\r\n1. {ITEM.NAME1} ({HOST.NAME1}:{ITEM.KEY1}): {ITEM.VALUE1}\r\n2. {ITEM.NAME2} ({HOST.NAME2}:{ITEM.KEY2}): {ITEM.VALUE2}\r\n3. {ITEM.NAME3} ({HOST.NAME3}:{ITEM.KEY3}): {ITEM.VALUE3}\r\n\r\nOriginal event ID: {EVENT.ID}",
                        "mediatypeid": "0"
                    }
                }
            ],
            "update_operations": [
                {
                    "operationid": "31",
                    "operationtype": "12",
                    "evaltype": "0",
                    "opmessage": {
                        "default_msg": "1",
                        "subject": "",
                        "message": "",
                        "mediatypeid": "0"
                    }
                },
                {
                    "operationid": "32",
                    "operationtype": "0",
                    "evaltype": "0",
                    "opmessage": {
                        "default_msg": "0",
                        "subject": "Updated: {TRIGGER.NAME}",
                        "message": "{USER.FULLNAME} updated problem at {EVENT.UPDATE.DATE} {EVENT.UPDATE.TIME} with the following message:\r\n{EVENT.UPDATE.MESSAGE}\r\n\r\nCurrent problem state is {EVENT.STATUS}",
                        "mediatypeid": "1"
                    },
                    "opmessage_grp": [
                        {
                            "usrgrpid": "7"
                        }
                    ],
                    "opmessage_usr": []
                },
                {
                    "operationid": "33",
                    "operationtype": "1",
                    "evaltype": "0",
                    "opcommand": {
                        "scriptid": "3"
                    },
                    "opcommand_hst": [
                        {
                            "hostid": "10084"
                        }
                    ],
                    "opcommand_grp": []
                }
            ]
        }
    ],
    "id": 1
}
```

[comment]: # ({/dabc835c-f7d2e806})

[comment]: # ({931fc05d-d96da9cf})
#### ディスカバリアクションの取得

設定されたすべてのディスカバリアクションを、アクションの条件と操作とともに取得します。このフィルターは"and"評価タイプを使用するため、`formula`プロパティは空で、`eval_formula`が自動的に生成されます。

[リクエスト](/manual/api#performing-requests) :

```json
{
    "jsonrpc": "2.0",
    "method": "action.get",
    "params": {
        "output": "extend",
        "selectOperations": "extend",
        "selectFilter": "extend",
        "filter": {
            "eventsource": 1
        }
    },
    "id": 1
}
```

レスポンス :

```json
{
    "jsonrpc": "2.0",
    "result": [
        {
            "actionid": "2",
            "name": "Auto discovery. Linux servers.",
            "eventsource": "1",
            "status": "1",
            "esc_period": "0s",
            "pause_suppressed": "1",
            "filter": {
                "evaltype": "0",
                "formula": "",
                "conditions": [
                    {
                        "conditiontype": "10",
                        "operator": "0",
                        "value": "0",
                        "value2": "",
                        "formulaid": "B"
                    },
                    {
                        "conditiontype": "8",
                        "operator": "0",
                        "value": "9",
                        "value2": "",
                        "formulaid": "C"
                    },
                    {
                        "conditiontype": "12",
                        "operator": "2",
                        "value": "Linux",
                        "value2": "",
                        "formulaid": "A"
                    }
                ],
                "eval_formula": "A and B and C"
            },
            "operations": [
                {
                    "operationid": "1",
                    "actionid": "2",
                    "operationtype": "6",
                    "esc_period": "0s",
                    "esc_step_from": "1",
                    "esc_step_to": "1",
                    "evaltype": "0",
                    "opconditions": [],
                    "optemplate": [
                        {
                            "templateid": "10001"
                        }
                    ]
                },
                {
                    "operationid": "2",
                    "actionid": "2",
                    "operationtype": "4",
                    "esc_period": "0s",
                    "esc_step_from": "1",
                    "esc_step_to": "1",
                    "evaltype": "0",
                    "opconditions": [],
                    "opgroup": [
                        {
                            "groupid": "2"
                        }
                    ]
                }
            ]
        }
    ],
    "id": 1
}
```

[comment]: # ({/931fc05d-d96da9cf})

[comment]: # ({7ab40057-755496f7})
### 関連項目

-   [アクションフィルター](object#action-filter)
-   [アクション操作](object#action-operation)

[comment]: # ({/7ab40057-755496f7})

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

CAction::get() in *ui/include/classes/api/services/CAction.php*.

[comment]: # ({/025b824e-025b824e})
