From f59ca2b6055aaa9a82d1ea4fbb5201e5cabd9b2e Mon Sep 17 00:00:00 2001 From: hantmac Date: Fri, 1 May 2020 23:11:51 +0800 Subject: [PATCH] Add swagger docs --- backend/docs/docs.go | 2816 ++++++++++++++++++++++++++++++++++++ backend/docs/swagger.json | 2748 +++++++++++++++++++++++++++++++++++ backend/docs/swagger.yaml | 1848 +++++++++++++++++++++++ backend/go.mod | 3 + backend/go.sum | 40 + backend/main.go | 11 + backend/routes/node.go | 55 + backend/routes/project.go | 47 + backend/routes/schedule.go | 67 + backend/routes/setting.go | 16 + backend/routes/spider.go | 326 +++++ 11 files changed, 7977 insertions(+) create mode 100644 backend/docs/docs.go create mode 100644 backend/docs/swagger.json create mode 100644 backend/docs/swagger.yaml diff --git a/backend/docs/docs.go b/backend/docs/docs.go new file mode 100644 index 00000000..bd40f33a --- /dev/null +++ b/backend/docs/docs.go @@ -0,0 +1,2816 @@ +// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// This file was generated by swaggo/swag at +// 2020-05-01 23:10:59.173446 +0800 CST m=+0.074737526 + +package docs + +import ( + "bytes" + "encoding/json" + "strings" + + "github.com/alecthomas/template" + "github.com/swaggo/swag" +) + +var doc = `{ + "schemes": {{ marshal .Schemes }}, + "swagger": "2.0", + "info": { + "description": "{{.Description}}", + "title": "{{.Title}}", + "contact": {}, + "license": {}, + "version": "{{.Version}}" + }, + "host": "{{.Host}}", + "basePath": "{{.BasePath}}", + "paths": { + "/nodes": { + "get": { + "description": "Get nodes", + "produces": [ + "application/json" + ], + "tags": [ + "node" + ], + "summary": "Get nodes", + "parameters": [ + { + "type": "string", + "description": "With the bearer started", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/nodes/{id}": { + "get": { + "description": "Get node", + "produces": [ + "application/json" + ], + "tags": [ + "node" + ], + "summary": "Get node", + "parameters": [ + { + "type": "string", + "description": "With the bearer started", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + }, + "post": { + "description": "Post node", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "node" + ], + "summary": "Post node", + "parameters": [ + { + "type": "string", + "description": "With the bearer started", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "post node", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + }, + "delete": { + "description": "Delete node", + "produces": [ + "application/json" + ], + "tags": [ + "node" + ], + "summary": "Delete node", + "parameters": [ + { + "type": "string", + "description": "With the bearer started", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "node id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/nodes/{id}/system": { + "get": { + "description": "Get system info", + "produces": [ + "application/json" + ], + "tags": [ + "node" + ], + "summary": "Get system info", + "parameters": [ + { + "type": "string", + "description": "With the bearer started", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "node id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/nodes/{id}/tasks": { + "get": { + "description": "Get tasks on node", + "produces": [ + "application/json" + ], + "tags": [ + "node" + ], + "summary": "Get tasks on node", + "parameters": [ + { + "type": "string", + "description": "With the bearer started", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "node id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/projects": { + "get": { + "description": "Get projects", + "produces": [ + "application/json" + ], + "tags": [ + "project" + ], + "summary": "Get projects", + "parameters": [ + { + "type": "string", + "description": "With the bearer started", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "projects", + "name": "tag", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + }, + "put": { + "description": "Put project", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "project" + ], + "summary": "Put project", + "parameters": [ + { + "type": "string", + "description": "With the bearer started", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "post project", + "name": "p", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/model.Project" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + } + }, + "/projects/tags": { + "get": { + "description": "Get projects tags", + "produces": [ + "application/json" + ], + "tags": [ + "project" + ], + "summary": "Get project tags", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/projects/{id}": { + "post": { + "description": "Post project", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "project" + ], + "summary": "Post project", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "project id", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "project item", + "name": "item", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/model.Project" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + }, + "delete": { + "description": "Delete project", + "produces": [ + "application/json" + ], + "tags": [ + "project" + ], + "summary": "Delete project", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "project id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/schedules": { + "get": { + "description": "Get schedule list", + "produces": [ + "application/json" + ], + "tags": [ + "schedule" + ], + "summary": "Get schedule list", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + }, + "put": { + "description": "Put schedule", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "schedule" + ], + "summary": "Put schedule", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "schedule item", + "name": "item", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/model.Schedule" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + } + }, + "/schedules/{id}": { + "get": { + "description": "Get schedule by id", + "produces": [ + "application/json" + ], + "tags": [ + "schedule" + ], + "summary": "Get schedule by id", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "schedule id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + }, + "post": { + "description": "Post schedule", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "schedule" + ], + "summary": "Post schedule", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "schedule id", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "schedule item", + "name": "newItem", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/model.Schedule" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + }, + "delete": { + "description": "Delete schedule", + "produces": [ + "application/json" + ], + "tags": [ + "schedule" + ], + "summary": "Delete schedule", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "schedule id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/schedules/{id}/disable": { + "post": { + "description": "disable schedule", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "schedule" + ], + "summary": "disable schedule", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "schedule id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + } + }, + "/schedules/{id}/enable": { + "post": { + "description": "enable schedule", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "schedule" + ], + "summary": "enable schedule", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "schedule id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + } + }, + "/setting": { + "get": { + "description": "Get setting", + "produces": [ + "application/json" + ], + "tags": [ + "setting" + ], + "summary": "Get setting", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders": { + "put": { + "description": "Put spider", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Put spider", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "spider item", + "name": "spider", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/model.Spider" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + }, + "post": { + "description": "delete spider", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "delete spider", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders-cancel": { + "post": { + "description": "cancel spider", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "cancel spider", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders-run": { + "post": { + "description": "run spider", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "run spider", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders/{id}": { + "get": { + "description": "Get spider by id", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Get spider by id", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "schedule id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + }, + "post": { + "description": "Post spider", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Post spider", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "schedule id", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "spider item", + "name": "item", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/model.Spider" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + }, + "delete": { + "description": "Delete spider by id", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Delete spider by id", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders/{id}/copy": { + "post": { + "description": "Copy spider", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Copy spider", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "schedule id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders/{id}/dir": { + "get": { + "description": "Get spider dir", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Get spider dir", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "path", + "name": "path", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders/{id}/file": { + "get": { + "description": "Get spider file", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Get spider file", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "path", + "name": "path", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + }, + "put": { + "description": "Post spider dir", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Post spider dir", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "path", + "name": "reqBody", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/routes.SpiderFileReqBody" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + }, + "post": { + "description": "Put spider file", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Put spider file", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "path", + "name": "reqBody", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/routes.SpiderFileReqBody" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + }, + "delete": { + "description": "Delete spider file", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Delete spider file", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "path", + "name": "reqBody", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/routes.SpiderFileReqBody" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders/{id}/file/rename": { + "post": { + "description": "Rename spider file", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Rename spider file", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "path", + "name": "reqBody", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/routes.SpiderFileReqBody" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders/{id}/file/tree": { + "get": { + "description": "Get spider dir", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Get spider dir", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders/{id}/git/reset": { + "post": { + "description": "Post spider reset git", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Post spider reset git", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders/{id}/git/sync": { + "post": { + "description": "Post spider sync git", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Post spider sync git", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders/{id}/publish": { + "post": { + "description": "Publish spider", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Publish spider", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "schedule id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders/{id}/schedules": { + "get": { + "description": "Get schedules", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Get schedules", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders/{id}/scrapy/items": { + "get": { + "description": "Get scrapy spider items", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Get scrapy spider items", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + }, + "post": { + "description": "Post scrapy spider items", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Post scrapy spider items", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "req data", + "name": "reqData", + "in": "body", + "required": true, + "schema": { + "type": "entity.ScrapyItem", + "items": { + "$ref": "#/definitions/entity.ScrapyItem" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders/{id}/scrapy/pipelines": { + "get": { + "description": "Get scrapy spider pipelines", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Get scrapy spider pipelines", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders/{id}/scrapy/settings": { + "get": { + "description": "Get scrapy spider settings", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Get scrapy spider settings", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + }, + "post": { + "description": "Get scrapy spider file", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Get scrapy spider file", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "req data", + "name": "reqData", + "in": "body", + "required": true, + "schema": { + "type": "entity.ScrapySettingParam", + "items": { + "$ref": "#/definitions/entity.ScrapySettingParam" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders/{id}/scrapy/spider/filepath": { + "get": { + "description": "Get scrapy spider file path", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Get scrapy spider file path", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders/{id}/scrapy/spiders": { + "get": { + "description": "Get scrapy spider file", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Get scrapy spider file", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + }, + "put": { + "description": "Put scrapy spider file", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Put scrapy spider file", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders/{id}/stats": { + "get": { + "description": "Get spider stats", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Get spider stats", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders/{id}/tasks": { + "get": { + "description": "Get task list", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Get task list", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders/{id}/upload": { + "post": { + "description": "Upload spider by id", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Upload spider by id", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "file", + "description": "spider file to upload", + "name": "file", + "in": "formData", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + } + }, + "/version": { + "get": { + "description": "Get version", + "produces": [ + "application/json" + ], + "tags": [ + "setting" + ], + "summary": "Get version", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + } + }, + "definitions": { + "entity.ConfigSpiderData": { + "type": "object", + "properties": { + "cmd": { + "description": "自定义爬虫", + "type": "string" + }, + "col": { + "type": "string" + }, + "display_name": { + "type": "string" + }, + "engine": { + "description": "可配置爬虫", + "type": "string" + }, + "name": { + "description": "通用", + "type": "string" + }, + "remark": { + "type": "string" + }, + "settings": { + "type": "object" + }, + "stages": { + "type": "array", + "items": { + "$ref": "#/definitions/entity.Stage" + } + }, + "start_stage": { + "type": "string" + }, + "start_url": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "entity.Field": { + "type": "object", + "properties": { + "attr": { + "type": "string" + }, + "css": { + "type": "string" + }, + "name": { + "type": "string" + }, + "next_stage": { + "type": "string" + }, + "remark": { + "type": "string" + }, + "xpath": { + "type": "string" + } + } + }, + "entity.ScrapyItem": { + "type": "object", + "properties": { + "fields": { + "type": "array", + "items": { + "type": "string" + } + }, + "name": { + "type": "string" + } + } + }, + "entity.ScrapySettingParam": { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "type": { + "type": "string" + }, + "value": { + "type": "object" + } + } + }, + "entity.Stage": { + "type": "object", + "properties": { + "fields": { + "type": "array", + "items": { + "$ref": "#/definitions/entity.Field" + } + }, + "is_list": { + "type": "boolean" + }, + "list_css": { + "type": "string" + }, + "list_xpath": { + "type": "string" + }, + "name": { + "type": "string" + }, + "page_attr": { + "type": "string" + }, + "page_css": { + "type": "string" + }, + "page_xpath": { + "type": "string" + } + } + }, + "model.Env": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "value": { + "type": "string" + } + } + }, + "model.Node": { + "type": "object", + "properties": { + "_id": { + "type": "string" + }, + "create_ts": { + "type": "string" + }, + "description": { + "type": "string" + }, + "hostname": { + "type": "string" + }, + "ip": { + "type": "string" + }, + "is_master": { + "description": "前端展示", + "type": "boolean" + }, + "key": { + "description": "用于唯一标识节点,可能是mac地址,可能是ip地址", + "type": "string" + }, + "mac": { + "type": "string" + }, + "name": { + "type": "string" + }, + "port": { + "type": "string" + }, + "status": { + "type": "string" + }, + "update_ts": { + "type": "string" + }, + "update_ts_unix": { + "type": "integer" + } + } + }, + "model.Project": { + "type": "object", + "properties": { + "_id": { + "type": "string" + }, + "create_ts": { + "type": "string" + }, + "description": { + "type": "string" + }, + "name": { + "type": "string" + }, + "spiders": { + "description": "前端展示", + "type": "array", + "items": { + "$ref": "#/definitions/model.Spider" + } + }, + "tags": { + "type": "array", + "items": { + "type": "string" + } + }, + "update_ts": { + "type": "string" + }, + "user_id": { + "type": "string" + }, + "username": { + "type": "string" + } + } + }, + "model.Schedule": { + "type": "object", + "properties": { + "_id": { + "type": "string" + }, + "create_ts": { + "type": "string" + }, + "cron": { + "type": "string" + }, + "description": { + "type": "string" + }, + "enabled": { + "type": "boolean" + }, + "entry_id": { + "type": "integer" + }, + "message": { + "type": "string" + }, + "name": { + "type": "string" + }, + "node_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "nodes": { + "type": "array", + "items": { + "$ref": "#/definitions/model.Node" + } + }, + "param": { + "type": "string" + }, + "run_type": { + "type": "string" + }, + "scrapy_log_level": { + "type": "string" + }, + "scrapy_spider": { + "type": "string" + }, + "spider_id": { + "type": "string" + }, + "spider_name": { + "description": "前端展示", + "type": "string" + }, + "status": { + "type": "string" + }, + "update_ts": { + "type": "string" + }, + "user_id": { + "type": "string" + }, + "user_name": { + "type": "string" + } + } + }, + "model.Spider": { + "type": "object", + "properties": { + "_id": { + "description": "爬虫ID", + "type": "string" + }, + "cmd": { + "description": "自定义爬虫", + "type": "string" + }, + "col": { + "description": "结果储存位置", + "type": "string" + }, + "config": { + "description": "可配置爬虫配置", + "type": "object", + "$ref": "#/definitions/entity.ConfigSpiderData" + }, + "create_ts": { + "type": "string" + }, + "dedup_field": { + "description": "去重字段", + "type": "string" + }, + "dedup_method": { + "description": "去重方式", + "type": "string" + }, + "display_name": { + "description": "爬虫显示名称", + "type": "string" + }, + "envs": { + "description": "环境变量", + "type": "array", + "items": { + "$ref": "#/definitions/model.Env" + } + }, + "file_id": { + "description": "GridFS文件ID", + "type": "string" + }, + "git_auto_sync": { + "description": "Git 是否自动同步", + "type": "boolean" + }, + "git_branch": { + "description": "Git 分支", + "type": "string" + }, + "git_has_credential": { + "description": "Git 是否加密", + "type": "boolean" + }, + "git_password": { + "description": "Git 密码", + "type": "string" + }, + "git_sync_error": { + "description": "Git 同步错误", + "type": "string" + }, + "git_sync_frequency": { + "description": "Git 同步频率", + "type": "string" + }, + "git_url": { + "description": "Git URL", + "type": "string" + }, + "git_username": { + "description": "Git 用户名", + "type": "string" + }, + "is_dedup": { + "description": "去重", + "type": "boolean" + }, + "is_git": { + "description": "Git 设置", + "type": "boolean" + }, + "is_long_task": { + "description": "长任务", + "type": "boolean" + }, + "is_public": { + "description": "是否公开", + "type": "boolean" + }, + "is_scrapy": { + "description": "Scrapy 爬虫(属于自定义爬虫)", + "type": "boolean" + }, + "is_web_hook": { + "description": "Web Hook", + "type": "boolean" + }, + "last_run_ts": { + "description": "前端展示", + "type": "string" + }, + "last_status": { + "description": "最后执行状态", + "type": "string" + }, + "latest_tasks": { + "description": "最近任务列表", + "type": "array", + "items": { + "$ref": "#/definitions/model.Task" + } + }, + "name": { + "description": "爬虫名称(唯一)", + "type": "string" + }, + "project_id": { + "description": "项目ID", + "type": "string" + }, + "remark": { + "description": "备注", + "type": "string" + }, + "site": { + "description": "爬虫网站", + "type": "string" + }, + "spider_names": { + "description": "爬虫名称列表", + "type": "array", + "items": { + "type": "string" + } + }, + "src": { + "description": "源码位置", + "type": "string" + }, + "template": { + "description": "可配置爬虫", + "type": "string" + }, + "type": { + "description": "爬虫类别", + "type": "string" + }, + "update_ts": { + "type": "string" + }, + "user_id": { + "description": "时间", + "type": "string" + }, + "username": { + "description": "用户名称", + "type": "string" + }, + "web_hook_url": { + "description": "Web Hook URL", + "type": "string" + } + } + }, + "model.Task": { + "type": "object", + "properties": { + "_id": { + "type": "string" + }, + "cmd": { + "type": "string" + }, + "create_ts": { + "type": "string" + }, + "error": { + "type": "string" + }, + "error_log_count": { + "type": "integer" + }, + "finish_ts": { + "type": "string" + }, + "log_path": { + "type": "string" + }, + "node_id": { + "type": "string" + }, + "node_name": { + "type": "string" + }, + "param": { + "type": "string" + }, + "pid": { + "type": "integer" + }, + "result_count": { + "type": "integer" + }, + "run_type": { + "type": "string" + }, + "runtime_duration": { + "type": "number" + }, + "schedule_id": { + "type": "string" + }, + "spider_id": { + "type": "string" + }, + "spider_name": { + "description": "前端数据", + "type": "string" + }, + "start_ts": { + "type": "string" + }, + "status": { + "type": "string" + }, + "total_duration": { + "type": "number" + }, + "update_ts": { + "type": "string" + }, + "user_id": { + "type": "string" + }, + "username": { + "type": "string" + }, + "wait_duration": { + "type": "number" + } + } + }, + "routes.SpiderFileReqBody": { + "type": "object", + "properties": { + "content": { + "type": "string" + }, + "new_path": { + "type": "string" + }, + "path": { + "type": "string" + } + } + } + } +}` + +type swaggerInfo struct { + Version string + Host string + BasePath string + Schemes []string + Title string + Description string +} + +// SwaggerInfo holds exported Swagger Info so clients can modify it +var SwaggerInfo = swaggerInfo{ + Version: "", + Host: "", + BasePath: "", + Schemes: []string{}, + Title: "", + Description: "", +} + +type s struct{} + +func (s *s) ReadDoc() string { + sInfo := SwaggerInfo + sInfo.Description = strings.Replace(sInfo.Description, "\n", "\\n", -1) + + t, err := template.New("swagger_info").Funcs(template.FuncMap{ + "marshal": func(v interface{}) string { + a, _ := json.Marshal(v) + return string(a) + }, + }).Parse(doc) + if err != nil { + return doc + } + + var tpl bytes.Buffer + if err := t.Execute(&tpl, sInfo); err != nil { + return doc + } + + return tpl.String() +} + +func init() { + swag.Register(swag.Name, &s{}) +} diff --git a/backend/docs/swagger.json b/backend/docs/swagger.json new file mode 100644 index 00000000..8ed42bcd --- /dev/null +++ b/backend/docs/swagger.json @@ -0,0 +1,2748 @@ +{ + "swagger": "2.0", + "info": { + "contact": {}, + "license": {} + }, + "paths": { + "/nodes": { + "get": { + "description": "Get nodes", + "produces": [ + "application/json" + ], + "tags": [ + "node" + ], + "summary": "Get nodes", + "parameters": [ + { + "type": "string", + "description": "With the bearer started", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/nodes/{id}": { + "get": { + "description": "Get node", + "produces": [ + "application/json" + ], + "tags": [ + "node" + ], + "summary": "Get node", + "parameters": [ + { + "type": "string", + "description": "With the bearer started", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + }, + "post": { + "description": "Post node", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "node" + ], + "summary": "Post node", + "parameters": [ + { + "type": "string", + "description": "With the bearer started", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "post node", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + }, + "delete": { + "description": "Delete node", + "produces": [ + "application/json" + ], + "tags": [ + "node" + ], + "summary": "Delete node", + "parameters": [ + { + "type": "string", + "description": "With the bearer started", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "node id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/nodes/{id}/system": { + "get": { + "description": "Get system info", + "produces": [ + "application/json" + ], + "tags": [ + "node" + ], + "summary": "Get system info", + "parameters": [ + { + "type": "string", + "description": "With the bearer started", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "node id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/nodes/{id}/tasks": { + "get": { + "description": "Get tasks on node", + "produces": [ + "application/json" + ], + "tags": [ + "node" + ], + "summary": "Get tasks on node", + "parameters": [ + { + "type": "string", + "description": "With the bearer started", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "node id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/projects": { + "get": { + "description": "Get projects", + "produces": [ + "application/json" + ], + "tags": [ + "project" + ], + "summary": "Get projects", + "parameters": [ + { + "type": "string", + "description": "With the bearer started", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "projects", + "name": "tag", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + }, + "put": { + "description": "Put project", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "project" + ], + "summary": "Put project", + "parameters": [ + { + "type": "string", + "description": "With the bearer started", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "post project", + "name": "p", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/model.Project" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + } + }, + "/projects/tags": { + "get": { + "description": "Get projects tags", + "produces": [ + "application/json" + ], + "tags": [ + "project" + ], + "summary": "Get project tags", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/projects/{id}": { + "post": { + "description": "Post project", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "project" + ], + "summary": "Post project", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "project id", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "project item", + "name": "item", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/model.Project" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + }, + "delete": { + "description": "Delete project", + "produces": [ + "application/json" + ], + "tags": [ + "project" + ], + "summary": "Delete project", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "project id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/schedules": { + "get": { + "description": "Get schedule list", + "produces": [ + "application/json" + ], + "tags": [ + "schedule" + ], + "summary": "Get schedule list", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + }, + "put": { + "description": "Put schedule", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "schedule" + ], + "summary": "Put schedule", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "schedule item", + "name": "item", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/model.Schedule" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + } + }, + "/schedules/{id}": { + "get": { + "description": "Get schedule by id", + "produces": [ + "application/json" + ], + "tags": [ + "schedule" + ], + "summary": "Get schedule by id", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "schedule id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + }, + "post": { + "description": "Post schedule", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "schedule" + ], + "summary": "Post schedule", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "schedule id", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "schedule item", + "name": "newItem", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/model.Schedule" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + }, + "delete": { + "description": "Delete schedule", + "produces": [ + "application/json" + ], + "tags": [ + "schedule" + ], + "summary": "Delete schedule", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "schedule id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/schedules/{id}/disable": { + "post": { + "description": "disable schedule", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "schedule" + ], + "summary": "disable schedule", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "schedule id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + } + }, + "/schedules/{id}/enable": { + "post": { + "description": "enable schedule", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "schedule" + ], + "summary": "enable schedule", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "schedule id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + } + }, + "/setting": { + "get": { + "description": "Get setting", + "produces": [ + "application/json" + ], + "tags": [ + "setting" + ], + "summary": "Get setting", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders": { + "put": { + "description": "Put spider", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Put spider", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "spider item", + "name": "spider", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/model.Spider" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + }, + "post": { + "description": "delete spider", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "delete spider", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders-cancel": { + "post": { + "description": "cancel spider", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "cancel spider", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders-run": { + "post": { + "description": "run spider", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "run spider", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders/{id}": { + "get": { + "description": "Get spider by id", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Get spider by id", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "schedule id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + }, + "post": { + "description": "Post spider", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Post spider", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "schedule id", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "spider item", + "name": "item", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/model.Spider" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + }, + "delete": { + "description": "Delete spider by id", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Delete spider by id", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders/{id}/copy": { + "post": { + "description": "Copy spider", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Copy spider", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "schedule id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders/{id}/dir": { + "get": { + "description": "Get spider dir", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Get spider dir", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "path", + "name": "path", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders/{id}/file": { + "get": { + "description": "Get spider file", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Get spider file", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "path", + "name": "path", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + }, + "put": { + "description": "Post spider dir", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Post spider dir", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "path", + "name": "reqBody", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/routes.SpiderFileReqBody" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + }, + "post": { + "description": "Put spider file", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Put spider file", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "path", + "name": "reqBody", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/routes.SpiderFileReqBody" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + }, + "delete": { + "description": "Delete spider file", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Delete spider file", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "path", + "name": "reqBody", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/routes.SpiderFileReqBody" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders/{id}/file/rename": { + "post": { + "description": "Rename spider file", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Rename spider file", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "path", + "name": "reqBody", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/routes.SpiderFileReqBody" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders/{id}/file/tree": { + "get": { + "description": "Get spider dir", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Get spider dir", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders/{id}/git/reset": { + "post": { + "description": "Post spider reset git", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Post spider reset git", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders/{id}/git/sync": { + "post": { + "description": "Post spider sync git", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Post spider sync git", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders/{id}/publish": { + "post": { + "description": "Publish spider", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Publish spider", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "schedule id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders/{id}/schedules": { + "get": { + "description": "Get schedules", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Get schedules", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders/{id}/scrapy/items": { + "get": { + "description": "Get scrapy spider items", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Get scrapy spider items", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + }, + "post": { + "description": "Post scrapy spider items", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Post scrapy spider items", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "req data", + "name": "reqData", + "in": "body", + "required": true, + "schema": { + "type": "entity.ScrapyItem", + "items": { + "$ref": "#/definitions/entity.ScrapyItem" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders/{id}/scrapy/pipelines": { + "get": { + "description": "Get scrapy spider pipelines", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Get scrapy spider pipelines", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders/{id}/scrapy/settings": { + "get": { + "description": "Get scrapy spider settings", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Get scrapy spider settings", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + }, + "post": { + "description": "Get scrapy spider file", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Get scrapy spider file", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "req data", + "name": "reqData", + "in": "body", + "required": true, + "schema": { + "type": "entity.ScrapySettingParam", + "items": { + "$ref": "#/definitions/entity.ScrapySettingParam" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders/{id}/scrapy/spider/filepath": { + "get": { + "description": "Get scrapy spider file path", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Get scrapy spider file path", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders/{id}/scrapy/spiders": { + "get": { + "description": "Get scrapy spider file", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Get scrapy spider file", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + }, + "put": { + "description": "Put scrapy spider file", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Put scrapy spider file", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders/{id}/stats": { + "get": { + "description": "Get spider stats", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Get spider stats", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders/{id}/tasks": { + "get": { + "description": "Get task list", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Get task list", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/spiders/{id}/upload": { + "post": { + "description": "Upload spider by id", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Upload spider by id", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "file", + "description": "spider file to upload", + "name": "file", + "in": "formData", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + } + }, + "/version": { + "get": { + "description": "Get version", + "produces": [ + "application/json" + ], + "tags": [ + "setting" + ], + "summary": "Get version", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + } + }, + "definitions": { + "entity.ConfigSpiderData": { + "type": "object", + "properties": { + "cmd": { + "description": "自定义爬虫", + "type": "string" + }, + "col": { + "type": "string" + }, + "display_name": { + "type": "string" + }, + "engine": { + "description": "可配置爬虫", + "type": "string" + }, + "name": { + "description": "通用", + "type": "string" + }, + "remark": { + "type": "string" + }, + "settings": { + "type": "object" + }, + "stages": { + "type": "array", + "items": { + "$ref": "#/definitions/entity.Stage" + } + }, + "start_stage": { + "type": "string" + }, + "start_url": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "entity.Field": { + "type": "object", + "properties": { + "attr": { + "type": "string" + }, + "css": { + "type": "string" + }, + "name": { + "type": "string" + }, + "next_stage": { + "type": "string" + }, + "remark": { + "type": "string" + }, + "xpath": { + "type": "string" + } + } + }, + "entity.ScrapyItem": { + "type": "object", + "properties": { + "fields": { + "type": "array", + "items": { + "type": "string" + } + }, + "name": { + "type": "string" + } + } + }, + "entity.ScrapySettingParam": { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "type": { + "type": "string" + }, + "value": { + "type": "object" + } + } + }, + "entity.Stage": { + "type": "object", + "properties": { + "fields": { + "type": "array", + "items": { + "$ref": "#/definitions/entity.Field" + } + }, + "is_list": { + "type": "boolean" + }, + "list_css": { + "type": "string" + }, + "list_xpath": { + "type": "string" + }, + "name": { + "type": "string" + }, + "page_attr": { + "type": "string" + }, + "page_css": { + "type": "string" + }, + "page_xpath": { + "type": "string" + } + } + }, + "model.Env": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "value": { + "type": "string" + } + } + }, + "model.Node": { + "type": "object", + "properties": { + "_id": { + "type": "string" + }, + "create_ts": { + "type": "string" + }, + "description": { + "type": "string" + }, + "hostname": { + "type": "string" + }, + "ip": { + "type": "string" + }, + "is_master": { + "description": "前端展示", + "type": "boolean" + }, + "key": { + "description": "用于唯一标识节点,可能是mac地址,可能是ip地址", + "type": "string" + }, + "mac": { + "type": "string" + }, + "name": { + "type": "string" + }, + "port": { + "type": "string" + }, + "status": { + "type": "string" + }, + "update_ts": { + "type": "string" + }, + "update_ts_unix": { + "type": "integer" + } + } + }, + "model.Project": { + "type": "object", + "properties": { + "_id": { + "type": "string" + }, + "create_ts": { + "type": "string" + }, + "description": { + "type": "string" + }, + "name": { + "type": "string" + }, + "spiders": { + "description": "前端展示", + "type": "array", + "items": { + "$ref": "#/definitions/model.Spider" + } + }, + "tags": { + "type": "array", + "items": { + "type": "string" + } + }, + "update_ts": { + "type": "string" + }, + "user_id": { + "type": "string" + }, + "username": { + "type": "string" + } + } + }, + "model.Schedule": { + "type": "object", + "properties": { + "_id": { + "type": "string" + }, + "create_ts": { + "type": "string" + }, + "cron": { + "type": "string" + }, + "description": { + "type": "string" + }, + "enabled": { + "type": "boolean" + }, + "entry_id": { + "type": "integer" + }, + "message": { + "type": "string" + }, + "name": { + "type": "string" + }, + "node_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "nodes": { + "type": "array", + "items": { + "$ref": "#/definitions/model.Node" + } + }, + "param": { + "type": "string" + }, + "run_type": { + "type": "string" + }, + "scrapy_log_level": { + "type": "string" + }, + "scrapy_spider": { + "type": "string" + }, + "spider_id": { + "type": "string" + }, + "spider_name": { + "description": "前端展示", + "type": "string" + }, + "status": { + "type": "string" + }, + "update_ts": { + "type": "string" + }, + "user_id": { + "type": "string" + }, + "user_name": { + "type": "string" + } + } + }, + "model.Spider": { + "type": "object", + "properties": { + "_id": { + "description": "爬虫ID", + "type": "string" + }, + "cmd": { + "description": "自定义爬虫", + "type": "string" + }, + "col": { + "description": "结果储存位置", + "type": "string" + }, + "config": { + "description": "可配置爬虫配置", + "type": "object", + "$ref": "#/definitions/entity.ConfigSpiderData" + }, + "create_ts": { + "type": "string" + }, + "dedup_field": { + "description": "去重字段", + "type": "string" + }, + "dedup_method": { + "description": "去重方式", + "type": "string" + }, + "display_name": { + "description": "爬虫显示名称", + "type": "string" + }, + "envs": { + "description": "环境变量", + "type": "array", + "items": { + "$ref": "#/definitions/model.Env" + } + }, + "file_id": { + "description": "GridFS文件ID", + "type": "string" + }, + "git_auto_sync": { + "description": "Git 是否自动同步", + "type": "boolean" + }, + "git_branch": { + "description": "Git 分支", + "type": "string" + }, + "git_has_credential": { + "description": "Git 是否加密", + "type": "boolean" + }, + "git_password": { + "description": "Git 密码", + "type": "string" + }, + "git_sync_error": { + "description": "Git 同步错误", + "type": "string" + }, + "git_sync_frequency": { + "description": "Git 同步频率", + "type": "string" + }, + "git_url": { + "description": "Git URL", + "type": "string" + }, + "git_username": { + "description": "Git 用户名", + "type": "string" + }, + "is_dedup": { + "description": "去重", + "type": "boolean" + }, + "is_git": { + "description": "Git 设置", + "type": "boolean" + }, + "is_long_task": { + "description": "长任务", + "type": "boolean" + }, + "is_public": { + "description": "是否公开", + "type": "boolean" + }, + "is_scrapy": { + "description": "Scrapy 爬虫(属于自定义爬虫)", + "type": "boolean" + }, + "is_web_hook": { + "description": "Web Hook", + "type": "boolean" + }, + "last_run_ts": { + "description": "前端展示", + "type": "string" + }, + "last_status": { + "description": "最后执行状态", + "type": "string" + }, + "latest_tasks": { + "description": "最近任务列表", + "type": "array", + "items": { + "$ref": "#/definitions/model.Task" + } + }, + "name": { + "description": "爬虫名称(唯一)", + "type": "string" + }, + "project_id": { + "description": "项目ID", + "type": "string" + }, + "remark": { + "description": "备注", + "type": "string" + }, + "site": { + "description": "爬虫网站", + "type": "string" + }, + "spider_names": { + "description": "爬虫名称列表", + "type": "array", + "items": { + "type": "string" + } + }, + "src": { + "description": "源码位置", + "type": "string" + }, + "template": { + "description": "可配置爬虫", + "type": "string" + }, + "type": { + "description": "爬虫类别", + "type": "string" + }, + "update_ts": { + "type": "string" + }, + "user_id": { + "description": "时间", + "type": "string" + }, + "username": { + "description": "用户名称", + "type": "string" + }, + "web_hook_url": { + "description": "Web Hook URL", + "type": "string" + } + } + }, + "model.Task": { + "type": "object", + "properties": { + "_id": { + "type": "string" + }, + "cmd": { + "type": "string" + }, + "create_ts": { + "type": "string" + }, + "error": { + "type": "string" + }, + "error_log_count": { + "type": "integer" + }, + "finish_ts": { + "type": "string" + }, + "log_path": { + "type": "string" + }, + "node_id": { + "type": "string" + }, + "node_name": { + "type": "string" + }, + "param": { + "type": "string" + }, + "pid": { + "type": "integer" + }, + "result_count": { + "type": "integer" + }, + "run_type": { + "type": "string" + }, + "runtime_duration": { + "type": "number" + }, + "schedule_id": { + "type": "string" + }, + "spider_id": { + "type": "string" + }, + "spider_name": { + "description": "前端数据", + "type": "string" + }, + "start_ts": { + "type": "string" + }, + "status": { + "type": "string" + }, + "total_duration": { + "type": "number" + }, + "update_ts": { + "type": "string" + }, + "user_id": { + "type": "string" + }, + "username": { + "type": "string" + }, + "wait_duration": { + "type": "number" + } + } + }, + "routes.SpiderFileReqBody": { + "type": "object", + "properties": { + "content": { + "type": "string" + }, + "new_path": { + "type": "string" + }, + "path": { + "type": "string" + } + } + } + } +} \ No newline at end of file diff --git a/backend/docs/swagger.yaml b/backend/docs/swagger.yaml new file mode 100644 index 00000000..0ced87e0 --- /dev/null +++ b/backend/docs/swagger.yaml @@ -0,0 +1,1848 @@ +definitions: + entity.ConfigSpiderData: + properties: + cmd: + description: 自定义爬虫 + type: string + col: + type: string + display_name: + type: string + engine: + description: 可配置爬虫 + type: string + name: + description: 通用 + type: string + remark: + type: string + settings: + type: object + stages: + items: + $ref: '#/definitions/entity.Stage' + type: array + start_stage: + type: string + start_url: + type: string + type: + type: string + type: object + entity.Field: + properties: + attr: + type: string + css: + type: string + name: + type: string + next_stage: + type: string + remark: + type: string + xpath: + type: string + type: object + entity.ScrapyItem: + properties: + fields: + items: + type: string + type: array + name: + type: string + type: object + entity.ScrapySettingParam: + properties: + key: + type: string + type: + type: string + value: + type: object + type: object + entity.Stage: + properties: + fields: + items: + $ref: '#/definitions/entity.Field' + type: array + is_list: + type: boolean + list_css: + type: string + list_xpath: + type: string + name: + type: string + page_attr: + type: string + page_css: + type: string + page_xpath: + type: string + type: object + model.Env: + properties: + name: + type: string + value: + type: string + type: object + model.Node: + properties: + _id: + type: string + create_ts: + type: string + description: + type: string + hostname: + type: string + ip: + type: string + is_master: + description: 前端展示 + type: boolean + key: + description: 用于唯一标识节点,可能是mac地址,可能是ip地址 + type: string + mac: + type: string + name: + type: string + port: + type: string + status: + type: string + update_ts: + type: string + update_ts_unix: + type: integer + type: object + model.Project: + properties: + _id: + type: string + create_ts: + type: string + description: + type: string + name: + type: string + spiders: + description: 前端展示 + items: + $ref: '#/definitions/model.Spider' + type: array + tags: + items: + type: string + type: array + update_ts: + type: string + user_id: + type: string + username: + type: string + type: object + model.Schedule: + properties: + _id: + type: string + create_ts: + type: string + cron: + type: string + description: + type: string + enabled: + type: boolean + entry_id: + type: integer + message: + type: string + name: + type: string + node_ids: + items: + type: string + type: array + nodes: + items: + $ref: '#/definitions/model.Node' + type: array + param: + type: string + run_type: + type: string + scrapy_log_level: + type: string + scrapy_spider: + type: string + spider_id: + type: string + spider_name: + description: 前端展示 + type: string + status: + type: string + update_ts: + type: string + user_id: + type: string + user_name: + type: string + type: object + model.Spider: + properties: + _id: + description: 爬虫ID + type: string + cmd: + description: 自定义爬虫 + type: string + col: + description: 结果储存位置 + type: string + config: + $ref: '#/definitions/entity.ConfigSpiderData' + description: 可配置爬虫配置 + type: object + create_ts: + type: string + dedup_field: + description: 去重字段 + type: string + dedup_method: + description: 去重方式 + type: string + display_name: + description: 爬虫显示名称 + type: string + envs: + description: 环境变量 + items: + $ref: '#/definitions/model.Env' + type: array + file_id: + description: GridFS文件ID + type: string + git_auto_sync: + description: Git 是否自动同步 + type: boolean + git_branch: + description: Git 分支 + type: string + git_has_credential: + description: Git 是否加密 + type: boolean + git_password: + description: Git 密码 + type: string + git_sync_error: + description: Git 同步错误 + type: string + git_sync_frequency: + description: Git 同步频率 + type: string + git_url: + description: Git URL + type: string + git_username: + description: Git 用户名 + type: string + is_dedup: + description: 去重 + type: boolean + is_git: + description: Git 设置 + type: boolean + is_long_task: + description: 长任务 + type: boolean + is_public: + description: 是否公开 + type: boolean + is_scrapy: + description: Scrapy 爬虫(属于自定义爬虫) + type: boolean + is_web_hook: + description: Web Hook + type: boolean + last_run_ts: + description: 前端展示 + type: string + last_status: + description: 最后执行状态 + type: string + latest_tasks: + description: 最近任务列表 + items: + $ref: '#/definitions/model.Task' + type: array + name: + description: 爬虫名称(唯一) + type: string + project_id: + description: 项目ID + type: string + remark: + description: 备注 + type: string + site: + description: 爬虫网站 + type: string + spider_names: + description: 爬虫名称列表 + items: + type: string + type: array + src: + description: 源码位置 + type: string + template: + description: 可配置爬虫 + type: string + type: + description: 爬虫类别 + type: string + update_ts: + type: string + user_id: + description: 时间 + type: string + username: + description: 用户名称 + type: string + web_hook_url: + description: Web Hook URL + type: string + type: object + model.Task: + properties: + _id: + type: string + cmd: + type: string + create_ts: + type: string + error: + type: string + error_log_count: + type: integer + finish_ts: + type: string + log_path: + type: string + node_id: + type: string + node_name: + type: string + param: + type: string + pid: + type: integer + result_count: + type: integer + run_type: + type: string + runtime_duration: + type: number + schedule_id: + type: string + spider_id: + type: string + spider_name: + description: 前端数据 + type: string + start_ts: + type: string + status: + type: string + total_duration: + type: number + update_ts: + type: string + user_id: + type: string + username: + type: string + wait_duration: + type: number + type: object + routes.SpiderFileReqBody: + properties: + content: + type: string + new_path: + type: string + path: + type: string + type: object +info: + contact: {} + license: {} +paths: + /nodes: + get: + description: Get nodes + parameters: + - description: With the bearer started + in: header + name: Authorization + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get nodes + tags: + - node + /nodes/{id}: + delete: + description: Delete node + parameters: + - description: With the bearer started + in: header + name: Authorization + required: true + type: string + - description: node id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Delete node + tags: + - node + get: + description: Get node + parameters: + - description: With the bearer started + in: header + name: Authorization + required: true + type: string + - description: id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get node + tags: + - node + post: + consumes: + - application/json + description: Post node + parameters: + - description: With the bearer started + in: header + name: Authorization + required: true + type: string + - description: post node + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "500": + description: Internal Server Error + schema: + type: json + summary: Post node + tags: + - node + /nodes/{id}/system: + get: + description: Get system info + parameters: + - description: With the bearer started + in: header + name: Authorization + required: true + type: string + - description: node id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get system info + tags: + - node + /nodes/{id}/tasks: + get: + description: Get tasks on node + parameters: + - description: With the bearer started + in: header + name: Authorization + required: true + type: string + - description: node id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get tasks on node + tags: + - node + /projects: + get: + description: Get projects + parameters: + - description: With the bearer started + in: header + name: Authorization + required: true + type: string + - description: projects + in: query + name: tag + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get projects + tags: + - project + put: + consumes: + - application/json + description: Put project + parameters: + - description: With the bearer started + in: header + name: Authorization + required: true + type: string + - description: post project + in: body + name: p + required: true + schema: + $ref: '#/definitions/model.Project' + type: object + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "500": + description: Internal Server Error + schema: + type: json + summary: Put project + tags: + - project + /projects/{id}: + delete: + description: Delete project + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: project id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Delete project + tags: + - project + post: + consumes: + - application/json + description: Post project + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: project id + in: path + name: id + required: true + type: string + - description: project item + in: body + name: item + required: true + schema: + $ref: '#/definitions/model.Project' + type: object + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "500": + description: Internal Server Error + schema: + type: json + summary: Post project + tags: + - project + /projects/tags: + get: + description: Get projects tags + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get project tags + tags: + - project + /schedules: + get: + description: Get schedule list + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get schedule list + tags: + - schedule + put: + consumes: + - application/json + description: Put schedule + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: schedule item + in: body + name: item + required: true + schema: + $ref: '#/definitions/model.Schedule' + type: object + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "500": + description: Internal Server Error + schema: + type: json + summary: Put schedule + tags: + - schedule + /schedules/{id}: + delete: + description: Delete schedule + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: schedule id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Delete schedule + tags: + - schedule + get: + description: Get schedule by id + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: schedule id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get schedule by id + tags: + - schedule + post: + consumes: + - application/json + description: Post schedule + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: schedule id + in: path + name: id + required: true + type: string + - description: schedule item + in: body + name: newItem + required: true + schema: + $ref: '#/definitions/model.Schedule' + type: object + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "500": + description: Internal Server Error + schema: + type: json + summary: Post schedule + tags: + - schedule + /schedules/{id}/disable: + post: + consumes: + - application/json + description: disable schedule + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: schedule id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "500": + description: Internal Server Error + schema: + type: json + summary: disable schedule + tags: + - schedule + /schedules/{id}/enable: + post: + consumes: + - application/json + description: enable schedule + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: schedule id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "500": + description: Internal Server Error + schema: + type: json + summary: enable schedule + tags: + - schedule + /setting: + get: + description: Get setting + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get setting + tags: + - setting + /spiders: + post: + consumes: + - application/json + description: delete spider + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "500": + description: Internal Server Error + schema: + type: json + summary: delete spider + tags: + - spider + put: + consumes: + - application/json + description: Put spider + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: spider item + in: body + name: spider + required: true + schema: + $ref: '#/definitions/model.Spider' + type: object + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "500": + description: Internal Server Error + schema: + type: json + summary: Put spider + tags: + - spider + /spiders-cancel: + post: + consumes: + - application/json + description: cancel spider + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "500": + description: Internal Server Error + schema: + type: json + summary: cancel spider + tags: + - spider + /spiders-run: + post: + consumes: + - application/json + description: run spider + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "500": + description: Internal Server Error + schema: + type: json + summary: run spider + tags: + - spider + /spiders/{id}: + delete: + description: Delete spider by id + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: spider id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Delete spider by id + tags: + - spider + get: + description: Get spider by id + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: schedule id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get spider by id + tags: + - spider + post: + consumes: + - application/json + description: Post spider + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: schedule id + in: path + name: id + required: true + type: string + - description: spider item + in: body + name: item + required: true + schema: + $ref: '#/definitions/model.Spider' + type: object + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "500": + description: Internal Server Error + schema: + type: json + summary: Post spider + tags: + - spider + /spiders/{id}/copy: + post: + consumes: + - application/json + description: Copy spider + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: schedule id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "500": + description: Internal Server Error + schema: + type: json + summary: Copy spider + tags: + - spider + /spiders/{id}/dir: + get: + description: Get spider dir + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: spider id + in: path + name: id + required: true + type: string + - description: path + in: query + name: path + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get spider dir + tags: + - spider + /spiders/{id}/file: + delete: + description: Delete spider file + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: spider id + in: path + name: id + required: true + type: string + - description: path + in: body + name: reqBody + required: true + schema: + $ref: '#/definitions/routes.SpiderFileReqBody' + type: object + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Delete spider file + tags: + - spider + get: + description: Get spider file + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: spider id + in: path + name: id + required: true + type: string + - description: path + in: query + name: path + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get spider file + tags: + - spider + post: + description: Put spider file + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: spider id + in: path + name: id + required: true + type: string + - description: path + in: body + name: reqBody + required: true + schema: + $ref: '#/definitions/routes.SpiderFileReqBody' + type: object + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Put spider file + tags: + - spider + put: + description: Post spider dir + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: spider id + in: path + name: id + required: true + type: string + - description: path + in: body + name: reqBody + required: true + schema: + $ref: '#/definitions/routes.SpiderFileReqBody' + type: object + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Post spider dir + tags: + - spider + /spiders/{id}/file/rename: + post: + description: Rename spider file + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: spider id + in: path + name: id + required: true + type: string + - description: path + in: body + name: reqBody + required: true + schema: + $ref: '#/definitions/routes.SpiderFileReqBody' + type: object + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Rename spider file + tags: + - spider + /spiders/{id}/file/tree: + get: + description: Get spider dir + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: spider id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get spider dir + tags: + - spider + /spiders/{id}/git/reset: + post: + description: Post spider reset git + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: spider id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Post spider reset git + tags: + - spider + /spiders/{id}/git/sync: + post: + description: Post spider sync git + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: spider id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Post spider sync git + tags: + - spider + /spiders/{id}/publish: + post: + consumes: + - application/json + description: Publish spider + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: schedule id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "500": + description: Internal Server Error + schema: + type: json + summary: Publish spider + tags: + - spider + /spiders/{id}/schedules: + get: + description: Get schedules + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: spider id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get schedules + tags: + - spider + /spiders/{id}/scrapy/items: + get: + description: Get scrapy spider items + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: spider id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get scrapy spider items + tags: + - spider + post: + description: Post scrapy spider items + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: spider id + in: path + name: id + required: true + type: string + - description: req data + in: body + name: reqData + required: true + schema: + items: + $ref: '#/definitions/entity.ScrapyItem' + type: entity.ScrapyItem + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Post scrapy spider items + tags: + - spider + /spiders/{id}/scrapy/pipelines: + get: + description: Get scrapy spider pipelines + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: spider id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get scrapy spider pipelines + tags: + - spider + /spiders/{id}/scrapy/settings: + get: + description: Get scrapy spider settings + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: spider id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get scrapy spider settings + tags: + - spider + post: + description: Get scrapy spider file + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: spider id + in: path + name: id + required: true + type: string + - description: req data + in: body + name: reqData + required: true + schema: + items: + $ref: '#/definitions/entity.ScrapySettingParam' + type: entity.ScrapySettingParam + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get scrapy spider file + tags: + - spider + /spiders/{id}/scrapy/spider/filepath: + get: + description: Get scrapy spider file path + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: spider id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get scrapy spider file path + tags: + - spider + /spiders/{id}/scrapy/spiders: + get: + description: Get scrapy spider file + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: spider id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get scrapy spider file + tags: + - spider + put: + description: Put scrapy spider file + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: spider id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Put scrapy spider file + tags: + - spider + /spiders/{id}/stats: + get: + description: Get spider stats + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: spider id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get spider stats + tags: + - spider + /spiders/{id}/tasks: + get: + description: Get task list + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: spider id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get task list + tags: + - spider + /spiders/{id}/upload: + post: + consumes: + - application/json + description: Upload spider by id + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: spider file to upload + in: formData + name: file + required: true + type: file + - description: spider id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "500": + description: Internal Server Error + schema: + type: json + summary: Upload spider by id + tags: + - spider + /version: + get: + description: Get version + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get version + tags: + - setting +swagger: "2.0" diff --git a/backend/go.mod b/backend/go.mod index 7503389a..6a6e65c1 100644 --- a/backend/go.mod +++ b/backend/go.mod @@ -6,6 +6,7 @@ require ( github.com/Masterminds/semver v1.4.2 // indirect github.com/Masterminds/sprig v2.16.0+incompatible // indirect github.com/Unknwon/goconfig v0.0.0-20191126170842-860a72fb44fd + github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc github.com/aokoli/goutils v1.0.1 // indirect github.com/apex/log v1.1.1 github.com/dgrijalva/jwt-go v3.2.0+incompatible @@ -30,6 +31,8 @@ require ( github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337 github.com/spf13/viper v1.4.0 github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf // indirect + github.com/swaggo/gin-swagger v1.2.0 + github.com/swaggo/swag v1.5.1 gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect gopkg.in/go-playground/validator.v9 v9.29.1 gopkg.in/gomail.v2 v2.0.0-20150902115704-41f357289737 diff --git a/backend/go.sum b/backend/go.sum index 1a253f5d..181899a8 100644 --- a/backend/go.sum +++ b/backend/go.sum @@ -6,10 +6,15 @@ github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF0 github.com/Masterminds/sprig v2.16.0+incompatible h1:QZbMUPxRQ50EKAq3LFMnxddMu88/EUUG3qmxwtDmPsY= github.com/Masterminds/sprig v2.16.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +github.com/PuerkitoBio/purell v1.1.0 h1:rmGxhojJlM0tuKtfdvliR84CFHljx9ag64t2xmVkjK4= +github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/Unknwon/goconfig v0.0.0-20191126170842-860a72fb44fd h1:+CYOsXi89xOqBkj7CuEJjA2It+j+R3ngUZEydr6mtkw= github.com/Unknwon/goconfig v0.0.0-20191126170842-860a72fb44fd/go.mod h1:wngxua9XCNjvHjDiTiV26DaKDT+0c63QR6H5hjVUUxw= github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 h1:uSoVVbwJiQipAclBbw+8quDsfcvFjOpI5iCf4p/cqCs= github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc h1:cAKDfWh5VpdgMhJosfJnn5/FoN2SRZ4p7fJNX58YPaU= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA= @@ -52,8 +57,14 @@ github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHqu github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/gin-contrib/gzip v0.0.1 h1:ezvKOL6jH+jlzdHNE4h9h8q8uMpDQjyl0NN0Jd7jozc= +github.com/gin-contrib/gzip v0.0.1/go.mod h1:fGBJBCdt6qCZuCAOwWuFhBB4OOq9EFqlo5dEaFhhu5w= +github.com/gin-contrib/sse v0.0.0-20170109093832-22d885f9ecc7/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3 h1:t8FVkw33L+wilf2QiWkw0UV77qRpcH/JHPKGpKa2E8g= github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= +github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= +github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= +github.com/gin-gonic/gin v1.3.0/go.mod h1:7cKuhb5qV2ggCFctp2fJQ+ErvciLZrIeoOSOm6mUr7Y= github.com/gin-gonic/gin v1.4.0 h1:3tMoCCfM7ppqsR0ptz/wi1impNpT7/9wQtMZ8lr1mCQ= github.com/gin-gonic/gin v1.4.0/go.mod h1:OW2EZn3DO8Ln9oIKOvM++LBO+5UPHJJDH72/q/3rZdM= github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0= @@ -63,6 +74,15 @@ github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0 github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-openapi/jsonpointer v0.17.0 h1:nH6xp8XdXHx8dqveo0ZuJBluCO2qGrPbDNZ0dwoRHP0= +github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= +github.com/go-openapi/jsonreference v0.17.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= +github.com/go-openapi/jsonreference v0.19.0 h1:BqWKpV1dFd+AuiKlgtddwVIFQsuMpxfBDBHGfM2yNpk= +github.com/go-openapi/jsonreference v0.19.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= +github.com/go-openapi/spec v0.19.0 h1:A4SZ6IWh3lnjH0rG0Z5lkxazMGBECtrZcbyYQi+64k4= +github.com/go-openapi/spec v0.19.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= +github.com/go-openapi/swag v0.17.0 h1:iqrgMg7Q7SvtbWLlltPrkMs0UBJI6oTSs79JFRUi880= +github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= github.com/go-playground/locales v0.12.1 h1:2FITxuFt/xuCNP1Acdhv62OzaCiviiE4kotfhkmOqEc= github.com/go-playground/locales v0.12.1/go.mod h1:IUMDtCfWo/w/mtMfIE/IG2K+Ey3ygWanZIBtBW0W2TM= github.com/go-playground/universal-translator v0.16.0 h1:X++omBR/4cE2MNg91AoC3rmGrCjJ8eAeUP/K/EKx4DM= @@ -112,6 +132,7 @@ github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jpillora/backoff v0.0.0-20180909062703-3050d21c67d7/go.mod h1:2iMrUgbbvHEiQClaW2NsSzMyGHqN+rDFqY705q49KG0= +github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.6 h1:MrUvLMLTMxbqFJ9kzlvat/rYZqZnW3u4wkLzWTaFwKs= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= @@ -133,12 +154,14 @@ github.com/leodido/go-urn v1.1.0 h1:Sm1gr51B1kKyfD2BlRcLSiEkffoG96g6TPv6eRoEiB8= github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw= github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.7.1 h1:mdxE1MF9o53iCb2Ghj1VfWvh7ZOwHpnVG/xwXrV90U8= github.com/mailru/easyjson v0.7.1/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs= github.com/matcornic/hermes v1.2.0 h1:AuqZpYcTOtTB7cahdevLfnhIpfzmpqw5Czv8vpdnFDU= github.com/matcornic/hermes v1.2.0/go.mod h1:lujJomb016Xjv8wBnWlNvUdtmvowjjfkqri5J/+1hYc= github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE= @@ -224,6 +247,10 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/swaggo/gin-swagger v1.2.0 h1:YskZXEiv51fjOMTsXrOetAjrMDfFaXD79PEoQBOe2W0= +github.com/swaggo/gin-swagger v1.2.0/go.mod h1:qlH2+W7zXGZkczuL+r2nEBR2JTT+/lX05Nn6vPhc7OI= +github.com/swaggo/swag v1.5.1 h1:2Agm8I4K5qb00620mHq0VJ05/KT4FtmALPIcQR9lEZM= +github.com/swaggo/swag v1.5.1/go.mod h1:1Bl9F/ZBpVWh22nY0zmYyASPO1lI/zIwRDrpZU+tv8Y= github.com/tj/assert v0.0.0-20171129193455-018094318fb0/go.mod h1:mZ9/Rh9oLWpLLDRpvE+3b7gP/C2YyLFYxNmcLnPTMe0= github.com/tj/go-elastic v0.0.0-20171221160941-36157cbbebc2/go.mod h1:WjeM0Oo1eNAjXGDx2yma7uG2XoyRZTq1uv3M/o7imD0= github.com/tj/go-kinesis v0.0.0-20171128231115-08b17f58cb1b/go.mod h1:/yhzCV0xPfx6jb1bBgRFjl5lytqVqZXEaeqWP8lTEao= @@ -231,6 +258,12 @@ github.com/tj/go-spin v1.1.0/go.mod h1:Mg1mzmePZm4dva8Qz60H2lHwmJ2loum4VIrLgVnKw github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/ugorji/go v1.1.4 h1:j4s+tAvLfL3bZyefP2SEWmhBzmuIlH/eqNuPdFPgngw= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= +github.com/ugorji/go v1.1.5-pre h1:jyJKFOSEbdOc2HODrf2qcCkYOdq7zzXqA9bhW5oV4fM= +github.com/ugorji/go v1.1.5-pre/go.mod h1:FwP/aQVg39TXzItUBMwnWp9T9gPQnXw4Poh4/oBQZ/0= +github.com/ugorji/go/codec v0.0.0-20181022190402-e5e69e061d4f/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= +github.com/ugorji/go/codec v1.1.5-pre h1:5YV9PsFAN+ndcCtTM7s60no7nY7eTG3LPtxhSwuxzCs= +github.com/ugorji/go/codec v1.1.5-pre/go.mod h1:tULtS6Gy1AE1yCENaw4Vb//HLH5njI2tfCQDUqRd8fI= +github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70= github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= @@ -254,6 +287,7 @@ golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -261,6 +295,7 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190611141213-3f473d35a33a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80 h1:Ao/3l156eZf2AW5wK8a7/smtodRU+gha3+BeqJ69lRk= @@ -278,12 +313,14 @@ golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190221075227-b4e8571b14e0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190610200419-93c9922d18ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e h1:D5TXcfTk7xF7hvieo4QErS3qqCB4teTffacDWr7CI+0= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= @@ -297,6 +334,9 @@ golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190606050223-4d9ae51c2468/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190611222205-d73e1c7e250b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190729092621-ff9f1409240a h1:mEQZbbaBjWyLNy0tmZmgEuQAR8XOQ3hL8GYi3J/NG64= golang.org/x/tools v0.0.0-20190729092621-ff9f1409240a/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/backend/main.go b/backend/main.go index 7ca18335..0c787ce6 100644 --- a/backend/main.go +++ b/backend/main.go @@ -4,6 +4,7 @@ import ( "context" "crawlab/config" "crawlab/database" + _ "crawlab/docs" "crawlab/lib/validate_bridge" "crawlab/middlewares" "crawlab/model" @@ -16,6 +17,8 @@ import ( "github.com/gin-gonic/gin/binding" "github.com/olivere/elastic/v7" "github.com/spf13/viper" + "github.com/swaggo/gin-swagger" + "github.com/swaggo/gin-swagger/swaggerFiles" "net" "net/http" "os" @@ -25,9 +28,17 @@ import ( "time" ) +var swagHandler gin.HandlerFunc + +func init() { + swagHandler = ginSwagger.WrapHandler(swaggerFiles.Handler) +} func main() { binding.Validator = new(validate_bridge.DefaultValidator) app := gin.Default() + if swagHandler != nil { + app.GET("/swagger/*any", swagHandler) + } // 初始化配置 if err := config.InitConfig(""); err != nil { diff --git a/backend/routes/node.go b/backend/routes/node.go index 7d030773..dfa593eb 100644 --- a/backend/routes/node.go +++ b/backend/routes/node.go @@ -8,6 +8,14 @@ import ( "net/http" ) +// @Summary Get nodes +// @Description Get nodes +// @Tags node +// @Produce json +// @Param Authorization header string true "With the bearer started" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /nodes [get] func GetNodeList(c *gin.Context) { nodes, err := model.GetNodeList(nil) if err != nil { @@ -26,6 +34,15 @@ func GetNodeList(c *gin.Context) { }) } +// @Summary Get node +// @Description Get node +// @Tags node +// @Produce json +// @Param Authorization header string true "With the bearer started" +// @Param id path string true "id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /nodes/{id} [get] func GetNode(c *gin.Context) { id := c.Param("id") @@ -54,6 +71,17 @@ func Ping(c *gin.Context) { }) } + +// @Summary Post node +// @Description Post node +// @Tags node +// @Accept json +// @Produce json +// @Param Authorization header string true "With the bearer started" +// @Param id path string true "post node" +// @Success 200 json string Response +// @Failure 500 json string Response +// @Router /nodes/{id} [post] func PostNode(c *gin.Context) { id := c.Param("id") @@ -81,6 +109,15 @@ func PostNode(c *gin.Context) { }) } +// @Summary Get tasks on node +// @Description Get tasks on node +// @Tags node +// @Produce json +// @Param Authorization header string true "With the bearer started" +// @Param id path string true "node id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /nodes/{id}/tasks [get] func GetNodeTaskList(c *gin.Context) { id := c.Param("id") @@ -97,6 +134,15 @@ func GetNodeTaskList(c *gin.Context) { }) } +// @Summary Get system info +// @Description Get system info +// @Tags node +// @Produce json +// @Param Authorization header string true "With the bearer started" +// @Param id path string true "node id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /nodes/{id}/system [get] func GetSystemInfo(c *gin.Context) { id := c.Param("id") @@ -109,6 +155,15 @@ func GetSystemInfo(c *gin.Context) { }) } +// @Summary Delete node +// @Description Delete node +// @Tags node +// @Produce json +// @Param Authorization header string true "With the bearer started" +// @Param id path string true "node id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /nodes/{id} [delete] func DeleteNode(c *gin.Context) { id := c.Param("id") node, err := model.GetNode(bson.ObjectIdHex(id)) diff --git a/backend/routes/project.go b/backend/routes/project.go index f0dd1198..86a8286d 100644 --- a/backend/routes/project.go +++ b/backend/routes/project.go @@ -10,6 +10,15 @@ import ( "net/http" ) +// @Summary Get projects +// @Description Get projects +// @Tags project +// @Produce json +// @Param Authorization header string true "With the bearer started" +// @Param tag query string true "projects" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /projects [get] func GetProjectList(c *gin.Context) { tag := c.Query("tag") @@ -70,6 +79,16 @@ func GetProjectList(c *gin.Context) { }) } +// @Summary Put project +// @Description Put project +// @Tags project +// @Accept json +// @Produce json +// @Param Authorization header string true "With the bearer started" +// @Param p body model.Project true "post project" +// @Success 200 json string Response +// @Failure 500 json string Response +// @Router /projects [put] func PutProject(c *gin.Context) { // 绑定请求数据 var p model.Project @@ -92,6 +111,17 @@ func PutProject(c *gin.Context) { }) } +// @Summary Post project +// @Description Post project +// @Tags project +// @Accept json +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "project id" +// @Param item body model.Project true "project item" +// @Success 200 json string Response +// @Failure 500 json string Response +// @Router /projects/{id} [post] func PostProject(c *gin.Context) { id := c.Param("id") @@ -116,6 +146,15 @@ func PostProject(c *gin.Context) { }) } +// @Summary Delete project +// @Description Delete project +// @Tags project +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "project id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /projects/{id} [delete] func DeleteProject(c *gin.Context) { id := c.Param("id") @@ -154,6 +193,14 @@ func DeleteProject(c *gin.Context) { }) } +// @Summary Get project tags +// @Description Get projects tags +// @Tags project +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /projects/tags [get] func GetProjectTags(c *gin.Context) { type Result struct { Tag string `json:"tag" bson:"tag"` diff --git a/backend/routes/schedule.go b/backend/routes/schedule.go index 27ad7825..e1e2fef3 100644 --- a/backend/routes/schedule.go +++ b/backend/routes/schedule.go @@ -8,6 +8,14 @@ import ( "net/http" ) +// @Summary Get schedule list +// @Description Get schedule list +// @Tags schedule +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /schedules [get] func GetScheduleList(c *gin.Context) { query := bson.M{} @@ -22,6 +30,15 @@ func GetScheduleList(c *gin.Context) { HandleSuccessData(c, results) } +// @Summary Get schedule by id +// @Description Get schedule by id +// @Tags schedule +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "schedule id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /schedules/{id} [get] func GetSchedule(c *gin.Context) { id := c.Param("id") @@ -34,6 +51,17 @@ func GetSchedule(c *gin.Context) { HandleSuccessData(c, result) } +// @Summary Post schedule +// @Description Post schedule +// @Tags schedule +// @Accept json +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "schedule id" +// @Param newItem body model.Schedule true "schedule item" +// @Success 200 json string Response +// @Failure 500 json string Response +// @Router /schedules/{id} [post] func PostSchedule(c *gin.Context) { id := c.Param("id") @@ -66,6 +94,16 @@ func PostSchedule(c *gin.Context) { HandleSuccess(c) } +// @Summary Put schedule +// @Description Put schedule +// @Tags schedule +// @Accept json +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param item body model.Schedule true "schedule item" +// @Success 200 json string Response +// @Failure 500 json string Response +// @Router /schedules [put] func PutSchedule(c *gin.Context) { var item model.Schedule @@ -99,6 +137,15 @@ func PutSchedule(c *gin.Context) { HandleSuccess(c) } +// @Summary Delete schedule +// @Description Delete schedule +// @Tags schedule +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "schedule id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /schedules/{id} [delete] func DeleteSchedule(c *gin.Context) { id := c.Param("id") @@ -118,6 +165,16 @@ func DeleteSchedule(c *gin.Context) { } // 停止定时任务 +// @Summary disable schedule +// @Description disable schedule +// @Tags schedule +// @Accept json +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "schedule id" +// @Success 200 json string Response +// @Failure 500 json string Response +// @Router /schedules/{id}/disable [post] func DisableSchedule(c *gin.Context) { id := c.Param("id") if err := services.Sched.Disable(bson.ObjectIdHex(id)); err != nil { @@ -128,6 +185,16 @@ func DisableSchedule(c *gin.Context) { } // 运行定时任务 +// @Summary enable schedule +// @Description enable schedule +// @Tags schedule +// @Accept json +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "schedule id" +// @Success 200 json string Response +// @Failure 500 json string Response +// @Router /schedules/{id}/enable [post] func EnableSchedule(c *gin.Context) { id := c.Param("id") if err := services.Sched.Enable(bson.ObjectIdHex(id)); err != nil { diff --git a/backend/routes/setting.go b/backend/routes/setting.go index 36bc46ca..5faea750 100644 --- a/backend/routes/setting.go +++ b/backend/routes/setting.go @@ -13,6 +13,14 @@ type SettingBody struct { EnableDemoSpiders string `json:"enable_demo_spiders"` } +// @Summary Get version +// @Description Get version +// @Tags setting +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /version [get] func GetVersion(c *gin.Context) { version := viper.GetString("version") @@ -23,6 +31,14 @@ func GetVersion(c *gin.Context) { }) } +// @Summary Get setting +// @Description Get setting +// @Tags setting +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /setting [get] func GetSetting(c *gin.Context) { body := SettingBody{ AllowRegister: viper.GetString("setting.allowRegister"), diff --git a/backend/routes/spider.go b/backend/routes/spider.go index b8feef6f..f229088e 100644 --- a/backend/routes/spider.go +++ b/backend/routes/spider.go @@ -28,6 +28,22 @@ import ( // ======== 爬虫管理 ======== +// @Summary Get spider list +// @Description Get spider list +// @Tags spider +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param page_num query string false "page num" +// @Param page_size query string false "page size" +// @Param keyword query string false "keyword" +// @Param project_id query string false "project_id" +// @Param type query string false "type" +// @Param sort_key query string false "sort_key" +// @Param sort_direction query string false "sort_direction" +// @Param owner_type query string false "owner_type" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /schedules [get] func GetSpiderList(c *gin.Context) { pageNum := c.Query("page_num") pageSize := c.Query("page_size") @@ -109,6 +125,15 @@ func GetSpiderList(c *gin.Context) { }) } +// @Summary Get spider by id +// @Description Get spider by id +// @Tags spider +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "schedule id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /spiders/{id} [get] func GetSpider(c *gin.Context) { id := c.Param("id") @@ -129,6 +154,17 @@ func GetSpider(c *gin.Context) { }) } +// @Summary Post spider +// @Description Post spider +// @Tags spider +// @Accept json +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "schedule id" +// @Param item body model.Spider true "spider item" +// @Success 200 json string Response +// @Failure 500 json string Response +// @Router /spiders/{id} [post] func PostSpider(c *gin.Context) { id := c.Param("id") @@ -177,6 +213,16 @@ func PostSpider(c *gin.Context) { }) } +// @Summary Publish spider +// @Description Publish spider +// @Tags spider +// @Accept json +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "schedule id" +// @Success 200 json string Response +// @Failure 500 json string Response +// @Router /spiders/{id}/publish [post] func PublishSpider(c *gin.Context) { id := c.Param("id") @@ -198,6 +244,16 @@ func PublishSpider(c *gin.Context) { }) } +// @Summary Put spider +// @Description Put spider +// @Tags spider +// @Accept json +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param spider body model.Spider true "spider item" +// @Success 200 json string Response +// @Failure 500 json string Response +// @Router /spiders [put] func PutSpider(c *gin.Context) { var spider model.Spider if err := c.ShouldBindJSON(&spider); err != nil { @@ -279,6 +335,16 @@ func PutSpider(c *gin.Context) { }) } +// @Summary Copy spider +// @Description Copy spider +// @Tags spider +// @Accept json +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "schedule id" +// @Success 200 json string Response +// @Failure 500 json string Response +// @Router /spiders/{id}/copy [post] func CopySpider(c *gin.Context) { type ReqBody struct { Name string `json:"name"` @@ -326,6 +392,20 @@ func CopySpider(c *gin.Context) { }) } +// @Summary Upload spider +// @Description Upload spider +// @Tags spider +// @Accept json +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param file formData file true "spider file to upload" +// @Param name formData string true "spider name" +// @Param display_name formData string true "display name" +// @Param col formData string true "col" +// @Param cmd formData string true "cmd" +// @Success 200 json string Response +// @Failure 500 json string Response +// @Router /spiders [post] func UploadSpider(c *gin.Context) { // 从body中获取文件 uploadFile, err := c.FormFile("file") @@ -467,6 +547,17 @@ func UploadSpider(c *gin.Context) { }) } +// @Summary Upload spider by id +// @Description Upload spider by id +// @Tags spider +// @Accept json +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param file formData file true "spider file to upload" +// @Param id path string true "spider id" +// @Success 200 json string Response +// @Failure 500 json string Response +// @Router /spiders/{id}/upload [post] func UploadSpiderFromId(c *gin.Context) { // TODO: 与 UploadSpider 部分逻辑重复,需要优化代码 // 爬虫ID @@ -560,6 +651,15 @@ func UploadSpiderFromId(c *gin.Context) { }) } +// @Summary Delete spider by id +// @Description Delete spider by id +// @Tags spider +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "spider id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /spiders/{id} [delete] func DeleteSpider(c *gin.Context) { id := c.Param("id") @@ -585,6 +685,15 @@ func DeleteSpider(c *gin.Context) { }) } +// @Summary delete spider +// @Description delete spider +// @Tags spider +// @Accept json +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Success 200 json string Response +// @Failure 500 json string Response +// @Router /spiders [post] func DeleteSelectedSpider(c *gin.Context) { type ReqBody struct { SpiderIds []string `json:"spider_ids"` @@ -615,6 +724,15 @@ func DeleteSelectedSpider(c *gin.Context) { }) } +// @Summary cancel spider +// @Description cancel spider +// @Tags spider +// @Accept json +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Success 200 json string Response +// @Failure 500 json string Response +// @Router /spiders-cancel [post] func CancelSelectedSpider(c *gin.Context) { type ReqBody struct { SpiderIds []string `json:"spider_ids"` @@ -639,6 +757,15 @@ func CancelSelectedSpider(c *gin.Context) { }) } +// @Summary run spider +// @Description run spider +// @Tags spider +// @Accept json +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Success 200 json string Response +// @Failure 500 json string Response +// @Router /spiders-run [post] func RunSelectedSpider(c *gin.Context) { type TaskParam struct { SpiderId bson.ObjectId `json:"spider_id"` @@ -734,6 +861,15 @@ func RunSelectedSpider(c *gin.Context) { }) } +// @Summary Get task list +// @Description Get task list +// @Tags spider +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "spider id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /spiders/{id}/tasks [get] func GetSpiderTasks(c *gin.Context) { id := c.Param("id") @@ -756,6 +892,15 @@ func GetSpiderTasks(c *gin.Context) { }) } +// @Summary Get spider stats +// @Description Get spider stats +// @Tags spider +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "spider id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /spiders/{id}/stats [get] func GetSpiderStats(c *gin.Context) { type Overview struct { TaskCount int `json:"task_count" bson:"task_count"` @@ -876,6 +1021,15 @@ func GetSpiderStats(c *gin.Context) { }) } +// @Summary Get schedules +// @Description Get schedules +// @Tags spider +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "spider id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /spiders/{id}/schedules [get] func GetSpiderSchedules(c *gin.Context) { id := c.Param("id") @@ -902,6 +1056,16 @@ func GetSpiderSchedules(c *gin.Context) { // ======== 爬虫文件管理 ======== +// @Summary Get spider dir +// @Description Get spider dir +// @Tags spider +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "spider id" +// @Param path query string true "path" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /spiders/{id}/dir [get] func GetSpiderDir(c *gin.Context) { // 爬虫ID id := c.Param("id") @@ -949,6 +1113,16 @@ type SpiderFileReqBody struct { NewPath string `json:"new_path"` } +// @Summary Get spider file +// @Description Get spider file +// @Tags spider +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "spider id" +// @Param path query string true "path" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /spiders/{id}/file [get] func GetSpiderFile(c *gin.Context) { // 爬虫ID id := c.Param("id") @@ -977,6 +1151,15 @@ func GetSpiderFile(c *gin.Context) { }) } +// @Summary Get spider dir +// @Description Get spider dir +// @Tags spider +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "spider id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /spiders/{id}/file/tree [get] func GetSpiderFileTree(c *gin.Context) { // 爬虫ID id := c.Param("id") @@ -1007,6 +1190,16 @@ func GetSpiderFileTree(c *gin.Context) { }) } +// @Summary Post spider file +// @Description Post spider file +// @Tags spider +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "spider id" +// @Param reqBody body routes.SpiderFileReqBody true "path" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /spiders/{id}/file [post] func PostSpiderFile(c *gin.Context) { // 爬虫ID id := c.Param("id") @@ -1044,6 +1237,16 @@ func PostSpiderFile(c *gin.Context) { }) } +// @Summary Put spider file +// @Description Put spider file +// @Tags spider +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "spider id" +// @Param reqBody body routes.SpiderFileReqBody true "path" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /spiders/{id}/file [post] func PutSpiderFile(c *gin.Context) { spiderId := c.Param("id") var reqBody SpiderFileReqBody @@ -1084,6 +1287,16 @@ func PutSpiderFile(c *gin.Context) { }) } +// @Summary Post spider dir +// @Description Post spider dir +// @Tags spider +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "spider id" +// @Param reqBody body routes.SpiderFileReqBody true "path" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /spiders/{id}/file [put] func PutSpiderDir(c *gin.Context) { spiderId := c.Param("id") var reqBody SpiderFileReqBody @@ -1124,6 +1337,16 @@ func PutSpiderDir(c *gin.Context) { }) } +// @Summary Delete spider file +// @Description Delete spider file +// @Tags spider +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "spider id" +// @Param reqBody body routes.SpiderFileReqBody true "path" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /spiders/{id}/file [delete] func DeleteSpiderFile(c *gin.Context) { spiderId := c.Param("id") var reqBody SpiderFileReqBody @@ -1154,6 +1377,16 @@ func DeleteSpiderFile(c *gin.Context) { }) } +// @Summary Rename spider file +// @Description Rename spider file +// @Tags spider +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "spider id" +// @Param reqBody body routes.SpiderFileReqBody true "path" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /spiders/{id}/file/rename [post] func RenameSpiderFile(c *gin.Context) { spiderId := c.Param("id") var reqBody SpiderFileReqBody @@ -1203,6 +1436,15 @@ func RenameSpiderFile(c *gin.Context) { // ======== Scrapy 部分 ======== +// @Summary Get scrapy spider file +// @Description Get scrapy spider file +// @Tags spider +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "spider id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /spiders/{id}/scrapy/spiders [get] func GetSpiderScrapySpiders(c *gin.Context) { id := c.Param("id") @@ -1230,6 +1472,15 @@ func GetSpiderScrapySpiders(c *gin.Context) { }) } +// @Summary Put scrapy spider file +// @Description Put scrapy spider file +// @Tags spider +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "spider id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /spiders/{id}/scrapy/spiders [put] func PutSpiderScrapySpiders(c *gin.Context) { type ReqBody struct { Name string `json:"name"` @@ -1267,6 +1518,15 @@ func PutSpiderScrapySpiders(c *gin.Context) { }) } +// @Summary Get scrapy spider settings +// @Description Get scrapy spider settings +// @Tags spider +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "spider id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /spiders/{id}/scrapy/settings [get] func GetSpiderScrapySettings(c *gin.Context) { id := c.Param("id") @@ -1294,6 +1554,16 @@ func GetSpiderScrapySettings(c *gin.Context) { }) } +// @Summary Get scrapy spider file +// @Description Get scrapy spider file +// @Tags spider +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "spider id" +// @Param reqData body []entity.ScrapySettingParam true "req data" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /spiders/{id}/scrapy/settings [post] func PostSpiderScrapySettings(c *gin.Context) { id := c.Param("id") @@ -1325,6 +1595,15 @@ func PostSpiderScrapySettings(c *gin.Context) { }) } +// @Summary Get scrapy spider items +// @Description Get scrapy spider items +// @Tags spider +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "spider id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /spiders/{id}/scrapy/items [get] func GetSpiderScrapyItems(c *gin.Context) { id := c.Param("id") @@ -1352,6 +1631,16 @@ func GetSpiderScrapyItems(c *gin.Context) { }) } +// @Summary Post scrapy spider items +// @Description Post scrapy spider items +// @Tags spider +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "spider id" +// @Param reqData body []entity.ScrapyItem true "req data" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /spiders/{id}/scrapy/items [post] func PostSpiderScrapyItems(c *gin.Context) { id := c.Param("id") @@ -1383,6 +1672,16 @@ func PostSpiderScrapyItems(c *gin.Context) { }) } + +// @Summary Get scrapy spider pipelines +// @Description Get scrapy spider pipelines +// @Tags spider +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "spider id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /spiders/{id}/scrapy/pipelines [get] func GetSpiderScrapyPipelines(c *gin.Context) { id := c.Param("id") @@ -1410,6 +1709,15 @@ func GetSpiderScrapyPipelines(c *gin.Context) { }) } +// @Summary Get scrapy spider file path +// @Description Get scrapy spider file path +// @Tags spider +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "spider id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /spiders/{id}/scrapy/spider/filepath [get] func GetSpiderScrapySpiderFilepath(c *gin.Context) { id := c.Param("id") @@ -1447,6 +1755,15 @@ func GetSpiderScrapySpiderFilepath(c *gin.Context) { // ======== Git 部分 ======== +// @Summary Post spider sync git +// @Description Post spider sync git +// @Tags spider +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "spider id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /spiders/{id}/git/sync [post] func PostSpiderSyncGit(c *gin.Context) { id := c.Param("id") @@ -1472,6 +1789,15 @@ func PostSpiderSyncGit(c *gin.Context) { }) } +// @Summary Post spider reset git +// @Description Post spider reset git +// @Tags spider +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "spider id" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /spiders/{id}/git/reset [post] func PostSpiderResetGit(c *gin.Context) { id := c.Param("id")