選取您的 Cookie 偏好設定

我們使用提供自身網站和服務所需的基本 Cookie 和類似工具。我們使用效能 Cookie 收集匿名統計資料,以便了解客戶如何使用我們的網站並進行改進。基本 Cookie 無法停用,但可以按一下「自訂」或「拒絕」以拒絕效能 Cookie。

如果您同意,AWS 與經核准的第三方也會使用 Cookie 提供實用的網站功能、記住您的偏好設定,並顯示相關內容,包括相關廣告。若要接受或拒絕所有非必要 Cookie,請按一下「接受」或「拒絕」。若要進行更詳細的選擇,請按一下「自訂」。

AWS IoT Things Graph 使用 的範例 AWS CLI - AWS SDK 程式碼範例

文件 AWS 開發套件範例 GitHub 儲存庫中有更多可用的 AWS SDK 範例

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

文件 AWS 開發套件範例 GitHub 儲存庫中有更多可用的 AWS SDK 範例

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

AWS IoT Things Graph 使用 的範例 AWS CLI

下列程式碼範例示範如何使用 AWS Command Line Interface 搭配 來執行動作和實作常見案例 AWS IoT Things Graph。

Actions 是大型程式的程式碼摘錄,必須在內容中執行。雖然動作會告訴您如何呼叫個別服務函數,但您可以在其相關情境中查看內容中的動作。

每個範例都包含完整原始程式碼的連結,您可以在其中找到如何在內容中設定和執行程式碼的指示。

主題

動作

下列程式碼範例示範如何使用 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 使用者指南中的建立和上傳模型

下列程式碼範例示範如何使用 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 使用者指南中的建立和上傳模型

下列程式碼範例示範如何使用 create-flow-template

AWS CLI

建立流程

下列create-flow-template範例會建立流程 (工作流程)。的值MyFlowDefinition是建立流程模型的 GraphQL。

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 使用者指南中的使用流程

下列程式碼範例示範如何使用 create-flow-template

AWS CLI

建立流程

下列create-flow-template範例會建立流程 (工作流程)。的值MyFlowDefinition是建立流程模型的 GraphQL。

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 使用者指南中的使用流程

下列程式碼範例示範如何使用 create-system-instance

AWS CLI

建立系統執行個體

下列create-system-instance範例會建立系統執行個體。的值MySystemInstanceDefinition是建立系統執行個體模型的 GraphQL。

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 使用者指南中的使用系統和流程組態

下列程式碼範例示範如何使用 create-system-instance

AWS CLI

建立系統執行個體

下列create-system-instance範例會建立系統執行個體。的值MySystemInstanceDefinition是建立系統執行個體模型的 GraphQL。

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 使用者指南中的使用系統和流程組態

下列程式碼範例示範如何使用 create-system-template

AWS CLI

建立系統

下列create-system-template範例會建立系統。MySystemDefinition 的值是建立系統模型的 GraphQL。

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

如需詳細資訊,請參閱 AWS IoT Things Graph 使用者指南中的建立系統

下列程式碼範例示範如何使用 create-system-template

AWS CLI

建立系統

下列create-system-template範例會建立系統。MySystemDefinition 的值是建立系統模型的 GraphQL。

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

如需詳細資訊,請參閱 AWS IoT Things Graph 使用者指南中的建立系統

下列程式碼範例示範如何使用 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 詳細資訊,請參閱《 AWS CLI 命令參考》中的 DeleteFlowTemplate

下列程式碼範例示範如何使用 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 詳細資訊,請參閱《 AWS CLI 命令參考》中的 DeleteFlowTemplate

下列程式碼範例示範如何使用 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 詳細資訊,請參閱 AWS CLI 命令參考中的 DeleteNamespace

下列程式碼範例示範如何使用 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 詳細資訊,請參閱 AWS CLI 命令參考中的 DeleteNamespace

下列程式碼範例示範如何使用 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

下列程式碼範例示範如何使用 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

下列程式碼範例示範如何使用 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

下列程式碼範例示範如何使用 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

下列程式碼範例示範如何使用 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 使用者指南中的使用系統和流程組態

下列程式碼範例示範如何使用 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 使用者指南中的使用系統和流程組態

下列程式碼範例示範如何使用 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

下列程式碼範例示範如何使用 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

下列程式碼範例示範如何使用 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

下列程式碼範例示範如何使用 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

下列程式碼範例示範如何使用 describe-namespace

AWS CLI

取得命名空間的描述

下列describe-namespace範例會取得命名空間的描述。

aws iotthingsgraph describe-namespace

輸出:

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

如需詳細資訊,請參閱 AWS IoT Things Graph 使用者指南中的命名空間

  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 DescribeNamespace

下列程式碼範例示範如何使用 describe-namespace

AWS CLI

取得命名空間的描述

下列describe-namespace範例會取得命名空間的描述。

aws iotthingsgraph describe-namespace

輸出:

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

如需詳細資訊,請參閱 AWS IoT Things Graph 使用者指南中的命名空間

  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 DescribeNamespace

下列程式碼範例示範如何使用 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 使用者指南中的建立和上傳模型

下列程式碼範例示範如何使用 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 使用者指南中的建立和上傳模型

下列程式碼範例示範如何使用 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 詳細資訊,請參閱 AWS CLI 命令參考中的 GetEntities

下列程式碼範例示範如何使用 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 詳細資訊,請參閱 AWS CLI 命令參考中的 GetEntities

下列程式碼範例示範如何使用 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 使用者指南中的使用流程

下列程式碼範例示範如何使用 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 使用者指南中的使用流程

下列程式碼範例示範如何使用 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 詳細資訊,請參閱《 AWS CLI 命令參考》中的 GetFlowTemplate

下列程式碼範例示範如何使用 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 詳細資訊,請參閱《 AWS CLI 命令參考》中的 GetFlowTemplate

下列程式碼範例示範如何使用 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 使用者指南中的命名空間

下列程式碼範例示範如何使用 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 使用者指南中的命名空間

下列程式碼範例示範如何使用 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 詳細資訊,請參閱 AWS CLI 命令參考中的 GetSystemInstance

下列程式碼範例示範如何使用 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 詳細資訊,請參閱 AWS CLI 命令參考中的 GetSystemInstance

下列程式碼範例示範如何使用 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 使用者指南中的使用系統和流程組態

下列程式碼範例示範如何使用 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 使用者指南中的使用系統和流程組態

下列程式碼範例示範如何使用 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 詳細資訊,請參閱《 AWS CLI 命令參考》中的 GetSystemTemplate

下列程式碼範例示範如何使用 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 詳細資訊,請參閱《 AWS CLI 命令參考》中的 GetSystemTemplate

下列程式碼範例示範如何使用 get-upload-status

AWS CLI

若要取得實體上傳的狀態

下列get-upload-status範例會取得實體上傳操作的狀態。的值MyUploadIdupload-entity-definitions操作傳回的 ID 值。

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 詳細資訊,請參閱 AWS CLI 命令參考中的 GetUploadStatus

下列程式碼範例示範如何使用 get-upload-status

AWS CLI

若要取得實體上傳的狀態

下列get-upload-status範例會取得實體上傳操作的狀態。的值MyUploadIdupload-entity-definitions操作傳回的 ID 值。

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 詳細資訊,請參閱 AWS CLI 命令參考中的 GetUploadStatus

下列程式碼範例示範如何使用 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 使用者指南中的使用流程

下列程式碼範例示範如何使用 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 使用者指南中的使用流程

下列程式碼範例示範如何使用 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

下列程式碼範例示範如何使用 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

下列程式碼範例示範如何使用 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 詳細資訊,請參閱 AWS CLI 命令參考中的 SearchEntities

下列程式碼範例示範如何使用 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 詳細資訊,請參閱 AWS CLI 命令參考中的 SearchEntities

下列程式碼範例示範如何使用 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 使用者指南中的使用系統和流程組態

下列程式碼範例示範如何使用 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 使用者指南中的使用系統和流程組態

下列程式碼範例示範如何使用 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 使用者指南中的使用流程

下列程式碼範例示範如何使用 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 使用者指南中的使用流程

下列程式碼範例示範如何使用 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 使用者指南中的使用系統和流程組態

下列程式碼範例示範如何使用 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 使用者指南中的使用系統和流程組態

下列程式碼範例示範如何使用 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 使用者指南中的使用流程

下列程式碼範例示範如何使用 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 使用者指南中的使用流程

下列程式碼範例示範如何使用 search-things

AWS CLI

搜尋與裝置和裝置模型相關聯的物件

下列search-things範例會搜尋與 HCSR501MotionSensor 裝置相關聯的所有物件。

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 詳細資訊,請參閱 AWS CLI 命令參考中的 SearchThings

下列程式碼範例示範如何使用 search-things

AWS CLI

搜尋與裝置和裝置模型相關聯的物件

下列search-things範例會搜尋與 HCSR501MotionSensor 裝置相關聯的所有物件。

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 詳細資訊,請參閱 AWS CLI 命令參考中的 SearchThings

下列程式碼範例示範如何使用 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 詳細資訊,請參閱《AWS CLI 命令參考》中的 TagResource

下列程式碼範例示範如何使用 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 詳細資訊,請參閱《AWS CLI 命令參考》中的 TagResource

下列程式碼範例示範如何使用 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

下列程式碼範例示範如何使用 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

下列程式碼範例示範如何使用 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 詳細資訊,請參閱《AWS CLI 命令參考》中的 UntagResource

下列程式碼範例示範如何使用 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 詳細資訊,請參閱《AWS CLI 命令參考》中的 UntagResource

下列程式碼範例示範如何使用 update-flow-template

AWS CLI

更新流程

下列update-flow-template範例會更新流程 (工作流程)。的值MyFlowDefinition是建立流程模型的 GraphQL。

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 使用者指南中的使用流程

下列程式碼範例示範如何使用 update-flow-template

AWS CLI

更新流程

下列update-flow-template範例會更新流程 (工作流程)。的值MyFlowDefinition是建立流程模型的 GraphQL。

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 使用者指南中的使用流程

下列程式碼範例示範如何使用 update-system-template

AWS CLI

更新系統

下列update-system-template範例會更新系統。的值MySystemDefinition是建立系統模型的 GraphQL。

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

如需詳細資訊,請參閱 AWS IoT Things Graph 使用者指南中的建立系統

下列程式碼範例示範如何使用 update-system-template

AWS CLI

更新系統

下列update-system-template範例會更新系統。的值MySystemDefinition是建立系統模型的 GraphQL。

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

如需詳細資訊,請參閱 AWS IoT Things Graph 使用者指南中的建立系統

下列程式碼範例示範如何使用 upload-entity-definitions

AWS CLI

上傳實體定義

下列upload-entity-definitions範例會將實體定義上傳至您的命名空間。的值MyEntityDefinitions是建立實體模型的 GraphQL。

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

輸出:

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

如需詳細資訊,請參閱 AWS IoT Things Graph 使用者指南中的建模實體

下列程式碼範例示範如何使用 upload-entity-definitions

AWS CLI

上傳實體定義

下列upload-entity-definitions範例會將實體定義上傳至您的命名空間。的值MyEntityDefinitions是建立實體模型的 GraphQL。

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

輸出:

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

如需詳細資訊,請參閱 AWS IoT Things Graph 使用者指南中的建模實體

隱私權網站條款Cookie 偏好設定
© 2025, Amazon Web Services, Inc.或其附屬公司。保留所有權利。