SiteWhere Java Model

SiteWhere Java Model and REST Client

License

License

Categories

Categories

Java Languages
GroupId

GroupId

com.sitewhere
ArtifactId

ArtifactId

sitewhere-java-model
Last Version

Last Version

3.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

SiteWhere Java Model
SiteWhere Java Model and REST Client
Project URL

Project URL

http://sitewhere.io
Source Code Management

Source Code Management

https://github.com/sitewhere/sitewhere-java-api

Download sitewhere-java-model

How to add to project

<!-- https://jarcasting.com/artifacts/com.sitewhere/sitewhere-java-model/ -->
<dependency>
    <groupId>com.sitewhere</groupId>
    <artifactId>sitewhere-java-model</artifactId>
    <version>3.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.sitewhere/sitewhere-java-model/
implementation 'com.sitewhere:sitewhere-java-model:3.0.0'
// https://jarcasting.com/artifacts/com.sitewhere/sitewhere-java-model/
implementation ("com.sitewhere:sitewhere-java-model:3.0.0")
'com.sitewhere:sitewhere-java-model:jar:3.0.0'
<dependency org="com.sitewhere" name="sitewhere-java-model" rev="3.0.0">
  <artifact name="sitewhere-java-model" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.sitewhere', module='sitewhere-java-model', version='3.0.0')
)
libraryDependencies += "com.sitewhere" % "sitewhere-java-model" % "3.0.0"
[com.sitewhere/sitewhere-java-model "3.0.0"]

Dependencies

compile (3)

Group / Artifact Type Version
com.fasterxml.jackson.core : jackson-databind jar
com.fasterxml.jackson.core : jackson-annotations jar
joda-time : joda-time jar 2.9.1

Project Modules

There are no modules declared in this project.

Maven Central

SiteWhere Java Model and REST API Library

This repository contains the core Java API and data model used to interact with REST services on a SiteWhere instance.

Using the Java Client

The Java client wraps the Spring RestTemplate mechanism and takes care of acquiring a JWT from the SiteWhere instance and storing it for use in the REST API calls. A new client with the default settings may be created as follows:

ISiteWhereClient client = SiteWhereClient.newBuilder().build().initialize();

The default settings are:

Attribute Value
Protocol HTTP
Hostname localhost
Port 80
Username admin
Password password

Note that the initialize() method must be called before using the client. This sets up the template and connects to the server to acquire a JWT.

To change the default connection settings use:

SiteWhereClient.newBuilder().withConnectionTo("https", "myhost", 8081).build().initialize();

To connect as a different user user:

SiteWhereClient.newBuilder().forUser("myuser", "mypassword").build().initialize();

Interacting with the SiteWhere Model

Once the client has been initialized, methods on it may be invoked to interact with the data model on the remote SiteWhere instance. There are two types of calls, global calls and tenant-specific calls.

Global Calls

For global calls, no extra information is required in order to make the invocation. For instance, to get the instance version information, invoke:

Version version = client.getSiteWhereVersion();

The object model for all of the core SiteWhere data model is included with the client.

Tenant Calls

For calls that are tenant-specific, more information must be passed along with each method invocation. You must provide the tenant id and tenant authentication token which are passed as headers to the REST call (along with the JWT used for all calls). The format for tenant calls is:

DeviceType type = getClient().getDeviceTypeByToken(SiteWhereClient.defaultTenant(), "galaxytab3");

for the default tenant installed with the contruction example data, or for an arbitrary tenant

DeviceType type = getClient().getDeviceTypeByToken(SiteWhereClient.forTenant("token", "auth"), "galaxytab3");

using the unique token for the tenant and the tenant authentication token specific to that tenant.

com.sitewhere

SiteWhere

The Open Platform for the Internet of Things

Versions

Version
3.0.0
3.0.0.beta17
3.0.0.beta16
3.0.0.beta15
3.0.0.beta14
3.0.0.beta13
3.0.0.beta12
3.0.0.beta10
3.0.0.beta9
3.0.0.beta8
3.0.0.beta7
3.0.0.beta6
3.0.0.beta5
3.0.0.beta4
3.0.0.beta3
3.0.0.beta2
3.0.0.beta1
3.0.0.alpha7
3.0.0.alpha6
3.0.0.alpha5
3.0.0.alpha4
3.0.0.alpha3
3.0.0.alpha2
3.0.0.alpha1
2.2.0
2.1.13
2.1.12
2.1.11
2.1.10
2.1.9
2.1.8
2.1.7
2.1.6
2.1.5
2.1.4
2.1.3
2.1.2
2.1.1
2.1.0
2.0.2
2.0.1
2.0.0