AWS IoT Things Graph を使用した の例 AWS CLI - AWS Command Line Interface

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

AWS IoT Things Graph を使用した の例 AWS CLI

次のコード例は、 AWS Command Line Interface で を使用してアクションを実行し、一般的なシナリオを実装する方法を示しています AWS IoT Things Graph。

アクションはより大きなプログラムからのコードの抜粋であり、コンテキスト内で実行する必要があります。アクションは個々のサービス機能を呼び出す方法を示していますが、コンテキスト内のアクションは、関連するシナリオで確認できます。

各例には、完全なソースコードへのリンクが含まれています。このリンクには、コンテキスト内でコードをセットアップして実行する方法の手順が記載されています。

トピック

アクション

次の例は、associate-entity-to-thing を使用する方法を説明しています。

AWS CLI

モノをデバイスに関連付けるには

次のassociate-entity-to-thing例では、モノをデバイスに関連付けます。この例では、パブリック名前空間にあるモーションセンサーデバイスを使用しています。

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

このコマンドでは何も出力されません。

詳細については、 AWS IoT Things Graph ユーザーガイド「モデルの作成とアップロード」を参照してください。

  • API 詳細については、「 コマンドリファレンスAssociateEntityToThing」の「」を参照してください。 AWS CLI

次のコード例は、create-flow-template を使用する方法を示しています。

AWS CLI

フローを作成するには

次のcreate-flow-template例では、フロー (ワークフロー) を作成します。の値は、フローをモデル化する GraphQL MyFlowDefinitionです。

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

出力:

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

詳細については、 AWS IoT Things Graph ユーザーガイドの「フローの使用」を参照してください。

  • API 詳細については、「 コマンドリファレンスCreateFlowTemplate」の「」を参照してください。 AWS CLI

次のコード例は、create-system-instance を使用する方法を示しています。

AWS CLI

システムインスタンスを作成するには

次のcreate-system-instance例では、システムインスタンスを作成します。の値は、システムインスタンスをモデル化する GraphQL MySystemInstanceDefinitionです。

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

出力:

{ "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 } }

詳細については、AWS 「 IoT Things Graph ユーザーガイド」の「システムとフロー設定の操作」を参照してください。

  • API 詳細については、「 コマンドリファレンスCreateSystemInstance」の「」を参照してください。 AWS CLI

次の例は、create-system-template を使用する方法を説明しています。

AWS CLI

システムを作成するには

次のcreate-system-template例では、システムを作成します。の値は、システムをモデル化する GraphQL MySystemDefinition です。

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

出力:

{ "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 } }

詳細については、「 IoT Things Graph ユーザーガイド」の「システムの作成」を参照してください。 AWS IoT

  • API 詳細については、「 コマンドリファレンスCreateSystemTemplate」の「」を参照してください。 AWS CLI

次の例は、delete-flow-template を使用する方法を説明しています。

AWS CLI

フローを削除するには

次のdelete-flow-template例では、フロー (ワークフロー) を削除します。

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

このコマンドでは何も出力されません。

詳細については、AWS 「 IoT Things Graph ユーザーガイド」の「IoT Things Graph エンティティ、フロー、システム、デプロイのライフサイクル管理」を参照してください。 AWS IoT

  • API 詳細については、「 コマンドリファレンスDeleteFlowTemplate」の「」を参照してください。 AWS CLI

次の例は、delete-namespace を使用する方法を説明しています。

AWS CLI

名前空間を削除するには

次のdelete-namespace例では、名前空間を削除します。

aws iotthingsgraph delete-namespace

出力:

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

詳細については、AWS 「 IoT Things Graph ユーザーガイド」の「IoT Things Graph エンティティ、フロー、システム、デプロイのライフサイクル管理」を参照してください。 AWS IoT

  • API 詳細については、「 コマンドリファレンスDeleteNamespace」の「」を参照してください。 AWS CLI

次のコード例は、delete-system-instance を使用する方法を示しています。

AWS CLI

システムインスタンスを削除するには

次のdelete-system-instance例では、システムインスタンスを削除します。

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

このコマンドでは何も出力されません。

詳細については、AWS 「 IoT Things Graph ユーザーガイド」の「IoT Things Graph エンティティ、フロー、システム、デプロイのライフサイクル管理」を参照してください。 AWS IoT

  • API 詳細については、「 コマンドリファレンスDeleteSystemInstance」の「」を参照してください。 AWS CLI

次の例は、delete-system-template を使用する方法を説明しています。

AWS CLI

システムを削除するには

次のdelete-system-template例では、システムを削除します。

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

このコマンドでは何も出力されません。

詳細については、AWS 「 IoT Things Graph ユーザーガイド」の「IoT Things Graph エンティティ、フロー、システム、デプロイのライフサイクル管理」を参照してください。 AWS IoT

  • API 詳細については、「 コマンドリファレンスDeleteSystemTemplate」の「」を参照してください。 AWS CLI

次のコード例は、deploy-system-instance を使用する方法を示しています。

AWS CLI

システムインスタンスをデプロイするには

次のdelete-system-template例では、システムインスタンスをデプロイします。

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

出力:

{ "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 } }

詳細については、AWS 「 IoT Things Graph ユーザーガイド」の「システムとフロー設定の操作」を参照してください。

  • API 詳細については、「 コマンドリファレンスDeploySystemInstance」の「」を参照してください。 AWS CLI

次の例は、deprecate-flow-template を使用する方法を説明しています。

AWS CLI

フローを非推奨にするには

次のdeprecate-flow-template例では、フロー (ワークフロー) を非推奨にします。

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

このコマンドでは何も出力されません。

詳細については、AWS 「 IoT Things Graph ユーザーガイド」の「IoT Things Graph エンティティ、フロー、システム、デプロイのライフサイクル管理」を参照してください。 AWS IoT

  • API 詳細については、「 コマンドリファレンスDeprecateFlowTemplate」の「」を参照してください。 AWS CLI

次の例は、deprecate-system-template を使用する方法を説明しています。

AWS CLI

システムを非推奨にするには

次のdeprecate-system-template例では、システムを非推奨にします。

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

このコマンドでは何も出力されません。

詳細については、AWS 「 IoT Things Graph ユーザーガイド」の「IoT Things Graph エンティティ、フロー、システム、デプロイのライフサイクル管理」を参照してください。 AWS IoT

  • API 詳細については、「 コマンドリファレンスDeprecateSystemTemplate」の「」を参照してください。 AWS CLI

次のコード例は、describe-namespace を使用する方法を示しています。

AWS CLI

名前空間の説明を取得するには

次のdescribe-namespace例では、名前空間の説明を取得します。

aws iotthingsgraph describe-namespace

出力:

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

詳細については、「 IoT Things Graph ユーザーガイド」の「名前空間」を参照してください。 AWS IoT

  • API 詳細については、「 コマンドリファレンスDescribeNamespace」の「」を参照してください。 AWS CLI

次の例は、dissociate-entity-from-thing を使用する方法を説明しています。

AWS CLI

デバイスからモノの関連付けを解除するには

次のdissociate-entity-from-thing例では、デバイスからモノの関連付けを解除します。

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

このコマンドでは何も出力されません。

詳細については、 AWS IoT Things Graph ユーザーガイド「モデルの作成とアップロード」を参照してください。

  • API 詳細については、「 コマンドリファレンスDissociateEntityFromThing」の「」を参照してください。 AWS CLI

次のコード例は、get-entities を使用する方法を示しています。

AWS CLI

エンティティの定義を取得するには

次のget-entities例では、デバイスモデルの定義を取得します。

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

出力:

{ "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}" } } ] }

詳細については、 AWS IoT Things Graph ユーザーガイド「モデルの作成とアップロード」を参照してください。

  • API 詳細については、「 コマンドリファレンスGetEntities」の「」を参照してください。 AWS CLI

次の例は、get-flow-template-revisions を使用する方法を説明しています。

AWS CLI

フローに関するリビジョン情報を取得するには

次のget-flow-template-revisions例では、フロー (ワークフロー) に関するリビジョン情報を取得します。

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

出力:

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

詳細については、 AWS IoT Things Graph ユーザーガイドの「フローの使用」を参照してください。

  • API 詳細については、「 コマンドリファレンスGetFlowTemplateRevisions」の「」を参照してください。 AWS CLI

次の例は、get-flow-template を使用する方法を説明しています。

AWS CLI

フロー定義を取得するには

次のget-flow-template例では、フロー (ワークフロー) の定義を取得します。

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

出力:

{ "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 } }

詳細については、AWS 「 IoT Things Graph ユーザーガイド」の「フローの使用」を参照してください。

  • API 詳細については、「 コマンドリファレンスGetFlowTemplate」の「」を参照してください。 AWS CLI

次のコード例は、get-namespace-deletion-status を使用する方法を示しています。

AWS CLI

名前空間削除タスクのステータスを取得するには

次のget-namespace-deletion-status例では、名前空間削除タスクのステータスを取得します。

aws iotthingsgraph get-namespace-deletion-status

出力:

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

詳細については、 AWS IoT Things Graph ユーザーガイド「名前空間」を参照してください。

  • API 詳細については、「 コマンドリファレンスGetNamespaceDeletionStatus」の「」を参照してください。 AWS CLI

次の例は、get-system-instance を使用する方法を説明しています。

AWS CLI

システムインスタンスを取得するには

次のget-system-instance例では、システムインスタンスの定義を取得します。

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

出力:

{ "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" } }

詳細については、AWS 「 IoT Things Graph ユーザーガイド」の「システムとフロー設定の操作」を参照してください。

  • API 詳細については、「 コマンドリファレンスGetSystemInstance」の「」を参照してください。 AWS CLI

次の例は、get-system-template-revisions を使用する方法を説明しています。

AWS CLI

システムに関するリビジョン情報を取得するには

次のget-system-template-revisions例では、システムに関するリビジョン情報を取得します。

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

出力:

{ "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 } ] }

詳細については、AWS 「 IoT Things Graph ユーザーガイド」の「システムとフロー設定の操作」を参照してください。

  • API 詳細については、「 コマンドリファレンスGetSystemTemplateRevisions」の「」を参照してください。 AWS CLI

次のコード例は、get-system-template を使用する方法を示しています。

AWS CLI

システムを取得するには

次のget-system-template例では、システムの定義を取得します。

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

出力:

{ "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 } }

詳細については、AWS 「 IoT Things Graph ユーザーガイド」の「システムとフロー設定の操作」を参照してください。

  • API 詳細については、「 コマンドリファレンスGetSystemTemplate」の「」を参照してください。 AWS CLI

次のコード例は、get-upload-status を使用する方法を示しています。

AWS CLI

エンティティアップロードのステータスを取得するには

次のget-upload-status例では、エンティティのアップロードオペレーションのステータスを取得します。の値は、 upload-entity-definitionsオペレーションによって返される ID 値MyUploadIdです。

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

出力:

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

詳細については、 AWS IoT Things Graph ユーザーガイドの「エンティティのモデリング」を参照してください。

  • API 詳細については、「 コマンドリファレンスGetUploadStatus」の「」を参照してください。 AWS CLI

次のコード例は、list-flow-execution-messages を使用する方法を示しています。

AWS CLI

フロー実行のイベントに関する情報を取得するには

次のlist-flow-execution-messages例では、フロー実行のイベントに関する情報を取得します。

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"

出力:

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

詳細については、AWS 「 IoT Things Graph ユーザーガイド」の「フローの使用」を参照してください。

  • API 詳細については、「 コマンドリファレンスListFlowExecutionMessages」の「」を参照してください。 AWS CLI

次のコード例は、list-tags-for-resource を使用する方法を示しています。

AWS CLI

リソースのすべてのタグを一覧表示するには

次のlist-tags-for-resource例では、 AWS IoT Things Graph リソースのすべてのタグを一覧表示します。

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

出力:

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

詳細については、AWS 「 IoT Things Graph ユーザーガイド」の「IoT Things Graph リソースのタグ付け」を参照してください。 AWS IoT

  • API 詳細については、「 コマンドリファレンスListTagsForResource」の「」を参照してください。 AWS CLI

次のコード例は、search-entities を使用する方法を示しています。

AWS CLI

エンティティを検索するには

次のsearch-entities例では、タイプ のすべてのエンティティを検索しますEVENT

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

出力:

{ "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" }

詳細については、AWS 「 IoT Things Graph ユーザーガイド」の「IoT Things Graph データモデルリファレンスAWS IoT」を参照してください。

  • API 詳細については、「 コマンドリファレンスSearchEntities」の「」を参照してください。 AWS CLI

次の例は、search-flow-executions を使用する方法を説明しています。

AWS CLI

フロー実行を検索するには

次のsearch-flow-executions例では、指定されたシステムインスタンス内のフローのすべての実行を検索します。

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

出力:

{ "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 } ] }

詳細については、AWS 「 IoT Things Graph ユーザーガイド」の「システムとフロー設定の使用」を参照してください。

  • API 詳細については、「 コマンドリファレンスSearchFlowExecutions」の「」を参照してください。 AWS CLI

次のコード例は、search-flow-templates を使用する方法を示しています。

AWS CLI

フロー (またはワークフロー) を検索するには

次のsearch-flow-templates例では、カメラデバイスモデルを含むすべてのフロー (ワークフロー) を検索します。

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

出力:

{ "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 } ] }

詳細については、AWS 「 IoT Things Graph ユーザーガイド」の「フローの使用」を参照してください。

  • API 詳細については、「 コマンドリファレンスSearchFlowTemplates」の「」を参照してください。 AWS CLI

次のコード例は、search-system-instances を使用する方法を示しています。

AWS CLI

システムインスタンスを検索するには

次のsearch-system-instances例では、指定されたシステムを含むすべてのシステムインスタンスを検索します。

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

出力:

{ "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 } ] }

詳細については、AWS 「 IoT Things Graph ユーザーガイド」の「システムとフロー設定の操作」を参照してください。

  • API 詳細については、「 コマンドリファレンスSearchSystemInstances」の「」を参照してください。 AWS CLI

次の例は、search-system-templates を使用する方法を説明しています。

AWS CLI

システムを検索するには

次のsearch-system-templates例では、指定されたフローを含むすべてのシステムを検索します。

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

出力:

{ "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 } ] }

詳細については、AWS 「 IoT Things Graph ユーザーガイド」の「フローの使用」を参照してください。

  • API 詳細については、「 コマンドリファレンスSearchSystemTemplates」の「」を参照してください。 AWS CLI

次のコード例は、search-things を使用する方法を示しています。

AWS CLI

デバイスおよびデバイスモデルに関連するモノを検索するには

次のsearch-things例では、HCSR501 MotionSensor デバイスに関連付けられているすべてのモノを検索します。

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

出力:

{ "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" } ] }

詳細については、 AWS IoT Things Graph ユーザーガイド「モデルの作成とアップロード」を参照してください。

  • API 詳細については、「 コマンドリファレンスSearchThings」の「」を参照してください。 AWS CLI

次のコード例は、tag-resource を使用する方法を示しています。

AWS CLI

リソースのタグを作成するには

次のtag-resource例では、指定されたリソースのタグを作成します。

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

このコマンドでは何も出力されません。

詳細については、AWS 「 IoT Things Graph ユーザーガイド」の「IoT Things Graph リソースのタグ付け」を参照してください。 AWS IoT

  • API 詳細については、「 コマンドリファレンスTagResource」の「」を参照してください。 AWS CLI

次の例は、undeploy-system-instance を使用する方法を説明しています。

AWS CLI

ターゲットからシステムインスタンスをデプロイ解除するには

次のundeploy-system-instance例では、ターゲットからシステムインスタンスを削除します。

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

出力:

{ "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" } }

詳細については、AWS 「 IoT Things Graph ユーザーガイド」の「IoT Things Graph エンティティ、フロー、システム、デプロイのライフサイクル管理」を参照してください。 AWS IoT

  • API 詳細については、「 コマンドリファレンスUndeploySystemInstance」の「」を参照してください。 AWS CLI

次の例は、untag-resource を使用する方法を説明しています。

AWS CLI

リソースのタグを削除するには

次のuntag-resource例では、指定されたリソースのタグを削除します。

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

このコマンドでは何も出力されません。

詳細については、AWS 「 IoT Things Graph ユーザーガイド」の「IoT Things Graph リソースのタグ付け」を参照してください。 AWS IoT

  • API 詳細については、「 コマンドリファレンスUntagResource」の「」を参照してください。 AWS CLI

次の例は、update-flow-template を使用する方法を説明しています。

AWS CLI

フローを更新するには

次のupdate-flow-template例では、フロー (ワークフロー) を更新します。の値は、フローをモデル化する GraphQL MyFlowDefinitionです。

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

出力:

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

詳細については、AWS 「 IoT Things Graph ユーザーガイド」の「フローの使用」を参照してください。

  • API 詳細については、「 コマンドリファレンスUpdateFlowTemplate」の「」を参照してください。 AWS CLI

次の例は、update-system-template を使用する方法を説明しています。

AWS CLI

システムを更新するには

次のupdate-system-template例では、システムを更新します。の値は、システムをモデル化する GraphQL MySystemDefinitionです。

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

出力:

{ "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 } }

詳細については、「 IoT Things Graph ユーザーガイド」の「システムの作成」を参照してください。 AWS IoT

  • API 詳細については、「 コマンドリファレンスUpdateSystemTemplate」の「」を参照してください。 AWS CLI

次の例は、upload-entity-definitions を使用する方法を説明しています。

AWS CLI

エンティティ定義をアップロードするには

次のupload-entity-definitions例では、エンティティ定義を 名前空間にアップロードします。の値は、エンティティをモデル化する GraphQL MyEntityDefinitionsです。

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

出力:

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

詳細については、 AWS IoT Things Graph ユーザーガイドの「エンティティのモデリング」を参照してください。

  • API 詳細については、「 コマンドリファレンスUploadEntityDefinitions」の「」を参照してください。 AWS CLI