summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukasz Stanislawski <l.stanislaws@samsung.com>2018-07-25 18:00:00 +0200
committerLukasz Stanislawski <l.stanislaws@samsung.com>2018-07-25 18:00:00 +0200
commitfe365e77fa99790bf2bb2370a52f5258daf10ebe (patch)
treebcc4a1bff0e636dcfdf4d9bc3cade173f484cdfd
parent8f5d052f9313d1f9e1fa920897523bcabe71bc2b (diff)
downloadttsd-worker-task-fe365e77fa99790bf2bb2370a52f5258daf10ebe.tar.gz
ttsd-worker-task-fe365e77fa99790bf2bb2370a52f5258daf10ebe.tar.bz2
ttsd-worker-task-fe365e77fa99790bf2bb2370a52f5258daf10ebe.zip
add json schemas
Change-Id: Idb2e992107de8b84ee9ba78d54394c69d7d9eac6
-rw-r--r--schemas/config.example.json28
-rw-r--r--schemas/config.schema.json84
-rw-r--r--schemas/load_avg.response.example.json9
-rw-r--r--schemas/process.reposnse.example.json20
-rw-r--r--schemas/response.schema.json120
-rw-r--r--schemas/system.response.example.json8
-rw-r--r--schemas/top.response.example.json38
7 files changed, 307 insertions, 0 deletions
diff --git a/schemas/config.example.json b/schemas/config.example.json
new file mode 100644
index 0000000..96d640e
--- /dev/null
+++ b/schemas/config.example.json
@@ -0,0 +1,28 @@
+{
+ "total_duration" : 60,
+ "config_entry" :
+ [
+ {
+ "type" : "SYSTEM",
+ "frequency" : 1
+ },
+ {
+ "type" : "PROCESS",
+ "frequency" : 10,
+ "matchers" : [
+ { "app_id": "org.tizen.clock" },
+ { "exe": "/usr/bin/python" }
+ ]
+ },
+ {
+ "type" : "TOP",
+ "subject" : "APPS",
+ "frequency" : 3,
+ "top" : 10
+ },
+ {
+ "type" : "LOAD_AVG",
+ "frequency" : 60
+ }
+ ]
+}
diff --git a/schemas/config.schema.json b/schemas/config.schema.json
new file mode 100644
index 0000000..8d1dfa7
--- /dev/null
+++ b/schemas/config.schema.json
@@ -0,0 +1,84 @@
+{
+ "$schema": "http://json-schema.org/schema#",
+ "id" : "http://ttsd-worker-task.org/schemas/config.json",
+
+ "definitions": {
+ "top" : {
+ "type" : "object",
+ "subject" : { "enum" : [
+ "APPS", "ALL"
+ ] },
+ "properties": {
+ "type" : { "const": "TOP" },
+ "frequency" : { "type" : "integer" },
+ "top" : { "type": "integer" }
+ },
+ "required": [ "type", "subject", "frequency", "top" ]
+ },
+
+ "system" : {
+ "type" : "object",
+ "properties": {
+ "type" : { "const": "SYSTEM" },
+ "frequency" : { "type" : "integer" }
+ },
+ "required": [ "type", "frequency" ]
+ },
+
+ "matcher" : {
+ "type" : "object",
+ "properties": {
+ "exe" : { "type" :"string" },
+ "app_id" : { "type" :"string" }
+ },
+ "oneOf": [
+ {"required": [
+ "exe"
+ ]},
+ {"required": [
+ "app_id"
+ ]}
+ ]
+ },
+
+ "process" : {
+ "type" : "object",
+ "properties": {
+ "type" : { "const": "PROCESS" },
+ "frequency" : { "type" : "integer" },
+ "matchers" : {
+ "type" : ["array"],
+ "items": {
+ "$ref": "#/definitions/matcher"
+ }
+ }
+ },
+ "required": [ "type", "frequency", "matchers" ]
+ },
+
+ "load_avg" : {
+ "type" : "object",
+ "properties": {
+ "type" : { "const": "LOAD_AVG" },
+ "frequency" : { "type" : "integer" }
+ },
+ "required": [ "type", "frequency" ]
+ }
+ },
+
+ "type" : "object",
+ "properties": {
+ "total_duration" : { "type" : "integer"},
+ "config_entry" : {
+ "type" : "array",
+ "items": {
+ "anyOf": [
+ { "$ref" : "#/definitions/top" },
+ { "$ref" : "#/definitions/system" },
+ { "$ref" : "#/definitions/process" },
+ { "$ref" : "#/definitions/load_avg" }
+ ]
+ }
+ }
+ }
+}
diff --git a/schemas/load_avg.response.example.json b/schemas/load_avg.response.example.json
new file mode 100644
index 0000000..20313dc
--- /dev/null
+++ b/schemas/load_avg.response.example.json
@@ -0,0 +1,9 @@
+{
+ "type": "LOAD_AVG",
+ "time": 1426751189,
+ "load_avg_data": {
+ "one_min_avg": 1.059999942779541,
+ "five_min_avg": 1.059999942779541,
+ "fifteen_min_avg": 1.0499999523162842
+ }
+}
diff --git a/schemas/process.reposnse.example.json b/schemas/process.reposnse.example.json
new file mode 100644
index 0000000..f8284ea
--- /dev/null
+++ b/schemas/process.reposnse.example.json
@@ -0,0 +1,20 @@
+{
+ "type": "PROCESS",
+ "time": 1426751608,
+ "process_data": [
+ {
+ "app_id": null,
+ "exe": "/usr/bin/sensord",
+ "pid": 359,
+ "cpu": 0.0033074936363846064,
+ "memory": 0.0094098867848515511
+ },
+ {
+ "app_id": "org.tizen.lockscreen",
+ "exe": "/usr/bin/launchpad-loader",
+ "pid": 7341,
+ "cpu": 0.0,
+ "memory": 0.025191599503159523
+ }
+ ]
+}
diff --git a/schemas/response.schema.json b/schemas/response.schema.json
new file mode 100644
index 0000000..a48e115
--- /dev/null
+++ b/schemas/response.schema.json
@@ -0,0 +1,120 @@
+{
+ "$schema": "http://json-schema.org/schema#",
+ "id": "http://ttsd-worker-task.org/schemas/response.json",
+ "definitions": {
+ "response_type": {
+ "enum": [
+ "LOAD_AVG",
+ "SYSTEM",
+ "PROCESS",
+ "TOP"
+ ]
+ },
+ "process": {
+ "type": "object",
+ "properties": {
+ "app_id": {
+ "type": ["string", "null"]
+ },
+ "exe": {
+ "type": "string"
+ },
+ "pid": {
+ "type": "integer"
+ },
+ "cpu": {
+ "type": "number"
+ },
+ "memory": {
+ "type": "number"
+ }
+ },
+ "required": [
+ "app_id",
+ "exe",
+ "cpu",
+ "memory",
+ "pid"
+ ],
+ "additionalProperties": false
+ }
+ },
+ "type": "object",
+ "properties": {
+ "type": {
+ "$ref": "#/definitions/response_type"
+ },
+ "time": {
+ "type": "integer"
+ },
+ "system_data": {
+ "type": "object",
+ "properties": {
+ "cpu": {
+ "type": "number"
+ },
+ "memory": {
+ "type": "number"
+ }
+ },
+ "required": [
+ "cpu",
+ "memory"
+ ]
+ },
+ "load_avg_data": {
+ "type": "object",
+ "properties": {
+ "one_min_avg": {
+ "type": "number"
+ },
+ "five_min_avg": {
+ "type": "number"
+ },
+ "fifteen_min_avg": {
+ "type": "number"
+ }
+ },
+ "required": [
+ "one_min_avg",
+ "five_min_avg",
+ "fifteen_min_avg"
+ ]
+ },
+ "process_data": {
+ "type": [
+ "array"
+ ],
+ "items": {
+ "$ref": "#/definitions/process"
+ }
+ },
+ "top_data": {
+ "type": "object",
+ "properties": {
+ "cpu": {
+ "type": [
+ "array"
+ ],
+ "items": {
+ "$ref": "#/definitions/process"
+ }
+ },
+ "memory": {
+ "type": [
+ "array"
+ ],
+ "items": {
+ "$ref": "#/definitions/process"
+ }
+ }
+ }
+ }
+ },
+ "required": [
+ "time",
+ "type"
+ ],
+ "minProperties": 1,
+ "additionalProperties": false
+}
diff --git a/schemas/system.response.example.json b/schemas/system.response.example.json
new file mode 100644
index 0000000..9fd688a
--- /dev/null
+++ b/schemas/system.response.example.json
@@ -0,0 +1,8 @@
+{
+ "type": "SYSTEM",
+ "time": 1426751215,
+ "system_data": {
+ "cpu": 0.010067113675177097,
+ "memory": 0.414577841758728
+ }
+}
diff --git a/schemas/top.response.example.json b/schemas/top.response.example.json
new file mode 100644
index 0000000..f305deb
--- /dev/null
+++ b/schemas/top.response.example.json
@@ -0,0 +1,38 @@
+{
+ "type": "TOP",
+ "time": 1426751252,
+ "top_data": {
+ "cpu": [
+ {
+ "app_id": null,
+ "exe": "/usr/bin/sensord",
+ "pid": 359,
+ "cpu": 0.0033074936363846064,
+ "memory": 0.0094098867848515511
+ },
+ {
+ "app_id": null,
+ "exe": "/usr/bin/stc-manager",
+ "pid": 476,
+ "cpu": 0.0033074936363846064,
+ "memory": 0.0051120435819029808
+ }
+ ],
+ "memory": [
+ {
+ "app_id": "org.tizen.clock",
+ "exe": "/usr/bin/launchpad-loader",
+ "pid": 11987,
+ "cpu": 0.0,
+ "memory": 0.032782699912786484
+ },
+ {
+ "app_id": "org.tizen.quickpanel",
+ "exe": "/usr/apps/org.tizen.quickpanel/bin/quickpanel",
+ "pid": 884,
+ "cpu": 0.0,
+ "memory": 0.02692531980574131
+ }
+ ]
+ }
+}