# 订阅管理 您可以使用以下 API 端点管理您的订阅。 ## 先决条件[​](#先决条件 "直接链接至先决条件") * 提交您的用户凭据,客户端ID和客户端机密以进行OAuth2验证。有关如何向Equinix API验证请求的更多信息,请参阅[API验证](https://docs.equinix.com/zh-Hans/equinix-api/api-authentication.md)。 ## 获取您的订阅[​](#获取您的订阅 "直接链接至获取您的订阅") 要返回所有流订阅列表,请向端点发送`GET`请求[`/smartview/v2/streaming/subscriptions`](https://docs.equinix.com/zh-Hans/api-catalog/smartviewv2/streaming-subscription-api/getallsubscriptions.md)。 cURL 请求示例: ``` curl -X GET 'https://api.equinix.com/smartview/v2/streaming/subscriptions' -H 'authorization: Bearer ' ``` 示例回答: ``` [ { "id": "606349eca6171829c70d8777", "status": "PENDING", "messageType": { "asset": [ { "accountNumber": "135888", "ibx": [ "DE2" ], "assetClassification": [ "MECHANICAL" ], "assetId": [ "string" ] } ], "environmental": [ { "accountNumber": "135888", "ibx": [ "DE2" ], "level": [ "ZONE" ] } ], "power": [ { "accountNumber": "135888", "ibx": [ "DE2" ] } ], "meteredPower": [ { "accountNumber": "135888", "ibx": [ "DE2" ] } ], "systemAlert": [ { "accountNumber": "135888", "ibx": [ "DE2" ] } ], "customAlert": [ { "accountNumber": "135888", "ibx": [ "DE2" ], "user": "abc" } ] }, "channel": { "channelType": "AWS_IOT_CORE", "awsIotCoreChannelConfiguration": { "url": "https://b4c3mzxe8syvhd-ats.iot.us-west-2.amazonaws.com" } }, "orgId": "123", "createdBy": "abc", "createdDateTime": "2019-08-24T14:15:22Z", "updatedBy": "abc", "updatedDateTime": "2019-08-24T14:15:22Z" } ] ``` ## 获取订阅详情[​](#获取订阅详情 "直接链接至获取订阅详情") 要获取指定订阅的详细信息,请向端点发送`GET`请求[`/smartview/v2/streaming/subscriptions/{id}`](https://docs.equinix.com/zh-Hans/api-catalog/smartviewv2/streaming-subscription-api/getsubscriptionbyid.md)。 cURL 请求示例: ``` curl -X GET 'https://api.equinix.com/smartview/v2/streaming/subscriptions/606349eca6171829c70d8777' -H 'authorization: Bearer ' ``` 示例回答: ``` { "id": "606349eca6171829c70d8777", "status": "ACTIVE", "messageType": { "asset": [ { "accountNumber": "135888", "ibx": [ "DE2" ], "assetClassification": [ "MECHANICAL" ], "assetId": [ "string" ] } ], "environmental": [ { "accountNumber": "135888", "ibx": [ "DE2" ], "level": [ "ZONE" ] } ], "power": [ { "accountNumber": "135888", "ibx": [ "DE2" ] } ], "meteredPower": [ { "accountNumber": "135888", "ibx": [ "DE2" ] } ], "systemAlert": [ { "accountNumber": "135888", "ibx": [ "DE2" ] } ], "customAlert": [ { "accountNumber": "135888", "ibx": [ "DE2" ], "user": "abc" } ] }, "channel": { "channelType": "AWS_IOT_CORE", "awsIotCoreChannelConfiguration": { "url": "https://b4c3mzxe8syvhd-ats.iot.us-west-2.amazonaws.com" } }, "orgId": "123", "createdBy": "abc", "createdDateTime": "2019-08-24T14:15:22Z", "updatedBy": "abc", "updatedDateTime": "2019-08-24T14:15:22Z" } ``` ## 更新订阅[​](#更新订阅 "直接链接至更新订阅") 要修改订阅,请向端点发送`PUT`请求[`/smartview/v2/streaming/subscriptions/{id}`](https://docs.equinix.com/zh-Hans/api-catalog/smartviewv2/streaming-subscription-api/updatesubscription.md)。新的请求主体取代了当前的订阅配置。 cURL 请求示例: ``` curl -X PUT 'https://api.equinix.com/smartview/v2/streaming/subscriptions/{id}' -H 'authorization: Bearer ' -d '{ "messageType": { "asset": [ { "accountNumber": "135888", "ibx": [ "DE2" ], "assetClassification": [ "MECHANICAL" ], "assetId": [ "string" ] } ], "environmental": [ { "accountNumber": "135888", "ibx": [ "DE2" ], "level": [ "ZONE" ] } ], "power": [ { "accountNumber": "135888", "ibx": [ "DE2" ] } ], "meteredPower": [ { "accountNumber": "135888", "ibx": [ "DE2" ] } ], "systemAlert": [ { "accountNumber": "135888", "ibx": [ "DE2" ] } ], "customAlert": [ { "accountNumber": "135888", "ibx": [ "DE2" ], "user": "abc" } ] }, "channel": { "channelType": "AWS_IOT_CORE", "awsIotCoreChannelConfiguration": { "url": "https://b4c3mzxe8syvhd-ats.iot.us-west-2.amazonaws.com" } } }' ``` ## 删除一个订阅[​](#删除一个订阅 "直接链接至删除一个订阅") 要删除订阅,请向端点发送`DELETE`请求[`/smartview/v2/streaming/subscriptions/{id}`](https://docs.equinix.com/zh-Hans/api-catalog/smartviewv2/streaming-subscription-api/deletesubscriptionbyid.md)。订阅收到删除请求后,事件将不再可供订阅使用。 cURL 请求示例: ``` curl -X DELETE 'https://api.equinix.com/smartview/v2/streaming/subscriptions/606349eca6171829c70d8777' -H 'authorization: Bearer ' ```