Cisco Cisco Prime Home 6.3 Developer's Guide

Page of 78
Cisco Prime Home – Integration Guide
 
 
OL-28557-01   v5.0.1
 
55 
*/ 
def setRMA(sn: String, oui: String): DeviceData = { 
val rmaFor = new JSONObject 
rmaFor 
.put("sn", sn) 
.put("oui", oui) 
json.put("rmaFor", rmaFor) 
this 

 
/** 

*/ 
def setApplicationDTO(applicationCode: String, name: String, value: 
String): DeviceData = { 
json 
.getJSONObject("applications") 
.getJSONObject(applicationCode) 
.getJSONObject("dto") 
.deepPut(name, value) 
this 
 
 
DeviceService.scala 
 
package com.clearaccess.example.api 
 
import org.springframework.beans.factory.annotation.Autowired 
import com.clearaccess.spring.rest.RestTemplate 
import com.clearaccess.example.HttpConfiguration 
import org.springframework.stereotype.Component 
import org.json.JSONObject 
 
@Component 
class DeviceService @Autowired()( 
val restTemplate: RestTemplate, 
val httpConfiguration: HttpConfiguration 
) extends JSONHelpers { 
private def devicesUrl: String = 
 
"http://%s/prime-home/api/v1/devices".format(httpConfiguration.host) 
 
private def deviceTemplateUrl: String = 
 
"http://%s/prime-
home/api/v1/templates/device".format(httpConfiguration.host) 
 
private def deviceDataUrl(deviceId: Long): String = 
 
"http://%s/prime-
home/api/v1/devices/%d/data".format(httpConfiguration.host, deviceId) 
 
private def deviceUrl(deviceId: Long): String = 
 
"http://%s/prime-home/api/v1/devices/%d".format(httpConfiguration. 
host, deviceId) 
 
private def deviceActionsUrl(deviceId: Long): String = 
 
"http://%s/prime-home/api/v1/devices/%d/actions".format(httpConfig 
uration.host, deviceId)