{ "schemes": [ "http" ], "swagger": "2.0", "info": { "description": "NethServer 8 API is used to create tasks across the nodes", "title": "NethServer 8 API", "termsOfService": "https://nethserver.org/terms/", "contact": { "name": "NethServer Developer Team", "url": "https://nethserver.org/support" }, "license": { "name": "GNU GENERAL PUBLIC LICENSE" }, "version": "1.0" }, "host": "localhost:8080", "basePath": "/api", "paths": { "/2FA": { "get": { "description": "get current 2FA status for user", "produces": [ "application/json" ], "tags": [ "/2FA auth" ], "summary": "Get current 2FA status for user", "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusOK" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "object" }, "message": { "type": "string" } } } ] } }, "500": { "description": "Internal Server Error", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusInternalServerError" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "object" }, "message": { "type": "string" } } } ] } } } }, "post": { "produces": [ "application/json" ], "tags": [ "/2FA auth" ], "summary": "Set the 2FA Redis flag, if OTP is verified", "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusOK" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "object" }, "message": { "type": "string" } } } ] } }, "400": { "description": "Bad Request", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusBadRequest" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "object" }, "message": { "type": "string" } } } ] } } } }, "delete": { "description": "revocate secret for 2FA", "produces": [ "application/json" ], "tags": [ "/2FA auth" ], "summary": "Revocate secret for 2FA", "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusOK" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "object" }, "message": { "type": "string" } } } ] } }, "500": { "description": "Internal Server Error", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusInternalServerError" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "object" }, "message": { "type": "string" } } } ] } } } } }, "/2FA/qrcode": { "get": { "description": "use this API to generate a valid qr-code for google auth", "produces": [ "application/json" ], "tags": [ "/2FA/qrcode auth" ], "summary": "Generate QRCode for 2FA", "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusOK" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "object" }, "message": { "type": "string" } } } ] } }, "500": { "description": "Internal Server Error", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusInternalServerError" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "object" }, "message": { "type": "string" } } } ] } } } } }, "/audit": { "get": { "description": "get audit logs (user, action, data, timestamp)", "produces": [ "application/json" ], "tags": [ "/audit audit" ], "summary": "Get audit logs for user, action and timestamp", "parameters": [ { "type": "string", "description": "user search by user", "name": "user", "in": "query" }, { "type": "string", "description": "action search by action", "name": "action", "in": "query" }, { "type": "string", "description": "data full text search by data", "name": "data", "in": "query" }, { "type": "string", "description": "filter result search by from date ISO8601", "name": "from", "in": "query" }, { "type": "string", "description": "filter result search by to date ISO8601", "name": "to", "in": "query" }, { "type": "string", "description": "limit results to limit value", "name": "limit", "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusOK" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "string" }, "message": { "type": "string" } } } ] }, "headers": { "Authorization": { "type": "string", "description": "Bearer \u003cvalid.JWT.token\u003e" } } }, "400": { "description": "Bad Request", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusBadRequest" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "object" }, "message": { "type": "string" } } } ] } } } } }, "/audit/actions": { "get": { "description": "get audit actions", "produces": [ "application/json" ], "tags": [ "/audit audit" ], "summary": "Get all actions in audit.db", "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusOK" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "string" }, "message": { "type": "string" } } } ] }, "headers": { "Authorization": { "type": "string", "description": "Bearer \u003cvalid.JWT.token\u003e" } } }, "400": { "description": "Bad Request", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusBadRequest" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "object" }, "message": { "type": "string" } } } ] } } } } }, "/audit/users": { "get": { "description": "get audit users", "produces": [ "application/json" ], "tags": [ "/audit audit" ], "summary": "Get all users in audit.db", "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusOK" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "string" }, "message": { "type": "string" } } } ] }, "headers": { "Authorization": { "type": "string", "description": "Bearer \u003cvalid.JWT.token\u003e" } } }, "400": { "description": "Bad Request", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusBadRequest" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "object" }, "message": { "type": "string" } } } ] } } } } }, "/cluster/task/{task_id}/context": { "get": { "description": "get task statuses (context)", "produces": [ "application/json" ], "tags": [ "/tasks cluster" ], "summary": "Get the context of a cluster task", "parameters": [ { "type": "string", "description": "Task ID", "name": "task_id", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusOK" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "string" }, "message": { "type": "string" } } } ] }, "headers": { "Authorization": { "type": "string", "description": "Bearer \u003cvalid.JWT.token\u003e" } } }, "400": { "description": "Bad Request", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusBadRequest" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "object" }, "message": { "type": "string" } } } ] } } } } }, "/cluster/task/{task_id}/status": { "get": { "description": "get task statuses (output, error, exit_code)", "produces": [ "application/json" ], "tags": [ "/tasks cluster" ], "summary": "Get the output, error or exit code of a cluster task", "parameters": [ { "type": "string", "description": "Task ID", "name": "task_id", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusOK" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "string" }, "message": { "type": "string" } } } ] }, "headers": { "Authorization": { "type": "string", "description": "Bearer \u003cvalid.JWT.token\u003e" } } }, "400": { "description": "Bad Request", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusBadRequest" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "object" }, "message": { "type": "string" } } } ] } } } } }, "/cluster/tasks": { "get": { "description": "get cluster tasks", "produces": [ "application/json" ], "tags": [ "/tasks cluster" ], "summary": "Get the list of current cluster tasks", "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusOK" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "array", "items": { "$ref": "#/definitions/models.Task" } }, "message": { "type": "string" } } } ] }, "headers": { "Authorization": { "type": "string", "description": "Bearer \u003cvalid.JWT.token\u003e" } } }, "400": { "description": "Bad Request", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusBadRequest" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "object" }, "message": { "type": "string" } } } ] } } } }, "post": { "description": "create a cluster task", "produces": [ "application/json" ], "tags": [ "/tasks cluster" ], "summary": "Create and queue a cluster task", "parameters": [ { "description": "Task Payload", "name": "payload", "in": "body", "required": true, "schema": { "$ref": "#/definitions/models.TaskJSON" } } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusCreated" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "$ref": "#/definitions/models.Task" }, "message": { "type": "string" } } } ] }, "headers": { "Authorization": { "type": "string", "description": "Bearer \u003cvalid.JWT.token\u003e" } } }, "400": { "description": "Bad Request", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusBadRequest" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "object" }, "message": { "type": "string" } } } ] } } } } }, "/logout": { "post": { "description": "logout and remove JWT token", "produces": [ "application/json" ], "tags": [ "/logout auth" ], "summary": "Login and remove JWT token", "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusOK" }, { "type": "object", "properties": { "code": { "type": "integer" } } } ] }, "headers": { "Authorization": { "type": "string", "description": "Bearer \u003cvalid.JWT.token\u003e" } } }, "500": { "description": "Internal Server Error", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusInternalServerError" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "object" }, "message": { "type": "string" } } } ] } } } } }, "/module/{module_id}/http-basic/{action}": { "get": { "description": "for a specific action, check basic auth for module", "produces": [ "application/json" ], "tags": [ "/module basic_auth" ], "summary": "Use Basic HTTP auth for module", "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusOK" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "object" }, "message": { "type": "string" } } } ] } }, "401": { "description": "Unauthorized", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusUnauthorized" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "object" }, "message": { "type": "string" } } } ] } }, "403": { "description": "Forbidden", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusForbidden" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "object" }, "message": { "type": "string" } } } ] } } } } }, "/module/{module_id}/task/{task_id}/context": { "get": { "description": "get task statuses (context)", "produces": [ "application/json" ], "tags": [ "/tasks module" ], "summary": "Get the context of a module task", "parameters": [ { "type": "string", "description": "Module ID", "name": "module_id", "in": "path", "required": true }, { "type": "string", "description": "Task ID", "name": "task_id", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusOK" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "string" }, "message": { "type": "string" } } } ] }, "headers": { "Authorization": { "type": "string", "description": "Bearer \u003cvalid.JWT.token\u003e" } } }, "400": { "description": "Bad Request", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusBadRequest" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "object" }, "message": { "type": "string" } } } ] } } } } }, "/module/{module_id}/task/{task_id}/status": { "get": { "description": "get task statuses (output, error, exit_code)", "produces": [ "application/json" ], "tags": [ "/tasks module" ], "summary": "Get the output, error or exit code of a module task", "parameters": [ { "type": "string", "description": "Module ID", "name": "module_id", "in": "path", "required": true }, { "type": "string", "description": "Task ID", "name": "task_id", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusOK" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "string" }, "message": { "type": "string" } } } ] }, "headers": { "Authorization": { "type": "string", "description": "Bearer \u003cvalid.JWT.token\u003e" } } }, "400": { "description": "Bad Request", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusBadRequest" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "object" }, "message": { "type": "string" } } } ] } } } } }, "/module/{module_id}/tasks": { "get": { "description": "get module tasks", "produces": [ "application/json" ], "tags": [ "/tasks module" ], "summary": "Get the list of current module tasks", "parameters": [ { "type": "string", "description": "Module ID", "name": "module_id", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusOK" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "array", "items": { "$ref": "#/definitions/models.Task" } }, "message": { "type": "string" } } } ] }, "headers": { "Authorization": { "type": "string", "description": "Bearer \u003cvalid.JWT.token\u003e" } } }, "400": { "description": "Bad Request", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusBadRequest" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "object" }, "message": { "type": "string" } } } ] } } } }, "post": { "description": "create a module task", "produces": [ "application/json" ], "tags": [ "/tasks module" ], "summary": "Create and queue a module task", "parameters": [ { "type": "string", "description": "Module ID", "name": "module_id", "in": "path", "required": true }, { "description": "Task Payload", "name": "payload", "in": "body", "required": true, "schema": { "$ref": "#/definitions/models.TaskJSON" } } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusCreated" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "$ref": "#/definitions/models.Task" }, "message": { "type": "string" } } } ] }, "headers": { "Authorization": { "type": "string", "description": "Bearer \u003cvalid.JWT.token\u003e" } } }, "400": { "description": "Bad Request", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusBadRequest" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "object" }, "message": { "type": "string" } } } ] } } } } }, "/modules": { "get": { "description": "get modules", "produces": [ "application/json" ], "tags": [ "/tasks node" ], "summary": "Get the list of modules", "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusOK" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "array", "items": { "type": "string" } }, "message": { "type": "string" } } } ] }, "headers": { "Authorization": { "type": "string", "description": "Bearer \u003cvalid.JWT.token\u003e" } } }, "400": { "description": "Bad Request", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusBadRequest" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "object" }, "message": { "type": "string" } } } ] } } } } }, "/node/{node_id}/task/{task_id}/context": { "get": { "description": "get task statuses (context)", "produces": [ "application/json" ], "tags": [ "/tasks node" ], "summary": "Get the context of a node task", "parameters": [ { "type": "string", "description": "Node ID", "name": "node_id", "in": "path", "required": true }, { "type": "string", "description": "Task ID", "name": "task_id", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusOK" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "string" }, "message": { "type": "string" } } } ] }, "headers": { "Authorization": { "type": "string", "description": "Bearer \u003cvalid.JWT.token\u003e" } } }, "400": { "description": "Bad Request", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusBadRequest" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "object" }, "message": { "type": "string" } } } ] } } } } }, "/node/{node_id}/task/{task_id}/status": { "get": { "description": "get task statuses (output, error, exit_code)", "produces": [ "application/json" ], "tags": [ "/tasks node" ], "summary": "Get the output, error or exit code of a node task", "parameters": [ { "type": "string", "description": "Node ID", "name": "node_id", "in": "path", "required": true }, { "type": "string", "description": "Task ID", "name": "task_id", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusOK" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "string" }, "message": { "type": "string" } } } ] }, "headers": { "Authorization": { "type": "string", "description": "Bearer \u003cvalid.JWT.token\u003e" } } }, "400": { "description": "Bad Request", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusBadRequest" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "object" }, "message": { "type": "string" } } } ] } } } } }, "/node/{node_id}/tasks": { "get": { "description": "get node tasks", "produces": [ "application/json" ], "tags": [ "/tasks node" ], "summary": "Get the list of current node tasks", "parameters": [ { "type": "string", "description": "Node ID", "name": "node_id", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusOK" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "array", "items": { "$ref": "#/definitions/models.Task" } }, "message": { "type": "string" } } } ] }, "headers": { "Authorization": { "type": "string", "description": "Bearer \u003cvalid.JWT.token\u003e" } } }, "400": { "description": "Bad Request", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusBadRequest" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "object" }, "message": { "type": "string" } } } ] } } } }, "post": { "description": "create a node task", "produces": [ "application/json" ], "tags": [ "/tasks node" ], "summary": "Create and queue a node task", "parameters": [ { "type": "string", "description": "Node ID", "name": "node_id", "in": "path", "required": true }, { "description": "Task Payload", "name": "payload", "in": "body", "required": true, "schema": { "$ref": "#/definitions/models.TaskJSON" } } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusCreated" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "$ref": "#/definitions/models.Task" }, "message": { "type": "string" } } } ] }, "headers": { "Authorization": { "type": "string", "description": "Bearer \u003cvalid.JWT.token\u003e" } } }, "400": { "description": "Bad Request", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusBadRequest" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "object" }, "message": { "type": "string" } } } ] } } } } }, "/nodes": { "get": { "description": "get nodes", "produces": [ "application/json" ], "tags": [ "/tasks node" ], "summary": "Get the list of nodes", "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusOK" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "array", "items": { "type": "string" } }, "message": { "type": "string" } } } ] }, "headers": { "Authorization": { "type": "string", "description": "Bearer \u003cvalid.JWT.token\u003e" } } }, "400": { "description": "Bad Request", "schema": { "allOf": [ { "$ref": "#/definitions/response.StatusBadRequest" }, { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "object" }, "message": { "type": "string" } } } ] } } } } } }, "definitions": { "models.Task": { "type": "object", "properties": { "action": { "type": "string" }, "data": {}, "extra": {}, "id": { "type": "string" }, "parent": { "type": "string" }, "queue": { "type": "string" }, "timestamp": { "type": "string" }, "user": { "type": "string" } } }, "models.TaskJSON": { "type": "object", "properties": { "action": { "type": "string", "example": "list-modules" }, "data": {}, "extra": {}, "id": { "type": "string", "example": "null" }, "parent": { "type": "string" } } }, "response.StatusBadRequest": { "type": "object", "properties": { "code": { "type": "integer", "example": 400 }, "data": {}, "message": { "type": "string", "example": "Bad request" } } }, "response.StatusCreated": { "type": "object", "properties": { "code": { "type": "integer", "example": 201 }, "data": {}, "message": { "type": "string", "example": "Created" } } }, "response.StatusForbidden": { "type": "object", "properties": { "code": { "type": "integer", "example": 403 }, "data": {}, "message": { "type": "string", "example": "Forbidden" } } }, "response.StatusInternalServerError": { "type": "object", "properties": { "code": { "type": "integer", "example": 500 }, "data": {}, "message": { "type": "string", "example": "Internal server error" } } }, "response.StatusOK": { "type": "object", "properties": { "code": { "type": "integer", "example": 200 }, "data": {}, "message": { "type": "string", "example": "Success" } } }, "response.StatusUnauthorized": { "type": "object", "properties": { "code": { "type": "integer", "example": 401 }, "data": {}, "message": { "type": "string", "example": "Unauthorized" } } } } }