AWS IoT Things Graph esempi utilizzando AWS CLI - AWS Command Line Interface

Questa documentazione è valida AWS CLI solo per la versione 1. Per la documentazione relativa alla versione 2 di AWS CLI, consulta la Guida per l'utente della versione 2.

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 Things Graph esempi utilizzando AWS CLI

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

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.

Argomenti

Azioni

Il seguente esempio di codice mostra come utilizzareassociate-entity-to-thing.

AWS CLI

Come associare un oggetto a un dispositivo

L’esempio associate-entity-to-thing seguente associa un oggetto a un dispositivo. L’esempio utilizza un dispositivo con sensore di movimento che si trova nel namespace pubblico.

aws iotthingsgraph associate-entity-to-thing \ --thing-name "MotionSensorName" \ --entity-id "urn:tdm:aws/examples:Device:HCSR501MotionSensor"

Questo comando non produce alcun output.

Per ulteriori informazioni, consulta Creazione e caricamento di modelli nella Guida per l’utente di AWS IoT Things Graph.

Il seguente esempio di codice mostra come utilizzarecreate-flow-template.

AWS CLI

Come creare un flusso

L’esempio create-flow-template seguente crea un flusso (di lavoro). Il valore di MyFlowDefinition è il GraphQL che modella il flusso.

aws iotthingsgraph create-flow-template \ --definition language=GRAPHQL,text="MyFlowDefinition"

Output:

{ "summary": { "createdAt": 1559248067.545, "id": "urn:tdm:us-west-2/123456789012/default:Workflow:MyFlow", "revisionNumber": 1 } }

Per ulteriori informazioni, consulta Utilizzo dei flussi nella Guida per l’utente di AWS IoT Things Graph.

Il seguente esempio di codice mostra come utilizzarecreate-system-instance.

AWS CLI

Come creare un’istanza di sistema

L’esempio create-system-instance seguente crea un’istanza di sistema. Il valore di MySystemInstanceDefinition è il GraphQL che modella l’istanza di sistema.

aws iotthingsgraph create-system-instance -\ -definition language=GRAPHQL,text="MySystemInstanceDefinition" \ --target CLOUD \ --flow-actions-role-arn myRoleARN

Output:

{ "summary": { "id": "urn:tdm:us-west-2/123456789012/default:Deployment:Room218", "arn": "arn:aws:iotthingsgraph:us-west-2:123456789012:Deployment/default/Room218", "status": "NOT_DEPLOYED", "target": "CLOUD", "createdAt": 1559249315.208, "updatedAt": 1559249315.208 } }

Per ulteriori informazioni, consulta Utilizzo di configurazioni di sistemi e flussi nella Guida per l’utente di AWS IoT Things Graph.

Il seguente esempio di codice mostra come utilizzarecreate-system-template.

AWS CLI

Come creare un sistema

L’esempio create-system-template seguente crea un sistema. Il valore di MySystemDefinition è il GraphQL che modella il sistema.

aws iotthingsgraph create-system-template \ --definition language=GRAPHQL,text="MySystemDefinition"

Output:

{ "summary": { "createdAt": 1559249776.254, "id": "urn:tdm:us-west-2/123456789012/default:System:MySystem", "arn": "arn:aws:iotthingsgraph:us-west-2:123456789012:System/default/MySystem", "revisionNumber": 1 } }

Per ulteriori informazioni, consulta Creazione dei sistemi nella Guida per l’utente di AWS IoT Things Graph.

Il seguente esempio di codice mostra come utilizzaredelete-flow-template.

AWS CLI

Come eliminare un flusso

L’esempio delete-flow-template seguente elimina un flusso (di lavoro).

aws iotthingsgraph delete-flow-template \ --id "urn:tdm:us-west-2/123456789012/default:Workflow:MyFlow"

Questo comando non produce alcun output.

Per ulteriori informazioni, consulta Lifecycle Management for AWS IoT Things Graph Entities, Flows, Systems and Deployments nella AWS IoT Things Graph User Guide.

Il seguente esempio di codice mostra come utilizzaredelete-namespace.

AWS CLI

Come eliminare un namespace

L’esempio delete-namespace seguente elimina un namespace.

aws iotthingsgraph delete-namespace

Output:

{ "namespaceArn": "arn:aws:iotthingsgraph:us-west-2:123456789012", "namespaceName": "us-west-2/123456789012/default" }

Per ulteriori informazioni, consulta Lifecycle Management for AWS IoT Things Graph Entities, Flows, Systems and Deployments nella AWS IoT Things Graph User Guide.

  • Per i dettagli sull'API, consulta DeleteNamespaceCommand Reference.AWS CLI

Il seguente esempio di codice mostra come utilizzaredelete-system-instance.

AWS CLI

Come eliminare un’istanza di sistema

L’esempio delete-system-instance seguente elimina un’istanza di sistema.

aws iotthingsgraph delete-system-instance \ --id "urn:tdm:us-west-2/123456789012/default:Deployment:Room218"

Questo comando non produce alcun output.

Per ulteriori informazioni, consulta Lifecycle Management for AWS IoT Things Graph Entities, Flows, Systems and Deployments nella AWS IoT Things Graph User Guide.

Il seguente esempio di codice mostra come utilizzaredelete-system-template.

AWS CLI

Come eliminare un sistema

L’esempio delete-system-template seguente elimina un sistema.

aws iotthingsgraph delete-system-template \ --id "urn:tdm:us-west-2/123456789012/default:System:MySystem"

Questo comando non produce alcun output.

Per ulteriori informazioni, consulta Lifecycle Management for AWS IoT Things Graph Entities, Flows, Systems and Deployments nella AWS IoT Things Graph User Guide.

Il seguente esempio di codice mostra come utilizzaredeploy-system-instance.

AWS CLI

Come implementare un’istanza di sistema

L’esempio delete-system-template seguente implementa un’istanza di sistema.

aws iotthingsgraph deploy-system-instance \ --id "urn:tdm:us-west-2/123456789012/default:Deployment:Room218"

Output:

{ "summary": { "arn": "arn:aws:iotthingsgraph:us-west-2:123456789012:Deployment:Room218", "createdAt": 1559249776.254, "id": "urn:tdm:us-west-2/123456789012/default:Deployment:Room218", "status": "DEPLOYED_IN_TARGET", "target": "CLOUD", "updatedAt": 1559249776.254 } }

Per ulteriori informazioni, consulta Utilizzo di configurazioni di sistemi e flussi nella Guida per l’utente di AWS IoT Things Graph.

Il seguente esempio di codice mostra come utilizzaredeprecate-flow-template.

AWS CLI

Come deprecare un flusso

L’esempio deprecate-flow-template seguente rende obsoleto un flusso (di lavoro).

aws iotthingsgraph deprecate-flow-template \ --id "urn:tdm:us-west-2/123456789012/default:Workflow:MyFlow"

Questo comando non produce alcun output.

Per ulteriori informazioni, consulta Lifecycle Management for AWS IoT Things Graph Entities, Flows, Systems and Deployments nella AWS IoT Things Graph User Guide.

Il seguente esempio di codice mostra come utilizzaredeprecate-system-template.

AWS CLI

Come deprecare un sistema

L’esempio deprecate-system-template seguente rende obsoleto un sistema.

aws iotthingsgraph deprecate-system-template \ --id "urn:tdm:us-west-2/123456789012/default:System:MySystem"

Questo comando non produce alcun output.

Per ulteriori informazioni, consulta Lifecycle Management for AWS IoT Things Graph Entities, Flows, Systems and Deployments nella AWS IoT Things Graph User Guide.

Il seguente esempio di codice mostra come utilizzaredescribe-namespace.

AWS CLI

Come ottenere una descrizione del namespace corrente

L’esempio describe-namespace seguente ottiene una descrizione del tuo namespace.

aws iotthingsgraph describe-namespace

Output:

{ "namespaceName": "us-west-2/123456789012/default", "trackingNamespaceName": "aws", "trackingNamespaceVersion": 1, "namespaceVersion": 5 }

Per ulteriori informazioni, consulta Namespace nella Guida per l’utente di AWS IoT Things Graph.

Il seguente esempio di codice mostra come utilizzaredissociate-entity-from-thing.

AWS CLI

Come dissociare un oggetto da un dispositivo

L’esempio dissociate-entity-from-thing seguente dissocia un oggetto da un dispositivo.

aws iotthingsgraph dissociate-entity-from-thing \ --thing-name "MotionSensorName" \ --entity-type "DEVICE"

Questo comando non produce alcun output.

Per ulteriori informazioni, consulta Creazione e caricamento di modelli nella Guida per l’utente di AWS IoT Things Graph.

Il seguente esempio di codice mostra come utilizzareget-entities.

AWS CLI

Come ottenere le definizioni delle entità

L’esempio get-entities seguente ottiene una definizione per un modello di dispositivo.

aws iotthingsgraph get-entities \ --ids "urn:tdm:aws/examples:DeviceModel:MotionSensor"

Output:

{ "descriptions": [ { "id": "urn:tdm:aws/examples:DeviceModel:MotionSensor", "type": "DEVICE_MODEL", "createdAt": 1559256190.599, "definition": { "language": "GRAPHQL", "text": "##\n# Specification of motion sensor devices interface.\n##\ntype MotionSensor @deviceModel(id: \"urn:tdm:aws/examples:deviceModel:MotionSensor\",\n capability: \"urn:tdm:aws/examples:capability:MotionSensorCapability\") {ignore:void}" } } ] }

Per ulteriori informazioni, consulta Creazione e caricamento di modelli nella Guida per l’utente di AWS IoT Things Graph.

Il seguente esempio di codice mostra come utilizzareget-flow-template-revisions.

AWS CLI

Come ottenere informazioni sulle revisioni di un flusso

L’esempio get-flow-template-revisions seguente ottiene informazioni di revisione su un flusso (di lavoro).

aws iotthingsgraph get-flow-template-revisions \ --id urn:tdm:us-west-2/123456789012/default:Workflow:MyFlow

Output:

{ "summaries": [ { "id": "urn:tdm:us-west-2/123456789012/default:Workflow:MyFlow", "revisionNumber": 1, "createdAt": 1559247540.292 } ] }

Per ulteriori informazioni, consulta Utilizzo dei flussi nella Guida per l’utente di AWS IoT Things Graph.

Il seguente esempio di codice mostra come utilizzareget-flow-template.

AWS CLI

Come ottenere una definizione del flusso

L’esempio get-flow-template seguente ottiene una definizione per un flusso (di lavoro).

aws iotthingsgraph get-flow-template \ --id "urn:tdm:us-west-2/123456789012/default:Workflow:MyFlow"

Output:

{ "description": { "summary": { "id": "urn:tdm:us-west-2/123456789012/default:Workflow:MyFlow", "revisionNumber": 1, "createdAt": 1559247540.292 }, "definition": { "language": "GRAPHQL", "text": "{\nquery MyFlow($camera: string!, $screen: string!) @workflowType(id: \"urn:tdm:us-west-2/123456789012/default:Workflow:MyFlow\") @annotation(type: \"tgc:FlowEvent\", id: \"sledged790c1b2bcd949e09da0c9bfc077f79d\", x: 1586, y: 653) @triggers(definition: \"{MotionSensor(description: \\\"\\\") @position(x: 1045, y: 635.6666564941406) {\\n condition(expr: \\\"devices[name == \\\\\\\"motionSensor\\\\\\\"].events[name == \\\\\\\"StateChanged\\\\\\\"].lastEvent\\\")\\n action(expr: \\\"\\\")\\n}}\") {\n variables {\n cameraResult @property(id: \"urn:tdm:aws/examples:property:CameraStateProperty\")\n }\n steps {\n step(name: \"Camera\", outEvent: [\"sledged790c1b2bcd949e09da0c9bfc077f79d\"]) @position(x: 1377, y: 638.6666564941406) {\n DeviceActivity(deviceModel: \"urn:tdm:aws/examples:deviceModel:Camera\", out: \"cameraResult\", deviceId: \"${camera}\") {\n capture\n }\n }\n step(name: \"Screen\", inEvent: [\"sledged790c1b2bcd949e09da0c9bfc077f79d\"]) @position(x: 1675.6666870117188, y: 637.9999847412109) {\n DeviceActivity(deviceModel: \"urn:tdm:aws/examples:deviceModel:Screen\", deviceId: \"${screen}\") {\n display(imageUrl: \"${cameraResult.lastClickedImage}\")\n }\n }\n }\n}\n}" }, "validatedNamespaceVersion": 5 } }

Per ulteriori informazioni, consulta Utilizzo dei flussi nella Guida per l’utente di AWS IoT Things Graph.

Il seguente esempio di codice mostra come utilizzareget-namespace-deletion-status.

AWS CLI

Come ottenere lo stato dell’attività di eliminazione del namespace

L’esempio get-namespace-deletion-status seguente ottiene lo stato dell’operazione di eliminazione del namespace.

aws iotthingsgraph get-namespace-deletion-status

Output:

{ "namespaceArn": "arn:aws:iotthingsgraph:us-west-2:123456789012", "namespaceName": "us-west-2/123456789012/default" "status": "SUCCEEDED " }

Per ulteriori informazioni, consulta Namespace nella Guida per l’utente di AWS IoT Things Graph.

Il seguente esempio di codice mostra come utilizzareget-system-instance.

AWS CLI

Come ottenere un’istanza di sistema

L’esempio get-system-instance seguente ottiene una definizione per un’istanza di sistema.

aws iotthingsgraph get-system-instance \ --id "urn:tdm:us-west-2/123456789012/default:Deployment:Room218"

Output:

{ "description": { "summary": { "id": "urn:tdm:us-west-2/123456789012/default:Deployment:Room218", "arn": "arn:aws:iotthingsgraph:us-west-2:123456789012:Deployment/default/Room218", "status": "NOT_DEPLOYED", "target": "CLOUD", "createdAt": 1559249315.208, "updatedAt": 1559249315.208 }, "definition": { "language": "GRAPHQL", "text": "{\r\nquery Room218 @deployment(id: \"urn:tdm:us-west-2/123456789012/default:Deployment:Room218\", systemId: \"urn:tdm:us-west-2/123456789012/default:System:SecurityFlow\") {\r\n motionSensor(deviceId: \"MotionSensorName\")\r\n screen(deviceId: \"ScreenName\")\r\n camera(deviceId: \"CameraName\") \r\n triggers {MotionEventTrigger(description: \"a trigger\") { \r\n condition(expr: \"devices[name == 'motionSensor'].events[name == 'StateChanged'].lastEvent\") \r\n action(expr: \"ThingsGraph.startFlow('SecurityFlow', bindings[name == 'camera'].deviceId, bindings[name == 'screen'].deviceId)\")\r\n }\r\n }\r\n }\r\n }" }, "metricsConfiguration": { "cloudMetricEnabled": false }, "validatedNamespaceVersion": 5, "flowActionsRoleArn": "arn:aws:iam::123456789012:role/ThingsGraphRole" } }

Per ulteriori informazioni, consulta Utilizzo di configurazioni di sistemi e flussi nella Guida per l’utente di AWS IoT Things Graph.

Il seguente esempio di codice mostra come utilizzareget-system-template-revisions.

AWS CLI

Come ottenere informazioni su un sistema

L’esempio get-system-template-revisions seguente ottiene informazioni sulla revisione di un sistema.

aws iotthingsgraph get-system-template-revisions \ --id "urn:tdm:us-west-2/123456789012/default:System:MySystem"

Output:

{ "summaries": [ { "id": "urn:tdm:us-west-2/123456789012/default:System:MySystem", "arn": "arn:aws:iotthingsgraph:us-west-2:123456789012:System/default/MySystem", "revisionNumber": 1, "createdAt": 1559247540.656 } ] }

Per ulteriori informazioni, consulta Utilizzo di configurazioni di sistemi e flussi nella Guida per l’utente di AWS IoT Things Graph.

Il seguente esempio di codice mostra come utilizzareget-system-template.

AWS CLI

Come ottenere un sistema

L’esempio get-system-template seguente ottiene una definizione per un sistema.

aws iotthingsgraph get-system-template \ --id "urn:tdm:us-west-2/123456789012/default:System:MySystem"

Output:

{ "description": { "summary": { "id": "urn:tdm:us-west-2/123456789012/default:System:MySystem", "arn": "arn:aws:iotthingsgraph:us-west-2:123456789012:System/default/MyFlow", "revisionNumber": 1, "createdAt": 1559247540.656 }, "definition": { "language": "GRAPHQL", "text": "{\ntype MySystem @systemType(id: \"urn:tdm:us-west-2/123456789012/default:System:MySystem\", description: \"\") {\n camera: Camera @thing(id: \"urn:tdm:aws/examples:deviceModel:Camera\")\n screen: Screen @thing(id: \"urn:tdm:aws/examples:deviceModel:Screen\")\n motionSensor: MotionSensor @thing(id: \"urn:tdm:aws/examples:deviceModel:MotionSensor\")\n MyFlow: MyFlow @workflow(id: \"urn:tdm:us-west-2/123456789012/default:Workflow:MyFlow\")\n}\n}" }, "validatedNamespaceVersion": 5 } }

Per ulteriori informazioni, consulta Utilizzo di configurazioni di sistemi e flussi nella Guida per l’utente di AWS IoT Things Graph.

Il seguente esempio di codice mostra come utilizzareget-upload-status.

AWS CLI

Come ottenere lo stato del caricamento dell’entità

L’esempio get-upload-status seguente ottiene lo stato dell’operazione di caricamento dell’entità. Il valore di MyUploadId è il valore ID restituito dall’operazione upload-entity-definitions.

aws iotthingsgraph get-upload-status \ --upload-id "MyUploadId"

Output:

{ "namespaceName": "us-west-2/123456789012/default", "namespaceVersion": 5, "uploadId": "f6294f1e-b109-4bbe-9073-f451a2dda2da", "uploadStatus": "SUCCEEDED" }

Per ulteriori informazioni, consulta Modellazione delle entità nella Guida per l’utente di AWS IoT Things Graph.

Il seguente esempio di codice mostra come utilizzarelist-flow-execution-messages.

AWS CLI

Come ottenere informazioni sugli eventi durante l’esecuzione di un flusso

L’esempio list-flow-execution-messages seguente ottiene informazioni sugli eventi in un’esecuzione di un flusso.

aws iotthingsgraph list-flow-execution-messages \ --flow-execution-id "urn:tdm:us-west-2/123456789012/default:Workflow:SecurityFlow_2019-05-11T19:39:55.317Z_MotionSensor_69b151ad-a611-42f5-ac21-fe537f9868ad"

Output:

{ "messages": [ { "eventType": "EXECUTION_STARTED", "messageId": "f6294f1e-b109-4bbe-9073-f451a2dda2da", "payload": "Flow execution started", "timestamp": 1559247540.656 } ] }

Per ulteriori informazioni, consulta Utilizzo dei flussi nella Guida per l’utente di AWS IoT Things Graph.

Il seguente esempio di codice mostra come utilizzarelist-tags-for-resource.

AWS CLI

Come elencare tutti i tag per una risorsa

L'list-tags-for-resourceesempio seguente elenca tutti i tag per una risorsa AWS IoT Things Graph.

aws iotthingsgraph list-tags-for-resource \ --resource-arn "arn:aws:iotthingsgraph:us-west-2:123456789012:Deployment/default/Room218"

Output:

{ "tags": [ { "key": "Type", "value": "Residential" } ] }

Per ulteriori informazioni, consulta Tagging Your AWS IoT Things Graph Resources nella AWS IoT Things Graph User Guide.

Il seguente esempio di codice mostra come utilizzaresearch-entities.

AWS CLI

Come cercare le entità

L’esempio search-entities seguente cerca tutte le entità di tipo EVENT.

aws iotthingsgraph search-entities \ --entity-types "EVENT"

Output:

{ "descriptions": [ { "id": "urn:tdm:aws/examples:Event:MotionSensorEvent", "type": "EVENT", "definition": { "language": "GRAPHQL", "text": "##\n# Description of events emitted by motion sensor.\n##\ntype MotionSensorEvent @eventType(id: \"urn:tdm:aws/examples:event:MotionSensorEvent\",\n payload: \"urn:tdm:aws/examples:property:MotionSensorStateProperty\") {ignore:void}" } }, { "id": "urn:tdm:us-west-2/123456789012/default:Event:CameraClickedEventV2", "type": "EVENT", "definition": { "language": "GRAPHQL", "text": "type CameraClickedEventV2 @eventType(id: \"urn:tdm:us-west-2/123456789012/default:event:CameraClickedEventV2\",\r\npayload: \"urn:tdm:aws:Property:Boolean\"){ignore:void}" } }, { "id": "urn:tdm:us-west-2/123456789012/default:Event:MotionSensorEventV2", "type": "EVENT", "definition": { "language": "GRAPHQL", "text": "# Event emitted by the motion sensor.\r\ntype MotionSensorEventV2 @eventType(id: \"urn:tdm:us-west-2/123456789012/default:event:MotionSensorEventV2\",\r\npayload: \"urn:tdm:us-west-2/123456789012/default:property:MotionSensorStateProperty2\") {ignore:void}" } } ], "nextToken": "urn:tdm:us-west-2/123456789012/default:Event:MotionSensorEventV2" }

Per ulteriori informazioni, consulta Riferimento al modello di dati di AWS IoT Things Graph nella Guida per l’utente di AWS IoT Things Graph.

Il seguente esempio di codice mostra come utilizzaresearch-flow-executions.

AWS CLI

Come cercare le esecuzioni del flusso

L’esempio search-flow-executions seguente cerca tutte le esecuzioni di un flusso in un’istanza di sistema specificata.

aws iotthingsgraph search-flow-executions \ --system-instance-id "urn:tdm:us-west-2/123456789012/default:Deployment:Room218"

Output:

{ "summaries": [ { "createdAt": 1559247540.656, "flowExecutionId": "f6294f1e-b109-4bbe-9073-f451a2dda2da", "flowTemplateId": "urn:tdm:us-west-2/123456789012/default:Workflow:MyFlow", "status": "RUNNING ", "systemInstanceId": "urn:tdm:us-west-2/123456789012/default:System:MySystem", "updatedAt": 1559247540.656 } ] }

Per ulteriori informazioni, consulta Utilizzo di configurazioni di sistemi e flussi nella Guida per l’utente di AWS IoT Things Graph.

Il seguente esempio di codice mostra come utilizzaresearch-flow-templates.

AWS CLI

Come cercare i flussi (o i flussi di lavoro)

L’esempio search-flow-templates seguente cerca tutti i flussi (di lavoro) che contengono il modello di dispositivo Camera.

aws iotthingsgraph search-flow-templates \ --filters name="DEVICE_MODEL_ID",value="urn:tdm:aws/examples:DeviceModel:Camera"

Output:

{ "summaries": [ { "id": "urn:tdm:us-west-2/123456789012/default:Workflow:MyFlow", "revisionNumber": 1, "createdAt": 1559247540.292 }, { "id": "urn:tdm:us-west-2/123456789012/default:Workflow:SecurityFlow", "revisionNumber": 3, "createdAt": 1548283099.27 } ] }

Per ulteriori informazioni, consulta Utilizzo dei flussi nella Guida per l’utente di AWS IoT Things Graph.

Il seguente esempio di codice mostra come utilizzaresearch-system-instances.

AWS CLI

Come cercare le istanze di sistema

L’esempio search-system-instances seguente cerca tutte le istanze di sistema che contengono il sistema specificato.

aws iotthingsgraph search-system-instances \ --filters name="SYSTEM_TEMPLATE_ID",value="urn:tdm:us-west-2/123456789012/default:System:SecurityFlow"

Output:

{ "summaries": [ { "id": "urn:tdm:us-west-2/123456789012/default:Deployment:DeploymentForSample", "arn": "arn:aws:iotthingsgraph:us-west-2:123456789012:Deployment/default/DeploymentForSample", "status": "NOT_DEPLOYED", "target": "GREENGRASS", "greengrassGroupName": "ThingsGraphGrnGr", "createdAt": 1555716314.707, "updatedAt": 1555716314.707 }, { "id": "urn:tdm:us-west-2/123456789012/default:Deployment:MockDeployment", "arn": "arn:aws:iotthingsgraph:us-west-2:123456789012:Deployment/default/MockDeployment", "status": "DELETED_IN_TARGET", "target": "GREENGRASS", "greengrassGroupName": "ThingsGraphGrnGr", "createdAt": 1549416462.049, "updatedAt": 1549416722.361, "greengrassGroupId": "01d04b07-2a51-467f-9d03-0c90b3cdcaaf", "greengrassGroupVersionId": "7365aed7-2d3e-4d13-aad8-75443d45eb05" }, { "id": "urn:tdm:us-west-2/123456789012/default:Deployment:MockDeployment2", "arn": "arn:aws:iotthingsgraph:us-west-2:123456789012:Deployment/default/MockDeployment2", "status": "DEPLOYED_IN_TARGET", "target": "GREENGRASS", "greengrassGroupName": "ThingsGraphGrnGr", "createdAt": 1549572385.774, "updatedAt": 1549572418.408, "greengrassGroupId": "01d04b07-2a51-467f-9d03-0c90b3cdcaaf", "greengrassGroupVersionId": "bfa70ab3-2bf7-409c-a4d4-bc8328ae5b86" }, { "id": "urn:tdm:us-west-2/123456789012/default:Deployment:Room215", "arn": "arn:aws:iotthingsgraph:us-west-2:123456789012:Deployment/default/Room215", "status": "NOT_DEPLOYED", "target": "GREENGRASS", "greengrassGroupName": "ThingsGraphGG", "createdAt": 1547056918.413, "updatedAt": 1547056918.413 }, { "id": "urn:tdm:us-west-2/123456789012/default:Deployment:Room218", "arn": "arn:aws:iotthingsgraph:us-west-2:123456789012:Deployment/default/Room218", "status": "NOT_DEPLOYED", "target": "CLOUD", "createdAt": 1559249315.208, "updatedAt": 1559249315.208 } ] }

Per ulteriori informazioni, consulta Utilizzo di configurazioni di sistemi e flussi nella Guida per l’utente di AWS IoT Things Graph.

Il seguente esempio di codice mostra come utilizzaresearch-system-templates.

AWS CLI

Come cercare il sistema

L’esempio search-system-templates seguente cerca tutti i sistemi che contengono il flusso specificato.

aws iotthingsgraph search-system-templates \ --filters name="FLOW_TEMPLATE_ID",value="urn:tdm:us-west-2/123456789012/default:Workflow:SecurityFlow"

Output:

{ "summaries": [ { "id": "urn:tdm:us-west-2/123456789012/default:System:SecurityFlow", "arn": "arn:aws:iotthingsgraph:us-west-2:123456789012:System/default/SecurityFlow", "revisionNumber": 1, "createdAt": 1548283099.433 } ] }

Per ulteriori informazioni, consulta Utilizzo dei flussi nella Guida per l’utente di AWS IoT Things Graph.

Il seguente esempio di codice mostra come utilizzaresearch-things.

AWS CLI

Come cercare gli elementi associati a dispositivi e modelli di dispositivi

L'search-thingsesempio seguente cerca tutti gli elementi associati al MotionSensor dispositivo HCSR5 01.

aws iotthingsgraph search-things \ --entity-id "urn:tdm:aws/examples:Device:HCSR501MotionSensor"

Output:

{ "things": [ { "thingArn": "arn:aws:iot:us-west-2:123456789012:thing/MotionSensor1", "thingName": "MotionSensor1" }, { "thingArn": "arn:aws:iot:us-west-2:123456789012:thing/TG_MS", "thingName": "TG_MS" } ] }

Per ulteriori informazioni, consulta Creazione e caricamento di modelli nella Guida per l’utente di AWS IoT Things Graph.

  • Per i dettagli sull'API, vedere SearchThingsin AWS CLI Command Reference.

Il seguente esempio di codice mostra come utilizzaretag-resource.

AWS CLI

Come creare un tag per una risorsa

L’esempio tag-resource seguente rimuove un tag dalla risorsa specificata.

aws iotthingsgraph tag-resource \ --resource-arn "arn:aws:iotthingsgraph:us-west-2:123456789012:Deployment/default/Room218" \ --tags key="Type",value="Residential"

Questo comando non produce alcun output.

Per ulteriori informazioni, consulta Tagging Your AWS IoT Things Graph Resources nella AWS IoT Things Graph User Guide.

Il seguente esempio di codice mostra come utilizzareundeploy-system-instance.

AWS CLI

Come annullare l’implementazione di un’istanza di sistema nella relativa destinazione

L’esempio undeploy-system-instance seguente rimuove un’istanza di sistema dalla relativa destinazione.

aws iotthingsgraph undeploy-system-instance \ --id "urn:tdm:us-west-2/123456789012/default:Deployment:Room215"

Output:

{ "summary": { "id": "urn:tdm:us-west-2/123456789012/default:Deployment:Room215", "arn": "arn:aws:iotthingsgraph:us-west-2:123456789012:Deployment/default/Room215", "status": "PENDING_DELETE", "target": "GREENGRASS", "greengrassGroupName": "ThingsGraphGrnGr", "createdAt": 1553189694.255, "updatedAt": 1559344549.601, "greengrassGroupId": "01d04b07-2a51-467f-9d03-0c90b3cdcaaf", "greengrassGroupVersionId": "731b371d-d644-4b67-ac64-3934e99b75d7" } }

Per ulteriori informazioni, consulta Lifecycle Management for AWS IoT Things Graph Entities, Flows, Systems and Deployments nella AWS IoT Things Graph User Guide.

Il seguente esempio di codice mostra come utilizzareuntag-resource.

AWS CLI

Come rimuovere un tag da una risorsa

L’esempio untag-resource seguente rimuove un tag dalla risorsa specificata.

aws iotthingsgraph untag-resource \ --resource-arn "arn:aws:iotthingsgraph:us-west-2:123456789012:Deployment/default/Room218" \ --tag-keys "Type"

Questo comando non produce alcun output.

Per ulteriori informazioni, consulta Tagging Your AWS IoT Things Graph Resources nella AWS IoT Things Graph User Guide.

Il seguente esempio di codice mostra come utilizzareupdate-flow-template.

AWS CLI

Come aggiornare un flusso

L’esempio update-flow-template seguente aggiorna un flusso (di lavoro). Il valore di MyFlowDefinition è il GraphQL che modella il flusso.

aws iotthingsgraph update-flow-template \ --id "urn:tdm:us-west-2/123456789012/default:Workflow:MyFlow" \ --definition language=GRAPHQL,text="MyFlowDefinition"

Output:

{ "summary": { "createdAt": 1559248067.545, "id": "urn:tdm:us-west-2/123456789012/default:Workflow:MyFlow", "revisionNumber": 2 } }

Per ulteriori informazioni, consulta Utilizzo dei flussi nella Guida per l’utente di AWS IoT Things Graph.

Il seguente esempio di codice mostra come utilizzareupdate-system-template.

AWS CLI

Come aggiornare un sistema

L’esempio update-system-template seguente aggiorna un sistema. Il valore di MySystemDefinition è il GraphQL che modella il sistema.

aws iotthingsgraph update-system-template \ --id "urn:tdm:us-west-2/123456789012/default:System:MySystem" \ --definition language=GRAPHQL,text="MySystemDefinition"

Output:

{ "summary": { "createdAt": 1559249776.254, "id": "urn:tdm:us-west-2/123456789012/default:System:MySystem", "arn": "arn:aws:iotthingsgraph:us-west-2:123456789012:System/default/MySystem", "revisionNumber": 2 } }

Per ulteriori informazioni, consulta Creazione dei sistemi nella Guida per l’utente di AWS IoT Things Graph.

Il seguente esempio di codice mostra come utilizzareupload-entity-definitions.

AWS CLI

Come caricare le definizioni delle entità

L’esempio upload-entity-definitions seguente carica le definizioni di entità nel tuo namespace. Il valore di MyEntityDefinitions è il GraphQL che modella le entità.

aws iotthingsgraph upload-entity-definitions \ --document language=GRAPHQL,text="MyEntityDefinitions"

Output:

{ "uploadId": "f6294f1e-b109-4bbe-9073-f451a2dda2da" }

Per ulteriori informazioni, consulta Modellazione delle entità nella Guida per l’utente di AWS IoT Things Graph.