文件 AWS 開發套件範例 GitHub 儲存庫中有更多可用的 AWS SDK 範例
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
AWS IoT SiteWise 使用 的範例 AWS CLI
下列程式碼範例示範如何使用 AWS Command Line Interface 搭配 來執行動作和實作常見案例 AWS IoT SiteWise。
Actions 是大型程式的程式碼摘錄,必須在內容中執行。雖然動作會告訴您如何呼叫個別服務函數,但您可以在其相關情境中查看內容中的動作。
每個範例都包含完整原始程式碼的連結,您可以在其中找到如何在內容中設定和執行程式碼的指示。
主題
動作
以下程式碼範例顯示如何使用 associate-assets。
- AWS CLI
-
將子資產與父資產建立關聯
下列
associate-assets範例會將風力發電機資產與風力發電廠資產建立關聯,其中風力發電機資產模型以階層形式存在於風力發電廠資產模型中。aws iotsitewise associate-assets \ --asset-ida1b2c3d4-5678-90ab-cdef-44444EXAMPLE\ --hierarchy-ida1b2c3d4-5678-90ab-cdef-77777EXAMPLE\ --child-asset-ida1b2c3d4-5678-90ab-cdef-33333EXAMPLE此命令不會產生輸出。
如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的關聯資產。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 AssociateAssets
。
-
以下程式碼範例顯示如何使用 batch-associate-project-assets。
- AWS CLI
-
將資產與專案建立關聯
下列
batch-associate-project-assets範例會將風力發電廠資產與專案建立關聯。aws iotsitewise batch-associate-project-assets \ --project-ida1b2c3d4-5678-90ab-cdef-eeeeeEXAMPLE\ --asset-idsa1b2c3d4-5678-90ab-cdef-44444EXAMPLE此命令不會產生輸出。
如需詳細資訊,請參閱 AWS IoT SiteWise Monitor 應用程式指南中的將資產新增至專案。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 BatchAssociateProjectAssets
。
-
以下程式碼範例顯示如何使用 batch-disassociate-project-assets。
- AWS CLI
-
取消資產與專案的關聯
下列
batch-disassociate-project-assets範例會取消風力發電廠資產與專案的關聯。aws iotsitewise batch-disassociate-project-assets \ --project-ida1b2c3d4-5678-90ab-cdef-eeeeeEXAMPLE\ --asset-idsa1b2c3d4-5678-90ab-cdef-44444EXAMPLE此命令不會產生輸出。
如需詳細資訊,請參閱 AWS IoT SiteWise Monitor 應用程式指南中的將資產新增至專案。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 BatchDisassociateProjectAssets
。
-
以下程式碼範例顯示如何使用 batch-put-asset-property-value。
- AWS CLI
-
將資料傳送至資產屬性
下列
batch-put-asset-property-value範例會將電源和溫度資料傳送至屬性別名識別的資產屬性。aws iotsitewise batch-put-asset-property-value \ --cli-input-jsonfile://batch-put-asset-property-value.jsonbatch-put-asset-property-value.json的內容:{ "entries": [ { "entryId": "1575691200-company-windfarm-3-turbine-7-power", "propertyAlias": "company-windfarm-3-turbine-7-power", "propertyValues": [ { "value": { "doubleValue": 4.92 }, "timestamp": { "timeInSeconds": 1575691200 }, "quality": "GOOD" } ] }, { "entryId": "1575691200-company-windfarm-3-turbine-7-temperature", "propertyAlias": "company-windfarm-3-turbine-7-temperature", "propertyValues": [ { "value": { "integerValue": 38 }, "timestamp": { "timeInSeconds": 1575691200 } } ] } ] }輸出:
{ "errorEntries": [] }如需詳細資訊,請參閱 IoT SiteWise 使用者指南中的使用 AWS IoT SiteWise API 擷取資料。 AWS IoT SiteWise
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 BatchPutAssetPropertyValue
。
-
以下程式碼範例顯示如何使用 create-access-policy。
- AWS CLI
-
範例 1:授予使用者入口網站的管理存取權
下列
create-access-policy範例會建立存取政策,授予使用者對風力發電廠公司 Web 入口網站的管理存取權。aws iotsitewise create-access-policy \ --cli-input-jsonfile://create-portal-administrator-access-policy.jsoncreate-portal-administrator-access-policy.json的內容:{ "accessPolicyIdentity": { "user": { "id": "a1b2c3d4e5-a1b2c3d4-5678-90ab-cdef-bbbbbEXAMPLE" } }, "accessPolicyPermission": "ADMINISTRATOR", "accessPolicyResource": { "portal": { "id": "a1b2c3d4-5678-90ab-cdef-aaaaaEXAMPLE" } } }輸出:
{ "accessPolicyId": "a1b2c3d4-5678-90ab-cdef-cccccEXAMPLE", "accessPolicyArn": "arn:aws:iotsitewise:us-west-2:123456789012:access-policy/a1b2c3d4-5678-90ab-cdef-cccccEXAMPLE" }如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的新增或移除入口網站管理員。
範例 2:授予使用者對專案的唯讀存取權
下列
create-access-policy範例會建立存取政策,授予使用者對風力發電廠專案的唯讀存取權。aws iotsitewise create-access-policy \ --cli-input-jsonfile://create-project-viewer-access-policy.jsoncreate-project-viewer-access-policy.json的內容:{ "accessPolicyIdentity": { "user": { "id": "a1b2c3d4e5-a1b2c3d4-5678-90ab-cdef-bbbbbEXAMPLE" } }, "accessPolicyPermission": "VIEWER", "accessPolicyResource": { "project": { "id": "a1b2c3d4-5678-90ab-cdef-eeeeeEXAMPLE" } } }輸出:
{ "accessPolicyId": "a1b2c3d4-5678-90ab-cdef-dddddEXAMPLE", "accessPolicyArn": "arn:aws:iotsitewise:us-west-2:123456789012:access-policy/a1b2c3d4-5678-90ab-cdef-dddddEXAMPLE" }如需詳細資訊,請參閱 AWS IoT SiteWise Monitor 應用程式指南中的指派專案檢視器。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 CreateAccessPolicy
。
-
以下程式碼範例顯示如何使用 create-asset-model。
- AWS CLI
-
建立資產模型
下列
create-asset-model範例會建立資產模型,以定義具有下列屬性的風力渦輪機:序號 - 風turbineGenerated功率 - 從風turbineTemperature C - 從風力發電機以 CelsiusTemperature F 產生的溫度資料串流 - 從攝氏到華氏的映射溫度資料點
aws iotsitewise create-asset-model \ --cli-input-jsonfile://create-wind-turbine-model.jsoncreate-wind-turbine-model.json的內容:{ "assetModelName": "Wind Turbine Model", "assetModelDescription": "Represents a wind turbine", "assetModelProperties": [ { "name": "Serial Number", "dataType": "STRING", "type": { "attribute": {} } }, { "name": "Generated Power", "dataType": "DOUBLE", "unit": "kW", "type": { "measurement": {} } }, { "name": "Temperature C", "dataType": "DOUBLE", "unit": "Celsius", "type": { "measurement": {} } }, { "name": "Temperature F", "dataType": "DOUBLE", "unit": "Fahrenheit", "type": { "transform": { "expression": "temp_c * 9 / 5 + 32", "variables": [ { "name": "temp_c", "value": { "propertyId": "Temperature C" } } ] } } }, { "name": "Total Generated Power", "dataType": "DOUBLE", "unit": "kW", "type": { "metric": { "expression": "sum(power)", "variables": [ { "name": "power", "value": { "propertyId": "Generated Power" } } ], "window": { "tumbling": { "interval": "1h" } } } } } ] }輸出:
{ "assetModelId": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE", "assetModelArn": "arn:aws:iotsitewise:us-west-2:123456789012:asset-model/a1b2c3d4-5678-90ab-cdef-11111EXAMPLE", "assetModelStatus": { "state": "CREATING" } }如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的定義資產模型。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 CreateAssetModel
。
-
以下程式碼範例顯示如何使用 create-asset。
- AWS CLI
-
建立資產
下列
create-asset範例會從風力渦輪機資產模型建立風力渦輪機資產。aws iotsitewise create-asset \ --asset-model-ida1b2c3d4-5678-90ab-cdef-11111EXAMPLE\ --asset-name"Wind Turbine 1"輸出:
{ "assetId": "a1b2c3d4-5678-90ab-cdef-33333EXAMPLE", "assetArn": "arn:aws:iotsitewise:us-west-2:123456789012:asset/a1b2c3d4-5678-90ab-cdef-33333EXAMPLE", "assetStatus": { "state": "CREATING" } }如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的建立資產。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 CreateAsset
。
-
以下程式碼範例顯示如何使用 create-dashboard。
- AWS CLI
-
建立儀表板
下列
create-dashboard範例會建立具有折線圖的儀表板,顯示風力發電廠產生的總功率。aws iotsitewise create-dashboard \ --project-ida1b2c3d4-5678-90ab-cdef-eeeeeEXAMPLE\ --dashboard-name"Wind Farm"\ --dashboard-definitionfile://create-wind-farm-dashboard.jsoncreate-wind-farm-dashboard.json的內容:{ "widgets": [ { "type": "monitor-line-chart", "title": "Generated Power", "x": 0, "y": 0, "height": 3, "width": 3, "metrics": [ { "label": "Power", "type": "iotsitewise", "assetId": "a1b2c3d4-5678-90ab-cdef-44444EXAMPLE", "propertyId": "a1b2c3d4-5678-90ab-cdef-99999EXAMPLE" } ] } ] }輸出:
{ "dashboardId": "a1b2c3d4-5678-90ab-cdef-fffffEXAMPLE", "dashboardArn": "arn:aws:iotsitewise:us-west-2:123456789012:dashboard/a1b2c3d4-5678-90ab-cdef-fffffEXAMPLE" }如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的建立儀表板 (CLI)。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 CreateDashboard
。
-
以下程式碼範例顯示如何使用 create-gateway。
- AWS CLI
-
建立閘道
下列
create-gateway範例會建立在 AWS IoT Greengrass 上執行的閘道。aws iotsitewise create-gateway \ --gateway-nameExampleCorpGateway\ --gateway-platformgreengrass={groupArn=arn:aws:greengrass:us-west-2:123456789012:/greengrass/groups/a1b2c3d4-5678-90ab-cdef-1b1b1EXAMPLE}輸出:
{ "gatewayId": "a1b2c3d4-5678-90ab-cdef-1a1a1EXAMPLE", "gatewayArn": "arn:aws:iotsitewise:us-west-2:123456789012:gateway/a1b2c3d4-5678-90ab-cdef-1a1a1EXAMPLE" }如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的設定閘道。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 CreateGateway
。
-
以下程式碼範例顯示如何使用 create-portal。
- AWS CLI
-
建立入口網站
下列
create-portal範例會為風力發電廠公司建立 Web 入口網站。您只能在啟用 AWS 單一登入的相同區域中建立入口網站。aws iotsitewise create-portal \ --portal-nameWindFarmPortal\ --portal-description"A portal that contains wind farm projects for Example Corp."\ --portal-contact-emailsupport@example.com\ --role-arnarn:aws:iam::123456789012:role/service-role/MySiteWiseMonitorServiceRole輸出:
{ "portalId": "a1b2c3d4-5678-90ab-cdef-aaaaaEXAMPLE", "portalArn": "arn:aws:iotsitewise:us-west-2:123456789012:portal/a1b2c3d4-5678-90ab-cdef-aaaaaEXAMPLE", "portalStartUrl": "https://a1b2c3d4-5678-90ab-cdef-aaaaaEXAMPLE.app.iotsitewise.aws", "portalStatus": { "state": "CREATING" }, "ssoApplicationId": "ins-a1b2c3d4-EXAMPLE" }如需詳細資訊,請參閱 IoT SiteWise 使用者指南中的 AWS IoT SiteWise Monitor 入門和 AWS IoT SiteWise 使用者指南中的啟用 AWS SSO。 AWS IoT SiteWise
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 CreatePortal
。
-
以下程式碼範例顯示如何使用 create-project。
- AWS CLI
-
建立專案
下列
create-project範例會建立風力發電廠專案。aws iotsitewise create-project \ --portal-ida1b2c3d4-5678-90ab-cdef-aaaaaEXAMPLE\ --project-name"Wind Farm 1"\ --project-description"Contains asset visualizations for Wind Farm #1 for Example Corp."輸出:
{ "projectId": "a1b2c3d4-5678-90ab-cdef-eeeeeEXAMPLE", "projectArn": "arn:aws:iotsitewise:us-west-2:123456789012:project/a1b2c3d4-5678-90ab-cdef-eeeeeEXAMPLE" }如需詳細資訊,請參閱 AWS IoT SiteWise Monitor 應用程式指南中的建立專案。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 CreateProject
。
-
以下程式碼範例顯示如何使用 delete-access-policy。
- AWS CLI
-
撤銷使用者對專案或入口網站的存取權
下列
delete-access-policy範例會刪除授予使用者入口網站管理存取權的存取政策。aws iotsitewise delete-access-policy \ --access-policy-ida1b2c3d4-5678-90ab-cdef-cccccEXAMPLE此命令不會產生輸出。
如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的新增或移除入口網站管理員。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 DeleteAccessPolicy
。
-
以下程式碼範例顯示如何使用 delete-asset-model。
- AWS CLI
-
刪除資產模型
下列
delete-asset-model範例會刪除風力渦輪機資產模型。aws iotsitewise delete-asset-model \ --asset-model-ida1b2c3d4-5678-90ab-cdef-11111EXAMPLE輸出:
{ "assetModelStatus": { "state": "DELETING" } }如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的刪除資產模型。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 DeleteAssetModel
。
-
以下程式碼範例顯示如何使用 delete-asset。
- AWS CLI
-
刪除資產
下列
delete-asset範例會刪除風力發電機資產。aws iotsitewise delete-asset \ --asset-ida1b2c3d4-5678-90ab-cdef-33333EXAMPLE輸出:
{ "assetStatus": { "state": "DELETING" } }如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的刪除資產。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 DeleteAsset
。
-
以下程式碼範例顯示如何使用 delete-dashboard。
- AWS CLI
-
刪除儀表板
下列
delete-dashboard範例會刪除風力發電機儀表板。aws iotsitewise delete-dashboard \ --dashboard-ida1b2c3d4-5678-90ab-cdef-fffffEXAMPLE此命令不會產生輸出。
如需詳細資訊,請參閱 AWS IoT SiteWise Monitor 應用程式指南中的刪除儀表板。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 DeleteDashboard
。
-
以下程式碼範例顯示如何使用 delete-gateway。
- AWS CLI
-
刪除閘道
下列
delete-gateway範例會刪除閘道。aws iotsitewise delete-gateway \ --gateway-ida1b2c3d4-5678-90ab-cdef-1a1a1EXAMPLE此命令不會產生輸出。
如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的使用閘道擷取資料。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 DeleteGateway
。
-
以下程式碼範例顯示如何使用 delete-portal。
- AWS CLI
-
刪除入口網站
下列
delete-portal範例會刪除風力發電廠公司的 Web 入口網站。aws iotsitewise delete-portal \ --portal-ida1b2c3d4-5678-90ab-cdef-aaaaaEXAMPLE輸出:
{ "portalStatus": { "state": "DELETING" } }如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的刪除入口網站。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 DeletePortal
。
-
以下程式碼範例顯示如何使用 delete-project。
- AWS CLI
-
刪除專案
下列
delete-project範例會刪除風力發電廠專案。aws iotsitewise delete-project \ --project-ida1b2c3d4-5678-90ab-cdef-eeeeeEXAMPLE此命令不會產生輸出。
如需詳細資訊,請參閱 AWS IoT SiteWise Monitor 應用程式指南中的刪除專案。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 DeleteProject
。
-
以下程式碼範例顯示如何使用 describe-access-policy。
- AWS CLI
-
描述存取政策
下列
describe-access-policy範例說明 存取政策,授予使用者對風力發電廠公司 Web 入口網站的管理存取權。aws iotsitewise describe-access-policy \ --access-policy-ida1b2c3d4-5678-90ab-cdef-cccccEXAMPLE輸出:
{ "accessPolicyId": "a1b2c3d4-5678-90ab-cdef-cccccEXAMPLE", "accessPolicyArn": "arn:aws:iotsitewise:us-west-2:123456789012:access-policy/a1b2c3d4-5678-90ab-cdef-cccccEXAMPLE", "accessPolicyIdentity": { "user": { "id": "a1b2c3d4e5-a1b2c3d4-5678-90ab-cdef-bbbbbEXAMPLE" } }, "accessPolicyResource": { "portal": { "id": "a1b2c3d4-5678-90ab-cdef-aaaaaEXAMPLE" } }, "accessPolicyPermission": "ADMINISTRATOR", "accessPolicyCreationDate": "2020-02-20T22:35:15.552880124Z", "accessPolicyLastUpdateDate": "2020-02-20T22:35:15.552880124Z" }如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的新增或移除入口網站管理員。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 DescribeAccessPolicy
。
-
以下程式碼範例顯示如何使用 describe-asset-model。
- AWS CLI
-
描述資產模型
下列
describe-asset-model範例說明風力發電廠資產模型。aws iotsitewise describe-asset-model \ --asset-model-ida1b2c3d4-5678-90ab-cdef-22222EXAMPLE輸出:
{ "assetModelId": "a1b2c3d4-5678-90ab-cdef-22222EXAMPLE", "assetModelArn": "arn:aws:iotsitewise:us-west-2:123456789012:asset-model/a1b2c3d4-5678-90ab-cdef-22222EXAMPLE", "assetModelName": "Wind Farm Model", "assetModelDescription": "Represents a wind farm that comprises many wind turbines", "assetModelProperties": [ { "id": "a1b2c3d4-5678-90ab-cdef-99999EXAMPLE", "name": "Total Generated Power", "dataType": "DOUBLE", "unit": "kW", "type": { "metric": { "expression": "sum(power)", "variables": [ { "name": "power", "value": { "propertyId": "a1b2c3d4-5678-90ab-cdef-66666EXAMPLE", "hierarchyId": "a1b2c3d4-5678-90ab-cdef-77777EXAMPLE" } } ], "window": { "tumbling": { "interval": "1h" } } } } }, { "id": "a1b2c3d4-5678-90ab-cdef-88888EXAMPLE", "name": "Region", "dataType": "STRING", "type": { "attribute": { "defaultValue": " " } } } ], "assetModelHierarchies": [ { "id": "a1b2c3d4-5678-90ab-cdef-77777EXAMPLE", "name": "Wind Turbines", "childAssetModelId": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE" } ], "assetModelCreationDate": 1575671284.0, "assetModelLastUpdateDate": 1575671988.0, "assetModelStatus": { "state": "ACTIVE" } }如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的描述特定資產模型。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 DescribeAssetModel
。
-
以下程式碼範例顯示如何使用 describe-asset-property。
- AWS CLI
-
描述資產屬性
下列
describe-asset-property範例說明風力發電廠資產的總產生功率屬性。aws iotsitewise describe-asset-property \ --asset-ida1b2c3d4-5678-90ab-cdef-44444EXAMPLE\ --property-ida1b2c3d4-5678-90ab-cdef-99999EXAMPLE輸出:
{ "assetId": "a1b2c3d4-5678-90ab-cdef-44444EXAMPLE", "assetName": "Wind Farm 1", "assetModelId": "a1b2c3d4-5678-90ab-cdef-22222EXAMPLE", "assetProperty": { "id": "a1b2c3d4-5678-90ab-cdef-99999EXAMPLE", "name": "Total Generated Power", "notification": { "topic": "$aws/sitewise/asset-models/a1b2c3d4-5678-90ab-cdef-22222EXAMPLE/assets/a1b2c3d4-5678-90ab-cdef-44444EXAMPLE/properties/a1b2c3d4-5678-90ab-cdef-99999EXAMPLE", "state": "DISABLED" }, "dataType": "DOUBLE", "unit": "kW", "type": { "metric": { "expression": "sum(power)", "variables": [ { "name": "power", "value": { "propertyId": "a1b2c3d4-5678-90ab-cdef-66666EXAMPLE", "hierarchyId": "a1b2c3d4-5678-90ab-cdef-77777EXAMPLE" } } ], "window": { "tumbling": { "interval": "1h" } } } } } }如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的描述特定資產屬性。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 DescribeAssetProperty
。
-
以下程式碼範例顯示如何使用 describe-asset。
- AWS CLI
-
描述資產
下列
describe-asset範例說明風力發電廠資產。aws iotsitewise describe-asset \ --asset-ida1b2c3d4-5678-90ab-cdef-44444EXAMPLE輸出:
{ "assetId": "a1b2c3d4-5678-90ab-cdef-44444EXAMPLE", "assetArn": "arn:aws:iotsitewise:us-west-2:123456789012:asset/a1b2c3d4-5678-90ab-cdef-44444EXAMPLE", "assetName": "Wind Farm 1", "assetModelId": "a1b2c3d4-5678-90ab-cdef-22222EXAMPLE", "assetProperties": [ { "id": "a1b2c3d4-5678-90ab-cdef-88888EXAMPLE", "name": "Region", "dataType": "STRING" }, { "id": "a1b2c3d4-5678-90ab-cdef-99999EXAMPLE", "name": "Total Generated Power", "dataType": "DOUBLE", "unit": "kW" } ], "assetHierarchies": [ { "id": "a1b2c3d4-5678-90ab-cdef-77777EXAMPLE", "name": "Wind Turbines" } ], "assetCreationDate": 1575672453.0, "assetLastUpdateDate": 1575672453.0, "assetStatus": { "state": "ACTIVE" } }如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的描述特定資產。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 DescribeAsset
。
-
以下程式碼範例顯示如何使用 describe-dashboard。
- AWS CLI
-
描述儀表板
下列
describe-dashboard範例說明指定的風力發電廠儀表板。aws iotsitewise describe-dashboard \ --dashboard-ida1b2c3d4-5678-90ab-cdef-fffffEXAMPLE輸出:
{ "dashboardId": "a1b2c3d4-5678-90ab-cdef-fffffEXAMPLE", "dashboardArn": "arn:aws:iotsitewise:us-west-2:123456789012:dashboard/a1b2c3d4-5678-90ab-cdef-fffffEXAMPLE", "dashboardName": "Wind Farm", "projectId": "a1b2c3d4-5678-90ab-cdef-eeeeeEXAMPLE", "dashboardDefinition": "{\"widgets\":[{\"type\":\"monitor-line-chart\",\"title\":\"Generated Power\",\"x\":0,\"y\":0,\"height\":3,\"width\":3,\"metrics\":[{\"label\":\"Power\",\"type\":\"iotsitewise\",\"assetId\":\"a1b2c3d4-5678-90ab-cdef-44444EXAMPLE\",\"propertyId\":\"a1b2c3d4-5678-90ab-cdef-99999EXAMPLE\"}]}]}", "dashboardCreationDate": "2020-05-01T20:32:12.228476348Z", "dashboardLastUpdateDate": "2020-05-01T20:32:12.228476348Z" }如需詳細資訊,請參閱 AWS IoT SiteWise Monitor 應用程式指南中的檢視儀表板。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 DescribeDashboard
。
-
以下程式碼範例顯示如何使用 describe-gateway-capability-configuration。
- AWS CLI
-
描述閘道功能
下列
describe-gateway-capability-configuration範例說明 OPC-UA 來源功能。aws iotsitewise describe-gateway-capability-configuration \ --gateway-ida1b2c3d4-5678-90ab-cdef-1a1a1EXAMPLE\ --capability-namespace"iotsitewise:opcuacollector:1"輸出:
{ "gatewayId": "a1b2c3d4-5678-90ab-cdef-1a1a1EXAMPLE", "capabilityNamespace": "iotsitewise:opcuacollector:1", "capabilityConfiguration": "{\"sources\":[{\"name\":\"Wind Farm #1\",\"endpoint\":{\"certificateTrust\":{\"type\":\"TrustAny\"},\"endpointUri\":\"opc.tcp://203.0.113.0:49320\",\"securityPolicy\":\"BASIC256\",\"messageSecurityMode\":\"SIGN_AND_ENCRYPT\",\"identityProvider\":{\"type\":\"Username\",\"usernameSecretArn\":\"arn:aws:secretsmanager:us-east-1:123456789012:secret:greengrass-factory1-auth-3QNDmM\"},\"nodeFilterRules\":[]},\"measurementDataStreamPrefix\":\"\"}]}", "capabilitySyncStatus": "IN_SYNC" }如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的設定資料來源。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 DescribeGatewayCapabilityConfiguration
。
-
以下程式碼範例顯示如何使用 describe-gateway。
- AWS CLI
-
描述閘道
下列
describe-gateway範例說明閘道。aws iotsitewise describe-gateway \ --gateway-ida1b2c3d4-5678-90ab-cdef-1a1a1EXAMPLE輸出:
{ "gatewayId": "a1b2c3d4-5678-90ab-cdef-1a1a1EXAMPLE", "gatewayName": "ExampleCorpGateway", "gatewayArn": "arn:aws:iotsitewise:us-west-2:123456789012:gateway/a1b2c3d4-5678-90ab-cdef-1a1a1EXAMPLE", "gatewayPlatform": { "greengrass": { "groupArn": "arn:aws:greengrass:us-west-2:123456789012:/greengrass/groups/a1b2c3d4-5678-90ab-cdef-1b1b1EXAMPLE" } }, "gatewayCapabilitySummaries": [ { "capabilityNamespace": "iotsitewise:opcuacollector:1", "capabilitySyncStatus": "IN_SYNC" } ], "creationDate": 1588369971.457, "lastUpdateDate": 1588369971.457 }如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的使用閘道擷取資料。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 DescribeGateway
。
-
以下程式碼範例顯示如何使用 describe-logging-options。
- AWS CLI
-
擷取目前的 AWS IoT SiteWise 記錄選項
下列
describe-logging-options範例會擷取目前區域中 AWS 您帳戶的目前 AWS IoT SiteWise 記錄選項。aws iotsitewise describe-logging-options輸出:
{ "loggingOptions": { "level": "INFO" } }如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的使用 Amazon CloudWatch Logs 監控IoT SiteWise。 AWS IoT SiteWise
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 DescribeLoggingOptions
。
-
以下程式碼範例顯示如何使用 describe-portal。
- AWS CLI
-
描述入口網站
下列
describe-portal範例說明風力發電廠公司的 Web 入口網站。aws iotsitewise describe-portal \ --portal-ida1b2c3d4-5678-90ab-cdef-aaaaaEXAMPLE輸出:
{ "portalId": "a1b2c3d4-5678-90ab-cdef-aaaaaEXAMPLE", "portalArn": "arn:aws:iotsitewise:us-west-2:123456789012:portal/a1b2c3d4-5678-90ab-cdef-aaaaaEXAMPLE", "portalName": "WindFarmPortal", "portalDescription": "A portal that contains wind farm projects for Example Corp.", "portalClientId": "E-a1b2c3d4e5f6_a1b2c3d4e5f6EXAMPLE", "portalStartUrl": "https://a1b2c3d4-5678-90ab-cdef-aaaaaEXAMPLE.app.iotsitewise.aws", "portalContactEmail": "support@example.com", "portalStatus": { "state": "ACTIVE" }, "portalCreationDate": "2020-02-04T23:01:52.90248068Z", "portalLastUpdateDate": "2020-02-04T23:01:52.90248078Z", "roleArn": "arn:aws:iam::123456789012:role/MySiteWiseMonitorServiceRole" }如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的管理入口網站。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 DescribePortal
。
-
以下程式碼範例顯示如何使用 describe-project。
- AWS CLI
-
描述專案
下列
describe-project範例說明風力發電廠專案。aws iotsitewise describe-project \ --project-ida1b2c3d4-5678-90ab-cdef-eeeeeEXAMPLE輸出:
{ "projectId": "a1b2c3d4-5678-90ab-cdef-eeeeeEXAMPLE", "projectArn": "arn:aws:iotsitewise:us-west-2:123456789012:project/a1b2c3d4-5678-90ab-cdef-eeeeeEXAMPLE", "projectName": "Wind Farm 1", "portalId": "a1b2c3d4-5678-90ab-cdef-aaaaaEXAMPLE", "projectDescription": "Contains asset visualizations for Wind Farm #1 for Example Corp.", "projectCreationDate": "2020-02-20T21:58:43.362246001Z", "projectLastUpdateDate": "2020-02-20T21:58:43.362246095Z" }如需詳細資訊,請參閱 AWS IoT SiteWise Monitor 應用程式指南中的檢視專案詳細資訊。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 DescribeProject
。
-
以下程式碼範例顯示如何使用 disassociate-assets。
- AWS CLI
-
取消子資產與父資產的關聯
下列
disassociate-assets範例會取消風力發電機資產與風力發電廠資產的關聯。aws iotsitewise disassociate-assets \ --asset-ida1b2c3d4-5678-90ab-cdef-44444EXAMPLE\ --hierarchy-ida1b2c3d4-5678-90ab-cdef-77777EXAMPLE\ --child-asset-ida1b2c3d4-5678-90ab-cdef-33333EXAMPLE此命令不會產生輸出。
如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的關聯資產。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 DisassociateAssets
。
-
以下程式碼範例顯示如何使用 get-asset-property-aggregates。
- AWS CLI
-
擷取資產屬性的彙總平均值和計數值
下列
get-asset-property-aggregates範例會擷取風力渦輪機資產的平均總功率,以及 1 小時內的總功率資料點計數。aws iotsitewise get-asset-property-aggregates \ --asset-ida1b2c3d4-5678-90ab-cdef-33333EXAMPLE\ --property-ida1b2c3d4-5678-90ab-cdef-66666EXAMPLE\ --start-date1580849400\ --end-date1580853000\ --aggregate-typesAVERAGECOUNT\ --resolution1h輸出:
{ "aggregatedValues": [ { "timestamp": 1580850000.0, "quality": "GOOD", "value": { "average": 8723.46538886233, "count": 12.0 } } ] }如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的查詢資產屬性彙總。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 GetAssetPropertyAggregates
。
-
以下程式碼範例顯示如何使用 get-asset-property-value-history。
- AWS CLI
-
擷取資產屬性的歷史值
下列
get-asset-property-value-history範例會擷取 20 分鐘內風力渦輪機資產的總功率值。aws iotsitewise get-asset-property-value-history \ --asset-ida1b2c3d4-5678-90ab-cdef-33333EXAMPLE\ --property-ida1b2c3d4-5678-90ab-cdef-66666EXAMPLE\ --start-date1580851800\ --end-date1580853000輸出:
{ "assetPropertyValueHistory": [ { "value": { "doubleValue": 7217.787046814844 }, "timestamp": { "timeInSeconds": 1580852100, "offsetInNanos": 0 }, "quality": "GOOD" }, { "value": { "doubleValue": 6941.242811875451 }, "timestamp": { "timeInSeconds": 1580852400, "offsetInNanos": 0 }, "quality": "GOOD" }, { "value": { "doubleValue": 6976.797662266717 }, "timestamp": { "timeInSeconds": 1580852700, "offsetInNanos": 0 }, "quality": "GOOD" }, { "value": { "doubleValue": 6890.8677520453875 }, "timestamp": { "timeInSeconds": 1580853000, "offsetInNanos": 0 }, "quality": "GOOD" } ] }如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的查詢歷史資產屬性值。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 GetAssetPropertyValueHistory
。
-
以下程式碼範例顯示如何使用 get-asset-property-value。
- AWS CLI
-
擷取資產屬性的目前值
下列
get-asset-property-value範例會擷取風力渦輪機資產目前的總功率。aws iotsitewise get-asset-property-value \ --asset-ida1b2c3d4-5678-90ab-cdef-33333EXAMPLE\ --property-ida1b2c3d4-5678-90ab-cdef-66666EXAMPLE輸出:
{ "propertyValue": { "value": { "doubleValue": 6890.8677520453875 }, "timestamp": { "timeInSeconds": 1580853000, "offsetInNanos": 0 }, "quality": "GOOD" } }如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的查詢目前的資產屬性值。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 GetAssetPropertyValue
。
-
以下程式碼範例顯示如何使用 list-access-policies。
- AWS CLI
-
列出所有存取政策
下列
list-access-policies範例列出入口網站管理員使用者的所有存取政策。aws iotsitewise list-access-policies \ --identity-typeUSER\ --identity-ida1b2c3d4e5-a1b2c3d4-5678-90ab-cdef-bbbbbEXAMPLE輸出:
{ "accessPolicySummaries": [ { "id": "a1b2c3d4-5678-90ab-cdef-cccccEXAMPLE", "identity": { "user": { "id": "a1b2c3d4e5-a1b2c3d4-5678-90ab-cdef-bbbbbEXAMPLE" } }, "resource": { "portal": { "id": "a1b2c3d4-5678-90ab-cdef-aaaaaEXAMPLE" } }, "permission": "ADMINISTRATOR" } ] }如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的管理入口網站。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 ListAccessPolicies
。
-
以下程式碼範例顯示如何使用 list-asset-models。
- AWS CLI
-
列出所有資產模型
下列
list-asset-models範例列出目前區域中 AWS 您帳戶中定義的所有資產模型。aws iotsitewise list-asset-models輸出:
{ "assetModelSummaries": [ { "id": "a1b2c3d4-5678-90ab-cdef-22222EXAMPLE", "arn": "arn:aws:iotsitewise:us-west-2:123456789012:asset-model/a1b2c3d4-5678-90ab-cdef-22222EXAMPLE", "name": "Wind Farm Model", "description": "Represents a wind farm that comprises many wind turbines", "creationDate": 1575671284.0, "lastUpdateDate": 1575671988.0, "status": { "state": "ACTIVE" } }, { "id": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE", "arn": "arn:aws:iotsitewise:us-west-2:123456789012:asset-model/a1b2c3d4-5678-90ab-cdef-11111EXAMPLE", "name": "Wind Turbine Model", "description": "Represents a wind turbine manufactured by Example Corp", "creationDate": 1575671207.0, "lastUpdateDate": 1575686273.0, "status": { "state": "ACTIVE" } } ] }如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的列出所有資產模型。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 ListAssetModels
。
-
以下程式碼範例顯示如何使用 list-assets。
- AWS CLI
-
範例 1:列出所有最上層資產
下列
list-assets範例列出資產階層樹狀結構中最上層並在目前區域中 AWS 的帳戶中定義的所有資產。aws iotsitewise list-assets \ --filterTOP_LEVEL輸出:
{ "assetSummaries": [ { "id": "a1b2c3d4-5678-90ab-cdef-44444EXAMPLE", "arn": "arn:aws:iotsitewise:us-west-2:123456789012:asset/a1b2c3d4-5678-90ab-cdef-44444EXAMPLE", "name": "Wind Farm 1", "assetModelId": "a1b2c3d4-5678-90ab-cdef-22222EXAMPLE", "creationDate": 1575672453.0, "lastUpdateDate": 1575672453.0, "status": { "state": "ACTIVE" }, "hierarchies": [ { "id": "a1b2c3d4-5678-90ab-cdef-77777EXAMPLE", "name": "Wind Turbines" } ] } ] }如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的列出資產。
範例 2:根據資產模型列出所有資產
下列
list-assets範例會根據資產模型列出所有資產,並在目前區域中的 AWS 帳戶中定義。aws iotsitewise list-assets \ --asset-model-ida1b2c3d4-5678-90ab-cdef-11111EXAMPLE輸出:
{ "assetSummaries": [ { "id": "a1b2c3d4-5678-90ab-cdef-33333EXAMPLE", "arn": "arn:aws:iotsitewise:us-west-2:123456789012:asset/a1b2c3d4-5678-90ab-cdef-33333EXAMPLE", "name": "Wind Turbine 1", "assetModelId": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE", "creationDate": 1575671550.0, "lastUpdateDate": 1575686308.0, "status": { "state": "ACTIVE" }, "hierarchies": [] } ] }如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的列出資產。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 ListAssets
。
-
以下程式碼範例顯示如何使用 list-associated-assets。
- AWS CLI
-
列出與特定階層中的資產相關聯的所有資產
下列
list-associated-assets範例列出與指定風力發電廠資產相關聯的所有風力發電機資產。aws iotsitewise list-associated-assets \ --asset-ida1b2c3d4-5678-90ab-cdef-44444EXAMPLE\ --hierarchy-ida1b2c3d4-5678-90ab-cdef-77777EXAMPLE輸出:
{ "assetSummaries": [ { "id": "a1b2c3d4-5678-90ab-cdef-33333EXAMPLE", "arn": "arn:aws:iotsitewise:us-west-2:123456789012:asset/a1b2c3d4-5678-90ab-cdef-33333EXAMPLE", "name": "Wind Turbine 1", "assetModelId": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE", "creationDate": 1575671550.0, "lastUpdateDate": 1575686308.0, "status": { "state": "ACTIVE" }, "hierarchies": [] } ] }如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的列出與特定資產相關聯的資產。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 ListAssociatedAssets
。
-
以下程式碼範例顯示如何使用 list-dashboards。
- AWS CLI
-
列出專案中的所有儀表板
下列
list-dashboards範例列出專案中定義的所有儀表板。aws iotsitewise list-dashboards \ --project-ida1b2c3d4-5678-90ab-cdef-eeeeeEXAMPLE輸出:
{ "dashboardSummaries": [ { "id": "a1b2c3d4-5678-90ab-cdef-fffffEXAMPLE", "name": "Wind Farm", "creationDate": "2020-05-01T20:32:12.228476348Z", "lastUpdateDate": "2020-05-01T20:32:12.228476348Z" } ] }如需詳細資訊,請參閱 AWS IoT SiteWise Monitor 應用程式指南中的檢視儀表板。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 ListDashboards
。
-
以下程式碼範例顯示如何使用 list-gateways。
- AWS CLI
-
列出所有閘道
下列
list-gateways範例列出目前區域中 AWS 您帳戶中定義的所有閘道。aws iotsitewise list-gateways輸出:
{ "gatewaySummaries": [ { "gatewayId": "a1b2c3d4-5678-90ab-cdef-1a1a1EXAMPLE", "gatewayName": "ExampleCorpGateway", "gatewayCapabilitySummaries": [ { "capabilityNamespace": "iotsitewise:opcuacollector:1", "capabilitySyncStatus": "IN_SYNC" } ], "creationDate": 1588369971.457, "lastUpdateDate": 1588369971.457 } ] }如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的使用閘道擷取資料。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 ListGateways
。
-
以下程式碼範例顯示如何使用 list-portals。
- AWS CLI
-
列出所有入口網站
下列
list-portals範例列出目前區域中 AWS 您帳戶中定義的所有入口網站。aws iotsitewise list-portals輸出:
{ "portalSummaries": [ { "id": "a1b2c3d4-5678-90ab-cdef-aaaaaEXAMPLE", "name": "WindFarmPortal", "description": "A portal that contains wind farm projects for Example Corp.", "startUrl": "https://a1b2c3d4-5678-90ab-cdef-aaaaaEXAMPLE.app.iotsitewise.aws", "creationDate": "2020-02-04T23:01:52.90248068Z", "lastUpdateDate": "2020-02-04T23:01:52.90248078Z", "roleArn": "arn:aws:iam::123456789012:role/service-role/MySiteWiseMonitorServiceRole" } ] }如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的管理入口網站。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 ListPortals
。
-
以下程式碼範例顯示如何使用 list-project-assets。
- AWS CLI
-
列出與專案相關聯的所有資產
下列
list-project-assets範例列出與風力發電廠專案相關聯的所有資產。aws iotsitewise list-projects \ --project-ida1b2c3d4-5678-90ab-cdef-eeeeeEXAMPLE輸出:
{ "assetIds": [ "a1b2c3d4-5678-90ab-cdef-44444EXAMPLE" ] }如需詳細資訊,請參閱 AWS IoT SiteWise Monitor 應用程式指南中的將資產新增至專案。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 ListProjectAssets
。
-
以下程式碼範例顯示如何使用 list-projects。
- AWS CLI
-
列出入口網站中的所有專案
下列
list-projects範例列出入口網站中定義的所有專案。aws iotsitewise list-projects \ --portal-ida1b2c3d4-5678-90ab-cdef-aaaaaEXAMPLE輸出:
{ "projectSummaries": [ { "id": "a1b2c3d4-5678-90ab-cdef-eeeeeEXAMPLE", "name": "Wind Farm 1", "description": "Contains asset visualizations for Wind Farm #1 for Example Corp.", "creationDate": "2020-02-20T21:58:43.362246001Z", "lastUpdateDate": "2020-02-20T21:58:43.362246095Z" } ] }如需詳細資訊,請參閱 AWS IoT SiteWise Monitor 應用程式指南中的檢視專案詳細資訊。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 ListProjects
。
-
以下程式碼範例顯示如何使用 list-tags-for-resource。
- AWS CLI
-
列出資源的所有標籤
下列
list-tags-for-resource範例列出風力發電機資產的所有標籤。aws iotsitewise list-tags-for-resource \ --resource-arnarn:aws:iotsitewise:us-west-2:123456789012:asset/a1b2c3d4-5678-90ab-cdef-33333EXAMPLE輸出:
{ "tags": { "Owner": "richard-roe" } }如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的標記您的資源。
-
如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 ListTagsForResource
。
-
以下程式碼範例顯示如何使用 put-logging-options。
- AWS CLI
-
指定記錄層級
下列
put-logging-options範例會在 AWS IoT SiteWise 中啟用INFO關卡記錄。其他層級包括DEBUG和OFF。aws iotsitewise put-logging-options \ --logging-optionslevel=INFO此命令不會產生輸出。
如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的使用 Amazon CloudWatch Logs 監控IoT SiteWise。 AWS IoT SiteWise
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 PutLoggingOptions
。
-
以下程式碼範例顯示如何使用 tag-resource。
- AWS CLI
-
將標籤加入資源
下列
tag-resource範例會將擁有者標籤新增至風力渦輪機資產。這可讓您根據擁有資產的人員來控制對資產的存取。aws iotsitewise tag-resource \ --resource-arnarn:aws:iotsitewise:us-west-2:123456789012:asset/a1b2c3d4-5678-90ab-cdef-33333EXAMPLE\ --tagsOwner=richard-roe此命令不會產生輸出。
如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的標記您的資源。
-
如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 TagResource
。
-
以下程式碼範例顯示如何使用 untag-resource。
- AWS CLI
-
從資源移除標籤
下列
untag-resource範例會從風力渦輪機資產移除擁有者標籤。aws iotsitewise untag-resource \ --resource-arnarn:aws:iotsitewise:us-west-2:123456789012:asset/a1b2c3d4-5678-90ab-cdef-33333EXAMPLE\ --tag-keysOwner此命令不會產生輸出。
如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的標記您的資源。
-
如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 UntagResource
。
-
以下程式碼範例顯示如何使用 update-access-policy。
- AWS CLI
-
授予專案的專案檢視器擁有權
下列
update-access-policy範例會更新授予專案檢視器擁有權的存取政策。aws iotsitewise update-access-policy \ --access-policy-ida1b2c3d4-5678-90ab-cdef-dddddEXAMPLE\ --cli-input-jsonfile://update-project-viewer-access-policy.jsonupdate-project-viewer-access-policy.json的內容:{ "accessPolicyIdentity": { "user": { "id": "a1b2c3d4e5-a1b2c3d4-5678-90ab-cdef-bbbbbEXAMPLE" } }, "accessPolicyPermission": "ADMINISTRATOR", "accessPolicyResource": { "project": { "id": "a1b2c3d4-5678-90ab-cdef-eeeeeEXAMPLE" } } }此命令不會產生輸出。
如需詳細資訊,請參閱 AWS IoT SiteWise Monitor 應用程式指南中的指派專案擁有者。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 UpdateAccessPolicy
。
-
以下程式碼範例顯示如何使用 update-asset-model。
- AWS CLI
-
更新資產模型
下列
update-asset-model範例會更新風力發電廠資產模型的描述。此範例包含模型的現有 IDs和定義,因為 會使用新模型update-asset-model覆寫現有模型。aws iotsitewise update-asset-model \ --cli-input-jsonfile://update-wind-farm-model.jsonupdate-wind-farm-model.json的內容:{ "assetModelName": "Wind Farm Model", "assetModelDescription": "Represents a wind farm that comprises many wind turbines", "assetModelProperties": [ { "id": "a1b2c3d4-5678-90ab-cdef-88888EXAMPLE", "name": "Region", "dataType": "STRING", "type": { "attribute": {} } }, { "id": "a1b2c3d4-5678-90ab-cdef-99999EXAMPLE", "name": "Total Generated Power", "dataType": "DOUBLE", "unit": "kW", "type": { "metric": { "expression": "sum(power)", "variables": [ { "name": "power", "value": { "hierarchyId": "a1b2c3d4-5678-90ab-cdef-77777EXAMPLE", "propertyId": "a1b2c3d4-5678-90ab-cdef-66666EXAMPLE" } } ], "window": { "tumbling": { "interval": "1h" } } } } } ], "assetModelHierarchies": [ { "id": "a1b2c3d4-5678-90ab-cdef-77777EXAMPLE", "name": "Wind Turbines", "childAssetModelId": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE" } ] }輸出:
{ "assetModelId": "a1b2c3d4-5678-90ab-cdef-22222EXAMPLE", "assetModelArn": "arn:aws:iotsitewise:us-west-2:123456789012:asset-model/a1b2c3d4-5678-90ab-cdef-22222EXAMPLE", "assetModelStatus": { "state": "CREATING" } }如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的更新資產模型。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 UpdateAssetModel
。
-
以下程式碼範例顯示如何使用 update-asset-property。
- AWS CLI
-
範例 1:更新資產屬性的別名
下列
update-asset-property範例會更新風力渦輪機資產的電源屬性別名。aws iotsitewise update-asset-property \ --asset-ida1b2c3d4-5678-90ab-cdef-33333EXAMPLE\ --property-ida1b2c3d4-5678-90ab-cdef-55555EXAMPLE\ --property-alias"/examplecorp/windfarm/1/turbine/1/power"\ --property-notification-stateDISABLED此命令不會產生輸出。
如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的將工業資料串流映射至資產屬性。
範例 2:啟用資產屬性通知
下列
update-asset-property範例會啟用風力渦輪機資產功率屬性的資產屬性更新通知。屬性值更新會發佈至 MQTT 主題$aws/sitewise/asset-models/<assetModelId>/assets/<assetId>/properties/<propertyId>,其中每個 ID 都會取代為資產屬性的屬性、資產和模型 ID。aws iotsitewise update-asset-property \ --asset-ida1b2c3d4-5678-90ab-cdef-33333EXAMPLE\ --property-ida1b2c3d4-5678-90ab-cdef-66666EXAMPLE\ --property-notification-stateENABLED\ --property-alias"/examplecorp/windfarm/1/turbine/1/power"此命令不會產生輸出。
如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的與其他 服務互動。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 UpdateAssetProperty
。
-
以下程式碼範例顯示如何使用 update-asset。
- AWS CLI
-
更新資產的名稱
下列
update-asset範例會更新風力發電機資產的名稱。aws iotsitewise update-asset \ --asset-ida1b2c3d4-5678-90ab-cdef-33333EXAMPLE\ --asset-name"Wind Turbine 2"輸出:
{ "assetStatus": { "state": "UPDATING" } }如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的更新資產。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 UpdateAsset
。
-
以下程式碼範例顯示如何使用 update-dashboard。
- AWS CLI
-
更新儀表板
下列
update-dashboard範例會變更儀表板折線圖的標題,顯示風力發電廠的總產生功率。aws iotsitewise update-dashboard \ --project-ida1b2c3d4-5678-90ab-cdef-fffffEXAMPLE\ --dashboard-name"Wind Farm"\ --dashboard-definitionfile://update-wind-farm-dashboard.jsonupdate-wind-farm-dashboard.json的內容:{ "widgets": [ { "type": "monitor-line-chart", "title": "Total Generated Power", "x": 0, "y": 0, "height": 3, "width": 3, "metrics": [ { "label": "Power", "type": "iotsitewise", "assetId": "a1b2c3d4-5678-90ab-cdef-44444EXAMPLE", "propertyId": "a1b2c3d4-5678-90ab-cdef-99999EXAMPLE" } ] } ] }此命令不會產生輸出。
如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的建立儀表板 (CLI)。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 UpdateDashboard
。
-
以下程式碼範例顯示如何使用 update-gateway-capability-configuration。
- AWS CLI
-
更新閘道功能
下列
update-gateway-capability-configuration範例會設定具有下列屬性的 OPC-UA 來源:信任任何憑證。使用 Basic256 演算法來保護訊息。使用 SignAndEncrypt 模式來保護連線。使用存放在 AWS Secrets Manager 秘密中的身分驗證憑證。
aws iotsitewise update-gateway-capability-configuration \ --gateway-ida1b2c3d4-5678-90ab-cdef-1a1a1EXAMPLE\ --capability-namespace"iotsitewise:opcuacollector:1"\ --capability-configurationfile://opc-ua-capability-configuration.jsonopc-ua-capability-configuration.json的內容:{ "sources": [ { "name": "Wind Farm #1", "endpoint": { "certificateTrust": { "type": "TrustAny" }, "endpointUri": "opc.tcp://203.0.113.0:49320", "securityPolicy": "BASIC256", "messageSecurityMode": "SIGN_AND_ENCRYPT", "identityProvider": { "type": "Username", "usernameSecretArn": "arn:aws:secretsmanager:us-west-2:123456789012:secret:greengrass-windfarm1-auth-1ABCDE" }, "nodeFilterRules": [] }, "measurementDataStreamPrefix": "" } ] }輸出:
{ "capabilityNamespace": "iotsitewise:opcuacollector:1", "capabilitySyncStatus": "OUT_OF_SYNC" }如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的設定資料來源。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 UpdateGatewayCapabilityConfiguration
。
-
以下程式碼範例顯示如何使用 update-gateway。
- AWS CLI
-
更新閘道的名稱
下列
update-gateway範例會更新閘道的名稱。aws iotsitewise update-gateway \ --gateway-ida1b2c3d4-5678-90ab-cdef-1a1a1EXAMPLE\ --gateway-nameExampleCorpGateway1此命令不會產生輸出。
如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的使用閘道擷取資料。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 UpdateGateway
。
-
以下程式碼範例顯示如何使用 update-portal。
- AWS CLI
-
更新入口網站的詳細資訊
下列
update-portal範例會更新風力發電廠公司的 Web 入口網站。aws iotsitewise update-portal \ --portal-ida1b2c3d4-5678-90ab-cdef-aaaaaEXAMPLE\ --portal-nameWindFarmPortal\ --portal-description"A portal that contains wind farm projects for Example Corp."\ --portal-contact-emailsupport@example.com\ --role-arnarn:aws:iam::123456789012:role/MySiteWiseMonitorServiceRole輸出:
{ "portalStatus": { "state": "UPDATING" } }如需詳細資訊,請參閱 AWS IoT SiteWise 使用者指南中的管理入口網站。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 UpdatePortal
。
-
以下程式碼範例顯示如何使用 update-project。
- AWS CLI
-
更新專案的詳細資訊
下列
update-project範例會更新風力發電廠專案。aws iotsitewise update-project \ --project-ida1b2c3d4-5678-90ab-cdef-eeeeeEXAMPLE\ --project-name"Wind Farm 1"\ --project-description"Contains asset visualizations for Wind Farm #1 for Example Corp."此命令不會產生輸出。
如需詳細資訊,請參閱 AWS IoT SiteWise Monitor 應用程式指南中的變更專案詳細資訊。
-
如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 UpdateProject
。
-