跳到主要内容

创建订阅

设置并配置数据收集器后,创建订阅以将您的主机托管数据传输到该数据收集器。

注意

您只能在贵组织中使用一种通信渠道类型。例如,如果您使用AWS物联网核心渠道创建订阅,则无法使用其他渠道类型创建其他订阅。

单个订阅仅允许一个频道。

先决条件​

  • 在调用订阅管理API之前,请参阅与收集器集成,为您的数据设置和配置目标。

  • 提交您的用户凭据,客户端ID和客户端机密以进行OAuth2验证。有关如何向Equinix API验证请求的更多信息,请参阅API验证。

AWS IoT Core​

要创建订阅以将数据发送至Amazon IoT Core,请向端点发送POST请求/smartview/v2/streaming/subscriptions。在请求正文中,在中指定channelTypeASAWS_IOT_CORE及其URLawsIotCoreChannelConfiguration。 指定应在对象中接收哪些数据messageType。

cURL 请求示例:

curl -X 
POST 'https://api.equinix.com/smartview/v2/streaming/subscriptions'
-H 'content-type: application/json'
-H 'authorization: Bearer <token>'
-d '{
    "messageType": {
        "asset": [],
        "environmental": [
            {
                "accountNumber": "116710",
                "ibx": [
                    "LD9"
                ],
                "level": [
                    "CAGE"
                ]
            }
        ],
        "power": [],
        "meteredPower": [],
        "systemAlert": [],
        "customAlert": []
    },
    "channel": {
        "channelType": "AWS_IOT_CORE",
        "awsIotCoreChannelConfiguration": {
            "url": "https://<awsIotCoreuri>.amazonaws.com"
        }
    }
}' 

可用选项的完整列表messageType,请参阅《API参考手册》。

Webhook​

要创建将数据发送至webhook的订阅,请向端点发送POST请求/smartview/v2/streaming/subscriptions。在请求正文中,在中指定channelTypeASWEBHOOK及其配置webhookChannelConfiguration。 指定应在对象中接收哪些数据messageType。

cURL 请求示例:

curl -X 
POST 'https://api.equinix.com/smartview/v2/streaming/subscriptions'
-H 'content-type: application/json'
-H 'authorization: Bearer <token>'
-d '{
    "messageType": {
        "asset": [],
        "environmental": [
            {
                "accountNumber": "116710",
                "ibx": [
                    "LD9"
                ],
                "level": [
                    "CAGE"
                ]
            }
        ],
        "power": [],
        "meteredPower": [],
        "systemAlert": [],
        "customAlert": []
    },
    "channel": {
        "channelType": "WEBHOOK",
        "webhookChannelConfiguration": {
"sslCertificate": "ZkFzZLY1IGRpY31kZXI=...",
"url": "https://<webhook-uri>.com",
"numberOfRetries": 1,
"numberOfConcurrentCalls": 20,
"batchSize": 5
},
    }
}' 

webhook配置选项和可用选项列表messageType,请参阅API参考手册。

Equinix REST API​

要创建订阅以从Equinix API获取您的数据,请向端点发送POST请求/smartview/v2/streaming/subscriptions。在请求正文中,指定channelTypeASREST。 指定应在对象中接收哪些数据messageType。

cURL 请求示例:

curl -X 
POST 'https://api.equinix.com/smartview/v2/streaming/subscriptions'
-H 'content-type: application/json'
-H 'authorization: Bearer <token>'
-d '{
    "messageType": {
        "asset": [],
        "environmental": [
            {
                "accountNumber": "116710",
                "ibx": [
                    "LD9"
                ],
                "level": [
                    "CAGE"
                ]
            }
        ],
        "power": [],
        "meteredPower": [],
        "systemAlert": [],
        "customAlert": []
    },
    channel": {
"channelType": "REST",
"restChannelConfiguration": {
}
}
}' 

可用选项的完整列表messageType,请参阅《API参考手册》。

示例回答:

HTTP/1.1 201 Created
Location: /smartview/v2/streaming/subscriptions/0f6bdb36-e130-4924-b038-ee1785fad999

Location响应中的标题包含使用实时源所需的订阅ID。

这个页面对您有帮助吗?