Pascal Maugeri

Control Room Automation with Event Center API

Blog Post created by Pascal Maugeri Employee on Jun 18, 2016


Introduction

This blog post describes a simple method to automate the creation of Event Center Control Rooms using the {OPEN} API Event Center. The idea is to create a Control Room template using the Luna User Interface and reuse this template when calling Event Center API. I successfully used this method during EURO 2016 event to create individual event for each of the football matches of the championship.

 

What do you need?

  1. a Luna Portal user account with sufficient privilege to create Event Center events (e.g. Admin),
  2. create a Client API (menu CONFIGURE > Manage APIs in Luna) with an active authorisation for using the Event Center API with a READ/WRITE access privilege,
  3. a working environment configured with the Client API credentials obtained when creating the Client API,
  4. install egcurl  in your working environment since this is the tool used here interact with the API.

 

 

Creating the Control Room Template

In this section, we will create the Control Room  that will be used as the template in the automation described below. Note that we could create this event template using the Event Center API, but I found it easier to create this first event using the User Interface of Luna that will provide user friendly form fields and list of possible values such as the stream IDs or sites CP Codes.

In Luna Portal go to menu PLAN then, in the Event Center section click Scheduler (see Figure 1).

 

     Figure 1: the Luna PLAN menu

 

A calendar will appear displaying all currently active Control Rooms. Click New Event button in order to create your Control Room template. Then configure your Control Room with the start/end dates, services, event name, etc. This should create a new event in the calendar, as shown in Figure 2.

 

     Figure 2: the control room is created and details are displayed

 

If the click the event in the calendar, it will display in right side the summary of the event creation and in particular the Event ID that we will use later on.

 

First calls to the Event Center API

The Event Center API is described in detailed here as part of the Akamai {OPEN} API documentation portal. You will find an overview of the API and a reference page presenting each of the call that the Rest API exposes to the developper.

 

Get an Event details

The API call Get an Event, with service details, is a HTTP GET request, with no body, that returns a JSON object with all the details about the event passed as parameter in the URL.

 

As decribed in reference page, the request should have the URL path: /events/v2/<accountId>/events/<eventId>

 

Example using egcurl (replace characters in bold by your settings):

$ egcurl --eg-config .egcurl --eg-section AkamaiPS -sSik --request GET --header "Content-Type: application/json" "https://akab-dktvlmb3ozd4gbmw-po4dxwf7zhn3eykq.luna.akamaiapis.net/events/v2/1-6JHGX/events/1952452?services=detail"

Remember that the <eventId> of your event can be easily obtained in the Control Room summary (see Figure 2).

$ egcurl --eg-config .egcurl --eg-section AkamaiPS -sSik --request GET --header "Content-Type: application/json" "<Base_URL>/events/v2/1-6JHGX/events/<Event_ID>?services=detail"

You should replace <Base_URL> by the https URL you retrieved from your Client API authorisation, and <Event_ID> by the event ID of your event template (see Figure 2).

 

If the API call run successfully, you should get this kind of result:

HTTP/1.1 200 OK

Server: Apache-Coyote/1.1

X-Content-Type-Options: nosniff

Pragma: no-cache

Expires: Thu, 01 Jan 1970 00:00:00 GMT

Cache-Control: no-cache

Cache-Control: no-store

Content-Type: application/json;charset=UTF-8

Content-Length: 921

Date: Fri, 17 Jun 2016 22:18:03 GMT

Connection: keep-alive

 

{"status":"ok","contents":{"id":1952452,"customerEventId":null,"version":4,"name":"EVENT TEMPLATE","description":null,"eventType":"STREAMING","customer":{"accountID":"1-6JHGX","accountName":"Akamai Professional Services","supportLevel":"STANDARD"},"start":1466177400000,"end":1466179200000,"createdDate":1466177668000,"createdBy":"pmaugeri","modifiedDate":1466184094000,"modifiedBy":"pmaugeri","audienceSize":0,"audienceLocations":[],"coordinators":["pmaugeri"],"locked":false,"tags":[],"services":{"universalLiveStreams":[{"streamId":223814,"streamName":"hls-stream1","enabledFormats":["APPLE_IOS"],"config":{"configId":20406,"configName":"hlshdsdash","hostname":"hlshdsdash-i.akamaihd.net","cpcode":{"cpcode":147484,"cpcodeName":"KM - HDN iPhone Live"}},"bitrates":[]}],"flashLiveStreams":[],"siteCPCodes":[],"sripConfigs":[],"silverlightLiveStreams":[],"qosmReportPackIds":[],"smReportPackIds":[]},"supportType":null}}

The part of the text in bold characters will be reused to create events based on this template.

 

Create a new event

To create event, we should send a POST request to the URL path /events/v2/<account_ID>/events. The body of the HTTP request should contain a JSON object similar to the one returned in the Get an Event section above.

 

However, since you want to create a new event you should not send the "id" field of the JSON object.

 

Hence the following command will create a new Event that is a copy of your template:

$ egcurl  --eg-config .egcurl --eg-section AkamaiPS -sSik --request POST --header "Content-Type: application/json" --data-binary '{"customerEventId":null,"version":1,"name":"My Control Room 1","description":null,"eventType":"STREAMING","customer":{"accountID":"1-6JHGX","accountName":"Akamai Professional Services","supportLevel":"STANDARD"},"start":1466177400000,"end":1466179200000,"createdDate":1466177668000,"createdBy":"pmaugeri","modifiedDate":1466177668000,"modifiedBy":"pmaugeri","audienceSize":0,"audienceLocations":[],"coordinators":["pmaugeri"],"locked":false,"tags":[],"services":{"universalLiveStreams":[{"streamId":223814,"streamName":"hls-stream1","enabledFormats":["APPLE_IOS"],"config":{"configId":20406,"configName":"hlshdsdash","hostname":"hlshdsdash-i.akamaihd.net","cpcode":{"cpcode":147484,"cpcodeName":"KM - HDN iPhone Live"}},"bitrates":[]}],"flashLiveStreams":[],"siteCPCodes":[],"sripConfigs":[],"silverlightLiveStreams":[],"qosmReportPackIds":[],"smReportPackIds":[]},"supportType":null}' '<Base_URL>/events/v2/1-6JHGX/events'

 

 

Automate creation of Control Room

It is now very simple to reuse the API call described in Create an Event section to create all the events you need. The only fields you would need to adapt in the JSON object sent are start (timestamp in milliseconds of the beginning of the event), end ((timestamp in milliseconds of the end of the event) and of course the name of the event to be created.

 

I recommend you to start describing all your events to be created in a spreadsheet. Then you export this spreadsheet to CSV and you can easily automate creation of the events with a simple shell script.

 

You can also explore other calls that the API offers you in the reference page. You will probably find useful to clean event Remove an Event that you created by errors, or creating a recurring event with Create a Recurring Event.

Outcomes