

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

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

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

*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-data_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-binary-format raw-in-base64-out \
    --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/developerguide/iotevents-commands.html#api-iotevents-data-BatchPutMessage)di Panduan *Pengembang Acara AWS IoT\$1*.  
+  Untuk detail API, lihat [BatchPutMessage](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/batch-put-message.html)di *Referensi AWS CLI Perintah*. 

### `batch-update-detector`
<a name="iot-events-data_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/developerguide/iotevents-commands.html#api-iotevents-data-BatchUpdateDetector)di Panduan *Pengembang Acara AWS IoT\$1*.  
+  Untuk detail API, lihat [BatchUpdateDetector](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/batch-update-detector.html)di *Referensi AWS CLI Perintah*. 

### `create-detector-model`
<a name="iot-events-data_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.  

```
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/developerguide/iotevents-commands.html#api-iotevents-CreateDetectorModel)di Panduan *Pengembang Acara AWS IoT\$1*.  
+  Untuk detail API, lihat [CreateDetectorModel](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/create-detector-model.html)di *Referensi AWS CLI Perintah*. 

### `create-input`
<a name="iot-events-data_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/developerguide/iotevents-commands.html#api-iotevents-CreateInput)di Panduan *Pengembang Acara AWS IoT\$1*.  
+  Untuk detail API, lihat [CreateInput](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/create-input.html)di *Referensi AWS CLI Perintah*. 

### `delete-detector-model`
<a name="iot-events-data_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. 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/developerguide/iotevents-commands.html#api-iotevents-DeleteDetectorModel)di Panduan *Pengembang Acara AWS IoT\$1*.  
+  Untuk detail API, lihat [DeleteDetectorModel](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/delete-detector-model.html)di *Referensi AWS CLI Perintah*. 

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

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

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

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

### `describe-detector-model`
<a name="iot-events-data_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 menjelaskan model detektor. Jika `version` parameter tidak ditentukan, perintah mengembalikan informasi tentang versi terbaru.  

```
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/developerguide/iotevents-commands.html#api-iotevents-DescribeDetectorModel)di Panduan *Pengembang Acara AWS IoT\$1*.  
+  Untuk detail API, lihat [DescribeDetectorModel](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/describe-detector-model.html)di *Referensi AWS CLI Perintah*. 

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

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

**AWS CLI**  
**Untuk mendapatkan informasi tentang detektor (instance)**  
`describe-detector`Contoh berikut mengembalikan informasi tentang 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/developerguide/iotevents-commands.html#api-iotevents-data-DescribeDetector)di Panduan *Pengembang Acara AWS IoT\$1*.  
+  Untuk detail API, lihat [DescribeDetector](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/describe-detector.html)di *Referensi AWS CLI Perintah*. 

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

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

**AWS CLI**  
**Untuk mendapatkan informasi tentang masukan**  
`describe-input`Contoh berikut mengambil rincian input.  

```
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/developerguide/iotevents-commands.html#api-iotevents-DescribeInput)di Panduan *Pengembang Acara AWS IoT\$1*.  
+  Untuk detail API, lihat [DescribeInput](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/describe-input.html)di *Referensi AWS CLI Perintah*. 

### `describe-logging-options`
<a name="iot-events-data_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 opsi logging Peristiwa AWS IoT saat ini.  

```
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/developerguide/iotevents-commands.html#api-iotevents-DescribeLoggingOptions)di Panduan *Pengembang Acara AWS IoT\$1*.  
+  Untuk detail API, lihat [DescribeLoggingOptions](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/describe-logging-options.html)di *Referensi AWS CLI Perintah*. 

### `list-detector-model-versions`
<a name="iot-events-data_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 mencantumkan 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/developerguide/iotevents-commands.html#api-iotevents-ListDetectorModelVersions)di Panduan *Pengembang Acara AWS IoT\$1*.  
+  Untuk detail API, lihat [ListDetectorModelVersions](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/list-detector-model-versions.html)di *Referensi AWS CLI Perintah*. 

### `list-detector-models`
<a name="iot-events-data_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 mencantumkan 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/developerguide/iotevents-commands.html#api-iotevents-ListDetectorModels)di Panduan *Pengembang Acara AWS IoT\$1*.  
+  Untuk detail API, lihat [ListDetectorModels](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/list-detector-models.html)di *Referensi AWS CLI Perintah*. 

### `list-detectors`
<a name="iot-events-data_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).  

```
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/developerguide/iotevents-commands.html#api-iotevents-ListDetectors)di Panduan *Pengembang Acara AWS IoT\$1*.  
+  Untuk detail API, lihat [ListDetectors](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/list-detectors.html)di *Referensi AWS CLI Perintah*. 

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

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

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

```
aws iotevents list-inputs
```
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/developerguide/iotevents-commands.html#api-iotevents-ListInputs)di Panduan *Pengembang Acara AWS IoT\$1*.  
+  Untuk detail API, lihat [ListInputs](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/list-inputs.html)di *Referensi AWS CLI Perintah*. 

### `list-tags-for-resource`
<a name="iot-events-data_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 tag (metadata) 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/developerguide/iotevents-commands.html#api-iotevents-ListTagsForResource)di Panduan *Pengembang Acara AWS IoT\$1*.  
+  Untuk detail API, lihat [ListTagsForResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/list-tags-for-resource.html)di *Referensi AWS CLI Perintah*. 

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

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

**AWS CLI**  
**Untuk mengatur opsi pencatatan**  
`list-tags-for-resource`Contoh berikut menetapkan atau memperbarui opsi logging Peristiwa AWS IoT. Jika Anda memperbarui nilai `loggingOptions` bidang apa pun, dibutuhkan waktu hingga satu menit agar perubahan diterapkan. Selain itu, jika Anda mengubah kebijakan yang dilampirkan pada peran yang Anda tentukan di `roleArn` bidang (misalnya, untuk memperbaiki kebijakan yang tidak valid), perubahan tersebut akan memakan 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/developerguide/iotevents-commands.html#api-iotevents-PutLoggingOptions)di Panduan *Pengembang Acara AWS IoT\$1*.  
+  Untuk detail API, lihat [PutLoggingOptions](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/put-logging-options.html)di *Referensi AWS CLI Perintah*. 

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

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

**AWS CLI**  
**Untuk menambahkan tag ke sumber daya**  
`tag-resource`Contoh berikut menambah atau memodifikasi tag dari sumber daya yang diberikan. Tag adalah metadata yang dapat digunakan untuk mengelola sumber daya.  

```
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/developerguide/iotevents-commands.html#api-iotevents-TagResource)di Panduan *Pengembang Acara AWS IoT\$1*.  
+  Untuk detail API, lihat [TagResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/tag-resource.html)di *Referensi AWS CLI Perintah*. 

### `untag-resource`
<a name="iot-events-data_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 yang ditentukan dari sumber daya.  

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

```
{
    "resourceArn": "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/developerguide/iotevents-commands.html#api-iotevents-UntagResource)di Panduan *Pengembang Acara AWS IoT\$1*.  
+  Untuk detail API, lihat [UntagResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/untag-resource.html)di *Referensi AWS CLI Perintah*. 

### `update-detector-model`
<a name="iot-events-data_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. 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/developerguide/iotevents-commands.html#api-iotevents-UpdateDetectorModel)di Panduan *Pengembang Acara AWS IoT\$1*.  
+  Untuk detail API, lihat [UpdateDetectorModel](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/update-detector-model.html)di *Referensi AWS CLI Perintah*. 

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

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

**AWS CLI**  
**Untuk memperbarui masukan**  
`update-input`Contoh berikut memperbarui input.  

```
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/developerguide/iotevents-commands.html#api-iotevents-UpdateInput)di Panduan *Pengembang Acara AWS IoT\$1*.  
+  Untuk detail API, lihat [UpdateInput](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/update-input.html)di *Referensi AWS CLI Perintah*. 