Package com.facebook.openwifi.cloudsdk
Class UCentralClient
- java.lang.Object
-
- com.facebook.openwifi.cloudsdk.UCentralClient
-
public class UCentralClient extends Object
uCentral OpenAPI client. This implementation supports both public and private endpoints.For public endpoint communication:
- Hardcode owsec URL and use "/systemendpoints" endpoint since Kafka may be inaccessible; access to Kafka is a hack for development only, but could be secured in production with SASL/MTLS
- Exchange username/password for an oauth token to pass to other services
- Use Kafka "system_endpoints" topic to find the private endpoint and API key for each service
-
-
Constructor Summary
Constructors Constructor Description UCentralClient(String rrmEndpoint, boolean usePublicEndpoints, String uCentralSecPublicEndpoint, String username, String password, int connectTimeoutMs, int socketTimeoutMs, int wifiScanTimeoutMs)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CommandInfo
configure(String serialNumber, String configuration)
Configure a device (by serial number).DeviceCapabilities
getCapabilities(String serialNumber)
Launch a get capabilities command for a device (by serial number).List<DeviceWithStatus>
getDevices()
Get a list of devices.StatisticsRecords
getLatestStats(String serialNumber, int limit)
Return the given number of latest statistics from a device (by serial number).EntityList
getProvEntities()
Retrieve a list of entities from owprov.InventoryTagList
getProvInventory()
Retrieve a list of inventory from owprov.SerialNumberList
getProvInventoryForRRM()
Retrieve a list of inventory with RRM enabled from owprov.RRMDetails
getProvInventoryRRMDetails(String serialNumber)
Retrieve the RRM config and schedule for a specific APVenueList
getProvVenues()
Retrieve a list of venues from owprov.SystemInfoResults
getSystemInfo()
Get uCentralGw system info.boolean
isInitialized()
Return true if this service has learned the endpoints of all essential dependent services, along with API keys (if necessary).boolean
isProvInitialized()
Return true if this service has learned the owprov endpoint, along with API keys (if necessary).boolean
login()
Perform login and uCentralGw endpoint retrieval.CommandInfo
runScript(String serialNumber, String script)
Run a shell script on a device and return the result, or null upon error.CommandInfo
runScript(String serialNumber, String script, int timeoutSec)
Run a shell script on a device and return the result, or null upon error.CommandInfo
runScript(String serialNumber, String script, int timeoutSec, String type)
Run a script on a device and return the result, or null upon error.void
setServiceEndpoint(String service, ServiceEvent event)
System endpoints and API keys come from the service_event Kafka topic.TokenValidationResult
validateToken(String token)
Validate the given token via uCentralSec.static void
verifySsl(boolean enable)
Toggle verifying SSL/TLS certificates.CommandInfo
wifiScan(String serialNumber, boolean verbose)
Launch a wifi scan for a device (by serial number).
-
-
-
Constructor Detail
-
UCentralClient
public UCentralClient(String rrmEndpoint, boolean usePublicEndpoints, String uCentralSecPublicEndpoint, String username, String password, int connectTimeoutMs, int socketTimeoutMs, int wifiScanTimeoutMs)
Constructor.- Parameters:
rrmEndpoint
- advertise this RRM endpoint to the SDKusePublicEndpoints
- whether to use public or private endpointsuCentralSecPublicEndpoint
- the uCentralSec public endpoint (if needed)username
- uCentral username (for public endpoints only)password
- uCentral password (for public endpoints only)connectTimeoutMs
- connection timeout for all requests, in mssocketTimeoutMs
- socket timeout for all requests, in mswifiScanTimeoutMs
- socket timeout for wifi scan requests, in ms
-
-
Method Detail
-
verifySsl
public static void verifySsl(boolean enable)
Toggle verifying SSL/TLS certificates. This should be set only during initialization, otherwise it may NOT take effect.
-
login
public boolean login()
Perform login and uCentralGw endpoint retrieval.
-
isInitialized
public boolean isInitialized()
Return true if this service has learned the endpoints of all essential dependent services, along with API keys (if necessary).
-
isProvInitialized
public boolean isProvInitialized()
Return true if this service has learned the owprov endpoint, along with API keys (if necessary).
-
getSystemInfo
public SystemInfoResults getSystemInfo()
Get uCentralGw system info.
-
getDevices
public List<DeviceWithStatus> getDevices()
Get a list of devices.
-
wifiScan
public CommandInfo wifiScan(String serialNumber, boolean verbose)
Launch a wifi scan for a device (by serial number).An AP can conduct a wifiscan, which can be either active or passive. In an active wifiscan, the AP sends out a wifiscan request and listens for responses from other APs. In a passive wifiscan, the AP does not send out a wifiscan request but instead just waits for periodic beacons from the other APs. (Note that neither the responses to requests (in active mode) or the periodic beacons are guaranteed to happen at any particular time (and it depends on network traffic)).
The AP conducting the wifiscan goes through every channel and listens for responses/beacons. However, the responding/beaconing APs only send responses on channels they are currently using.
-
configure
public CommandInfo configure(String serialNumber, String configuration)
Configure a device (by serial number).
-
getLatestStats
public StatisticsRecords getLatestStats(String serialNumber, int limit)
Return the given number of latest statistics from a device (by serial number).
-
getCapabilities
public DeviceCapabilities getCapabilities(String serialNumber)
Launch a get capabilities command for a device (by serial number).
-
runScript
public CommandInfo runScript(String serialNumber, String script)
Run a shell script on a device and return the result, or null upon error.- See Also:
runScript(String, String, int)
-
runScript
public CommandInfo runScript(String serialNumber, String script, int timeoutSec)
Run a shell script on a device and return the result, or null upon error.- See Also:
runScript(String, String, int, String)
-
runScript
public CommandInfo runScript(String serialNumber, String script, int timeoutSec, String type)
Run a script on a device and return the result, or null upon error.- Parameters:
serialNumber
- the devicescript
- the script contentstimeoutSec
- the timeout in secondstype
- the script type (either "shell" or "ucode")- See Also:
UCentralUtils.getScriptOutput(CommandInfo)
-
getProvInventory
public InventoryTagList getProvInventory()
Retrieve a list of inventory from owprov.
-
getProvInventoryForRRM
public SerialNumberList getProvInventoryForRRM()
Retrieve a list of inventory with RRM enabled from owprov.
-
getProvInventoryRRMDetails
public RRMDetails getProvInventoryRRMDetails(String serialNumber)
Retrieve the RRM config and schedule for a specific AP- Parameters:
serialNumber
- the serial number of the AP- Returns:
- RRMDetails, containing information about the RRM schedule and parameters
-
getProvVenues
public VenueList getProvVenues()
Retrieve a list of venues from owprov.
-
getProvEntities
public EntityList getProvEntities()
Retrieve a list of entities from owprov.
-
setServiceEndpoint
public void setServiceEndpoint(String service, ServiceEvent event)
System endpoints and API keys come from the service_event Kafka topic.
-
validateToken
public TokenValidationResult validateToken(String token)
Validate the given token via uCentralSec.
-
-