From 20e71717d730f65b2f922477e4aaf7fef9f6dcb4 Mon Sep 17 00:00:00 2001 From: xuxuepeng Date: Tue, 5 Nov 2024 23:10:59 +0800 Subject: [PATCH 22/25] json schema for sandbox api Signed-off-by: xuxuepeng --- src/json/schema/defs.json | 16 +++++++ src/json/schema/sandbox/create-request.json | 33 ++++++++++++++ src/json/schema/sandbox/create-response.json | 9 ++++ src/json/schema/sandbox/metrics-request.json | 12 +++++ src/json/schema/sandbox/metrics-response.json | 18 ++++++++ src/json/schema/sandbox/platform-request.json | 12 +++++ .../schema/sandbox/platform-response.json | 15 +++++++ src/json/schema/sandbox/sandbox.json | 44 +++++++++++++++++++ src/json/schema/sandbox/shutdown-request.json | 12 +++++ src/json/schema/sandbox/start-request.json | 12 +++++ src/json/schema/sandbox/start-response.json | 24 ++++++++++ src/json/schema/sandbox/status-request.json | 15 +++++++ src/json/schema/sandbox/status-response.json | 36 +++++++++++++++ src/json/schema/sandbox/stop-request.json | 15 +++++++ src/json/schema/sandbox/update-request.json | 21 +++++++++ src/json/schema/sandbox/wait-request.json | 12 +++++ src/json/schema/sandbox/wait-response.json | 15 +++++++ 17 files changed, 321 insertions(+) create mode 100644 src/json/schema/sandbox/create-request.json create mode 100644 src/json/schema/sandbox/create-response.json create mode 100644 src/json/schema/sandbox/metrics-request.json create mode 100644 src/json/schema/sandbox/metrics-response.json create mode 100644 src/json/schema/sandbox/platform-request.json create mode 100644 src/json/schema/sandbox/platform-response.json create mode 100644 src/json/schema/sandbox/sandbox.json create mode 100644 src/json/schema/sandbox/shutdown-request.json create mode 100644 src/json/schema/sandbox/start-request.json create mode 100644 src/json/schema/sandbox/start-response.json create mode 100644 src/json/schema/sandbox/status-request.json create mode 100644 src/json/schema/sandbox/status-response.json create mode 100644 src/json/schema/sandbox/stop-request.json create mode 100644 src/json/schema/sandbox/update-request.json create mode 100644 src/json/schema/sandbox/wait-request.json create mode 100644 src/json/schema/sandbox/wait-response.json diff --git a/src/json/schema/defs.json b/src/json/schema/defs.json index 22683c2..854a816 100644 --- a/src/json/schema/defs.json +++ b/src/json/schema/defs.json @@ -406,6 +406,22 @@ } } }, + "mapStringObjectByteArray": { + "type": "object", + "patternProperties": { + ".{1,}": { + "type": "object", + "properties": { + "Element": { + "type": "array", + "items": { + "type": "byte" + } + } + } + } + } + }, "digest": { "type": "string", "pattern": "^[a-z0-9]+(?:[+._-][a-z0-9]+)*:[a-zA-Z0-9=_-]+$" diff --git a/src/json/schema/sandbox/create-request.json b/src/json/schema/sandbox/create-request.json new file mode 100644 index 0000000..2e5a06d --- /dev/null +++ b/src/json/schema/sandbox/create-request.json @@ -0,0 +1,33 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "sandbox_id": { + "type": "string" + }, + "rootfs": { + "type": "array", + "items": { + "$ref": "mount.json" + } + }, + "options": { + "type": "array", + "items": { + "type": "byte" + } + }, + "netns_path": { + "type": "string" + }, + "annotations": { + "$ref": "../defs.json#/definitions/mapStringString" + }, + "sandbox":{ + "$ref": "sandbox.json" + }, + "sandboxer": { + "type": "string" + } + } +} diff --git a/src/json/schema/sandbox/create-response.json b/src/json/schema/sandbox/create-response.json new file mode 100644 index 0000000..54d0eae --- /dev/null +++ b/src/json/schema/sandbox/create-response.json @@ -0,0 +1,9 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "sandbox_id": { + "type": "string" + } + } +} diff --git a/src/json/schema/sandbox/metrics-request.json b/src/json/schema/sandbox/metrics-request.json new file mode 100644 index 0000000..c54006b --- /dev/null +++ b/src/json/schema/sandbox/metrics-request.json @@ -0,0 +1,12 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "sandbox_id": { + "type": "string" + }, + "sandboxer": { + "type": "string" + } + } +} diff --git a/src/json/schema/sandbox/metrics-response.json b/src/json/schema/sandbox/metrics-response.json new file mode 100644 index 0000000..b0a255d --- /dev/null +++ b/src/json/schema/sandbox/metrics-response.json @@ -0,0 +1,18 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "timestamp": { + "type": "uint64" + }, + "id": { + "type": "string" + }, + "data": { + "type": "array", + "items": { + "type": "byte" + } + } + } +} diff --git a/src/json/schema/sandbox/platform-request.json b/src/json/schema/sandbox/platform-request.json new file mode 100644 index 0000000..c54006b --- /dev/null +++ b/src/json/schema/sandbox/platform-request.json @@ -0,0 +1,12 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "sandbox_id": { + "type": "string" + }, + "sandboxer": { + "type": "string" + } + } +} diff --git a/src/json/schema/sandbox/platform-response.json b/src/json/schema/sandbox/platform-response.json new file mode 100644 index 0000000..c469d8d --- /dev/null +++ b/src/json/schema/sandbox/platform-response.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "os": { + "type": "string" + }, + "architecture": { + "type": "string" + }, + "variant": { + "type": "string" + } + } +} diff --git a/src/json/schema/sandbox/sandbox.json b/src/json/schema/sandbox/sandbox.json new file mode 100644 index 0000000..786ac1f --- /dev/null +++ b/src/json/schema/sandbox/sandbox.json @@ -0,0 +1,44 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "sandbox_id": { + "type": "string" + }, + "runtime": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "options": { + "type": "array", + "items": { + "type": "byte" + } + } + } + }, + "spec": { + "type": "array", + "items": { + "type": "byte" + } + }, + "labels": { + "$ref": "../defs.json#/definitions/mapStringString" + }, + "created_at": { + "type": "uint64" + }, + "updated_at": { + "type": "uint64" + }, + "extensions": { + "$ref": "../defs.json#/definitions/mapStringObjectByteArray" + }, + "sandboxer": { + "type": "string" + } + } +} diff --git a/src/json/schema/sandbox/shutdown-request.json b/src/json/schema/sandbox/shutdown-request.json new file mode 100644 index 0000000..c54006b --- /dev/null +++ b/src/json/schema/sandbox/shutdown-request.json @@ -0,0 +1,12 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "sandbox_id": { + "type": "string" + }, + "sandboxer": { + "type": "string" + } + } +} diff --git a/src/json/schema/sandbox/start-request.json b/src/json/schema/sandbox/start-request.json new file mode 100644 index 0000000..c54006b --- /dev/null +++ b/src/json/schema/sandbox/start-request.json @@ -0,0 +1,12 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "sandbox_id": { + "type": "string" + }, + "sandboxer": { + "type": "string" + } + } +} diff --git a/src/json/schema/sandbox/start-response.json b/src/json/schema/sandbox/start-response.json new file mode 100644 index 0000000..19d94de --- /dev/null +++ b/src/json/schema/sandbox/start-response.json @@ -0,0 +1,24 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "sandbox_id": { + "type": "string" + }, + "pid": { + "type": "uint32" + }, + "created_at": { + "type": "uint64" + }, + "labels": { + "$ref": "../defs.json#/definitions/mapStringString" + }, + "address": { + "type": "string" + }, + "version": { + "type": "uint32" + } + } +} \ No newline at end of file diff --git a/src/json/schema/sandbox/status-request.json b/src/json/schema/sandbox/status-request.json new file mode 100644 index 0000000..023abe8 --- /dev/null +++ b/src/json/schema/sandbox/status-request.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "sandbox_id": { + "type": "string" + }, + "verbose": { + "type": "boolean" + }, + "sandboxer": { + "type": "string" + } + } +} diff --git a/src/json/schema/sandbox/status-response.json b/src/json/schema/sandbox/status-response.json new file mode 100644 index 0000000..779a35d --- /dev/null +++ b/src/json/schema/sandbox/status-response.json @@ -0,0 +1,36 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "sandbox_id": { + "type": "string" + }, + "pid": { + "type": "uint32" + }, + "state": { + "type": "string" + }, + "info": { + "$ref": "../defs.json#/definitions/mapStringString" + }, + "created_at": { + "type": "uint64" + }, + "exited_at": { + "type": "uint64" + }, + "extra": { + "type": "array", + "items": { + "type": "byte" + } + }, + "address": { + "type": "string" + }, + "version": { + "type": "uint32" + } + } +} diff --git a/src/json/schema/sandbox/stop-request.json b/src/json/schema/sandbox/stop-request.json new file mode 100644 index 0000000..ee7c8ac --- /dev/null +++ b/src/json/schema/sandbox/stop-request.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "sandbox_id": { + "type": "string" + }, + "timeout_secs": { + "type": "uint32" + }, + "sandboxer": { + "type": "string" + } + } +} diff --git a/src/json/schema/sandbox/update-request.json b/src/json/schema/sandbox/update-request.json new file mode 100644 index 0000000..60c44a2 --- /dev/null +++ b/src/json/schema/sandbox/update-request.json @@ -0,0 +1,21 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "sandbox_id": { + "type": "string" + }, + "sandboxer": { + "type": "string" + }, + "sandbox": { + "$ref": "sandbox.json" + }, + "fields": { + "type": "array", + "items": { + "type": "string" + } + } + } +} diff --git a/src/json/schema/sandbox/wait-request.json b/src/json/schema/sandbox/wait-request.json new file mode 100644 index 0000000..3b77d39 --- /dev/null +++ b/src/json/schema/sandbox/wait-request.json @@ -0,0 +1,12 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "sandbox_id": { + "type": "string" + }, + "sandboxer": { + "type": "string" + } + } +} \ No newline at end of file diff --git a/src/json/schema/sandbox/wait-response.json b/src/json/schema/sandbox/wait-response.json new file mode 100644 index 0000000..49a42f1 --- /dev/null +++ b/src/json/schema/sandbox/wait-response.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "sandbox_id": { + "type": "string" + }, + "exit_status": { + "type": "uint32" + }, + "exited_at": { + "type": "uint64" + } + } +} -- 2.34.1