[comment]: # ({c7072ca6-c7072ca6})
# triggerprototype.get

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

[comment]: # ({1e3ce6d6-12701833})
### 説明

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

このメソッドは、指定したパラメーターに応じたトリガーのプロトタイプを取得できます。

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

[comment]: # ({/1e3ce6d6-12701833})

[comment]: # ({9b9fb5f8-14171778})
### パラメータ

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

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

|Parameter|[Type](/manual/api/reference_commentary#data-types)|Description|
|--|--|------|
|active|flag|監視中のホストに属する有効なトリガープロトタイプのみを返します。|
|discoveryids|ID/array|指定されたLLDルールに属するトリガープロトタイプのみを返します。|
|functions|string/array|指定された関数を使用するトリガーのみを返します。<br><br>サポートされている関数の一覧は、[Supported functions](/manual/appendix/functions)ページを参照してください。|
|group|string|指定された名前のホストグループまたはテンプレートグループに属するホストまたはテンプレートに属するトリガープロトタイプのみを返します。|
|groupids|ID/array|指定されたホストグループまたはテンプレートグループに属するホストまたはテンプレートに属するトリガープロトタイプのみを返します。|
|host|string|指定された名前のホストに属するトリガープロトタイプのみを返します。|
|hostids|ID/array|指定されたホストに属するトリガープロトタイプのみを返します。|
|inherited|boolean|`true` に設定した場合、テンプレートから継承されたトリガープロトタイプのみを返します。|
|maintenance|boolean|`true` に設定した場合、メンテナンス中のホストに属する有効なトリガープロトタイプのみを返します。|
|min\_severity|integer|指定された深刻度以上のトリガープロトタイプのみを返します。|
|monitored|flag|監視中のホストに属し、有効なアイテムのみを含む有効なトリガープロトタイプのみを返します。|
|templated|boolean|`true` に設定した場合、テンプレートに属するトリガープロトタイプのみを返します。|
|templateids|ID/array|指定されたテンプレートに属するトリガープロトタイプのみを返します。|
|triggerids|ID/array|指定されたIDを持つトリガープロトタイプのみを返します。|
|expandExpression|flag|トリガー条件式内の関数およびマクロを展開します。|
|selectDependencies|query|トリガープロトタイプが依存しているトリガープロトタイプおよびトリガーを、`dependencies` プロパティで返します。|
|selectDiscoveryRule|query|トリガープロトタイプが属する[LLDルール](/manual/api/reference/discoveryrule/object)を、`discoveryRule` プロパティで返します。|
|selectFunctions|query|トリガープロトタイプで使用されている関数を、`functions` プロパティで返します。<br><br>関数オブジェクトはトリガー条件式で使用される関数を表し、以下のプロパティを持ちます。<br>`functionid` - `(ID)` 関数のID。<br>`itemid` - `(ID)` 関数で使用されるアイテムのID。<br>`function` - `(string)` 関数名。<br>`parameter` - `(string)` 関数に渡されるパラメータ。クエリパラメータは、返される文字列では `$` 記号に置き換えられます。|
|selectHostGroups|query|トリガープロトタイプが属するホストグループを、[`hostgroups`](/manual/api/reference/hostgroup/object) プロパティで返します。|
|selectHosts|query|トリガープロトタイプが属するホストを、[`hosts`](/manual/api/reference/host/object) プロパティで返します。|
|selectItems|query|トリガープロトタイプで使用されるアイテムおよびアイテムプロトタイプを、[`items`](/manual/api/reference/item/object) プロパティで返します。|
|selectTags|query|トリガープロトタイプのタグを、[`tags`](/manual/api/reference/triggerprototype/object#trigger-prototype-tag) プロパティで返します。|
|selectTemplateGroups|query|トリガープロトタイプが属するテンプレートグループを、[`templategroups`](/manual/api/reference/templategroup/object) プロパティで返します。|
|filter|object|指定されたフィルターに完全一致する結果のみを返します。<br><br>プロパティ名をキーとし、照合する値または値の配列を値とするオブジェクトを受け付けます。<br><br>`text` [data type](/manual/api/reference_commentary#data-types) のプロパティはサポートされません。<br><br>追加のプロパティをサポートします。<br>`host` - トリガープロトタイプが属するホストの技術名。<br>`hostid` - トリガープロトタイプが属するホストのID。|
|limitSelects|integer|サブセレクトで返されるレコード数を制限します。<br><br>以下のサブセレクトに適用されます。<br>`selectHosts` - 結果は `host` でソートされます。|
|sortfield|string/array|指定されたプロパティで結果をソートします。<br><br>指定可能な値: `triggerid`, `description`, `status`, `priority`, `discovered`.|
|countOutput|boolean|これらのパラメータは[reference commentary](/manual/api/reference_commentary#common-get-method-parameters)で説明されています。|
|editable|boolean|^|
|excludeSearch|boolean|^|
|limit|integer|^|
|output|query|^|
|preservekeys|boolean|^|
|search|object|^|
|searchByAny|boolean|^|
|searchWildcardsEnabled|boolean|^|
|sortorder|string/array|^|
|startSearch|boolean|^|
|selectGroups<br>(deprecated)|query|このパラメータは非推奨です。代わりに `selectHostGroups` または `selectTemplateGroups` を使用してください。<br>トリガープロトタイプが属するホストグループおよびテンプレートグループを、`groups` プロパティで返します。|

[comment]: # ({/9b9fb5f8-14171778})

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

`(integer/array)` 次のいずれかを返します:

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

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

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

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

[comment]: # ({8756baad-81de28c1})
#### LLDルールからトリガープロトタイプを取得

LLDルールから、すべてのトリガープロトタイプとその関数を取得します。

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

```json
{
    "jsonrpc": "2.0",
    "method": "triggerprototype.get",
    "params": {
        "output": "extend",
        "selectFunctions": "extend",
        "discoveryids": "22450"
    },
    "id": 1
}
```

レスポンス:

```json
{
    "jsonrpc": "2.0",
    "result": [
        {
            "triggerid": "13272",
            "expression": "{12598}<20",
            "description": "ボリューム {#FSNAME} の空きinode数が20%未満です",
            "url": "",
            "status": "0",
            "value": "0",
            "priority": "2",
            "lastchange": "0",
            "comments": "",
            "error": "",
            "templateid": "0",
            "type": "0",
            "state": "0",
            "flags": "2",
            "recovery_mode": "0",
            "recovery_expression": "",
            "correlation_mode": "0",
            "correlation_tag": "",
            "manual_close": "0",
            "opdata": "",
            "discover": "0",
            "event_name": "",
            "uuid": "6ce467d05e8745409a177799bed34bb3",
            "url_name": "",
            "functions": [
                {
                    "functionid": "12598",
                    "itemid": "22454",
                    "parameter": "$",
                    "function": "last"
                }
            ]
        },
        {
            "triggerid": "13266",
            "expression": "{13500}<20",
            "description": "ボリューム {#FSNAME} の空きディスク容量が20%未満です",
            "url": "",
            "status": "0",
            "value": "0",
            "priority": "2",
            "lastchange": "0",
            "comments": "",
            "error": "",
            "templateid": "0",
            "type": "0",
            "state": "0",
            "flags": "2",
            "recovery_mode": "0",
            "recovery_expression": "",
            "correlation_mode": "0",
            "correlation_tag": "",
            "manual_close": "0",
            "opdata": "",
            "discover": "0",
            "event_name": "",
            "uuid": "74a1fc62bfe24b7eabe4e244c70dc384",
            "url_name": "",
            "functions": [
                {
                    "functionid": "13500",
                    "itemid": "22686",
                    "parameter": "$",
                    "function": "last"
                }
            ]
        }
    ],
    "id": 1
}
```

[comment]: # ({/8756baad-81de28c1})

[comment]: # ({af95a04d-2cb80f2d})
#### タグで特定のトリガープロトタイプを取得

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

```json
{
    "jsonrpc": "2.0",
    "method": "triggerprototype.get",
    "params": {
        "output": [
            "triggerid",
            "description"
        ],
        "selectTags": "extend",
        "triggerids": [
            "17373"
        ]
    },
    "id": 1
}
```

レスポンス :

```json
{
    "jsonrpc": "2.0",
    "result": [
        {
            "triggerid": "17373",
            "description": "Free disk space is less than 20% on volume {#FSNAME}",
            "tags": [
                {
                    "tag": "volume",
                    "value": "{#FSNAME}"
                },
                {
                    "tag": "type",
                    "value": "{#FSTYPE}"
                }
            ]
        }
    ],
    "id": 1
}
```

[comment]: # ({/af95a04d-2cb80f2d})

[comment]: # ({cf0cf439-222d46a0})
### 関連項目

-   [ディスカバリルール](/manual/api/reference/discoveryrule/object#discovery-rule)
-   [アイテム](/manual/api/reference/item/object#item)
-   [ホスト](/manual/api/reference/host/object#host)
-   [ホストグループ](/manual/api/reference/hostgroup/object#host-group)
-   [テンプレートグループ](/manual/api/reference/templategroup/object#template-group)

[comment]: # ({/cf0cf439-222d46a0})

[comment]: # ({526ca55d-1136c1c7})
### ソース

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

[comment]: # ({/526ca55d-1136c1c7})
