Esempi di AWS IoT Things Graph con la AWS CLI
Gli esempi di codice seguenti mostrano come eseguire azioni e implementare scenari comuni utilizzando la AWS Command Line Interface con AWS IoT Things Graph.
Le operazioni sono estratti di codice da programmi più grandi e devono essere eseguite nel contesto. Sebbene le operazioni mostrino come richiamare le singole funzioni del servizio, è possibile visualizzarle contestualizzate negli scenari correlati.
Ogni esempio include un link al codice sorgente completo, dove è possibile trovare le istruzioni su come configurare ed eseguire il codice nel contesto.
Argomenti
Operazioni
L’esempio di codice seguente mostra come utilizzare associate-entity-to-thing.
- AWS CLI
-
Come associare un oggetto a un dispositivo
L’esempio
associate-entity-to-thingseguente 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.
-
Per informazioni dettagliate sull’API, consulta AssociateEntityToThing
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare create-flow-template.
- AWS CLI
-
Come creare un flusso
L’esempio
create-flow-templateseguente crea un flusso (di lavoro). Il valore diMyFlowDefinitionè 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.
-
Per informazioni dettagliate sull’API, consulta CreateFlowTemplate
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare create-system-instance.
- AWS CLI
-
Come creare un’istanza di sistema
L’esempio
create-system-instanceseguente crea un’istanza di sistema. Il valore diMySystemInstanceDefinitionè il GraphQL che modella l’istanza di sistema.aws iotthingsgraph create-system-instance -\-definitionlanguage=GRAPHQL,text="MySystemInstanceDefinition" \ --targetCLOUD\ --flow-actions-role-arnmyRoleARNOutput:
{ "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.
-
Per informazioni dettagliate sull’API, consulta CreateSystemInstance
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare create-system-template.
- AWS CLI
-
Come creare un sistema
L’esempio
create-system-templateseguente 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.
-
Per informazioni dettagliate sull’API, consulta CreateSystemTemplate
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare delete-flow-template.
- AWS CLI
-
Come eliminare un flusso
L’esempio
delete-flow-templateseguente 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 Gestione del ciclo di vita di entità, flussi, sistemi e implementazioni di AWS IoT Things Graph nella Guida per l’utente di AWS IoT Things Graph.
-
Per informazioni dettagliate sull’API, consulta DeleteFlowTemplate
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare delete-namespace.
- AWS CLI
-
Come eliminare un namespace
L’esempio
delete-namespaceseguente elimina un namespace.aws iotthingsgraph delete-namespaceOutput:
{ "namespaceArn": "arn:aws:iotthingsgraph:us-west-2:123456789012", "namespaceName": "us-west-2/123456789012/default" }Per ulteriori informazioni, consulta Gestione del ciclo di vita di entità, flussi, sistemi e implementazioni di AWS IoT Things Graph nella Guida per l’utente di AWS IoT Things Graph.
-
Per informazioni dettagliate sull’API, consulta DeleteNamespace
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare delete-system-instance.
- AWS CLI
-
Come eliminare un’istanza di sistema
L’esempio
delete-system-instanceseguente 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 Gestione del ciclo di vita di entità, flussi, sistemi e implementazioni di AWS IoT Things Graph nella Guida per l’utente di AWS IoT Things Graph.
-
Per informazioni dettagliate sull’API, consulta DeleteSystemInstance
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare delete-system-template.
- AWS CLI
-
Come eliminare un sistema
L’esempio
delete-system-templateseguente 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 Gestione del ciclo di vita di entità, flussi, sistemi e implementazioni di AWS IoT Things Graph nella Guida per l’utente di AWS IoT Things Graph.
-
Per informazioni dettagliate sull’API, consulta DeleteSystemTemplate
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare deploy-system-instance.
- AWS CLI
-
Come implementare un’istanza di sistema
L’esempio
delete-system-templateseguente distribuisce 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.
-
Per informazioni dettagliate sull’API, consulta DeploySystemInstance
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare deprecate-flow-template.
- AWS CLI
-
Come deprecare un flusso
L’esempio
deprecate-flow-templateseguente 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 Gestione del ciclo di vita di entità, flussi, sistemi e implementazioni di AWS IoT Things Graph nella Guida per l’utente di AWS IoT Things Graph.
-
Per informazioni dettagliate sull’API, consulta DeprecateFlowTemplate
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare deprecate-system-template.
- AWS CLI
-
Come deprecare un sistema
L’esempio
deprecate-system-templateseguente 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 Gestione del ciclo di vita di entità, flussi, sistemi e implementazioni di AWS IoT Things Graph nella Guida per l’utente di AWS IoT Things Graph.
-
Per informazioni dettagliate sull’API, consulta DeprecateSystemTemplate
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare describe-namespace.
- AWS CLI
-
Come ottenere una descrizione del namespace corrente
L’esempio
describe-namespaceseguente ottiene una descrizione del tuo namespace.aws iotthingsgraph describe-namespaceOutput:
{ "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.
-
Per informazioni dettagliate sull’API, consulta DescribeNamespace
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare dissociate-entity-from-thing.
- AWS CLI
-
Come dissociare un oggetto da un dispositivo
L’esempio
dissociate-entity-from-thingseguente 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.
-
Per informazioni dettagliate sull’API, consulta DissociateEntityFromThing
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare get-entities.
- AWS CLI
-
Come ottenere le definizioni delle entità
L’esempio
get-entitiesseguente 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.
-
Per informazioni dettagliate sull’API, consulta GetEntities
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare get-flow-template-revisions.
- AWS CLI
-
Come ottenere informazioni sulle revisioni di un flusso
L’esempio
get-flow-template-revisionsseguente ottiene informazioni di revisione su un flusso (di lavoro).aws iotthingsgraph get-flow-template-revisions \ --idurn:tdm:us-west-2/123456789012/default:Workflow:MyFlowOutput:
{ "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.
-
Per informazioni dettagliate sull’API, consulta GetFlowTemplateRevisions
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare get-flow-template.
- AWS CLI
-
Come ottenere una definizione del flusso
L’esempio
get-flow-templateseguente 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.
-
Per informazioni dettagliate sull’API, consulta GetFlowTemplate
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare get-namespace-deletion-status.
- AWS CLI
-
Come ottenere lo stato dell’attività di eliminazione del namespace
L’esempio
get-namespace-deletion-statusseguente ottiene lo stato dell’operazione di eliminazione del namespace.aws iotthingsgraph get-namespace-deletion-statusOutput:
{ "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.
-
Per informazioni dettagliate sull’API, consulta GetNamespaceDeletionStatus
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare get-system-instance.
- AWS CLI
-
Come ottenere un’istanza di sistema
L’esempio
get-system-instanceseguente 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.
-
Per informazioni dettagliate sull’API, consulta GetSystemInstance
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare get-system-template-revisions.
- AWS CLI
-
Come ottenere informazioni su un sistema
L’esempio
get-system-template-revisionsseguente 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.
-
Per informazioni dettagliate sull’API, consulta GetSystemTemplateRevisions
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare get-system-template.
- AWS CLI
-
Come ottenere un sistema
L’esempio
get-system-templateseguente 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.
-
Per informazioni dettagliate sull’API, consulta GetSystemTemplate
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare get-upload-status.
- AWS CLI
-
Come ottenere lo stato del caricamento dell’entità
L’esempio
get-upload-statusseguente ottiene lo stato dell’operazione di caricamento dell’entità. Il valore diMyUploadIdè il valore ID restituito dall’operazioneupload-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.
-
Per informazioni dettagliate sull’API, consulta GetUploadStatus
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare list-flow-execution-messages.
- AWS CLI
-
Come ottenere informazioni sugli eventi durante l’esecuzione di un flusso
L’esempio
list-flow-execution-messagesseguente 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.
-
Per informazioni dettagliate sull’API, consulta ListFlowExecutionMessages
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare list-tags-for-resource.
- AWS CLI
-
Come elencare tutti i tag per una risorsa
L’esempio
list-tags-for-resourceseguente elenca tutti i tag associati a una risorsa di 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 Assegnazione di tag alle risorse AWS IoT Things Graph nella Guida per l’utente di AWS.
-
Per informazioni dettagliate sull’API, consulta ListTagsForResource
nella Documentazione di riferimento dei comandi della AWS CLI.
-
L’esempio di codice seguente mostra come utilizzare search-entities.
- AWS CLI
-
Come cercare le entità
L’esempio
search-entitiesseguente cerca tutte le entità di tipoEVENT.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 AWSIoT Things Graph User Guide.
-
Per informazioni dettagliate sull’API, consulta SearchEntities
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare search-flow-executions.
- AWS CLI
-
Come cercare le esecuzioni del flusso
L’esempio
search-flow-executionsseguente 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.
-
Per informazioni dettagliate sull’API, consulta SearchFlowExecutions
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare search-flow-templates.
- AWS CLI
-
Come cercare i flussi (o i flussi di lavoro)
L’esempio
search-flow-templatesseguente 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.
-
Per informazioni dettagliate sull’API, consulta SearchFlowTemplates
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare search-system-instances.
- AWS CLI
-
Come cercare le istanze di sistema
L’esempio
search-system-instancesseguente 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.
-
Per informazioni dettagliate sull’API, consulta SearchSystemInstances
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare search-system-templates.
- AWS CLI
-
Come cercare il sistema
L’esempio
search-system-templatesseguente 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.
-
Per informazioni dettagliate sull’API, consulta SearchSystemTemplates
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare search-things.
- AWS CLI
-
Come cercare gli elementi associati a dispositivi e modelli di dispositivi
L’esempio
search-thingsseguente cerca tutti gli elementi associati al dispositivo HCSR501MotionSensor.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 informazioni dettagliate sull’API, consulta SearchThings
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare tag-resource.
- AWS CLI
-
Come creare un tag per una risorsa
Nell’esempio seguente,
tag-resourcerimuove 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 Assegnazione di tag alle risorse AWS IoT Things Graph nella Guida per l’utente di AWS.
-
Per informazioni dettagliate sull’API, consulta TagResource
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare undeploy-system-instance.
- AWS CLI
-
Come annullare l’implementazione di un’istanza di sistema nella relativa destinazione
L’esempio
undeploy-system-instanceseguente 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 Gestione del ciclo di vita di entità, flussi, sistemi e implementazioni di AWS IoT Things Graph nella Guida per l’utente di AWS IoT Things Graph.
-
Per informazioni dettagliate sull’API, consulta UndeploySystemInstance
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare untag-resource.
- AWS CLI
-
Come rimuovere un tag da una risorsa
Nell’esempio seguente,
untag-resourcerimuove 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 Assegnazione di tag alle risorse AWS IoT Things Graph nella Guida per l’utente di AWS.
-
Per informazioni dettagliate sull’API, consulta UntagResource
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare update-flow-template.
- AWS CLI
-
Come aggiornare un flusso
L’esempio
update-flow-templateseguente aggiorna un flusso (di lavoro). Il valore diMyFlowDefinitionè 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.
-
Per informazioni dettagliate sull’API, consulta UpdateFlowTemplate
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare update-system-template.
- AWS CLI
-
Come aggiornare un sistema
Nell’esempio seguente,
update-system-templateaggiorna un sistema. Il valore diMySystemDefinitionè 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.
-
Per informazioni dettagliate sull’API, consulta UpdateSystemTemplate
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare upload-entity-definitions.
- AWS CLI
-
Come caricare le definizioni delle entità
L’esempio
upload-entity-definitionsseguente carica le definizioni di entità nel tuo namespace. Il valore diMyEntityDefinitionsè 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.
-
Per informazioni dettagliate sull’API, consulta UploadEntityDefinitions
in AWS CLI Command Reference.
-