Cisco Cisco Prime Home 6.3 개발자 가이드
Cisco Prime Home – Integration Guide
OL-28558-01 v5.1
53
Sample Code
DeviceActions.scala
package com.clearaccess.example.api
import org.json.JSONObject
class DeviceActions(val json: JSONObject) extends JSONHelpers {
/**
* @return the underlying json object
*/
def getJSON(): JSONObject = json
/**
* @return the underlying json object
*/
def getJSON(): JSONObject = json
/**
* sets the state of a service to 'ENABLED' or 'DISABLED'
* @param serviceCode the service code of the service. this
service must be present
* @param isEnabled determines whether to set the status to
'ENABLED' or 'DISABLED'
* @return self, for chaining
*/
* @param serviceCode the service code of the service. this
service must be present
* @param isEnabled determines whether to set the status to
'ENABLED' or 'DISABLED'
* @return self, for chaining
*/
def setServiceEnabled(serviceCode: String, isEnabled: Boolean):
DeviceActions = {
val status = if (isEnabled) "ENABLED" else "DISABLED"
json.deepPut(List("services", serviceCode, "status"),
status)
this
json.deepPut(List("services", serviceCode, "status"),
status)
this
}
/**
/**
* marks an application state as requiring a synchronization
*
* @param applicationCode the code of the application to be
marked
* @param pendingSync whether or not the application needs to
be
synced
*
* @return self, for chaining
*/
*
* @param applicationCode the code of the application to be
marked
* @param pendingSync whether or not the application needs to
be
synced
*
* @return self, for chaining
*/
def setApplicationPendingSync(applicationCode: String,
pendingSync: Boolean): DeviceActions = {
pendingSync: Boolean): DeviceActions = {
json
.getJSONObject("applications")
.getJSONObject(applicationCode)
.put("pendingSync", pendingSync)
.getJSONObject(applicationCode)
.put("pendingSync", pendingSync)
this
}
/**
/**
* set to make the system request a connection from the device
*
* @param applyImmediately whether the changes should be applied
immediately to the device
*
* @return self, for chaining
*/
*
* @param applyImmediately whether the changes should be applied
immediately to the device
*
* @return self, for chaining
*/
def setApplyImmediately(applyImmediately: Boolean): DeviceActions
= {
= {
json.put("solicit", applyImmediately)
this
this
}
}