AWS CLI를 사용한 AWS IoT Things Graph 예제 - AWS Command Line Interface

이 문서는 AWS CLI의 버전 1에만 해당합니다. AWS CLI의 버전 2와 관련된 문서는 버전 2 사용 설명서를 참조하세요.

AWS CLI를 사용한 AWS IoT Things Graph 예제

다음 코드 예시에서는 AWS IoT Things Graph에서 AWS Command Line Interface를 사용하여 작업을 수행하고 일반적인 시나리오를 구현하는 방법을 보여줍니다.

작업은 대규모 프로그램에서 발췌한 코드이며 컨텍스트에 맞춰 실행해야 합니다. 작업은 개별 서비스 함수를 직접적으로 호출하는 방법을 보여주며 관련 시나리오의 컨텍스트에 맞는 작업을 볼 수 있습니다.

각 예시에는 컨텍스트에서 코드를 설정하고 실행하는 방법에 대한 지침을 찾을 수 있는 전체 소스 코드에 대한 링크가 포함되어 있습니다.

주제

작업

다음 코드 예시에서는 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 사물 그래프 사용자 안내서Creating and Uploading Models를 참조하세요.

다음 코드 예시에서는 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 사물 그래프 사용자 안내서Working with Flows를 참조하세요.

  • API 세부 정보는 AWS CLI 명령 참조CreateFlowTemplate 섹션을 참조하세요.

다음 코드 예시에서는 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 사물 그래프 사용자 안내서Working with Systems and Flow Configurations를 참조하세요.

다음 코드 예시에서는 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 사물 그래프 사용자 안내서Creating Systems를 참조하세요.

다음 코드 예시에서는 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 사물 그래프 사용자 안내서Lifecycle Management for AWS IoT Things Graph Entities, Flows, Systems, and Deployments를 참조하세요.

  • 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 사물 그래프 사용자 안내서Lifecycle Management for AWS IoT Things Graph Entities, Flows, Systems, and Deployments를 참조하세요.

  • 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 사물 그래프 사용자 안내서Lifecycle Management for AWS IoT Things Graph Entities, Flows, Systems, and Deployments를 참조하세요.

다음 코드 예시에서는 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 사물 그래프 사용자 안내서Lifecycle Management for AWS IoT Things Graph Entities, Flows, Systems, and Deployments를 참조하세요.

다음 코드 예시에서는 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 사물 그래프 사용자 안내서Working with Systems and Flow Configurations를 참조하세요.

다음 코드 예시에서는 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 사물 그래프 사용자 안내서Lifecycle Management for AWS IoT Things Graph Entities, Flows, Systems, and Deployments를 참조하세요.

다음 코드 예시에서는 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 사물 그래프 사용자 안내서Lifecycle Management for AWS IoT Things Graph Entities, Flows, Systems, and Deployments를 참조하세요.

다음 코드 예시에서는 describe-namespace 코드를 사용하는 방법을 보여줍니다.

AWS CLI

네임스페이스에 대한 설명을 가져오는 방법

다음 describe-namespace 예시에서는 네임스페이스 설명을 가져옵니다.

aws iotthingsgraph describe-namespace

출력:

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

자세한 내용은 AWS IoT 사물 그래프 사용자 안내서Namespaces를 참조하세요.

  • 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 사물 그래프 사용자 안내서Creating and Uploading Models를 참조하세요.

다음 코드 예시에서는 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 사물 그래프 사용자 안내서Creating and Uploading Models를 참조하세요.

  • 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 사물 그래프 사용자 안내서Working with Flows를 참조하세요.

다음 코드 예시에서는 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 사물 그래프 사용자 안내서Working with Flows를 참조하세요.

  • 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 사물 그래프 사용자 안내서Namespaces를 참조하세요.

다음 코드 예시에서는 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 사물 그래프 사용자 안내서Working with Systems and Flow Configurations를 참조하세요.

  • 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 사물 그래프 사용자 안내서Working with Systems and Flow Configurations를 참조하세요.

다음 코드 예시에서는 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 사물 그래프 사용자 안내서Working with Systems and Flow Configurations를 참조하세요.

  • API 세부 정보는 AWS CLI 명령 참조GetSystemTemplate 섹션을 참조하세요.

다음 코드 예시에서는 get-upload-status 코드를 사용하는 방법을 보여줍니다.

AWS CLI

엔터티 업로드 상태를 가져오는 방법

다음 get-upload-status 예시에서는 엔터티 업로드 작업의 상태를 가져옵니다. MyUploadId의 값은 upload-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 사물 그래프 사용자 안내서Modeling Entities를 참조하세요.

  • 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 사물 그래프 사용자 안내서Working with Flows를 참조하세요.

다음 코드 예시에서는 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 사물 그래프 사용자 안내서Tagging Your AWS IoT Things Graph Resources를 참조하세요.

다음 코드 예시에서는 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 사물 그래프 사용자 안내서AWS IoT Things Graph Data Model Reference를 참조하세요.

  • 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 사물 그래프 사용자 안내서Working with Systems and Flow Configurations를 참조하세요.

다음 코드 예시에서는 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 사물 그래프 사용자 안내서Working with Flows를 참조하세요.

다음 코드 예시에서는 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 사물 그래프 사용자 안내서Working with Systems and Flow Configurations를 참조하세요.

다음 코드 예시에서는 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 사물 그래프 사용자 안내서Working with Flows를 참조하세요.

다음 코드 예시에서는 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 사물 그래프 사용자 안내서Creating and Uploading Models를 참조하세요.

  • 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 사물 그래프 사용자 안내서Tagging Your AWS IoT Things Graph Resources를 참조하세요.

  • 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 사물 그래프 사용자 안내서Lifecycle Management for AWS IoT Things Graph Entities, Flows, Systems, and Deployments를 참조하세요.

다음 코드 예시에서는 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 사물 그래프 사용자 안내서Tagging Your AWS IoT Things Graph Resources를 참조하세요.

  • API 세부 정보는 AWS CLI Command Reference의 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 사물 그래프 사용자 안내서Working with Flows를 참조하세요.

  • API 세부 정보는 AWS CLI 명령 참조UpdateFlowTemplate 섹션을 참조하세요.

다음 코드 예시에서는 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 사물 그래프 사용자 안내서Creating Systems를 참조하세요.

다음 코드 예시에서는 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 사물 그래프 사용자 안내서Modeling Entities를 참조하세요.