aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Krey <krey.christoph@gmail.com>2017-06-30 12:24:55 +0200
committerChristoph Krey <krey.christoph@gmail.com>2017-06-30 12:24:55 +0200
commit89f5ca6340b71f01e57684ed4900c801e043a9c4 (patch)
tree905ebc763919eddf3eab00682a2a64e77915bcff
parentc12a28b811b3310eab5942e9c3650d50c2df1606 (diff)
downloadtraccar-server-89f5ca6340b71f01e57684ed4900c801e043a9c4.tar.gz
traccar-server-89f5ca6340b71f01e57684ed4900c801e043a9c4.tar.bz2
traccar-server-89f5ca6340b71f01e57684ed4900c801e043a9c4.zip
[NEW] add GET device to API for external monitoring
-rw-r--r--src/org/traccar/api/resource/DeviceResource.java13
-rw-r--r--swagger.json21
2 files changed, 33 insertions, 1 deletions
diff --git a/src/org/traccar/api/resource/DeviceResource.java b/src/org/traccar/api/resource/DeviceResource.java
index bfd05aad5..64d40f4af 100644
--- a/src/org/traccar/api/resource/DeviceResource.java
+++ b/src/org/traccar/api/resource/DeviceResource.java
@@ -31,6 +31,7 @@ import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import javax.ws.rs.WebApplicationException;
import java.sql.SQLException;
import java.util.Collection;
@@ -74,6 +75,18 @@ public class DeviceResource extends BaseResource {
}
@Path("{id}")
+ @GET
+ public Response get(@PathParam("id") long id) throws SQLException {
+ Context.getPermissionsManager().checkDevice(getUserId(), id);
+ Device device = Context.getDeviceManager().getDeviceById(id);
+ if (device != null) {
+ return Response.ok(Context.getDeviceManager().getDeviceById(id)).build();
+ } else {
+ throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build());
+ }
+ }
+
+ @Path("{id}")
@PUT
public Response update(Device entity) throws SQLException {
Context.getPermissionsManager().checkReadonly(getUserId());
diff --git a/swagger.json b/swagger.json
index 32391d4fa..4f62bdf96 100644
--- a/swagger.json
+++ b/swagger.json
@@ -92,6 +92,25 @@
}
},
"/devices/{id}": {
+ "get": {
+ "summary": "Get a Device",
+ "parameters": [
+ {
+ "$ref": "#/parameters/entityId"
+ },
+ {
+ "$ref": "#/parameters/Device"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/Device"
+ }
+ }
+ }
+ },
"put": {
"summary": "Update a Device",
"parameters": [
@@ -112,7 +131,7 @@
}
},
"delete": {
- "summary": "Update a Device",
+ "summary": "Delete a Device",
"parameters": [
{
"$ref": "#/parameters/entityId"