Package com.telenordigital.nbiot
Class Client
- java.lang.Object
-
- com.telenordigital.nbiot.Client
-
public class Client extends Object
This is the client for the Telenor NB-IoT REST API.
-
-
Field Summary
Fields Modifier and Type Field Description DataSearchParametersDEFAULT_DATA_SEARCH_PARAMSDefault data search parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TeamacceptInvite(String code)Accept an invite.BroadcastResultbroadcast(String collectionID, DownstreamMessage msg)Broadcast a messsage to all devices in a collection.Collectioncollection(String collectionID)Retrieve a collection.Collection[]collections()Retrieve all collections the user has access to.CollectioncreateCollection(Collection collection)Create a new collection.DevicecreateDevice(String collectionID, Device device)Create a device.InvitecreateInvite(String teamID)Create a new invite.OutputcreateOutput(String collectionID, Output output)Create an output.TeamcreateTeam(Team team)Create a new team.OutputDataMessage[]data(String collectionID)Fetch data for a collectionOutputDataMessage[]data(String collectionID, DataSearchParameters parameters)Fetch data for a collectionOutputDataMessage[]data(String collectionID, String deviceId)Fetch data for a deviceOutputDataMessage[]data(String collectionID, String deviceId, DataSearchParameters parameters)Fetch data for a devicevoiddeleteCollection(String collectionID)Delete a collection.voiddeleteCollectionTag(String collectionID, String key)Delete a collection tag.voiddeleteDevice(String collectionID, String deviceID)Delete a device.voiddeleteDeviceTag(String collectionID, String deviceID, String key)Delete a device tag.voiddeleteInvite(String teamID, String code)Delete an invite.voiddeleteOutput(String collectionID, String outputID)Delete an output.voiddeleteOutputTag(String collectionID, String outputID, String key)Delete a output tag.voiddeleteTeam(String teamID)Delete a team.voiddeleteTeamMember(String teamID, String userID)Delete a team member.voiddeleteTeamTag(String teamID, String key)Delete a team tag.Devicedevice(String collectionID, String deviceID)Retrieve a device.Device[]devices(String collectionID)Retrieve all devices in a collection.Inviteinvite(String teamID, String code)Retrieve an invite.Invite[]invites(String teamID)Retrieve all invites to a team.Outputoutput(String collectionID, String outputID)Retrieve an output.OutputLogEntry[]outputLogs(String collectionID, String outputID)Retrieve output logs.Output[]outputs(String collectionID)Retrieve all outputs in a collection.OutputStatusoutputStatus(String collectionID, String outputID)Retrieve output status.org.eclipse.jetty.websocket.client.WebSocketClientoutputStream(String collectionID, String deviceID, Consumer<OutputStreamHandler> handler)Receive data messages sent by a device.org.eclipse.jetty.websocket.client.WebSocketClientoutputStream(String collectionID, Consumer<OutputStreamHandler> handler)Receive data messages sent by all devices in a collection.voidsend(String collectionID, String deviceID, DownstreamMessage msg)Send a messsage to a device.SystemDefaultssystemDefaults()Retrieve the system configurationTeamteam(String teamID)Retrieve a team.Team[]teams()Retrieve all teams the user has access to.CollectionupdateCollection(Collection collection)Update a collection.DeviceupdateDevice(String collectionID, Device device)Update a device.OutputupdateOutput(String collectionID, Output output)Update an output.TeamupdateTeam(Team team)Update a team.MemberupdateTeamMemberRole(String teamID, String userID, String role)Update a team member role.
-
-
-
Field Detail
-
DEFAULT_DATA_SEARCH_PARAMS
public final DataSearchParameters DEFAULT_DATA_SEARCH_PARAMS
Default data search parameters. Used if no search parameters is provided indata(String, String)anddata(String)
-
-
Constructor Detail
-
Client
public Client() throws ClientExceptionCreate a new Telenor NB-IoT client using the configuration. The configuration can either be set by adding a ${HOME}/.telenor-nbiot file or by setting the environment variables TELENOR_NBIOT_ADDRESS and TELENOR_NBIOT_TOKEN. The environment variables override the configuration file.- Throws:
ClientException
-
-
Method Detail
-
systemDefaults
public SystemDefaults systemDefaults() throws ClientException
Retrieve the system configuration- Throws:
ClientException
-
team
public Team team(String teamID) throws ClientException
Retrieve a team.- Throws:
ClientException
-
teams
public Team[] teams() throws ClientException
Retrieve all teams the user has access to.- Throws:
ClientException
-
createTeam
public Team createTeam(Team team) throws ClientException
Create a new team.- Throws:
ClientException
-
updateTeamMemberRole
public Member updateTeamMemberRole(String teamID, String userID, String role) throws ClientException
Update a team member role.- Throws:
ClientException
-
deleteTeamMember
public void deleteTeamMember(String teamID, String userID) throws ClientException
Delete a team member.- Throws:
ClientException
-
deleteTeamTag
public void deleteTeamTag(String teamID, String key) throws ClientException
Delete a team tag.- Throws:
ClientException
-
updateTeam
public Team updateTeam(Team team) throws ClientException
Update a team. No tags are deleted, only added or updated.- Throws:
ClientException
-
deleteTeam
public void deleteTeam(String teamID) throws ClientException
Delete a team.- Throws:
ClientException
-
invite
public Invite invite(String teamID, String code) throws ClientException
Retrieve an invite.- Throws:
ClientException
-
invites
public Invite[] invites(String teamID) throws ClientException
Retrieve all invites to a team.- Throws:
ClientException
-
createInvite
public Invite createInvite(String teamID) throws ClientException
Create a new invite.- Throws:
ClientException
-
acceptInvite
public Team acceptInvite(String code) throws ClientException
Accept an invite.- Throws:
ClientException
-
deleteInvite
public void deleteInvite(String teamID, String code) throws ClientException
Delete an invite.- Throws:
ClientException
-
collection
public Collection collection(String collectionID) throws ClientException
Retrieve a collection.- Throws:
ClientException
-
collections
public Collection[] collections() throws ClientException
Retrieve all collections the user has access to.- Throws:
ClientException
-
createCollection
public Collection createCollection(Collection collection) throws ClientException
Create a new collection.- Throws:
ClientException
-
updateCollection
public Collection updateCollection(Collection collection) throws ClientException
Update a collection. No tags are deleted, only added or updated.- Throws:
ClientException
-
deleteCollectionTag
public void deleteCollectionTag(String collectionID, String key) throws ClientException
Delete a collection tag.- Throws:
ClientException
-
deleteCollection
public void deleteCollection(String collectionID) throws ClientException
Delete a collection.- Throws:
ClientException
-
data
public OutputDataMessage[] data(String collectionID) throws ClientException
Fetch data for a collection- Parameters:
collectionID- Collection id as string- Returns:
- A list of OutputDataMessage
- Throws:
ClientException
-
data
public OutputDataMessage[] data(String collectionID, DataSearchParameters parameters) throws ClientException
Fetch data for a collection- Parameters:
collectionID- Collection id as stringparameters- Map of DataSearchParameters- Returns:
- A list of OutputDataMessage
- Throws:
ClientException
-
broadcast
public BroadcastResult broadcast(String collectionID, DownstreamMessage msg) throws ClientException
Broadcast a messsage to all devices in a collection.- Throws:
ClientException
-
device
public Device device(String collectionID, String deviceID) throws ClientException
Retrieve a device.- Throws:
ClientException
-
devices
public Device[] devices(String collectionID) throws ClientException
Retrieve all devices in a collection.- Throws:
ClientException
-
createDevice
public Device createDevice(String collectionID, Device device) throws ClientException
Create a device.- Throws:
ClientException
-
updateDevice
public Device updateDevice(String collectionID, Device device) throws ClientException
Update a device. No tags are deleted, only added or updated.- Throws:
ClientException
-
deleteDeviceTag
public void deleteDeviceTag(String collectionID, String deviceID, String key) throws ClientException
Delete a device tag.- Throws:
ClientException
-
deleteDevice
public void deleteDevice(String collectionID, String deviceID) throws ClientException
Delete a device.- Throws:
ClientException
-
data
public OutputDataMessage[] data(String collectionID, String deviceId) throws ClientException
Fetch data for a device- Parameters:
collectionID- Collection id as stringdeviceId- Device id as string- Returns:
- A list of OutputDataMessage
- Throws:
ClientException
-
data
public OutputDataMessage[] data(String collectionID, String deviceId, DataSearchParameters parameters) throws ClientException
Fetch data for a device- Parameters:
collectionID- Collection id as stringdeviceId- Device id as stringparameters- Map of DataSearchParameters- Returns:
- A list of OutputDataMessage
- Throws:
ClientException
-
send
public void send(String collectionID, String deviceID, DownstreamMessage msg) throws ClientException
Send a messsage to a device.- Throws:
ClientException
-
output
public Output output(String collectionID, String outputID) throws ClientException
Retrieve an output.- Throws:
ClientException
-
outputs
public Output[] outputs(String collectionID) throws ClientException
Retrieve all outputs in a collection.- Throws:
ClientException
-
createOutput
public Output createOutput(String collectionID, Output output) throws ClientException
Create an output.- Throws:
ClientException
-
updateOutput
public Output updateOutput(String collectionID, Output output) throws ClientException
Update an output. No tags are deleted, only added or updated.- Throws:
ClientException
-
outputLogs
public OutputLogEntry[] outputLogs(String collectionID, String outputID) throws ClientException
Retrieve output logs.- Throws:
ClientException
-
outputStatus
public OutputStatus outputStatus(String collectionID, String outputID) throws ClientException
Retrieve output status.- Throws:
ClientException
-
deleteOutputTag
public void deleteOutputTag(String collectionID, String outputID, String key) throws ClientException
Delete a output tag.- Throws:
ClientException
-
deleteOutput
public void deleteOutput(String collectionID, String outputID) throws ClientException
Delete an output.- Throws:
ClientException
-
outputStream
public org.eclipse.jetty.websocket.client.WebSocketClient outputStream(String collectionID, Consumer<OutputStreamHandler> handler)
Receive data messages sent by all devices in a collection.
-
outputStream
public org.eclipse.jetty.websocket.client.WebSocketClient outputStream(String collectionID, String deviceID, Consumer<OutputStreamHandler> handler)
Receive data messages sent by a device.
-
-