设备接入 IOTDA-创建设备策略:请求示例

时间:2024-06-28 09:24:33

请求示例

  • 创建设备策略-允许设备订阅与发布指定topic

    POST https://{endpoint}/v5/iot/{project_id}/device-policies
    
    {
      "policy_name" : "myPolicyAllow",
      "app_id" : "jeQDJQZltU8iKgFFoW060F5SGZka",
      "statement" : [ {
        "effect" : "ALLOW",
        "actions" : [ "iotda:devices:publish\niotda:devices:subscribe" ],
        "resources" : [ "topic:/v1/${devices.deviceId}/test/allow" ]
      } ]
    }
  • 创建设备策略-不允许设备订阅与发布指定topic

    POST https://{endpoint}/v5/iot/{project_id}/device-policies
    
    {
      "policy_name" : "myPolicyDeny",
      "app_id" : "jeQDJQZltU8iKgFFoW060F5SGZka",
      "statement" : [ {
        "effect" : "DENY",
        "actions" : [ "iotda:devices:publish\niotda:devices:subscribe" ],
        "resources" : [ "topic:/v1/${devices.deviceId}/test/deny" ]
      } ]
    }
support.huaweicloud.com/api-iothub/CreateDevicePolicy.html