This article discusses how a partner using Plantronics(PLT) /Streams api can get events streams available for them at PLT tenant level and get metadata needed to listen for events streams from them as well as start and stop stream requests for a tenant.
The following sequence of API calls will illustrate the API interactions needed to establish a real time stream:
- Once a partner has registered using partner provisioning APIs on to PLT cloud entitlement, partners will be given a id similar to. All APIs calls to PLT with a partner_id header. (partner_id: <ID)). This will be used by the APIs to identify the partner.
- On Swagger UI, the following APIs should show up (under 'streams'):
3. Get access to all streams available by tenant will be as below:
curl -X GET -H "Content-Type: application/json" -H "charset: UTF-8" -H "partner_id: e69130ce-64db-4d9d-805e-e3738bde4dd5" -H "Cache-Control: no-cache" -H "Postman-Token: 613bf921-02c9-83bb-3b53-3ae0a84ab0a3" "http://localhost:8090/v1/realtime/streams"
The reponse seen on Swagger UI here:
The above response contains the id for the subscription, the tenant name, id and stream name and id.
4. Next, the partner can get more metadata for requesting a start for a stream. Header : partner id & path paramter stream id obtained from the previous call. The response contains
Curl:
curl -X GET --header 'Accept: application/json' --header 'partner_id: e69130ce-64db-4d9d-805e-e3738bde4dd5'
'http://localhost:8090/v1/realtime/streams/3e39258f-c888-4cfa-a6d1-63f4ccb77ac7'
{
"typeId": "3e39258f-c888-4cfa-a6d1-63f4ccb77ac7",
"streamName": "QUICKDISCONNECT",
"notificationType": "pubnub",
"pubKey": null,
"subKey": "sub-c-cf5b662a-0da9-11e6-996b-0619f8945a4f",
"pubChannel": null,
"subChannel": [
"e69130ce-64db-4d9d-805e-e3738bde4dd5_sub1"
],
"isPublishOnly": false,
"isSubscribeOnly": false,
"partnerId": "e69130ce-64db-4d9d-805e-e3738bde4dd5",
"tenantId": "dc560b50-9e20-41b9-a76b-d32ebfbdcd7a"
}
The above subKey should be used by partner application for subscribing to a pub nub channel under subChannel list.
5. Next step, is to initiate starting the event stream ingestion to the PLT Cloud :
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/xml' --header 'partner_id: e69130ce-64db-4d9d-805e-e3738bde4dd5' 'http://localhost:8090/v1/realtime/streams/3e39258f-c888-4cfa-a6d1-63f4ccb77ac7/start'
This will instantiate PLT cloud to signal Hub for the tenant to start ingesting in real time the specific stream id. A successful response 200 would signify the stream will be started.
6. A stop would be close to start semantic. The following screen shot illustrates that: