

Sono disponibili altri esempi AWS SDK nel repository [AWS Doc SDK](https://github.com/awsdocs/aws-doc-sdk-examples) Examples. GitHub 

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

# AWS IoT Events-Data esempi che utilizzano AWS CLI
<a name="cli_2_iot-events-data_code_examples"></a>

I seguenti esempi di codice mostrano come eseguire azioni e implementare scenari comuni utilizzando AWS Command Line Interface with AWS IoT Events-Data.

Le *azioni* sono estratti di codice da programmi più grandi e devono essere eseguite nel contesto. Sebbene le azioni mostrino come richiamare le singole funzioni del servizio, è possibile visualizzarle contestualizzate negli scenari correlati.

Ogni esempio include un link al codice sorgente completo, in cui vengono fornite le istruzioni su come configurare ed eseguire il codice nel contesto.

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

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

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

Il seguente esempio di codice mostra come utilizzare`batch-put-message`.

**AWS CLI**  
**Per inviare messaggi (input) a AWS IoT Events**  
L'`batch-put-message`esempio seguente invia una serie di messaggi al sistema AWS IoT Events. Ogni payload del messaggio viene trasformato nell’input specificato (`inputName`) e inserito in tutti i rilevatori che monitorano tale input. Se vengono inviati più messaggi, l’ordine in cui i messaggi vengono elaborati non è garantito. Per garantire l’ordine, è necessario inviare i messaggi uno alla volta e attendere una risposta corretta.  

```
aws iotevents-data batch-put-message \
    --cli-binary-format raw-in-base64-out \
    --cli-input-json file://highPressureMessage.json
```
Contenuto di `highPressureMessage.json`:  

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

```
{
    "BatchPutMessageErrorEntries": []
}
```
Per ulteriori informazioni, consulta [BatchPutMessage](https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-commands.html#api-iotevents-data-BatchPutMessage)la *AWS IoT Events Developer Guide\$1*.  
+  Per i dettagli sull'API, consulta [BatchPutMessage AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/batch-put-message.html)*Command Reference.* 

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

Il seguente esempio di codice mostra come utilizzare`batch-update-detector`.

**AWS CLI**  
**Come aggiornare un rilevatore (istanza)**  
L’esempio `batch-update-detector` seguente aggiorna lo stato, i valori delle variabili e le impostazioni del timer di uno o più rilevatori (istanze) di un modello di rilevatore specificato.  

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

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

```
{
    "batchUpdateDetectorErrorEntries": []
}
```
Per ulteriori informazioni, consulta [BatchUpdateDetector](https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-commands.html#api-iotevents-data-BatchUpdateDetector)la *AWS IoT Events Developer Guide\$1*.  
+  Per i dettagli sull'API, consulta [BatchUpdateDetector AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/batch-update-detector.html)*Command Reference.* 

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

Il seguente esempio di codice mostra come utilizzare`create-detector-model`.

**AWS CLI**  
**Come creare un modello di rivelatore**  
L’esempio `create-detector-model` seguente crea un modello di rilevatore.  

```
aws iotevents create-detector-model \
    --cli-input-json file://motorDetectorModel.json
```
Contenuto di `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"
    }
}
```
Per ulteriori informazioni, consulta [CreateDetectorModel](https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-commands.html#api-iotevents-CreateDetectorModel)la *AWS IoT Events Developer Guide\$1*.  
+  Per i dettagli sull'API, consulta [CreateDetectorModel AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/create-detector-model.html)*Command Reference.* 

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

Il seguente esempio di codice mostra come utilizzare`create-input`.

**AWS CLI**  
**Come creare un input**  
L’esempio `create-input` seguente crea un input.  

```
aws iotevents create-input \
    --cli-input-json file://pressureInput.json
```
Contenuto di `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"
    }
}
```
Per ulteriori informazioni, consulta [CreateInput](https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-commands.html#api-iotevents-CreateInput)la *AWS IoT Events Developer Guide\$1*.  
+  Per i dettagli sull'API, consulta [CreateInput AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/create-input.html)*Command Reference.* 

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

Il seguente esempio di codice mostra come utilizzare`delete-detector-model`.

**AWS CLI**  
**Come eliminare un modello di rilevatore**  
L’esempio `delete-detector-model` seguente elimina un modello di rilevatore. Vengono eliminate anche tutte le istanze attive del modello di rilevatore.  

```
aws iotevents delete-detector-model \
    --detector-model-name motorDetectorModel*
```
Questo comando non produce alcun output.  
Per ulteriori informazioni, consulta [DeleteDetectorModel](https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-commands.html#api-iotevents-DeleteDetectorModel)la *AWS IoT Events Developer Guide\$1*.  
+  Per i dettagli sull'API, consulta [DeleteDetectorModel AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/delete-detector-model.html)*Command Reference.* 

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

Il seguente esempio di codice mostra come utilizzare`delete-input`.

**AWS CLI**  
**Come eliminare un input**  
L’esempio `delete-input` seguente elimina un input.  

```
aws iotevents delete-input \
    --input-name PressureInput
```
Questo comando non produce alcun output.  
Per ulteriori informazioni, consulta [DeleteInput](https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-commands.html#api-iotevents-DeleteInput)la *AWS IoT Events Developer Guide\$1*.  
+  Per i dettagli sull'API, consulta [DeleteInput AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/delete-input.html)*Command Reference.* 

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

Il seguente esempio di codice mostra come utilizzare`describe-detector-model`.

**AWS CLI**  
**Come ottenere informazioni su un modello di rilevatore**  
L’esempio `describe-detector-model` seguente descrive un modello di rilevatore. Se il parametro `version` non è specificato, il comando restituisce le informazioni sulla versione più recente.  

```
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"
        }
    }
}
```
Per ulteriori informazioni, consulta [DescribeDetectorModel](https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-commands.html#api-iotevents-DescribeDetectorModel)la *AWS IoT Events Developer Guide\$1*.  
+  Per i dettagli sull'API, consulta [DescribeDetectorModel AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/describe-detector-model.html)*Command Reference.* 

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

Il seguente esempio di codice mostra come utilizzare`describe-detector`.

**AWS CLI**  
**Come ottenere informazioni su un rilevatore (istanza)**  
L’esempio `describe-detector` seguente restituisce informazioni sul rilevatore specificato (istanza).  

```
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"
    }
}
```
Per ulteriori informazioni, consulta [DescribeDetector](https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-commands.html#api-iotevents-data-DescribeDetector)la *AWS IoT Events Developer Guide\$1*.  
+  Per i dettagli sull'API, consulta [DescribeDetector AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/describe-detector.html)*Command Reference.* 

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

Il seguente esempio di codice mostra come utilizzare`describe-input`.

**AWS CLI**  
**Come ottenere informazioni su un input**  
L’esempio `describe-input` seguente recupera i dettagli di un 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"
                }
            ]
        }
    }
}
```
Per ulteriori informazioni, consulta [DescribeInput](https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-commands.html#api-iotevents-DescribeInput)la *AWS IoT Events Developer Guide\$1*.  
+  Per i dettagli sull'API, consulta [DescribeInput AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/describe-input.html)*Command Reference.* 

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

Il seguente esempio di codice mostra come utilizzare`describe-logging-options`.

**AWS CLI**  
**Come ottenere informazioni sulle impostazioni della registrazione di log**  
L'`describe-logging-options`esempio seguente recupera le attuali opzioni di registrazione degli eventi AWS IoT.  

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

```
{
    "loggingOptions": {
        "roleArn": "arn:aws:iam::123456789012:role/IoTEventsRole",
        "enabled": false,
        "level": "ERROR"
    }
}
```
Per ulteriori informazioni, consulta [DescribeLoggingOptions](https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-commands.html#api-iotevents-DescribeLoggingOptions)la *AWS IoT Events Developer Guide\$1*.  
+  Per i dettagli sull'API, consulta [DescribeLoggingOptions AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/describe-logging-options.html)*Command Reference.* 

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

Il seguente esempio di codice mostra come utilizzare`list-detector-model-versions`.

**AWS CLI**  
**Come ottenere informazioni sulle versioni di un modello di rilevatore**  
L’esempio `list-detector-model-versions` seguente elenca tutte le versioni di un modello di rilevatore. Vengono restituiti solo i metadati associati a ciascuna versione del modello di rivelatore.  

```
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"
        }
    ]
}
```
Per ulteriori informazioni, consulta [ListDetectorModelVersions](https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-commands.html#api-iotevents-ListDetectorModelVersions)la *AWS IoT Events Developer Guide\$1*.  
+  Per i dettagli sull'API, consulta [ListDetectorModelVersions AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/list-detector-model-versions.html)*Command Reference.* 

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

Il seguente esempio di codice mostra come utilizzare`list-detector-models`.

**AWS CLI**  
**Come ottenere un elenco dei modelli di rilevatori**  
L’esempio `list-detector-models` seguente elenca i modelli di rilevatore creati. Vengono restituiti solo i metadati associati a ciascun modello di rivelatore.  

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

```
{
    "detectorModelSummaries": [
        {
            "detectorModelName": "motorDetectorModel",
            "creationTime": 1552072424.212
            "detectorModelDescription": "Detect overpressure in a motor."
        }
    ]
}
```
Per ulteriori informazioni, consulta [ListDetectorModels](https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-commands.html#api-iotevents-ListDetectorModels)la *AWS IoT Events Developer Guide\$1*.  
+  Per i dettagli sull'API, consulta [ListDetectorModels AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/list-detector-models.html)*Command Reference.* 

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

Il seguente esempio di codice mostra come utilizzare`list-detectors`.

**AWS CLI**  
**Come ottenere un elenco di rilevatori per un modello di rilevatore**  
L’esempio `list-detectors` seguente elenca i rilevatori (le istanze di un modello di rivelatore).  

```
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"
        }
    ]
}
```
Per ulteriori informazioni, consulta [ListDetectors](https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-commands.html#api-iotevents-ListDetectors)la *AWS IoT Events Developer Guide\$1*.  
+  Per i dettagli sull'API, consulta [ListDetectors AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/list-detectors.html)*Command Reference.* 

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

Il seguente esempio di codice mostra come utilizzare`list-inputs`.

**AWS CLI**  
**Come elencare gli input**  
L’esempio `list-inputs` seguente elenca gli input creati.  

```
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"
}
```
Per ulteriori informazioni, consulta [ListInputs](https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-commands.html#api-iotevents-ListInputs)la *AWS IoT Events Developer Guide\$1*.  
+  Per i dettagli sull'API, consulta [ListInputs AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/list-inputs.html)*Command Reference.* 

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

Il seguente esempio di codice mostra come utilizzare`list-tags-for-resource`.

**AWS CLI**  
**Come elencare i tag assegnati a una risorsa**  
L’esempio `list-tags-for-resource` seguente elenca i tag (metadati) assegnati alla risorsa.  

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

```
{
    "tags": [
        {
            "value": "motor",
            "key": "deviceType"
        }
    ]
}
```
Per ulteriori informazioni, consulta [ListTagsForResource](https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-commands.html#api-iotevents-ListTagsForResource)la *AWS IoT Events Developer Guide\$1*.  
+  Per i dettagli sull'API, consulta [ListTagsForResource AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/list-tags-for-resource.html)*Command Reference.* 

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

Il seguente esempio di codice mostra come utilizzare`put-logging-options`.

**AWS CLI**  
**Come impostare le opzioni di registrazione di log**  
L'`list-tags-for-resource`esempio seguente imposta o aggiorna le opzioni di registrazione degli eventi AWS IoT. Se aggiorni il valore di qualsiasi campo `loggingOptions`, dovrai attendere fino a un minuto per rendere effettiva la modifica. Inoltre, se modifichi la policy collegata al ruolo specificato nel campo `roleArn` (ad esempio per correggere una policy non valida), dovrai attendere fino a cinque minuti per rendere effettiva la modifica.  

```
aws iotevents put-logging-options \
    --cli-input-json file://logging-options.json
```
Contenuto di `logging-options.json`:  

```
{
    "loggingOptions": {
        "roleArn": "arn:aws:iam::123456789012:role/IoTEventsRole",
        "level": "DEBUG",
        "enabled": true,
        "detectorDebugOptions": [
            {
                "detectorModelName": "motorDetectorModel",
                "keyValue": "Fulton-A32"
            }
        ]
    }
}
```
Questo comando non produce alcun output.  
Per ulteriori informazioni, consulta [PutLoggingOptions](https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-commands.html#api-iotevents-PutLoggingOptions)la *AWS IoT Events Developer Guide\$1*.  
+  Per i dettagli sull'API, consulta [PutLoggingOptions AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/put-logging-options.html)*Command Reference.* 

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

Il seguente esempio di codice mostra come utilizzare`tag-resource`.

**AWS CLI**  
**Come aggiungere tag a una risorsa**  
L’esempio `tag-resource` seguente aggiunge o modifica i tag di una determinata risorsa. I tag sono metadati utilizzabili per gestire una risorsa.  

```
aws iotevents tag-resource \
    --cli-input-json file://pressureInput.tag.json
```
Contenuto di `pressureInput.tag.json`:  

```
{
    "resourceArn": "arn:aws:iotevents:us-west-2:123456789012:input/PressureInput",
    "tags": [
        {
            "key": "deviceType",
            "value": "motor"
        }
    ]
}
```
Questo comando non produce alcun output.  
Per ulteriori informazioni, consulta [TagResource](https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-commands.html#api-iotevents-TagResource)la *AWS IoT Events Developer Guide\$1*.  
+  Per i dettagli sull'API, consulta [TagResource AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/tag-resource.html)*Command Reference.* 

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

Il seguente esempio di codice mostra come utilizzare`untag-resource`.

**AWS CLI**  
**Come rimuovere tag da una risorsa**  
L’esempio `untag-resource` seguente rimuove i tag specificati dalla risorsa.  

```
aws iotevents untag-resource \
    --cli-input-json file://pressureInput.untag.json
```
Contenuto di `pressureInput.untag.json`:  

```
{
    "resourceArn": "arn:aws:iotevents:us-west-2:123456789012:input/PressureInput",
    "tagKeys": [
            "deviceType"
    ]
}
```
Questo comando non produce alcun output.  
Per ulteriori informazioni, consulta [UntagResource](https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-commands.html#api-iotevents-UntagResource)la *AWS IoT Events Developer Guide\$1*.  
+  Per i dettagli sull'API, consulta [UntagResource AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/untag-resource.html)*Command Reference.* 

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

Il seguente esempio di codice mostra come utilizzare`update-detector-model`.

**AWS CLI**  
**Come aggiornare un modello di rivelatore**  
L’esempio `update-detector-model` seguente aggiorna un modello di rilevatore. I rilevatori (istanze) generati dalla versione precedente vengono eliminati e quindi ricreati all’arrivo di nuovi input.  

```
aws iotevents update-detector-model \
    --cli-input-json file://motorDetectorModel.update.json
```
Contenuto di 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"
    }
}
```
Per ulteriori informazioni, consulta [UpdateDetectorModel](https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-commands.html#api-iotevents-UpdateDetectorModel)la *AWS IoT Events Developer Guide\$1*.  
+  Per i dettagli sull'API, consulta [UpdateDetectorModel AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/update-detector-model.html)*Command Reference.* 

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

Il seguente esempio di codice mostra come utilizzare`update-input`.

**AWS CLI**  
**Come aggiornare un input**  
L’esempio `update-input` seguente aggiorna un input.  

```
aws iotevents update-input \
    --cli-input-json file://pressureInput.json
```
Contenuto di `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"
    }
}
```
Per ulteriori informazioni, consulta [UpdateInput](https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-commands.html#api-iotevents-UpdateInput)la *AWS IoT Events Developer Guide\$1*.  
+  Per i dettagli sull'API, consulta [UpdateInput AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents-data/update-input.html)*Command Reference.* 