From f4058d92243ecd7c5e6b4d1669f38a81041eaa40 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Mon, 24 Jul 2017 10:57:12 +0500 Subject: Describe Permissions API in swagger --- swagger.json | 355 ++++++++--------------------------------------------------- 1 file changed, 44 insertions(+), 311 deletions(-) diff --git a/swagger.json b/swagger.json index a82232f02..a8d4f5641 100644 --- a/swagger.json +++ b/swagger.json @@ -164,37 +164,6 @@ } } }, - "/devices/geofences": { - "post": { - "summary": "Link a Geofence to a Device", - "parameters": [ - { - "$ref": "#/parameters/DeviceGeofence" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/DeviceGeofence" - } - } - } - }, - "delete": { - "summary": "Remove a Geofence from a Device", - "parameters": [ - { - "$ref": "#/parameters/DeviceGeofence" - } - ], - "responses": { - "204": { - "description": "No Content" - } - } - } - }, "/groups": { "get": { "summary": "Fetch a list of Groups", @@ -273,50 +242,19 @@ } } }, - "/groups/geofences": { - "post": { - "summary": "Link a Geofence to a Group", - "parameters": [ - { - "$ref": "#/parameters/GroupGeofence" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/GroupGeofence" - } - } - } - }, - "delete": { - "summary": "Remove a Geofence from a Group", - "parameters": [ - { - "$ref": "#/parameters/GroupGeofence" - } - ], - "responses": { - "204": { - "description": "No Content" - } - } - } - }, - "/permissions/devices": { + "/permissions": { "post": { - "summary": "Link a Device to a User", + "summary": "Link an Object to another Object", "parameters": [ { - "$ref": "#/parameters/DevicePermission" + "$ref": "#/parameters/Permission" } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/DevicePermission" + "$ref": "#/definitions/Permission" } }, "400": { @@ -325,134 +263,10 @@ } }, "delete": { - "summary": "Remove a Device from a User", - "parameters": [ - { - "$ref": "#/parameters/DevicePermission" - } - ], - "responses": { - "204": { - "description": "No Content" - } - } - } - }, - "/permissions/groups": { - "post": { - "summary": "Link a Group to a User", - "parameters": [ - { - "$ref": "#/parameters/GroupPermission" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/GroupPermission" - } - } - } - }, - "delete": { - "summary": "Remove a Group from a User", - "parameters": [ - { - "$ref": "#/parameters/GroupPermission" - } - ], - "responses": { - "204": { - "description": "No Content" - } - } - } - }, - "/permissions/geofences": { - "post": { - "summary": "Link a Geofence to a User", - "parameters": [ - { - "$ref": "#/parameters/GeofencePermission" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/GeofencePermission" - } - } - } - }, - "delete": { - "summary": "Remove a Geofence from a User", + "summary": "Unlink an Object from another Object", "parameters": [ { - "$ref": "#/parameters/GeofencePermission" - } - ], - "responses": { - "204": { - "description": "No Content" - } - } - } - }, - "/permissions/calendars": { - "post": { - "summary": "Link a Calendar to a User", - "parameters": [ - { - "$ref": "#/parameters/CalendarPermission" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/CalendarPermission" - } - } - } - }, - "delete": { - "summary": "Remove a Calendar from a User", - "parameters": [ - { - "$ref": "#/parameters/CalendarPermission" - } - ], - "responses": { - "204": { - "description": "No Content" - } - } - } - }, - "/permissions/users": { - "post": { - "summary": "Link a User to a manager User", - "parameters": [ - { - "$ref": "#/parameters/UserPermission" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/UserPermission" - } - } - } - }, - "delete": { - "summary": "Remove a User from a manager User", - "parameters": [ - { - "$ref": "#/parameters/UserPermission" + "$ref": "#/parameters/Permission" } ], "responses": { @@ -1473,75 +1287,42 @@ "attributes": {} } }, - "DevicePermission": { - "properties": { - "userId": { - "type": "integer" - }, - "deviceId": { - "type": "integer" - } - } - }, - "GroupPermission": { - "properties": { - "userId": { - "type": "integer" - }, - "groupId": { - "type": "integer" - } - } - }, - "GeofencePermission": { - "properties": { - "userId": { - "type": "integer" - }, - "geofenceId": { - "type": "integer" - } - } - }, - "CalendarPermission": { - "properties": { - "userId": { - "type": "integer" - }, - "calendarId": { - "type": "integer" - } - } - }, - "UserPermission": { - "properties": { - "userId": { - "type": "integer" - }, - "managedUserId": { - "type": "integer" - } - } - }, - "GroupGeofence": { - "properties": { - "groupId": { - "type": "integer" - }, - "geofenceId": { - "type": "integer" - } - } - }, - "DeviceGeofence": { - "properties": { - "deviceId": { - "type": "integer" - }, - "geofenceId": { - "type": "integer" - } - } + "Permission": { + "description": "This is a permission map that contain two object indexes. It is used to link/unlink objects. Order is important. Example: { deviceId:8, geofenceId: 16 }", + "properties": { + "userId": { + "description": "User Id, can be only first parameter", + "type": "integer" + }, + "deviceId": { + "description": "Device Id, can be first parameter or second only in combination with userId", + "type": "integer" + }, + "groupId": { + "description": "Group Id, can be first parameter or second only in combination with userId", + "type": "integer" + }, + "geofenceId": { + "description": "Geofence Id, can be second parameter only", + "type": "integer" + }, + "calendarId": { + "description": "Geofence Id, can be second parameter only and only in combination with userId", + "type": "integer" + }, + "attributeId": { + "description": "Computed Attribute Id, can be second parameter only", + "type": "integer" + }, + "driverId": { + "description": "Driver Id, can be second parameter only", + "type": "integer" + }, + "managedUserId": { + "description": "User Id, can be second parameter only and only in combination with userId", + "type": "integer" + } + } }, "CommandType": { "properties": { @@ -1793,12 +1574,12 @@ "$ref": "#/definitions/Device" } }, - "DeviceGeofence": { + "Permission": { "name": "body", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/DeviceGeofence" + "$ref": "#/definitions/Permission" } }, "Group": { @@ -1809,54 +1590,6 @@ "$ref": "#/definitions/Group" } }, - "GroupGeofence": { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/GroupGeofence" - } - }, - "DevicePermission": { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/DevicePermission" - } - }, - "GroupPermission": { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/GroupPermission" - } - }, - "GeofencePermission": { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/GeofencePermission" - } - }, - "CalendarPermission": { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/CalendarPermission" - } - }, - "UserPermission": { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/UserPermission" - } - }, "User": { "name": "body", "in": "body", -- cgit v1.2.3 From f57b2094210de3de6f7333fd5169b8218478f8f9 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Mon, 24 Jul 2017 11:17:18 +0500 Subject: Add Computed Attributes to swagger --- swagger.json | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 117 insertions(+), 4 deletions(-) diff --git a/swagger.json b/swagger.json index a8d4f5641..970052e79 100644 --- a/swagger.json +++ b/swagger.json @@ -607,12 +607,10 @@ "$ref": "#/parameters/userId" }, { - "name": "groupId", - "in": "query", - "type": "integer" + "$ref": "#/parameters/deviceId" }, { - "$ref": "#/parameters/deviceId" + "$ref": "#/parameters/groupId" }, { "name": "refresh", @@ -1036,6 +1034,87 @@ } } } + }, + "/attributes/computed": { + "get": { + "summary": "Fetch a list of Attributes", + "description": "Without params, it returns a list of Attributes the user has access to", + "parameters": [ + { + "$ref": "#/parameters/all" + }, + { + "$ref": "#/parameters/userId" + }, + { + "$ref": "#/parameters/deviceId" + }, + { + "$ref": "#/parameters/groupId" + }, + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Attribute" + } + } + } + } + }, + "post": { + "summary": "Create an Attribute", + "parameters": [ + { + "$ref": "#/parameters/Attribute" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/Attribute" + } + } + } + } + }, + "/attributes/computed/{id}": { + "put": { + "summary": "Update an Attribute", + "parameters": [ + { + "$ref": "#/parameters/entityId" + }, + { + "$ref": "#/parameters/Attribute" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/Attribute" + } + } + } + }, + "delete": { + "summary": "Delete an Attribute", + "parameters": [ + { + "$ref": "#/parameters/entityId" + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } } }, "definitions": { @@ -1539,6 +1618,26 @@ }, "atributes": {} } + }, + "Attribute": { + "properties": { + "id": { + "type": "integer" + }, + "description": { + "type": "string" + }, + "attribute": { + "type": "string" + }, + "expression": { + "type": "string" + }, + "type": { + "type": "string", + "description": "String|Number|Boolean" + } + } } }, "parameters": { @@ -1566,6 +1665,12 @@ "description": "Standard users can use this only with _deviceId_s, they have access to", "type": "integer" }, + "groupId": { + "name": "groupId", + "in": "query", + "description": "Standard users can use this only with _groupId_s, they have access to", + "type": "integer" + }, "Device": { "name": "body", "in": "body", @@ -1622,6 +1727,14 @@ "$ref": "#/definitions/Calendar" } }, + "Attribute": { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Attribute" + } + }, "deviceIdArray": { "name": "deviceId", "in": "query", -- cgit v1.2.3 From d54ea579899e7d03a3065fbc3e119ca4e676696a Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Mon, 24 Jul 2017 11:28:14 +0500 Subject: Add Drivers to swagger --- swagger.json | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 117 insertions(+), 4 deletions(-) diff --git a/swagger.json b/swagger.json index 970052e79..fcc9f5153 100644 --- a/swagger.json +++ b/swagger.json @@ -613,10 +613,7 @@ "$ref": "#/parameters/groupId" }, { - "name": "refresh", - "in": "query", - "required": false, - "type": "boolean" + "$ref": "#/parameters/refresh" } ], "responses": { @@ -1052,6 +1049,9 @@ { "$ref": "#/parameters/groupId" }, + { + "$ref": "#/parameters/refresh" + } ], "responses": { "200": { @@ -1115,6 +1115,90 @@ } } } + }, + "/drivers": { + "get": { + "summary": "Fetch a list of Drivers", + "description": "Without params, it returns a list of Drivers the user has access to", + "parameters": [ + { + "$ref": "#/parameters/all" + }, + { + "$ref": "#/parameters/userId" + }, + { + "$ref": "#/parameters/deviceId" + }, + { + "$ref": "#/parameters/groupId" + }, + { + "$ref": "#/parameters/refresh" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Driver" + } + } + } + } + }, + "post": { + "summary": "Create a Driver", + "parameters": [ + { + "$ref": "#/parameters/Driver" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/Driver" + } + } + } + } + }, + "/drivers/{id}": { + "put": { + "summary": "Update a Driver", + "parameters": [ + { + "$ref": "#/parameters/entityId" + }, + { + "$ref": "#/parameters/Driver" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/Driver" + } + } + } + }, + "delete": { + "summary": "Delete a Driver", + "parameters": [ + { + "$ref": "#/parameters/entityId" + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } } }, "definitions": { @@ -1638,6 +1722,20 @@ "description": "String|Number|Boolean" } } + }, + "Driver": { + "properties": { + "id": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "uniqueId": { + "type": "string" + }, + "atributes": {} + } } }, "parameters": { @@ -1653,6 +1751,13 @@ "description": "Can only be used by admins or managers to fetch all entities", "type": "boolean" }, + { + "refresh": { + "name": "refresh", + "in": "query", + "required": false, + "type": "boolean" + }, "userId": { "name": "userId", "in": "query", @@ -1735,6 +1840,14 @@ "$ref": "#/definitions/Attribute" } }, + "Driver": { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Driver" + } + }, "deviceIdArray": { "name": "deviceId", "in": "query", -- cgit v1.2.3 From a8c885e4e3d893181bed355f55d8d79b6722441b Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Mon, 24 Jul 2017 11:40:10 +0500 Subject: Add Stops report --- swagger.json | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/swagger.json b/swagger.json index fcc9f5153..d6850fca5 100644 --- a/swagger.json +++ b/swagger.json @@ -1579,6 +1579,10 @@ "type": "number", "description": "in meters" }, + "spentFuel": { + "type": "number", + "description": "in liters" + }, "engineHours": { "type": "integer" } @@ -1604,6 +1608,10 @@ "type": "number", "description": "in meters" }, + "spentFuel": { + "type": "number", + "description": "in liters" + }, "duration": { "type": "integer" }, @@ -1634,7 +1642,52 @@ }, "endLon": { "type": "number" + }, + "driverUniqueId": { + "type": "integer" + }, + "driverName": { + "type": "string" + }, + }, + "ReportStops": { + "properties": { + "deviceId": { + "type": "integer" + }, + "deviceName": { + "type": "string" + }, + "duration": { + "type": "integer" + }, + "startTime": { + "type": "string", + "format": "date-time", + "description": "in IS0 8601 format. eg. `1963-11-22T18:30:00Z`" + }, + "address": { + "type": "string" + }, + "lat": { + "type": "number" + }, + "lon": { + "type": "number" + }, + "endTime": { + "type": "string", + "format": "date-time", + "description": "in IS0 8601 format. eg. `1963-11-22T18:30:00Z`" + }, + "spentFuel": { + "type": "number", + "description": "in liters" + }, + "engineHours": { + "type": "integer" } + } }, "Statistics": { -- cgit v1.2.3 From 4292ab3b4bb638895a654e407cc548fd12ff49a8 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Mon, 24 Jul 2017 12:12:15 +0500 Subject: Fix JSON --- swagger.json | 79 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 39 insertions(+), 40 deletions(-) diff --git a/swagger.json b/swagger.json index d6850fca5..f4e816a5a 100644 --- a/swagger.json +++ b/swagger.json @@ -1451,41 +1451,41 @@ } }, "Permission": { - "description": "This is a permission map that contain two object indexes. It is used to link/unlink objects. Order is important. Example: { deviceId:8, geofenceId: 16 }", - "properties": { - "userId": { - "description": "User Id, can be only first parameter", - "type": "integer" - }, - "deviceId": { - "description": "Device Id, can be first parameter or second only in combination with userId", - "type": "integer" - }, - "groupId": { - "description": "Group Id, can be first parameter or second only in combination with userId", - "type": "integer" - }, - "geofenceId": { - "description": "Geofence Id, can be second parameter only", - "type": "integer" - }, - "calendarId": { - "description": "Geofence Id, can be second parameter only and only in combination with userId", - "type": "integer" - }, - "attributeId": { - "description": "Computed Attribute Id, can be second parameter only", - "type": "integer" - }, - "driverId": { - "description": "Driver Id, can be second parameter only", - "type": "integer" - }, - "managedUserId": { - "description": "User Id, can be second parameter only and only in combination with userId", - "type": "integer" - } - } + "description": "This is a permission map that contain two object indexes. It is used to link/unlink objects. Order is important. Example: { deviceId:8, geofenceId: 16 }", + "properties": { + "userId": { + "description": "User Id, can be only first parameter", + "type": "integer" + }, + "deviceId": { + "description": "Device Id, can be first parameter or second only in combination with userId", + "type": "integer" + }, + "groupId": { + "description": "Group Id, can be first parameter or second only in combination with userId", + "type": "integer" + }, + "geofenceId": { + "description": "Geofence Id, can be second parameter only", + "type": "integer" + }, + "calendarId": { + "description": "Geofence Id, can be second parameter only and only in combination with userId", + "type": "integer" + }, + "attributeId": { + "description": "Computed Attribute Id, can be second parameter only", + "type": "integer" + }, + "driverId": { + "description": "Driver Id, can be second parameter only", + "type": "integer" + }, + "managedUserId": { + "description": "User Id, can be second parameter only and only in combination with userId", + "type": "integer" + } + } }, "CommandType": { "properties": { @@ -1648,9 +1648,10 @@ }, "driverName": { "type": "string" - }, - }, - "ReportStops": { + } + } + }, + "ReportStops": { "properties": { "deviceId": { "type": "integer" @@ -1687,7 +1688,6 @@ "engineHours": { "type": "integer" } - } }, "Statistics": { @@ -1804,7 +1804,6 @@ "description": "Can only be used by admins or managers to fetch all entities", "type": "boolean" }, - { "refresh": { "name": "refresh", "in": "query", -- cgit v1.2.3