

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

# AWS IoT Events contoh menggunakan AWS CLI
<a name="cli_iot-events_code_examples"></a>

Contoh kode berikut menunjukkan cara melakukan tindakan dan menerapkan skenario umum dengan menggunakan AWS Command Line Interface with AWS IoT Events.

*Tindakan* merupakan kutipan kode dari program yang lebih besar dan harus dijalankan dalam konteks. Sementara tindakan menunjukkan cara memanggil fungsi layanan individual, Anda dapat melihat tindakan dalam konteks dalam skenario terkait.

Setiap contoh menyertakan tautan ke kode sumber lengkap, di mana Anda dapat menemukan instruksi tentang cara mengatur dan menjalankan kode dalam konteks.

**Topics**
+ [Tindakan](#actions)

## Tindakan
<a name="actions"></a>

### `batch-put-message`
<a name="iot-events_BatchPutMessage_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`batch-put-message`.

**AWS CLI**  
**Untuk mengirim pesan (input) ke AWS IoT Events**  
`batch-put-message`Contoh berikut mengirimkan satu set pesan ke sistem AWS IoT Events. Setiap payload pesan diubah menjadi input yang Anda tentukan (`inputName`) dan dicerna ke detektor apa pun yang memantau input tersebut. Jika beberapa pesan dikirim, urutan pemrosesan pesan tidak dijamin. Untuk menjamin pemesanan, Anda harus mengirim pesan satu per satu dan menunggu respons yang berhasil.  

```
aws iotevents-data batch-put-message \
    --cli-input-json file://highPressureMessage.json
```
Isi dari `highPressureMessage.json`:  

```
{
    "messages": [
        {
            "messageId": "00001",
            "inputName": "PressureInput",
            "payload": "{\"motorid\": \"Fulton-A32\", \"sensorData\": {\"pressure\": 80, \"temperature\": 39} }"
        }
    ]
}
```
Output:  

```
{
    "BatchPutMessageErrorEntries": []
}
```
Untuk informasi selengkapnya, lihat [BatchPutMessage](https://docs.aws.amazon.com/iotevents/latest/apireference/API_iotevents-data_BatchPutMessage.html)di Referensi *API Acara AWS IoT*.  
+  Untuk detail API, lihat [BatchPutMessage](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/batch-put-message.html)di *Referensi AWS CLI Perintah*. 

### `batch-update-detector`
<a name="iot-events_BatchUpdateDetector_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`batch-update-detector`.

**AWS CLI**  
**Untuk memperbarui detektor (contoh)**  
`batch-update-detector`Contoh berikut memperbarui status, nilai variabel, dan pengaturan timer dari satu atau lebih detektor (instance) dari model detektor tertentu.  

```
aws iotevents-data batch-update-detector \
    --cli-input-json file://budFulton-A32.json
```
Isi dari `budFulton-A32.json`:  

```
{
    "detectors": [
        {
            "messageId": "00001",
            "detectorModelName": "motorDetectorModel",
            "keyValue": "Fulton-A32",
            "state": {
                "stateName": "Normal",
                "variables": [
                    {
                        "name": "pressureThresholdBreached",
                        "value": "0"
                    }
                ],
                "timers": [
                ]
            }
        }
    ]
}
```
Output:  

```
{
    "batchUpdateDetectorErrorEntries": []
}
```
Untuk informasi selengkapnya, lihat [BatchUpdateDetector](https://docs.aws.amazon.com/iotevents/latest/apireference/API_iotevents-data_BatchUpdateDetector.html)di Referensi *API Acara AWS IoT*.  
+  Untuk detail API, lihat [BatchUpdateDetector](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/batch-update-detector.html)di *Referensi AWS CLI Perintah*. 

### `create-detector-model`
<a name="iot-events_CreateDetectorModel_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`create-detector-model`.

**AWS CLI**  
**Untuk membuat model detektor**  
`create-detector-model`Contoh berikut membuat model detektor dengan konfigurasi yang ditentukan oleh file parameter.  

```
aws iotevents create-detector-model  \
    --cli-input-json file://motorDetectorModel.json
```
Isi dari `motorDetectorModel.json`:  

```
{
    "detectorModelName": "motorDetectorModel",
    "detectorModelDefinition": {
        "states": [
            {
                "stateName": "Normal",
                "onEnter": {
                    "events": [
                        {
                            "eventName": "init",
                            "condition": "true",
                            "actions": [
                                {
                                    "setVariable": {
                                        "variableName": "pressureThresholdBreached",
                                        "value": "0"
                                    }
                                }
                            ]
                        }
                    ]
                },
                "onInput": {
                    "transitionEvents": [
                        {
                            "eventName": "Overpressurized",
                            "condition": "$input.PressureInput.sensorData.pressure &gt; 70",
                            "actions": [
                                {
                                    "setVariable": {
                                        "variableName": "pressureThresholdBreached",
                                        "value": "$variable.pressureThresholdBreached + 3"
                                    }
                                }
                            ],
                            "nextState": "Dangerous"
                        }
                    ]
                }
            },
            {
                "stateName": "Dangerous",
                "onEnter": {
                    "events": [
                        {
                            "eventName": "Pressure Threshold Breached",
                            "condition": "$variable.pressureThresholdBreached &gt; 1",
                            "actions": [
                                {
                                    "sns": {
                                        "targetArn": "arn:aws:sns:us-east-1:123456789012:underPressureAction"
                                    }
                                }
                            ]
                        }
                    ]
                },
                "onInput": {
                    "events": [
                        {
                            "eventName": "Overpressurized",
                            "condition": "$input.PressureInput.sensorData.pressure &gt; 70",
                            "actions": [
                                {
                                    "setVariable": {
                                        "variableName": "pressureThresholdBreached",
                                        "value": "3"
                                    }
                                }
                            ]
                        },
                        {
                            "eventName": "Pressure Okay",
                            "condition": "$input.PressureInput.sensorData.pressure &lt;= 70",
                            "actions": [
                                {
                                    "setVariable": {
                                        "variableName": "pressureThresholdBreached",
                                        "value": "$variable.pressureThresholdBreached - 1"
                                    }
                                }
                            ]
                        }
                    ],
                    "transitionEvents": [
                        {
                            "eventName": "BackToNormal",
                            "condition": "$input.PressureInput.sensorData.pressure &lt;= 70 &amp;&amp; $variable.pressureThresholdBreached &lt;= 1",
                            "nextState": "Normal"
                        }
                    ]
                },
                "onExit": {
                    "events": [
                        {
                            "eventName": "Normal Pressure Restored",
                            "condition": "true",
                            "actions": [
                                {
                                    "sns": {
                                        "targetArn": "arn:aws:sns:us-east-1:123456789012:pressureClearedAction"
                                    }
                                }
                            ]
                        }
                    ]
                }
            }
        ],
        "initialStateName": "Normal"
    },
    "key": "motorid",
    "roleArn": "arn:aws:iam::123456789012:role/IoTEventsRole"
}
```
Output:  

```
{
    "detectorModelConfiguration": {
        "status": "ACTIVATING",
        "lastUpdateTime": 1560796816.077,
        "roleArn": "arn:aws:iam::123456789012:role/IoTEventsRole",
        "creationTime": 1560796816.077,
        "detectorModelArn": "arn:aws:iotevents:us-west-2:123456789012:detectorModel/motorDetectorModel",
        "key": "motorid",
        "detectorModelName": "motorDetectorModel",
        "detectorModelVersion": "1"
    }
}
```
Untuk informasi selengkapnya, lihat [CreateDetectorModel](https://docs.aws.amazon.com/iotevents/latest/apireference/API_CreateDetectorModel.html)di Referensi *API Acara AWS IoT*.  
+  Untuk detail API, lihat [CreateDetectorModel](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/create-detector-model.html)di *Referensi AWS CLI Perintah*. 

### `create-input`
<a name="iot-events_CreateInput_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`create-input`.

**AWS CLI**  
**Untuk membuat masukan**  
`create-input`Contoh berikut menciptakan masukan.  

```
aws iotevents create-input  \
    --cli-input-json file://pressureInput.json
```
Isi dari `pressureInput.json`:  

```
{
    "inputName": "PressureInput",
    "inputDescription": "Pressure readings from a motor",
    "inputDefinition": {
        "attributes": [
            { "jsonPath": "sensorData.pressure" },
            { "jsonPath": "motorid" }
        ]
    }
}
```
Output:  

```
{
    "inputConfiguration": {
        "status": "ACTIVE",
        "inputArn": "arn:aws:iotevents:us-west-2:123456789012:input/PressureInput",
        "lastUpdateTime": 1560795312.542,
        "creationTime": 1560795312.542,
        "inputName": "PressureInput",
        "inputDescription": "Pressure readings from a motor"
    }
}
```
Untuk informasi selengkapnya, lihat [CreateInput](https://docs.aws.amazon.com/iotevents/latest/apireference/API_CreateInput)di Referensi *API Acara AWS IoT*.  
+  Untuk detail API, lihat [CreateInput](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/create-input.html)di *Referensi AWS CLI Perintah*. 

### `delete-detector-model`
<a name="iot-events_DeleteDetectorModel_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`delete-detector-model`.

**AWS CLI**  
**Untuk menghapus model detektor**  
`delete-detector-model`Contoh berikut menghapus model detektor yang ditentukan. Setiap contoh aktif dari model detektor juga dihapus.  

```
aws iotevents delete-detector-model \
    --detector-model-name motorDetectorModel
```
Perintah ini tidak menghasilkan output.  
Untuk informasi selengkapnya, lihat [DeleteDetectorModel](https://docs.aws.amazon.com/iotevents/latest/apireference/API_DeleteDetectorModel)di Referensi *API Acara AWS IoT*.  
+  Untuk detail API, lihat [DeleteDetectorModel](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/delete-detector-model.html)di *Referensi AWS CLI Perintah*. 

### `delete-input`
<a name="iot-events_DeleteInput_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`delete-input`.

**AWS CLI**  
**Untuk menghapus input**  
`delete-input`Contoh berikut menghapus input yang ditentukan.  

```
aws iotevents delete-input \
    --input-name PressureInput
```
Perintah ini tidak menghasilkan output.  
Untuk informasi selengkapnya, lihat [DeleteInput](https://docs.aws.amazon.com/iotevents/latest/apireference/API_DeleteInput)di Referensi *API Acara AWS IoT*.  
+  Untuk detail API, lihat [DeleteInput](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/delete-input.html)di *Referensi AWS CLI Perintah*. 

### `describe-detector-model`
<a name="iot-events_DescribeDetectorModel_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`describe-detector-model`.

**AWS CLI**  
**Untuk mendapatkan informasi tentang model detektor**  
`describe-detector-model`Contoh berikut menampilkan rincian untuk model detektor yang ditentukan. Karena `version` parameter tidak ditentukan, informasi tentang versi terbaru dikembalikan.  

```
aws iotevents describe-detector-model \
    --detector-model-name motorDetectorModel
```
Output:  

```
{
    "detectorModel": {
        "detectorModelConfiguration": {
            "status": "ACTIVE",
            "lastUpdateTime": 1560796816.077,
            "roleArn": "arn:aws:iam::123456789012:role/IoTEventsRole",
            "creationTime": 1560796816.077,
            "detectorModelArn": "arn:aws:iotevents:us-west-2:123456789012:detectorModel/motorDetectorModel",
            "key": "motorid",
            "detectorModelName": "motorDetectorModel",
            "detectorModelVersion": "1"
        },
        "detectorModelDefinition": {
            "states": [
                {
                    "onInput": {
                        "transitionEvents": [
                            {
                                "eventName": "Overpressurized",
                                "actions": [
                                    {
                                        "setVariable": {
                                            "variableName": "pressureThresholdBreached",
                                            "value": "$variable.pressureThresholdBreached + 3"
                                        }
                                    }
                                ],
                                "condition": "$input.PressureInput.sensorData.pressure > 70",
                                "nextState": "Dangerous"
                            }
                        ],
                        "events": []
                    },
                    "stateName": "Normal",
                    "onEnter": {
                        "events": [
                            {
                                "eventName": "init",
                                "actions": [
                                    {
                                        "setVariable": {
                                            "variableName": "pressureThresholdBreached",
                                            "value": "0"
                                        }
                                    }
                                ],
                                "condition": "true"
                            }
                        ]
                    },
                    "onExit": {
                        "events": []
                    }
                },
                {
                    "onInput": {
                        "transitionEvents": [
                            {
                                "eventName": "BackToNormal",
                                "actions": [],
                                "condition": "$input.PressureInput.sensorData.pressure <= 70 && $variable.pressureThresholdBreached <= 1",
                                "nextState": "Normal"
                            }
                        ],
                        "events": [
                            {
                                "eventName": "Overpressurized",
                                "actions": [
                                    {
                                        "setVariable": {
                                            "variableName": "pressureThresholdBreached",
                                            "value": "3"
                                        }
                                    }
                                ],
                                "condition": "$input.PressureInput.sensorData.pressure > 70"
                            },
                            {
                                "eventName": "Pressure Okay",
                                "actions": [
                                    {
                                        "setVariable": {
                                            "variableName": "pressureThresholdBreached",
                                            "value": "$variable.pressureThresholdBreached - 1"
                                        }
                                    }
                                ],
                                "condition": "$input.PressureInput.sensorData.pressure <= 70"
                            }
                        ]
                    },
                    "stateName": "Dangerous",
                    "onEnter": {
                        "events": [
                            {
                                "eventName": "Pressure Threshold Breached",
                                "actions": [
                                    {
                                        "sns": {
                                            "targetArn": "arn:aws:sns:us-east-1:123456789012:underPressureAction"
                                        }
                                    }
                                ],
                                "condition": "$variable.pressureThresholdBreached > 1"
                            }
                        ]
                    },
                    "onExit": {
                        "events": [
                            {
                                "eventName": "Normal Pressure Restored",
                                "actions": [
                                    {
                                        "sns": {
                                            "targetArn": "arn:aws:sns:us-east-1:123456789012:pressureClearedAction"
                                        }
                                    }
                                ],
                                "condition": "true"
                            }
                        ]
                    }
                }
            ],
            "initialStateName": "Normal"
        }
    }
}
```
Untuk informasi selengkapnya, lihat [DescribeDetectorModel](https://docs.aws.amazon.com/iotevents/latest/apireference/API_DescribeDetectorModel)di Referensi *API Acara AWS IoT*.  
+  Untuk detail API, lihat [DescribeDetectorModel](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/describe-detector-model.html)di *Referensi AWS CLI Perintah*. 

### `describe-detector`
<a name="iot-events_DescribeDetector_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`describe-detector`.

**AWS CLI**  
**Untuk mendapatkan informasi tentang detektor (instance).**  
`describe-detector`Contoh berikut menampilkan rincian untuk detektor tertentu (contoh).  

```
aws iotevents-data describe-detector \
    --detector-model-name motorDetectorModel \
    --key-value "Fulton-A32"
```
Output:  

```
{
    "detector": {
        "lastUpdateTime": 1560797852.776,
        "creationTime": 1560797852.775,
        "state": {
            "variables": [
                {
                    "name": "pressureThresholdBreached",
                    "value": "3"
                }
            ],
            "stateName": "Dangerous",
            "timers": []
        },
        "keyValue": "Fulton-A32",
        "detectorModelName": "motorDetectorModel",
        "detectorModelVersion": "1"
    }
}
```
Untuk informasi selengkapnya, lihat [DescribeDetector](https://docs.aws.amazon.com/iotevents/latest/apireference/API_iotevents-data_DescribeDetector)di Referensi *API Acara AWS IoT*.  
+  Untuk detail API, lihat [DescribeDetector](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/describe-detector.html)di *Referensi AWS CLI Perintah*. 

### `describe-input`
<a name="iot-events_DescribeInput_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`describe-input`.

**AWS CLI**  
**Untuk mendapatkan informasi tentang masukan**  
`describe-input`Contoh berikut menampilkan rincian untuk input yang ditentukan.  

```
aws iotevents describe-input \
    --input-name PressureInput
```
Output:  

```
{
    "input": {
        "inputConfiguration": {
            "status": "ACTIVE",
            "inputArn": "arn:aws:iotevents:us-west-2:123456789012:input/PressureInput",
            "lastUpdateTime": 1560795312.542,
            "creationTime": 1560795312.542,
            "inputName": "PressureInput",
            "inputDescription": "Pressure readings from a motor"
        },
        "inputDefinition": {
            "attributes": [
                {
                    "jsonPath": "sensorData.pressure"
                },
                {
                    "jsonPath": "motorid"
                }
            ]
        }
    }
}
```
Untuk informasi selengkapnya, lihat [DescribeInput](https://docs.aws.amazon.com/iotevents/latest/apireference/API_DescribeInput)di Referensi *API Acara AWS IoT*.  
+  Untuk detail API, lihat [DescribeInput](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/describe-input.html)di *Referensi AWS CLI Perintah*. 

### `describe-logging-options`
<a name="iot-events_DescribeLoggingOptions_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`describe-logging-options`.

**AWS CLI**  
**Untuk mendapatkan informasi tentang pengaturan logging**  
`describe-logging-options`Contoh berikut mengambil pengaturan saat ini dari opsi logging Peristiwa AWS IoT.  

```
aws iotevents describe-logging-options
```
Output:  

```
{
    "loggingOptions": {
        "roleArn": "arn:aws:iam::123456789012:role/IoTEventsRole",
        "enabled": false,
        "level": "ERROR"
    }
}
```
Untuk informasi selengkapnya, lihat [DescribeLoggingOptions](https://docs.aws.amazon.com/iotevents/latest/apireference/API_DescribeLoggingOptions)di Referensi *API Acara AWS IoT*.  
+  Untuk detail API, lihat [DescribeLoggingOptions](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/describe-logging-options.html)di *Referensi AWS CLI Perintah*. 

### `list-detector-model-versions`
<a name="iot-events_ListDetectorModelVersions_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`list-detector-model-versions`.

**AWS CLI**  
**Untuk mendapatkan informasi tentang versi model detektor**  
`list-detector-model-versions`Contoh berikut Daftar semua versi model detektor. Hanya metadata yang terkait dengan setiap versi model detektor yang dikembalikan.  

```
aws iotevents list-detector-model-versions \
    --detector-model-name motorDetectorModel
```
Output:  

```
{
    "detectorModelVersionSummaries": [
        {
            "status": "ACTIVE",
            "lastUpdateTime": 1560796816.077,
            "roleArn": "arn:aws:iam::123456789012:role/IoTEventsRole",
            "creationTime": 1560796816.077,
            "detectorModelArn": "arn:aws:iotevents:us-west-2:123456789012:detectorModel/motorDetectorModel",
            "detectorModelName": "motorDetectorModel",
            "detectorModelVersion": "1"
        }
    ]
}
```
Untuk informasi selengkapnya, lihat [ListDetectorModelVersions](https://docs.aws.amazon.com/iotevents/latest/apireference/API_ListDetectorModelVersions)di Referensi *API Acara AWS IoT*.  
+  Untuk detail API, lihat [ListDetectorModelVersions](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/list-detector-model-versions.html)di *Referensi AWS CLI Perintah*. 

### `list-detector-models`
<a name="iot-events_ListDetectorModels_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`list-detector-models`.

**AWS CLI**  
**Untuk mendapatkan daftar model detektor Anda**  
`list-detector-models`Contoh berikut Daftar model detektor yang telah Anda buat. Hanya metadata yang terkait dengan setiap model detektor yang dikembalikan.  

```
aws iotevents list-detector-models
```
Output:  

```
{
    "detectorModelSummaries": [
        {
            "detectorModelName": "motorDetectorModel",
            "creationTime": 1552072424.212
            "detectorModelDescription": "Detect overpressure in a motor."
        }
    ]
}
```
Untuk informasi selengkapnya, lihat [ListDetectorModels](https://docs.aws.amazon.com/iotevents/latest/apireference/API_ListDetectorModels)di Referensi *API Acara AWS IoT*.  
+  Untuk detail API, lihat [ListDetectorModels](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/list-detector-models.html)di *Referensi AWS CLI Perintah*. 

### `list-detectors`
<a name="iot-events_ListDetectors_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`list-detectors`.

**AWS CLI**  
**Untuk mendapatkan daftar detektor untuk model detektor**  
`list-detectors`Contoh berikut mencantumkan detektor (contoh model detektor) di akun Anda.  

```
aws iotevents-data list-detectors \
    --detector-model-name motorDetectorModel
```
Output:  

```
{
    "detectorSummaries": [
        {
            "lastUpdateTime": 1558129925.2,
            "creationTime": 1552073155.527,
            "state": {
                "stateName": "Normal"
            },
            "keyValue": "Fulton-A32",
            "detectorModelName": "motorDetectorModel",
            "detectorModelVersion": "1"
        }
    ]
}
```
Untuk informasi selengkapnya, lihat [ListDetectors](https://docs.aws.amazon.com/iotevents/latest/apireference/API_iotevents-data_ListDetectors)di Referensi *API Acara AWS IoT*.  
+  Untuk detail API, lihat [ListDetectors](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/list-detectors.html)di *Referensi AWS CLI Perintah*. 

### `list-inputs`
<a name="iot-events_ListInputs_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`list-inputs`.

**AWS CLI**  
**Untuk daftar input**  
`list-inputs`Contoh berikut mencantumkan input yang telah Anda buat di akun Anda.  

```
aws iotevents list-inputs
```
Perintah ini tidak menghasilkan output. Output:  

```
{
    {
        "status": "ACTIVE",
        "inputArn": "arn:aws:iotevents:us-west-2:123456789012:input/PressureInput",
        "lastUpdateTime": 1551742986.768,
        "creationTime": 1551742986.768,
        "inputName": "PressureInput",
        "inputDescription": "Pressure readings from a motor"
    }
}
```
Untuk informasi selengkapnya, lihat [ListInputs](https://docs.aws.amazon.com/iotevents/latest/apireference/API_ListInputs)di Referensi *API Acara AWS IoT*.  
+  Untuk detail API, lihat [ListInputs](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/list-inputs.html)di *Referensi AWS CLI Perintah*. 

### `list-tags-for-resource`
<a name="iot-events_ListTagsForResource_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`list-tags-for-resource`.

**AWS CLI**  
**Untuk mencantumkan tag yang ditetapkan ke sumber daya.**  
`list-tags-for-resource`Contoh berikut mencantumkan nama kunci tag dan nilai yang telah Anda tetapkan ke sumber daya.  

```
aws iotevents list-tags-for-resource \
    --resource-arn "arn:aws:iotevents:us-west-2:123456789012:input/PressureInput"
```
Output:  

```
{
    "tags": [
        {
            "value": "motor",
            "key": "deviceType"
        }
    ]
}
```
Untuk informasi selengkapnya, lihat [ListTagsForResource](https://docs.aws.amazon.com/iotevents/latest/apireference/API_ListTagsForResource)di Referensi *API Acara AWS IoT*.  
+  Untuk detail API, lihat [ListTagsForResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/list-tags-for-resource.html)di *Referensi AWS CLI Perintah*. 

### `put-logging-options`
<a name="iot-events_PutLoggingOptions_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`put-logging-options`.

**AWS CLI**  
**Untuk mengatur opsi pencatatan**  
`put-logging-options`Contoh berikut menetapkan atau memperbarui opsi logging Peristiwa AWS IoT. Jika Anda memperbarui nilai `loggingOptions` field, it can take up to one minute for the change to take effect. Also, if you change the policy attached to the role you specified in the ``roleArn` bidang apa pun (misalnya, untuk memperbaiki kebijakan yang tidak valid), diperlukan waktu hingga lima menit agar perubahan tersebut diterapkan.  

```
aws iotevents put-logging-options \
    --cli-input-json file://logging-options.json
```
Isi dari `logging-options.json`:  

```
{
    "loggingOptions": {
        "roleArn": "arn:aws:iam::123456789012:role/IoTEventsRole",
        "level": "DEBUG",
        "enabled": true,
        "detectorDebugOptions": [
            {
                "detectorModelName": "motorDetectorModel",
                "keyValue": "Fulton-A32"
            }
        ]
    }
}
```
Perintah ini tidak menghasilkan output.  
Untuk informasi selengkapnya, lihat [PutLoggingOptions](https://docs.aws.amazon.com/iotevents/latest/apireference/API_PutLoggingOptions)di Referensi *API Acara AWS IoT*.  
+  Untuk detail API, lihat [PutLoggingOptions](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/put-logging-options.html)di *Referensi AWS CLI Perintah*. 

### `tag-resource`
<a name="iot-events_TagResource_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`tag-resource`.

**AWS CLI**  
**Untuk menambahkan tag ke sumber daya**  
`tag-resource`Contoh berikut menambahkan atau memodifikasi (jika kunci `deviceType` sudah ada) tag yang dilampirkan sumber daya yang ditentukan.  

```
aws iotevents tag-resource \
    --cli-input-json file://pressureInput.tag.json
```
Isi dari `pressureInput.tag.json`:  

```
{
    "resourceArn": "arn:aws:iotevents:us-west-2:123456789012:input/PressureInput",
    "tags": [
        {
            "key": "deviceType",
            "value": "motor"
        }
    ]
}
```
Perintah ini tidak menghasilkan output.  
Untuk informasi selengkapnya, lihat [TagResource](https://docs.aws.amazon.com/iotevents/latest/apireference/API_TagResource)di Referensi *API Acara AWS IoT*.  
+  Untuk detail API, lihat [TagResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/tag-resource.html)di *Referensi AWS CLI Perintah*. 

### `untag-resource`
<a name="iot-events_UntagResource_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`untag-resource`.

**AWS CLI**  
**Untuk menghapus tag dari sumber daya**  
`untag-resource`Contoh berikut menghapus tag dengan nama kunci yang ditentukan dari sumber daya yang ditentukan.  

```
aws iotevents untag-resource \
    --resource-arn arn:aws:iotevents:us-west-2:123456789012:input/PressureInput \
    --tagkeys deviceType
```
Perintah ini tidak menghasilkan output.  
Untuk informasi selengkapnya, lihat [UntagResource](https://docs.aws.amazon.com/iotevents/latest/apireference/API_UntagResource)di Referensi *API Acara AWS IoT*.  
+  Untuk detail API, lihat [UntagResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/untag-resource.html)di *Referensi AWS CLI Perintah*. 

### `update-detector-model`
<a name="iot-events_UpdateDetectorModel_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`update-detector-model`.

**AWS CLI**  
**Untuk memperbarui model detektor**  
`update-detector-model`Contoh berikut memperbarui model detektor yang ditentukan. Detektor (instance) yang dihasilkan oleh versi sebelumnya dihapus dan kemudian dibuat ulang saat input baru tiba.  

```
aws iotevents update-detector-model \
    --cli-input-json file://motorDetectorModel.update.json
```
Isi dari `motorDetectorModel.update.json`:  

```
{
    "detectorModelName": "motorDetectorModel",
    "detectorModelDefinition": {
        "states": [
            {
                "stateName": "Normal",
                "onEnter": {
                    "events": [
                        {
                            "eventName": "init",
                            "condition": "true",
                            "actions": [
                                {
                                    "setVariable": {
                                        "variableName": "pressureThresholdBreached",
                                        "value": "0"
                                    }
                                }
                            ]
                        }
                    ]
                },
                "onInput": {
                    "transitionEvents": [
                        {
                            "eventName": "Overpressurized",
                            "condition": "$input.PressureInput.sensorData.pressure > 70",
                            "actions": [
                                {
                                    "setVariable": {
                                        "variableName": "pressureThresholdBreached",
                                        "value": "$variable.pressureThresholdBreached + 3"
                                    }
                                }
                            ],
                            "nextState": "Dangerous"
                        }
                    ]
                }
            },
            {
                "stateName": "Dangerous",
                "onEnter": {
                    "events": [
                        {
                            "eventName": "Pressure Threshold Breached",
                            "condition": "$variable.pressureThresholdBreached > 1",
                            "actions": [
                                {
                                    "sns": {
                                        "targetArn": "arn:aws:sns:us-east-1:123456789012:underPressureAction"
                                    }
                                }
                            ]
                        }
                    ]
                },
                "onInput": {
                    "events": [
                        {
                            "eventName": "Overpressurized",
                            "condition": "$input.PressureInput.sensorData.pressure > 70",
                            "actions": [
                                {
                                    "setVariable": {
                                        "variableName": "pressureThresholdBreached",
                                        "value": "3"
                                    }
                                }
                            ]
                        },
                        {
                            "eventName": "Pressure Okay",
                            "condition": "$input.PressureInput.sensorData.pressure <= 70",
                            "actions": [
                                {
                                    "setVariable": {
                                        "variableName": "pressureThresholdBreached",
                                        "value": "$variable.pressureThresholdBreached - 1"
                                    }
                                }
                            ]
                        }
                    ],
                    "transitionEvents": [
                        {
                            "eventName": "BackToNormal",
                            "condition": "$input.PressureInput.sensorData.pressure <= 70 && $variable.pressureThresholdBreached <= 1",
                            "nextState": "Normal"
                        }
                    ]
                },
                "onExit": {
                    "events": [
                        {
                            "eventName": "Normal Pressure Restored",
                            "condition": "true",
                            "actions": [
                                {
                                    "sns": {
                                        "targetArn": "arn:aws:sns:us-east-1:123456789012:pressureClearedAction"
                                    }
                                }
                            ]
                        }
                    ]
                }
            }
        ],
        "initialStateName": "Normal"
    },
    "roleArn": "arn:aws:iam::123456789012:role/IoTEventsRole"
}
```
Output:  

```
{
    "detectorModelConfiguration": {
        "status": "ACTIVATING",
        "lastUpdateTime": 1560799387.719,
        "roleArn": "arn:aws:iam::123456789012:role/IoTEventsRole",
        "creationTime": 1560799387.719,
        "detectorModelArn": "arn:aws:iotevents:us-west-2:123456789012:detectorModel/motorDetectorModel",
        "key": "motorid",
        "detectorModelName": "motorDetectorModel",
        "detectorModelVersion": "2"
    }
}
```
Untuk informasi selengkapnya, lihat [UpdateDetectorModel](https://docs.aws.amazon.com/iotevents/latest/apireference/API_UpdateDetectorModel)di Referensi *API Acara AWS IoT*.  
+  Untuk detail API, lihat [UpdateDetectorModel](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/update-detector-model.html)di *Referensi AWS CLI Perintah*. 

### `update-input`
<a name="iot-events_UpdateInput_cli_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`update-input`.

**AWS CLI**  
**Untuk memperbarui input**  
`update-input`Contoh berikut memperbarui input yang ditentukan dengan deskripsi dan definisi baru.  

```
aws iotevents update-input \
    --cli-input-json file://pressureInput.json
```
Isi dari `pressureInput.json`:  

```
{
    "inputName": "PressureInput",
    "inputDescription": "Pressure readings from a motor",
    "inputDefinition": {
        "attributes": [
            { "jsonPath": "sensorData.pressure" },
            { "jsonPath": "motorid" }
        ]
    }
}
```
Output:  

```
{
    "inputConfiguration": {
        "status": "ACTIVE",
        "inputArn": "arn:aws:iotevents:us-west-2:123456789012:input/PressureInput",
        "lastUpdateTime": 1560795976.458,
        "creationTime": 1560795312.542,
        "inputName": "PressureInput",
        "inputDescription": "Pressure readings from a motor"
    }
}
```
Untuk informasi selengkapnya, lihat [UpdateInput](https://docs.aws.amazon.com/iotevents/latest/apireference/API_UpdateInput)di Referensi *API Acara AWS IoT*.  
+  Untuk detail API, lihat [UpdateInput](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/update-input.html)di *Referensi AWS CLI Perintah*. 