diff --git a/Makefile b/Makefile
index 0eb12cda329..7247909d582 100644
--- a/Makefile
+++ b/Makefile
@@ -290,7 +290,6 @@ help:
@echo "make e2e-test run e2e tests"
@echo "make e2e-test-coverage run e2e tests with coverage"
@echo "make clean-e2e-test clean e2e tests"
- @echo "make swag-manager generate swagger api"
@echo "make kind-load-image kind load docker image"
@echo "make kind-load-cdn kind load cdn docker image"
@echo "make kind-load-scheduler kind load scheduler docker image"
diff --git a/api/manager/docs.go b/api/manager/docs.go
index 927a4ec152d..2fc01a59492 100644
--- a/api/manager/docs.go
+++ b/api/manager/docs.go
@@ -561,6 +561,227 @@ var doc = `{
}
}
},
+ "/configs": {
+ "get": {
+ "description": "Get Configs",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Config"
+ ],
+ "summary": "Get Configs",
+ "parameters": [
+ {
+ "type": "integer",
+ "default": 0,
+ "description": "current page",
+ "name": "page",
+ "in": "query",
+ "required": true
+ },
+ {
+ "maximum": 50,
+ "minimum": 2,
+ "type": "integer",
+ "default": 10,
+ "description": "return max item count, default 10, max 50",
+ "name": "per_page",
+ "in": "query",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/model.Config"
+ }
+ }
+ },
+ "400": {
+ "description": ""
+ },
+ "404": {
+ "description": ""
+ },
+ "500": {
+ "description": ""
+ }
+ }
+ },
+ "post": {
+ "description": "create by json config",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Config"
+ ],
+ "summary": "Create Config",
+ "parameters": [
+ {
+ "description": "Config",
+ "name": "Config",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/types.CreateConfigRequest"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/model.Config"
+ }
+ },
+ "400": {
+ "description": ""
+ },
+ "404": {
+ "description": ""
+ },
+ "500": {
+ "description": ""
+ }
+ }
+ }
+ },
+ "/configs/{id}": {
+ "get": {
+ "description": "Get Config by id",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Config"
+ ],
+ "summary": "Get Config",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "id",
+ "name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/model.Config"
+ }
+ },
+ "400": {
+ "description": ""
+ },
+ "404": {
+ "description": ""
+ },
+ "500": {
+ "description": ""
+ }
+ }
+ },
+ "delete": {
+ "description": "Destroy by id",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Config"
+ ],
+ "summary": "Destroy Config",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "id",
+ "name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": ""
+ },
+ "400": {
+ "description": ""
+ },
+ "404": {
+ "description": ""
+ },
+ "500": {
+ "description": ""
+ }
+ }
+ },
+ "patch": {
+ "description": "Update by json config",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Config"
+ ],
+ "summary": "Update Config",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "id",
+ "name": "id",
+ "in": "path",
+ "required": true
+ },
+ {
+ "description": "Config",
+ "name": "Config",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/types.UpdateConfigRequest"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/model.Config"
+ }
+ },
+ "400": {
+ "description": ""
+ },
+ "404": {
+ "description": ""
+ },
+ "500": {
+ "description": ""
+ }
+ }
+ }
+ },
"/healthy": {
"get": {
"description": "Get app health",
@@ -852,7 +1073,7 @@ var doc = `{
"tags": [
"Preheat"
],
- "summary": "Create Preheat",
+ "summary": "Create V1 Preheat",
"parameters": [
{
"description": "Preheat",
@@ -860,7 +1081,7 @@ var doc = `{
"in": "body",
"required": true,
"schema": {
- "$ref": "#/definitions/types.CreatePreheatRequest"
+ "$ref": "#/definitions/types.CreateV1PreheatRequest"
}
}
],
@@ -868,7 +1089,7 @@ var doc = `{
"200": {
"description": "OK",
"schema": {
- "$ref": "#/definitions/types.Preheat"
+ "$ref": "#/definitions/types.CreateV1PreheatResponse"
}
},
"400": {
@@ -895,7 +1116,7 @@ var doc = `{
"tags": [
"Preheat"
],
- "summary": "Get Preheat",
+ "summary": "Get V1 Preheat",
"parameters": [
{
"type": "string",
@@ -909,7 +1130,7 @@ var doc = `{
"200": {
"description": "OK",
"schema": {
- "$ref": "#/definitions/types.Preheat"
+ "$ref": "#/definitions/types.GetV1PreheatResponse"
}
},
"400": {
@@ -2212,62 +2433,68 @@ var doc = `{
}
}
}
- }
- },
- "definitions": {
- "model.Assertion": {
- "type": "object",
- "properties": {
- "key": {
- "type": "string"
- },
- "policy": {
- "type": "array",
- "items": {
- "type": "array",
- "items": {
- "type": "string"
- }
- }
- },
- "policyMap": {
- "type": "object",
- "additionalProperties": {
- "type": "integer"
+ },
+ "/users/{id}": {
+ "get": {
+ "description": "Get User by id",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "User"
+ ],
+ "summary": "Get User",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "id",
+ "name": "id",
+ "in": "path",
+ "required": true
}
- },
- "rm": {
- "$ref": "#/definitions/rbac.RoleManager"
- },
- "tokens": {
- "type": "array",
- "items": {
- "type": "string"
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/model.User"
+ }
+ },
+ "400": {
+ "description": ""
+ },
+ "404": {
+ "description": ""
+ },
+ "500": {
+ "description": ""
}
- },
- "value": {
- "type": "string"
}
}
- },
- "model.AssertionMap": {
- "type": "object",
- "additionalProperties": {
- "$ref": "#/definitions/model.Assertion"
- }
- },
+ }
+ },
+ "definitions": {
"model.CDN": {
"type": "object",
"properties": {
"cdnclusterID": {
"type": "integer"
},
+ "created_at": {
+ "type": "string"
+ },
"download_port": {
"type": "integer"
},
"host_name": {
"type": "string"
},
+ "id": {
+ "type": "integer"
+ },
"idc": {
"type": "string"
},
@@ -2282,6 +2509,9 @@ var doc = `{
},
"status": {
"type": "string"
+ },
+ "updated_at": {
+ "type": "string"
}
}
},
@@ -2294,14 +2524,49 @@ var doc = `{
"config": {
"$ref": "#/definitions/model.JSONMap"
},
+ "created_at": {
+ "type": "string"
+ },
+ "id": {
+ "type": "integer"
+ },
"is_default": {
"type": "boolean"
},
"name": {
"type": "string"
},
- "securityGroupID": {
+ "security_group_id": {
+ "type": "integer"
+ },
+ "updated_at": {
+ "type": "string"
+ }
+ }
+ },
+ "model.Config": {
+ "type": "object",
+ "properties": {
+ "bio": {
+ "type": "string"
+ },
+ "created_at": {
+ "type": "string"
+ },
+ "id": {
+ "type": "integer"
+ },
+ "key": {
+ "type": "string"
+ },
+ "updated_at": {
+ "type": "string"
+ },
+ "user_id": {
"type": "integer"
+ },
+ "value": {
+ "type": "string"
}
}
},
@@ -2321,20 +2586,35 @@ var doc = `{
"client_secret": {
"type": "string"
},
+ "created_at": {
+ "type": "string"
+ },
+ "id": {
+ "type": "integer"
+ },
"name": {
"type": "string"
},
"redirect_url": {
"type": "string"
+ },
+ "updated_at": {
+ "type": "string"
}
}
},
"model.Scheduler": {
"type": "object",
"properties": {
+ "created_at": {
+ "type": "string"
+ },
"host_name": {
"type": "string"
},
+ "id": {
+ "type": "integer"
+ },
"idc": {
"type": "string"
},
@@ -2356,6 +2636,9 @@ var doc = `{
"status": {
"type": "string"
},
+ "updated_at": {
+ "type": "string"
+ },
"vips": {
"type": "string"
}
@@ -2367,12 +2650,24 @@ var doc = `{
"bio": {
"type": "string"
},
+ "cdn_clusters": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/model.CDNCluster"
+ }
+ },
"client_config": {
"$ref": "#/definitions/model.JSONMap"
},
"config": {
"$ref": "#/definitions/model.JSONMap"
},
+ "created_at": {
+ "type": "string"
+ },
+ "id": {
+ "type": "integer"
+ },
"is_default": {
"type": "boolean"
},
@@ -2382,8 +2677,11 @@ var doc = `{
"scopes": {
"$ref": "#/definitions/model.JSONMap"
},
- "securityGroupID": {
+ "security_group_id": {
"type": "integer"
+ },
+ "updated_at": {
+ "type": "string"
}
}
},
@@ -2393,14 +2691,23 @@ var doc = `{
"bio": {
"type": "string"
},
+ "created_at": {
+ "type": "string"
+ },
"domain": {
"type": "string"
},
+ "id": {
+ "type": "integer"
+ },
"name": {
"type": "string"
},
"proxy_domain": {
"type": "string"
+ },
+ "updated_at": {
+ "type": "string"
}
}
},
@@ -2413,9 +2720,15 @@ var doc = `{
"bio": {
"type": "string"
},
+ "created_at": {
+ "type": "string"
+ },
"email": {
"type": "string"
},
+ "id": {
+ "type": "integer"
+ },
"location": {
"type": "string"
},
@@ -2425,10 +2738,10 @@ var doc = `{
"phone": {
"type": "string"
},
- "private_token": {
+ "state": {
"type": "string"
},
- "state": {
+ "updated_at": {
"type": "string"
}
}
@@ -2448,9 +2761,6 @@ var doc = `{
}
}
},
- "rbac.RoleManager": {
- "type": "object"
- },
"types.AddPermissionForRoleRequest": {
"type": "object",
"required": [
@@ -2466,6 +2776,17 @@ var doc = `{
}
}
},
+ "types.CDNClusterConfig": {
+ "type": "object",
+ "properties": {
+ "load_limit": {
+ "type": "integer"
+ },
+ "net_topology": {
+ "type": "string"
+ }
+ }
+ },
"types.CreateCDNClusterRequest": {
"type": "object",
"required": [
@@ -2477,8 +2798,7 @@ var doc = `{
"type": "string"
},
"config": {
- "type": "object",
- "additionalProperties": true
+ "$ref": "#/definitions/types.CDNClusterConfig"
},
"name": {
"type": "string"
@@ -2522,6 +2842,28 @@ var doc = `{
}
}
},
+ "types.CreateConfigRequest": {
+ "type": "object",
+ "required": [
+ "key",
+ "user_id",
+ "value"
+ ],
+ "properties": {
+ "bio": {
+ "type": "string"
+ },
+ "key": {
+ "type": "string"
+ },
+ "user_id": {
+ "type": "integer"
+ },
+ "value": {
+ "type": "string"
+ }
+ }
+ },
"types.CreateOauthRequest": {
"type": "object",
"required": [
@@ -2607,12 +2949,10 @@ var doc = `{
"type": "integer"
},
"client_config": {
- "type": "object",
- "additionalProperties": true
+ "$ref": "#/definitions/types.SchedulerClusterClientConfig"
},
"config": {
- "type": "object",
- "additionalProperties": true
+ "$ref": "#/definitions/types.SchedulerClusterConfig"
},
"is_default": {
"type": "boolean"
@@ -2621,8 +2961,7 @@ var doc = `{
"type": "string"
},
"scopes": {
- "type": "object",
- "additionalProperties": true
+ "$ref": "#/definitions/types.SchedulerClusterScopes"
},
"security_group_domain": {
"type": "string"
@@ -2687,6 +3026,38 @@ var doc = `{
}
}
},
+ "types.CreateV1PreheatRequest": {
+ "type": "object",
+ "required": [
+ "type",
+ "url"
+ ],
+ "properties": {
+ "filter": {
+ "type": "string"
+ },
+ "headers": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "string"
+ }
+ },
+ "type": {
+ "type": "string"
+ },
+ "url": {
+ "type": "string"
+ }
+ }
+ },
+ "types.CreateV1PreheatResponse": {
+ "type": "object",
+ "properties": {
+ "ID": {
+ "type": "string"
+ }
+ }
+ },
"types.DeletePermissionForRoleRequest": {
"type": "object",
"required": [
@@ -2702,6 +3073,23 @@ var doc = `{
}
}
},
+ "types.GetV1PreheatResponse": {
+ "type": "object",
+ "properties": {
+ "ID": {
+ "type": "string"
+ },
+ "finishTime": {
+ "type": "string"
+ },
+ "startTime": {
+ "type": "string"
+ },
+ "status": {
+ "type": "string"
+ }
+ }
+ },
"types.Preheat": {
"type": "object",
"properties": {
@@ -2731,6 +3119,20 @@ var doc = `{
}
}
},
+ "types.SchedulerClusterClientConfig": {
+ "type": "object",
+ "properties": {
+ "load_limit": {
+ "type": "integer"
+ }
+ }
+ },
+ "types.SchedulerClusterConfig": {
+ "type": "object"
+ },
+ "types.SchedulerClusterScopes": {
+ "type": "object"
+ },
"types.SignUpRequest": {
"type": "object",
"required": [
@@ -2769,8 +3171,7 @@ var doc = `{
"type": "string"
},
"config": {
- "type": "object",
- "additionalProperties": true
+ "$ref": "#/definitions/types.CDNClusterConfig"
},
"name": {
"type": "string"
@@ -2803,6 +3204,23 @@ var doc = `{
}
}
},
+ "types.UpdateConfigRequest": {
+ "type": "object",
+ "properties": {
+ "bio": {
+ "type": "string"
+ },
+ "key": {
+ "type": "string"
+ },
+ "user_id": {
+ "type": "integer"
+ },
+ "value": {
+ "type": "string"
+ }
+ }
+ },
"types.UpdateOauthRequest": {
"type": "object",
"properties": {
@@ -2833,12 +3251,10 @@ var doc = `{
"type": "integer"
},
"client_config": {
- "type": "object",
- "additionalProperties": true
+ "$ref": "#/definitions/types.SchedulerClusterClientConfig"
},
"config": {
- "type": "object",
- "additionalProperties": true
+ "$ref": "#/definitions/types.SchedulerClusterConfig"
},
"is_default": {
"type": "boolean"
@@ -2847,8 +3263,7 @@ var doc = `{
"type": "string"
},
"scopes": {
- "type": "object",
- "additionalProperties": true
+ "$ref": "#/definitions/types.SchedulerClusterScopes"
},
"security_group_domain": {
"type": "string"
diff --git a/api/manager/swagger.json b/api/manager/swagger.json
index 5309764900c..47b2c6f37cc 100644
--- a/api/manager/swagger.json
+++ b/api/manager/swagger.json
@@ -546,6 +546,227 @@
}
}
},
+ "/configs": {
+ "get": {
+ "description": "Get Configs",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Config"
+ ],
+ "summary": "Get Configs",
+ "parameters": [
+ {
+ "type": "integer",
+ "default": 0,
+ "description": "current page",
+ "name": "page",
+ "in": "query",
+ "required": true
+ },
+ {
+ "maximum": 50,
+ "minimum": 2,
+ "type": "integer",
+ "default": 10,
+ "description": "return max item count, default 10, max 50",
+ "name": "per_page",
+ "in": "query",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/model.Config"
+ }
+ }
+ },
+ "400": {
+ "description": ""
+ },
+ "404": {
+ "description": ""
+ },
+ "500": {
+ "description": ""
+ }
+ }
+ },
+ "post": {
+ "description": "create by json config",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Config"
+ ],
+ "summary": "Create Config",
+ "parameters": [
+ {
+ "description": "Config",
+ "name": "Config",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/types.CreateConfigRequest"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/model.Config"
+ }
+ },
+ "400": {
+ "description": ""
+ },
+ "404": {
+ "description": ""
+ },
+ "500": {
+ "description": ""
+ }
+ }
+ }
+ },
+ "/configs/{id}": {
+ "get": {
+ "description": "Get Config by id",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Config"
+ ],
+ "summary": "Get Config",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "id",
+ "name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/model.Config"
+ }
+ },
+ "400": {
+ "description": ""
+ },
+ "404": {
+ "description": ""
+ },
+ "500": {
+ "description": ""
+ }
+ }
+ },
+ "delete": {
+ "description": "Destroy by id",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Config"
+ ],
+ "summary": "Destroy Config",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "id",
+ "name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": ""
+ },
+ "400": {
+ "description": ""
+ },
+ "404": {
+ "description": ""
+ },
+ "500": {
+ "description": ""
+ }
+ }
+ },
+ "patch": {
+ "description": "Update by json config",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Config"
+ ],
+ "summary": "Update Config",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "id",
+ "name": "id",
+ "in": "path",
+ "required": true
+ },
+ {
+ "description": "Config",
+ "name": "Config",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/types.UpdateConfigRequest"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/model.Config"
+ }
+ },
+ "400": {
+ "description": ""
+ },
+ "404": {
+ "description": ""
+ },
+ "500": {
+ "description": ""
+ }
+ }
+ }
+ },
"/healthy": {
"get": {
"description": "Get app health",
@@ -837,7 +1058,7 @@
"tags": [
"Preheat"
],
- "summary": "Create Preheat",
+ "summary": "Create V1 Preheat",
"parameters": [
{
"description": "Preheat",
@@ -845,7 +1066,7 @@
"in": "body",
"required": true,
"schema": {
- "$ref": "#/definitions/types.CreatePreheatRequest"
+ "$ref": "#/definitions/types.CreateV1PreheatRequest"
}
}
],
@@ -853,7 +1074,7 @@
"200": {
"description": "OK",
"schema": {
- "$ref": "#/definitions/types.Preheat"
+ "$ref": "#/definitions/types.CreateV1PreheatResponse"
}
},
"400": {
@@ -880,7 +1101,7 @@
"tags": [
"Preheat"
],
- "summary": "Get Preheat",
+ "summary": "Get V1 Preheat",
"parameters": [
{
"type": "string",
@@ -894,7 +1115,7 @@
"200": {
"description": "OK",
"schema": {
- "$ref": "#/definitions/types.Preheat"
+ "$ref": "#/definitions/types.GetV1PreheatResponse"
}
},
"400": {
@@ -2197,62 +2418,68 @@
}
}
}
- }
- },
- "definitions": {
- "model.Assertion": {
- "type": "object",
- "properties": {
- "key": {
- "type": "string"
- },
- "policy": {
- "type": "array",
- "items": {
- "type": "array",
- "items": {
- "type": "string"
- }
- }
- },
- "policyMap": {
- "type": "object",
- "additionalProperties": {
- "type": "integer"
+ },
+ "/users/{id}": {
+ "get": {
+ "description": "Get User by id",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "User"
+ ],
+ "summary": "Get User",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "id",
+ "name": "id",
+ "in": "path",
+ "required": true
}
- },
- "rm": {
- "$ref": "#/definitions/rbac.RoleManager"
- },
- "tokens": {
- "type": "array",
- "items": {
- "type": "string"
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/model.User"
+ }
+ },
+ "400": {
+ "description": ""
+ },
+ "404": {
+ "description": ""
+ },
+ "500": {
+ "description": ""
}
- },
- "value": {
- "type": "string"
}
}
- },
- "model.AssertionMap": {
- "type": "object",
- "additionalProperties": {
- "$ref": "#/definitions/model.Assertion"
- }
- },
+ }
+ },
+ "definitions": {
"model.CDN": {
"type": "object",
"properties": {
"cdnclusterID": {
"type": "integer"
},
+ "created_at": {
+ "type": "string"
+ },
"download_port": {
"type": "integer"
},
"host_name": {
"type": "string"
},
+ "id": {
+ "type": "integer"
+ },
"idc": {
"type": "string"
},
@@ -2267,6 +2494,9 @@
},
"status": {
"type": "string"
+ },
+ "updated_at": {
+ "type": "string"
}
}
},
@@ -2279,14 +2509,49 @@
"config": {
"$ref": "#/definitions/model.JSONMap"
},
+ "created_at": {
+ "type": "string"
+ },
+ "id": {
+ "type": "integer"
+ },
"is_default": {
"type": "boolean"
},
"name": {
"type": "string"
},
- "securityGroupID": {
+ "security_group_id": {
+ "type": "integer"
+ },
+ "updated_at": {
+ "type": "string"
+ }
+ }
+ },
+ "model.Config": {
+ "type": "object",
+ "properties": {
+ "bio": {
+ "type": "string"
+ },
+ "created_at": {
+ "type": "string"
+ },
+ "id": {
+ "type": "integer"
+ },
+ "key": {
+ "type": "string"
+ },
+ "updated_at": {
+ "type": "string"
+ },
+ "user_id": {
"type": "integer"
+ },
+ "value": {
+ "type": "string"
}
}
},
@@ -2306,20 +2571,35 @@
"client_secret": {
"type": "string"
},
+ "created_at": {
+ "type": "string"
+ },
+ "id": {
+ "type": "integer"
+ },
"name": {
"type": "string"
},
"redirect_url": {
"type": "string"
+ },
+ "updated_at": {
+ "type": "string"
}
}
},
"model.Scheduler": {
"type": "object",
"properties": {
+ "created_at": {
+ "type": "string"
+ },
"host_name": {
"type": "string"
},
+ "id": {
+ "type": "integer"
+ },
"idc": {
"type": "string"
},
@@ -2341,6 +2621,9 @@
"status": {
"type": "string"
},
+ "updated_at": {
+ "type": "string"
+ },
"vips": {
"type": "string"
}
@@ -2352,12 +2635,24 @@
"bio": {
"type": "string"
},
+ "cdn_clusters": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/model.CDNCluster"
+ }
+ },
"client_config": {
"$ref": "#/definitions/model.JSONMap"
},
"config": {
"$ref": "#/definitions/model.JSONMap"
},
+ "created_at": {
+ "type": "string"
+ },
+ "id": {
+ "type": "integer"
+ },
"is_default": {
"type": "boolean"
},
@@ -2367,8 +2662,11 @@
"scopes": {
"$ref": "#/definitions/model.JSONMap"
},
- "securityGroupID": {
+ "security_group_id": {
"type": "integer"
+ },
+ "updated_at": {
+ "type": "string"
}
}
},
@@ -2378,14 +2676,23 @@
"bio": {
"type": "string"
},
+ "created_at": {
+ "type": "string"
+ },
"domain": {
"type": "string"
},
+ "id": {
+ "type": "integer"
+ },
"name": {
"type": "string"
},
"proxy_domain": {
"type": "string"
+ },
+ "updated_at": {
+ "type": "string"
}
}
},
@@ -2398,9 +2705,15 @@
"bio": {
"type": "string"
},
+ "created_at": {
+ "type": "string"
+ },
"email": {
"type": "string"
},
+ "id": {
+ "type": "integer"
+ },
"location": {
"type": "string"
},
@@ -2410,10 +2723,10 @@
"phone": {
"type": "string"
},
- "private_token": {
+ "state": {
"type": "string"
},
- "state": {
+ "updated_at": {
"type": "string"
}
}
@@ -2433,9 +2746,6 @@
}
}
},
- "rbac.RoleManager": {
- "type": "object"
- },
"types.AddPermissionForRoleRequest": {
"type": "object",
"required": [
@@ -2451,6 +2761,17 @@
}
}
},
+ "types.CDNClusterConfig": {
+ "type": "object",
+ "properties": {
+ "load_limit": {
+ "type": "integer"
+ },
+ "net_topology": {
+ "type": "string"
+ }
+ }
+ },
"types.CreateCDNClusterRequest": {
"type": "object",
"required": [
@@ -2462,8 +2783,7 @@
"type": "string"
},
"config": {
- "type": "object",
- "additionalProperties": true
+ "$ref": "#/definitions/types.CDNClusterConfig"
},
"name": {
"type": "string"
@@ -2507,6 +2827,28 @@
}
}
},
+ "types.CreateConfigRequest": {
+ "type": "object",
+ "required": [
+ "key",
+ "user_id",
+ "value"
+ ],
+ "properties": {
+ "bio": {
+ "type": "string"
+ },
+ "key": {
+ "type": "string"
+ },
+ "user_id": {
+ "type": "integer"
+ },
+ "value": {
+ "type": "string"
+ }
+ }
+ },
"types.CreateOauthRequest": {
"type": "object",
"required": [
@@ -2592,12 +2934,10 @@
"type": "integer"
},
"client_config": {
- "type": "object",
- "additionalProperties": true
+ "$ref": "#/definitions/types.SchedulerClusterClientConfig"
},
"config": {
- "type": "object",
- "additionalProperties": true
+ "$ref": "#/definitions/types.SchedulerClusterConfig"
},
"is_default": {
"type": "boolean"
@@ -2606,8 +2946,7 @@
"type": "string"
},
"scopes": {
- "type": "object",
- "additionalProperties": true
+ "$ref": "#/definitions/types.SchedulerClusterScopes"
},
"security_group_domain": {
"type": "string"
@@ -2672,6 +3011,38 @@
}
}
},
+ "types.CreateV1PreheatRequest": {
+ "type": "object",
+ "required": [
+ "type",
+ "url"
+ ],
+ "properties": {
+ "filter": {
+ "type": "string"
+ },
+ "headers": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "string"
+ }
+ },
+ "type": {
+ "type": "string"
+ },
+ "url": {
+ "type": "string"
+ }
+ }
+ },
+ "types.CreateV1PreheatResponse": {
+ "type": "object",
+ "properties": {
+ "ID": {
+ "type": "string"
+ }
+ }
+ },
"types.DeletePermissionForRoleRequest": {
"type": "object",
"required": [
@@ -2687,6 +3058,23 @@
}
}
},
+ "types.GetV1PreheatResponse": {
+ "type": "object",
+ "properties": {
+ "ID": {
+ "type": "string"
+ },
+ "finishTime": {
+ "type": "string"
+ },
+ "startTime": {
+ "type": "string"
+ },
+ "status": {
+ "type": "string"
+ }
+ }
+ },
"types.Preheat": {
"type": "object",
"properties": {
@@ -2716,6 +3104,20 @@
}
}
},
+ "types.SchedulerClusterClientConfig": {
+ "type": "object",
+ "properties": {
+ "load_limit": {
+ "type": "integer"
+ }
+ }
+ },
+ "types.SchedulerClusterConfig": {
+ "type": "object"
+ },
+ "types.SchedulerClusterScopes": {
+ "type": "object"
+ },
"types.SignUpRequest": {
"type": "object",
"required": [
@@ -2754,8 +3156,7 @@
"type": "string"
},
"config": {
- "type": "object",
- "additionalProperties": true
+ "$ref": "#/definitions/types.CDNClusterConfig"
},
"name": {
"type": "string"
@@ -2788,6 +3189,23 @@
}
}
},
+ "types.UpdateConfigRequest": {
+ "type": "object",
+ "properties": {
+ "bio": {
+ "type": "string"
+ },
+ "key": {
+ "type": "string"
+ },
+ "user_id": {
+ "type": "integer"
+ },
+ "value": {
+ "type": "string"
+ }
+ }
+ },
"types.UpdateOauthRequest": {
"type": "object",
"properties": {
@@ -2818,12 +3236,10 @@
"type": "integer"
},
"client_config": {
- "type": "object",
- "additionalProperties": true
+ "$ref": "#/definitions/types.SchedulerClusterClientConfig"
},
"config": {
- "type": "object",
- "additionalProperties": true
+ "$ref": "#/definitions/types.SchedulerClusterConfig"
},
"is_default": {
"type": "boolean"
@@ -2832,8 +3248,7 @@
"type": "string"
},
"scopes": {
- "type": "object",
- "additionalProperties": true
+ "$ref": "#/definitions/types.SchedulerClusterScopes"
},
"security_group_domain": {
"type": "string"
diff --git a/api/manager/swagger.yaml b/api/manager/swagger.yaml
index 5c4434ee201..1df2e6d383e 100644
--- a/api/manager/swagger.yaml
+++ b/api/manager/swagger.yaml
@@ -1,40 +1,17 @@
basePath: /api/v1
definitions:
- model.Assertion:
- properties:
- key:
- type: string
- policy:
- items:
- items:
- type: string
- type: array
- type: array
- policyMap:
- additionalProperties:
- type: integer
- type: object
- rm:
- $ref: '#/definitions/rbac.RoleManager'
- tokens:
- items:
- type: string
- type: array
- value:
- type: string
- type: object
- model.AssertionMap:
- additionalProperties:
- $ref: '#/definitions/model.Assertion'
- type: object
model.CDN:
properties:
cdnclusterID:
type: integer
+ created_at:
+ type: string
download_port:
type: integer
host_name:
type: string
+ id:
+ type: integer
idc:
type: string
ip:
@@ -45,6 +22,8 @@ definitions:
type: integer
status:
type: string
+ updated_at:
+ type: string
type: object
model.CDNCluster:
properties:
@@ -52,12 +31,35 @@ definitions:
type: string
config:
$ref: '#/definitions/model.JSONMap'
+ created_at:
+ type: string
+ id:
+ type: integer
is_default:
type: boolean
name:
type: string
- securityGroupID:
+ security_group_id:
type: integer
+ updated_at:
+ type: string
+ type: object
+ model.Config:
+ properties:
+ bio:
+ type: string
+ created_at:
+ type: string
+ id:
+ type: integer
+ key:
+ type: string
+ updated_at:
+ type: string
+ user_id:
+ type: integer
+ value:
+ type: string
type: object
model.JSONMap:
additionalProperties: true
@@ -70,15 +72,25 @@ definitions:
type: string
client_secret:
type: string
+ created_at:
+ type: string
+ id:
+ type: integer
name:
type: string
redirect_url:
type: string
+ updated_at:
+ type: string
type: object
model.Scheduler:
properties:
+ created_at:
+ type: string
host_name:
type: string
+ id:
+ type: integer
idc:
type: string
ip:
@@ -93,6 +105,8 @@ definitions:
type: integer
status:
type: string
+ updated_at:
+ type: string
vips:
type: string
type: object
@@ -100,29 +114,45 @@ definitions:
properties:
bio:
type: string
+ cdn_clusters:
+ items:
+ $ref: '#/definitions/model.CDNCluster'
+ type: array
client_config:
$ref: '#/definitions/model.JSONMap'
config:
$ref: '#/definitions/model.JSONMap'
+ created_at:
+ type: string
+ id:
+ type: integer
is_default:
type: boolean
name:
type: string
scopes:
$ref: '#/definitions/model.JSONMap'
- securityGroupID:
+ security_group_id:
type: integer
+ updated_at:
+ type: string
type: object
model.SecurityGroup:
properties:
bio:
type: string
+ created_at:
+ type: string
domain:
type: string
+ id:
+ type: integer
name:
type: string
proxy_domain:
type: string
+ updated_at:
+ type: string
type: object
model.User:
properties:
@@ -130,18 +160,22 @@ definitions:
type: string
bio:
type: string
+ created_at:
+ type: string
email:
type: string
+ id:
+ type: integer
location:
type: string
name:
type: string
phone:
type: string
- private_token:
- type: string
state:
type: string
+ updated_at:
+ type: string
type: object
rbac.Permission:
properties:
@@ -153,8 +187,6 @@ definitions:
- action
- object
type: object
- rbac.RoleManager:
- type: object
types.AddPermissionForRoleRequest:
properties:
action:
@@ -165,13 +197,19 @@ definitions:
- action
- object
type: object
+ types.CDNClusterConfig:
+ properties:
+ load_limit:
+ type: integer
+ net_topology:
+ type: string
+ type: object
types.CreateCDNClusterRequest:
properties:
bio:
type: string
config:
- additionalProperties: true
- type: object
+ $ref: '#/definitions/types.CDNClusterConfig'
name:
type: string
security_group_domain:
@@ -204,6 +242,21 @@ definitions:
- ip
- port
type: object
+ types.CreateConfigRequest:
+ properties:
+ bio:
+ type: string
+ key:
+ type: string
+ user_id:
+ type: integer
+ value:
+ type: string
+ required:
+ - key
+ - user_id
+ - value
+ type: object
types.CreateOauthRequest:
properties:
bio:
@@ -258,18 +311,15 @@ definitions:
cdn_cluster_id:
type: integer
client_config:
- additionalProperties: true
- type: object
+ $ref: '#/definitions/types.SchedulerClusterClientConfig'
config:
- additionalProperties: true
- type: object
+ $ref: '#/definitions/types.SchedulerClusterConfig'
is_default:
type: boolean
name:
type: string
scopes:
- additionalProperties: true
- type: object
+ $ref: '#/definitions/types.SchedulerClusterScopes'
security_group_domain:
type: string
required:
@@ -317,6 +367,27 @@ definitions:
- domain
- name
type: object
+ types.CreateV1PreheatRequest:
+ properties:
+ filter:
+ type: string
+ headers:
+ additionalProperties:
+ type: string
+ type: object
+ type:
+ type: string
+ url:
+ type: string
+ required:
+ - type
+ - url
+ type: object
+ types.CreateV1PreheatResponse:
+ properties:
+ ID:
+ type: string
+ type: object
types.DeletePermissionForRoleRequest:
properties:
action:
@@ -327,6 +398,17 @@ definitions:
- action
- object
type: object
+ types.GetV1PreheatResponse:
+ properties:
+ ID:
+ type: string
+ finishTime:
+ type: string
+ startTime:
+ type: string
+ status:
+ type: string
+ type: object
types.Preheat:
properties:
create_at:
@@ -346,6 +428,15 @@ definitions:
- new_password
- old_password
type: object
+ types.SchedulerClusterClientConfig:
+ properties:
+ load_limit:
+ type: integer
+ type: object
+ types.SchedulerClusterConfig:
+ type: object
+ types.SchedulerClusterScopes:
+ type: object
types.SignUpRequest:
properties:
avatar:
@@ -372,8 +463,7 @@ definitions:
bio:
type: string
config:
- additionalProperties: true
- type: object
+ $ref: '#/definitions/types.CDNClusterConfig'
name:
type: string
security_group_domain:
@@ -394,6 +484,17 @@ definitions:
port:
type: integer
type: object
+ types.UpdateConfigRequest:
+ properties:
+ bio:
+ type: string
+ key:
+ type: string
+ user_id:
+ type: integer
+ value:
+ type: string
+ type: object
types.UpdateOauthRequest:
properties:
bio:
@@ -414,18 +515,15 @@ definitions:
cdn_cluster_id:
type: integer
client_config:
- additionalProperties: true
- type: object
+ $ref: '#/definitions/types.SchedulerClusterClientConfig'
config:
- additionalProperties: true
- type: object
+ $ref: '#/definitions/types.SchedulerClusterConfig'
is_default:
type: boolean
name:
type: string
scopes:
- additionalProperties: true
- type: object
+ $ref: '#/definitions/types.SchedulerClusterScopes'
security_group_domain:
type: string
type: object
@@ -826,6 +924,154 @@ paths:
summary: Update CDN
tags:
- CDN
+ /configs:
+ get:
+ consumes:
+ - application/json
+ description: Get Configs
+ parameters:
+ - default: 0
+ description: current page
+ in: query
+ name: page
+ required: true
+ type: integer
+ - default: 10
+ description: return max item count, default 10, max 50
+ in: query
+ maximum: 50
+ minimum: 2
+ name: per_page
+ required: true
+ type: integer
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ items:
+ $ref: '#/definitions/model.Config'
+ type: array
+ "400":
+ description: ""
+ "404":
+ description: ""
+ "500":
+ description: ""
+ summary: Get Configs
+ tags:
+ - Config
+ post:
+ consumes:
+ - application/json
+ description: create by json config
+ parameters:
+ - description: Config
+ in: body
+ name: Config
+ required: true
+ schema:
+ $ref: '#/definitions/types.CreateConfigRequest'
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/model.Config'
+ "400":
+ description: ""
+ "404":
+ description: ""
+ "500":
+ description: ""
+ summary: Create Config
+ tags:
+ - Config
+ /configs/{id}:
+ delete:
+ consumes:
+ - application/json
+ description: Destroy by id
+ parameters:
+ - description: id
+ in: path
+ name: id
+ required: true
+ type: string
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: ""
+ "400":
+ description: ""
+ "404":
+ description: ""
+ "500":
+ description: ""
+ summary: Destroy Config
+ tags:
+ - Config
+ get:
+ consumes:
+ - application/json
+ description: Get Config by id
+ parameters:
+ - description: id
+ in: path
+ name: id
+ required: true
+ type: string
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/model.Config'
+ "400":
+ description: ""
+ "404":
+ description: ""
+ "500":
+ description: ""
+ summary: Get Config
+ tags:
+ - Config
+ patch:
+ consumes:
+ - application/json
+ description: Update by json config
+ parameters:
+ - description: id
+ in: path
+ name: id
+ required: true
+ type: string
+ - description: Config
+ in: body
+ name: Config
+ required: true
+ schema:
+ $ref: '#/definitions/types.UpdateConfigRequest'
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/model.Config'
+ "400":
+ description: ""
+ "404":
+ description: ""
+ "500":
+ description: ""
+ summary: Update Config
+ tags:
+ - Config
/healthy:
get:
consumes:
@@ -1023,21 +1269,21 @@ paths:
name: CDN
required: true
schema:
- $ref: '#/definitions/types.CreatePreheatRequest'
+ $ref: '#/definitions/types.CreateV1PreheatRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
- $ref: '#/definitions/types.Preheat'
+ $ref: '#/definitions/types.CreateV1PreheatResponse'
"400":
description: ""
"404":
description: ""
"500":
description: ""
- summary: Create Preheat
+ summary: Create V1 Preheat
tags:
- Preheat
/preheats/{id}:
@@ -1057,14 +1303,14 @@ paths:
"200":
description: OK
schema:
- $ref: '#/definitions/types.Preheat'
+ $ref: '#/definitions/types.GetV1PreheatResponse'
"400":
description: ""
"404":
description: ""
"500":
description: ""
- summary: Get Preheat
+ summary: Get V1 Preheat
tags:
- Preheat
/roles:
@@ -1925,4 +2171,31 @@ paths:
summary: Add Role For User
tags:
- Users
+ /users/{id}:
+ get:
+ consumes:
+ - application/json
+ description: Get User by id
+ parameters:
+ - description: id
+ in: path
+ name: id
+ required: true
+ type: string
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/model.User'
+ "400":
+ description: ""
+ "404":
+ description: ""
+ "500":
+ description: ""
+ summary: Get User
+ tags:
+ - User
swagger: "2.0"
diff --git a/docs/en/api/api.md b/docs/en/api/api.md
index 85830fb7af0..356e4fcc574 100644
--- a/docs/en/api/api.md
+++ b/docs/en/api/api.md
@@ -547,6 +547,223 @@ Update by json config
* CDN
+
+### Create Config
+```
+POST /api/v1/configs
+```
+
+
+#### Description
+create by json config
+
+
+#### Parameters
+
+|Type|Name|Description|Schema|
+|---|---|---|---|
+|**Body**|**Config**
*required*|Config|[types.CreateConfigRequest](#types-createconfigrequest)|
+
+
+#### Responses
+
+|HTTP Code|Description|Schema|
+|---|---|---|
+|**200**|OK|[model.Config](#model-config)|
+|**400**||No Content|
+|**404**||No Content|
+|**500**||No Content|
+
+
+#### Consumes
+
+* `application/json`
+
+
+#### Produces
+
+* `application/json`
+
+
+#### Tags
+
+* Config
+
+
+
+### Get Configs
+```
+GET /api/v1/configs
+```
+
+
+#### Description
+Get Configs
+
+
+#### Parameters
+
+|Type|Name|Description|Schema|Default|
+|---|---|---|---|---|
+|**Query**|**page**
*required*|current page|integer|`0`|
+|**Query**|**per_page**
*required*|return max item count, default 10, max 50|integer|`10`|
+
+
+#### Responses
+
+|HTTP Code|Description|Schema|
+|---|---|---|
+|**200**|OK|< [model.Config](#model-config) > array|
+|**400**||No Content|
+|**404**||No Content|
+|**500**||No Content|
+
+
+#### Consumes
+
+* `application/json`
+
+
+#### Produces
+
+* `application/json`
+
+
+#### Tags
+
+* Config
+
+
+
+### Get Config
+```
+GET /api/v1/configs/{id}
+```
+
+
+#### Description
+Get Config by id
+
+
+#### Parameters
+
+|Type|Name|Description|Schema|
+|---|---|---|---|
+|**Path**|**id**
*required*|id|string|
+
+
+#### Responses
+
+|HTTP Code|Description|Schema|
+|---|---|---|
+|**200**|OK|[model.Config](#model-config)|
+|**400**||No Content|
+|**404**||No Content|
+|**500**||No Content|
+
+
+#### Consumes
+
+* `application/json`
+
+
+#### Produces
+
+* `application/json`
+
+
+#### Tags
+
+* Config
+
+
+
+### Destroy Config
+```
+DELETE /api/v1/configs/{id}
+```
+
+
+#### Description
+Destroy by id
+
+
+#### Parameters
+
+|Type|Name|Description|Schema|
+|---|---|---|---|
+|**Path**|**id**
*required*|id|string|
+
+
+#### Responses
+
+|HTTP Code|Schema|
+|---|---|
+|**200**|No Content|
+|**400**|No Content|
+|**404**|No Content|
+|**500**|No Content|
+
+
+#### Consumes
+
+* `application/json`
+
+
+#### Produces
+
+* `application/json`
+
+
+#### Tags
+
+* Config
+
+
+
+### Update Config
+```
+PATCH /api/v1/configs/{id}
+```
+
+
+#### Description
+Update by json config
+
+
+#### Parameters
+
+|Type|Name|Description|Schema|
+|---|---|---|---|
+|**Path**|**id**
*required*|id|string|
+|**Body**|**Config**
*required*|Config|[types.UpdateConfigRequest](#types-updateconfigrequest)|
+
+
+#### Responses
+
+|HTTP Code|Description|Schema|
+|---|---|---|
+|**200**|OK|[model.Config](#model-config)|
+|**400**||No Content|
+|**404**||No Content|
+|**500**||No Content|
+
+
+#### Consumes
+
+* `application/json`
+
+
+#### Produces
+
+* `application/json`
+
+
+#### Tags
+
+* Config
+
+
### Get Health
```
@@ -831,7 +1048,7 @@ Get Permissions
-### Create Preheat
+### Create V1 Preheat
```
POST /api/v1/preheats
```
@@ -845,14 +1062,14 @@ create by json config
|Type|Name|Description|Schema|
|---|---|---|---|
-|**Body**|**CDN**
*required*|Preheat|[types.CreatePreheatRequest](#types-createpreheatrequest)|
+|**Body**|**CDN**
*required*|Preheat|[types.CreateV1PreheatRequest](#types-createv1preheatrequest)|
#### Responses
|HTTP Code|Description|Schema|
|---|---|---|
-|**200**|OK|[types.Preheat](#types-preheat)|
+|**200**|OK|[types.CreateV1PreheatResponse](#types-createv1preheatresponse)|
|**400**||No Content|
|**404**||No Content|
|**500**||No Content|
@@ -874,7 +1091,7 @@ create by json config
-### Get Preheat
+### Get V1 Preheat
```
GET /api/v1/preheats/{id}
```
@@ -895,7 +1112,7 @@ Get Preheat by id
|HTTP Code|Description|Schema|
|---|---|---|
-|**200**|OK|[types.Preheat](#types-preheat)|
+|**200**|OK|[types.GetV1PreheatResponse](#types-getv1preheatresponse)|
|**400**||No Content|
|**404**||No Content|
|**500**||No Content|
@@ -2230,42 +2447,70 @@ delete role by uri config
* Users
+
+### Get User
+```
+GET /api/v1/users/{id}
+```
-
-## Definitions
+#### Description
+Get User by id
-
-### model.Assertion
-|Name|Schema|
-|---|---|
-|**key**
*optional*|string|
-|**policy**
*optional*|< < string > array > array|
-|**policyMap**
*optional*|< string, integer > map|
-|**rm**
*optional*|[rbac.RoleManager](#rbac-rolemanager)|
-|**tokens**
*optional*|< string > array|
-|**value**
*optional*|string|
+#### Parameters
+
+|Type|Name|Description|Schema|
+|---|---|---|---|
+|**Path**|**id**
*required*|id|string|
+
+
+#### Responses
+
+|HTTP Code|Description|Schema|
+|---|---|---|
+|**200**|OK|[model.User](#model-user)|
+|**400**||No Content|
+|**404**||No Content|
+|**500**||No Content|
+
+
+#### Consumes
+
+* `application/json`
+
+#### Produces
+
+* `application/json`
+
+
+#### Tags
+
+* User
-
-### model.AssertionMap
-*Type* : < string, [model.Assertion](#model-assertion) > map
+
+
+## Definitions
+
### model.CDN
|Name|Schema|
|---|---|
|**cdnclusterID**
*optional*|integer|
+|**created_at**
*optional*|string|
|**download_port**
*optional*|integer|
|**host_name**
*optional*|string|
+|**id**
*optional*|integer|
|**idc**
*optional*|string|
|**ip**
*optional*|string|
|**location**
*optional*|string|
|**port**
*optional*|integer|
|**status**
*optional*|string|
+|**updated_at**
*optional*|string|
@@ -2275,9 +2520,26 @@ delete role by uri config
|---|---|
|**bio**
*optional*|string|
|**config**
*optional*|[model.JSONMap](#model-jsonmap)|
+|**created_at**
*optional*|string|
+|**id**
*optional*|integer|
|**is_default**
*optional*|boolean|
|**name**
*optional*|string|
-|**securityGroupID**
*optional*|integer|
+|**security_group_id**
*optional*|integer|
+|**updated_at**
*optional*|string|
+
+
+
+### model.Config
+
+|Name|Schema|
+|---|---|
+|**bio**
*optional*|string|
+|**created_at**
*optional*|string|
+|**id**
*optional*|integer|
+|**key**
*optional*|string|
+|**updated_at**
*optional*|string|
+|**user_id**
*optional*|integer|
+|**value**
*optional*|string|
@@ -2293,8 +2555,11 @@ delete role by uri config
|**bio**
*optional*|string|
|**client_id**
*optional*|string|
|**client_secret**
*optional*|string|
+|**created_at**
*optional*|string|
+|**id**
*optional*|integer|
|**name**
*optional*|string|
|**redirect_url**
*optional*|string|
+|**updated_at**
*optional*|string|
@@ -2302,7 +2567,9 @@ delete role by uri config
|Name|Schema|
|---|---|
+|**created_at**
*optional*|string|
|**host_name**
*optional*|string|
+|**id**
*optional*|integer|
|**idc**
*optional*|string|
|**ip**
*optional*|string|
|**location**
*optional*|string|
@@ -2310,6 +2577,7 @@ delete role by uri config
|**port**
*optional*|integer|
|**schedulerClusterID**
*optional*|integer|
|**status**
*optional*|string|
+|**updated_at**
*optional*|string|
|**vips**
*optional*|string|
@@ -2319,12 +2587,16 @@ delete role by uri config
|Name|Schema|
|---|---|
|**bio**
*optional*|string|
+|**cdn_clusters**
*optional*|< [model.CDNCluster](#model-cdncluster) > array|
|**client_config**
*optional*|[model.JSONMap](#model-jsonmap)|
|**config**
*optional*|[model.JSONMap](#model-jsonmap)|
+|**created_at**
*optional*|string|
+|**id**
*optional*|integer|
|**is_default**
*optional*|boolean|
|**name**
*optional*|string|
|**scopes**
*optional*|[model.JSONMap](#model-jsonmap)|
-|**securityGroupID**
*optional*|integer|
+|**security_group_id**
*optional*|integer|
+|**updated_at**
*optional*|string|
@@ -2333,9 +2605,12 @@ delete role by uri config
|Name|Schema|
|---|---|
|**bio**
*optional*|string|
+|**created_at**
*optional*|string|
|**domain**
*optional*|string|
+|**id**
*optional*|integer|
|**name**
*optional*|string|
|**proxy_domain**
*optional*|string|
+|**updated_at**
*optional*|string|
@@ -2345,12 +2620,14 @@ delete role by uri config
|---|---|
|**avatar**
*optional*|string|
|**bio**
*optional*|string|
+|**created_at**
*optional*|string|
|**email**
*optional*|string|
+|**id**
*optional*|integer|
|**location**
*optional*|string|
|**name**
*optional*|string|
|**phone**
*optional*|string|
-|**private_token**
*optional*|string|
|**state**
*optional*|string|
+|**updated_at**
*optional*|string|
@@ -2362,11 +2639,6 @@ delete role by uri config
|**object**
*required*|string|
-
-### rbac.RoleManager
-*Type* : object
-
-
### types.AddPermissionForRoleRequest
@@ -2376,13 +2648,22 @@ delete role by uri config
|**object**
*required*|string|
+
+### types.CDNClusterConfig
+
+|Name|Schema|
+|---|---|
+|**load_limit**
*optional*|integer|
+|**net_topology**
*optional*|string|
+
+
### types.CreateCDNClusterRequest
|Name|Schema|
|---|---|
|**bio**
*optional*|string|
-|**config**
*required*|object|
+|**config**
*required*|[types.CDNClusterConfig](#types-cdnclusterconfig)|
|**name**
*required*|string|
|**security_group_domain**
*optional*|string|
@@ -2401,6 +2682,17 @@ delete role by uri config
|**port**
*required*|integer|
+
+### types.CreateConfigRequest
+
+|Name|Schema|
+|---|---|
+|**bio**
*optional*|string|
+|**key**
*required*|string|
+|**user_id**
*required*|integer|
+|**value**
*required*|string|
+
+
### types.CreateOauthRequest
@@ -2441,11 +2733,11 @@ delete role by uri config
|---|---|
|**bio**
*optional*|string|
|**cdn_cluster_id**
*optional*|integer|
-|**client_config**
*required*|object|
-|**config**
*required*|object|
+|**client_config**
*required*|[types.SchedulerClusterClientConfig](#types-schedulerclusterclientconfig)|
+|**config**
*required*|[types.SchedulerClusterConfig](#types-schedulerclusterconfig)|
|**is_default**
*optional*|boolean|
|**name**
*required*|string|
-|**scopes**
*optional*|object|
+|**scopes**
*optional*|[types.SchedulerClusterScopes](#types-schedulerclusterscopes)|
|**security_group_domain**
*optional*|string|
@@ -2475,6 +2767,25 @@ delete role by uri config
|**proxy_domain**
*optional*|string|
+
+### types.CreateV1PreheatRequest
+
+|Name|Schema|
+|---|---|
+|**filter**
*optional*|string|
+|**headers**
*optional*|< string, string > map|
+|**type**
*required*|string|
+|**url**
*required*|string|
+
+
+
+### types.CreateV1PreheatResponse
+
+|Name|Schema|
+|---|---|
+|**ID**
*optional*|string|
+
+
### types.DeletePermissionForRoleRequest
@@ -2484,6 +2795,17 @@ delete role by uri config
|**object**
*required*|string|
+
+### types.GetV1PreheatResponse
+
+|Name|Schema|
+|---|---|
+|**ID**
*optional*|string|
+|**finishTime**
*optional*|string|
+|**startTime**
*optional*|string|
+|**status**
*optional*|string|
+
+
### types.Preheat
@@ -2503,6 +2825,24 @@ delete role by uri config
|**old_password**
*required*|string|
+
+### types.SchedulerClusterClientConfig
+
+|Name|Schema|
+|---|---|
+|**load_limit**
*optional*|integer|
+
+
+
+### types.SchedulerClusterConfig
+*Type* : object
+
+
+
+### types.SchedulerClusterScopes
+*Type* : object
+
+
### types.SignUpRequest
@@ -2523,7 +2863,7 @@ delete role by uri config
|Name|Schema|
|---|---|
|**bio**
*optional*|string|
-|**config**
*optional*|object|
+|**config**
*optional*|[types.CDNClusterConfig](#types-cdnclusterconfig)|
|**name**
*optional*|string|
|**security_group_domain**
*optional*|string|
@@ -2541,6 +2881,17 @@ delete role by uri config
|**port**
*optional*|integer|
+
+### types.UpdateConfigRequest
+
+|Name|Schema|
+|---|---|
+|**bio**
*optional*|string|
+|**key**
*optional*|string|
+|**user_id**
*optional*|integer|
+|**value**
*optional*|string|
+
+
### types.UpdateOauthRequest
@@ -2560,11 +2911,11 @@ delete role by uri config
|---|---|
|**bio**
*optional*|string|
|**cdn_cluster_id**
*optional*|integer|
-|**client_config**
*optional*|object|
-|**config**
*optional*|object|
+|**client_config**
*optional*|[types.SchedulerClusterClientConfig](#types-schedulerclusterclientconfig)|
+|**config**
*optional*|[types.SchedulerClusterConfig](#types-schedulerclusterconfig)|
|**is_default**
*optional*|boolean|
|**name**
*optional*|string|
-|**scopes**
*optional*|object|
+|**scopes**
*optional*|[types.SchedulerClusterScopes](#types-schedulerclusterscopes)|
|**security_group_domain**
*optional*|string|
diff --git a/docs/zh-CN/api/api.md b/docs/zh-CN/api/api.md
index 325e937fae2..da6d4faf008 100644
--- a/docs/zh-CN/api/api.md
+++ b/docs/zh-CN/api/api.md
@@ -547,6 +547,223 @@ Update by json config
* CDN
+
+### Create Config
+```
+POST /api/v1/configs
+```
+
+
+#### 说明
+create by json config
+
+
+#### 参数
+
+|类型|名称|说明|类型|
+|---|---|---|---|
+|**Body**|**Config**
*必填*|Config|[types.CreateConfigRequest](#types-createconfigrequest)|
+
+
+#### 响应
+
+|HTTP代码|说明|类型|
+|---|---|---|
+|**200**|OK|[model.Config](#model-config)|
+|**400**||无内容|
+|**404**||无内容|
+|**500**||无内容|
+
+
+#### 消耗
+
+* `application/json`
+
+
+#### 生成
+
+* `application/json`
+
+
+#### 标签
+
+* Config
+
+
+
+### Get Configs
+```
+GET /api/v1/configs
+```
+
+
+#### 说明
+Get Configs
+
+
+#### 参数
+
+|类型|名称|说明|类型|默认值|
+|---|---|---|---|---|
+|**Query**|**page**
*必填*|current page|integer|`0`|
+|**Query**|**per_page**
*必填*|return max item count, default 10, max 50|integer|`10`|
+
+
+#### 响应
+
+|HTTP代码|说明|类型|
+|---|---|---|
+|**200**|OK|< [model.Config](#model-config) > array|
+|**400**||无内容|
+|**404**||无内容|
+|**500**||无内容|
+
+
+#### 消耗
+
+* `application/json`
+
+
+#### 生成
+
+* `application/json`
+
+
+#### 标签
+
+* Config
+
+
+
+### Get Config
+```
+GET /api/v1/configs/{id}
+```
+
+
+#### 说明
+Get Config by id
+
+
+#### 参数
+
+|类型|名称|说明|类型|
+|---|---|---|---|
+|**Path**|**id**
*必填*|id|string|
+
+
+#### 响应
+
+|HTTP代码|说明|类型|
+|---|---|---|
+|**200**|OK|[model.Config](#model-config)|
+|**400**||无内容|
+|**404**||无内容|
+|**500**||无内容|
+
+
+#### 消耗
+
+* `application/json`
+
+
+#### 生成
+
+* `application/json`
+
+
+#### 标签
+
+* Config
+
+
+
+### Destroy Config
+```
+DELETE /api/v1/configs/{id}
+```
+
+
+#### 说明
+Destroy by id
+
+
+#### 参数
+
+|类型|名称|说明|类型|
+|---|---|---|---|
+|**Path**|**id**
*必填*|id|string|
+
+
+#### 响应
+
+|HTTP代码|类型|
+|---|---|
+|**200**|无内容|
+|**400**|无内容|
+|**404**|无内容|
+|**500**|无内容|
+
+
+#### 消耗
+
+* `application/json`
+
+
+#### 生成
+
+* `application/json`
+
+
+#### 标签
+
+* Config
+
+
+
+### Update Config
+```
+PATCH /api/v1/configs/{id}
+```
+
+
+#### 说明
+Update by json config
+
+
+#### 参数
+
+|类型|名称|说明|类型|
+|---|---|---|---|
+|**Path**|**id**
*必填*|id|string|
+|**Body**|**Config**
*必填*|Config|[types.UpdateConfigRequest](#types-updateconfigrequest)|
+
+
+#### 响应
+
+|HTTP代码|说明|类型|
+|---|---|---|
+|**200**|OK|[model.Config](#model-config)|
+|**400**||无内容|
+|**404**||无内容|
+|**500**||无内容|
+
+
+#### 消耗
+
+* `application/json`
+
+
+#### 生成
+
+* `application/json`
+
+
+#### 标签
+
+* Config
+
+
### Get Health
```
@@ -831,7 +1048,7 @@ Get Permissions
-### Create Preheat
+### Create V1 Preheat
```
POST /api/v1/preheats
```
@@ -845,14 +1062,14 @@ create by json config
|类型|名称|说明|类型|
|---|---|---|---|
-|**Body**|**CDN**
*必填*|Preheat|[types.CreatePreheatRequest](#types-createpreheatrequest)|
+|**Body**|**CDN**
*必填*|Preheat|[types.CreateV1PreheatRequest](#types-createv1preheatrequest)|
#### 响应
|HTTP代码|说明|类型|
|---|---|---|
-|**200**|OK|[types.Preheat](#types-preheat)|
+|**200**|OK|[types.CreateV1PreheatResponse](#types-createv1preheatresponse)|
|**400**||无内容|
|**404**||无内容|
|**500**||无内容|
@@ -874,7 +1091,7 @@ create by json config
-### Get Preheat
+### Get V1 Preheat
```
GET /api/v1/preheats/{id}
```
@@ -895,7 +1112,7 @@ Get Preheat by id
|HTTP代码|说明|类型|
|---|---|---|
-|**200**|OK|[types.Preheat](#types-preheat)|
+|**200**|OK|[types.GetV1PreheatResponse](#types-getv1preheatresponse)|
|**400**||无内容|
|**404**||无内容|
|**500**||无内容|
@@ -2230,42 +2447,70 @@ delete role by uri config
* Users
+
+### Get User
+```
+GET /api/v1/users/{id}
+```
-
-## 定义
+#### 说明
+Get User by id
-
-### model.Assertion
-|名称|类型|
-|---|---|
-|**key**
*可选*|string|
-|**policy**
*可选*|< < string > array > array|
-|**policyMap**
*可选*|< string, integer > map|
-|**rm**
*可选*|[rbac.RoleManager](#rbac-rolemanager)|
-|**tokens**
*可选*|< string > array|
-|**value**
*可选*|string|
+#### 参数
+
+|类型|名称|说明|类型|
+|---|---|---|---|
+|**Path**|**id**
*必填*|id|string|
+
+
+#### 响应
+
+|HTTP代码|说明|类型|
+|---|---|---|
+|**200**|OK|[model.User](#model-user)|
+|**400**||无内容|
+|**404**||无内容|
+|**500**||无内容|
+
+
+#### 消耗
+
+* `application/json`
+
+#### 生成
+
+* `application/json`
+
+
+#### 标签
+
+* User
-
-### model.AssertionMap
-*类型* : < string, [model.Assertion](#model-assertion) > map
+
+
+## 定义
+
### model.CDN
|名称|类型|
|---|---|
|**cdnclusterID**
*可选*|integer|
+|**created_at**
*可选*|string|
|**download_port**
*可选*|integer|
|**host_name**
*可选*|string|
+|**id**
*可选*|integer|
|**idc**
*可选*|string|
|**ip**
*可选*|string|
|**location**
*可选*|string|
|**port**
*可选*|integer|
|**status**
*可选*|string|
+|**updated_at**
*可选*|string|
@@ -2275,9 +2520,26 @@ delete role by uri config
|---|---|
|**bio**
*可选*|string|
|**config**
*可选*|[model.JSONMap](#model-jsonmap)|
+|**created_at**
*可选*|string|
+|**id**
*可选*|integer|
|**is_default**
*可选*|boolean|
|**name**
*可选*|string|
-|**securityGroupID**
*可选*|integer|
+|**security_group_id**
*可选*|integer|
+|**updated_at**
*可选*|string|
+
+
+
+### model.Config
+
+|名称|类型|
+|---|---|
+|**bio**
*可选*|string|
+|**created_at**
*可选*|string|
+|**id**
*可选*|integer|
+|**key**
*可选*|string|
+|**updated_at**
*可选*|string|
+|**user_id**
*可选*|integer|
+|**value**
*可选*|string|
@@ -2293,8 +2555,11 @@ delete role by uri config
|**bio**
*可选*|string|
|**client_id**
*可选*|string|
|**client_secret**
*可选*|string|
+|**created_at**
*可选*|string|
+|**id**
*可选*|integer|
|**name**
*可选*|string|
|**redirect_url**
*可选*|string|
+|**updated_at**
*可选*|string|
@@ -2302,7 +2567,9 @@ delete role by uri config
|名称|类型|
|---|---|
+|**created_at**
*可选*|string|
|**host_name**
*可选*|string|
+|**id**
*可选*|integer|
|**idc**
*可选*|string|
|**ip**
*可选*|string|
|**location**
*可选*|string|
@@ -2310,6 +2577,7 @@ delete role by uri config
|**port**
*可选*|integer|
|**schedulerClusterID**
*可选*|integer|
|**status**
*可选*|string|
+|**updated_at**
*可选*|string|
|**vips**
*可选*|string|
@@ -2319,12 +2587,16 @@ delete role by uri config
|名称|类型|
|---|---|
|**bio**
*可选*|string|
+|**cdn_clusters**
*可选*|< [model.CDNCluster](#model-cdncluster) > array|
|**client_config**
*可选*|[model.JSONMap](#model-jsonmap)|
|**config**
*可选*|[model.JSONMap](#model-jsonmap)|
+|**created_at**
*可选*|string|
+|**id**
*可选*|integer|
|**is_default**
*可选*|boolean|
|**name**
*可选*|string|
|**scopes**
*可选*|[model.JSONMap](#model-jsonmap)|
-|**securityGroupID**
*可选*|integer|
+|**security_group_id**
*可选*|integer|
+|**updated_at**
*可选*|string|
@@ -2333,9 +2605,12 @@ delete role by uri config
|名称|类型|
|---|---|
|**bio**
*可选*|string|
+|**created_at**
*可选*|string|
|**domain**
*可选*|string|
+|**id**
*可选*|integer|
|**name**
*可选*|string|
|**proxy_domain**
*可选*|string|
+|**updated_at**
*可选*|string|
@@ -2345,12 +2620,14 @@ delete role by uri config
|---|---|
|**avatar**
*可选*|string|
|**bio**
*可选*|string|
+|**created_at**
*可选*|string|
|**email**
*可选*|string|
+|**id**
*可选*|integer|
|**location**
*可选*|string|
|**name**
*可选*|string|
|**phone**
*可选*|string|
-|**private_token**
*可选*|string|
|**state**
*可选*|string|
+|**updated_at**
*可选*|string|
@@ -2362,11 +2639,6 @@ delete role by uri config
|**object**
*必填*|string|
-
-### rbac.RoleManager
-*类型* : object
-
-
### types.AddPermissionForRoleRequest
@@ -2376,13 +2648,22 @@ delete role by uri config
|**object**
*必填*|string|
+
+### types.CDNClusterConfig
+
+|名称|类型|
+|---|---|
+|**load_limit**
*可选*|integer|
+|**net_topology**
*可选*|string|
+
+
### types.CreateCDNClusterRequest
|名称|类型|
|---|---|
|**bio**
*可选*|string|
-|**config**
*必填*|object|
+|**config**
*必填*|[types.CDNClusterConfig](#types-cdnclusterconfig)|
|**name**
*必填*|string|
|**security_group_domain**
*可选*|string|
@@ -2401,6 +2682,17 @@ delete role by uri config
|**port**
*必填*|integer|
+
+### types.CreateConfigRequest
+
+|名称|类型|
+|---|---|
+|**bio**
*可选*|string|
+|**key**
*必填*|string|
+|**user_id**
*必填*|integer|
+|**value**
*必填*|string|
+
+
### types.CreateOauthRequest
@@ -2441,11 +2733,11 @@ delete role by uri config
|---|---|
|**bio**
*可选*|string|
|**cdn_cluster_id**
*可选*|integer|
-|**client_config**
*必填*|object|
-|**config**
*必填*|object|
+|**client_config**
*必填*|[types.SchedulerClusterClientConfig](#types-schedulerclusterclientconfig)|
+|**config**
*必填*|[types.SchedulerClusterConfig](#types-schedulerclusterconfig)|
|**is_default**
*可选*|boolean|
|**name**
*必填*|string|
-|**scopes**
*可选*|object|
+|**scopes**
*可选*|[types.SchedulerClusterScopes](#types-schedulerclusterscopes)|
|**security_group_domain**
*可选*|string|
@@ -2475,6 +2767,25 @@ delete role by uri config
|**proxy_domain**
*可选*|string|
+
+### types.CreateV1PreheatRequest
+
+|名称|类型|
+|---|---|
+|**filter**
*可选*|string|
+|**headers**
*可选*|< string, string > map|
+|**type**
*必填*|string|
+|**url**
*必填*|string|
+
+
+
+### types.CreateV1PreheatResponse
+
+|名称|类型|
+|---|---|
+|**ID**
*可选*|string|
+
+
### types.DeletePermissionForRoleRequest
@@ -2484,6 +2795,17 @@ delete role by uri config
|**object**
*必填*|string|
+
+### types.GetV1PreheatResponse
+
+|名称|类型|
+|---|---|
+|**ID**
*可选*|string|
+|**finishTime**
*可选*|string|
+|**startTime**
*可选*|string|
+|**status**
*可选*|string|
+
+
### types.Preheat
@@ -2503,6 +2825,24 @@ delete role by uri config
|**old_password**
*必填*|string|
+
+### types.SchedulerClusterClientConfig
+
+|名称|类型|
+|---|---|
+|**load_limit**
*可选*|integer|
+
+
+
+### types.SchedulerClusterConfig
+*类型* : object
+
+
+
+### types.SchedulerClusterScopes
+*类型* : object
+
+
### types.SignUpRequest
@@ -2523,7 +2863,7 @@ delete role by uri config
|名称|类型|
|---|---|
|**bio**
*可选*|string|
-|**config**
*可选*|object|
+|**config**
*可选*|[types.CDNClusterConfig](#types-cdnclusterconfig)|
|**name**
*可选*|string|
|**security_group_domain**
*可选*|string|
@@ -2541,6 +2881,17 @@ delete role by uri config
|**port**
*可选*|integer|
+
+### types.UpdateConfigRequest
+
+|名称|类型|
+|---|---|
+|**bio**
*可选*|string|
+|**key**
*可选*|string|
+|**user_id**
*可选*|integer|
+|**value**
*可选*|string|
+
+
### types.UpdateOauthRequest
@@ -2560,11 +2911,11 @@ delete role by uri config
|---|---|
|**bio**
*可选*|string|
|**cdn_cluster_id**
*可选*|integer|
-|**client_config**
*可选*|object|
-|**config**
*可选*|object|
+|**client_config**
*可选*|[types.SchedulerClusterClientConfig](#types-schedulerclusterclientconfig)|
+|**config**
*可选*|[types.SchedulerClusterConfig](#types-schedulerclusterconfig)|
|**is_default**
*可选*|boolean|
|**name**
*可选*|string|
-|**scopes**
*可选*|object|
+|**scopes**
*可选*|[types.SchedulerClusterScopes](#types-schedulerclusterscopes)|
|**security_group_domain**
*可选*|string|
diff --git a/manager/database/database.go b/manager/database/database.go
index 7daa431cc02..4d1ee37fc90 100644
--- a/manager/database/database.go
+++ b/manager/database/database.go
@@ -114,6 +114,7 @@ func migrate(db *gorm.DB) error {
&model.SecurityGroup{},
&model.User{},
&model.Oauth{},
+ &model.Config{},
)
}
diff --git a/manager/handlers/config.go b/manager/handlers/config.go
new file mode 100644
index 00000000000..8a61bad0fa4
--- /dev/null
+++ b/manager/handlers/config.go
@@ -0,0 +1,174 @@
+/*
+ * Copyright 2020 The Dragonfly Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package handlers
+
+import (
+ "net/http"
+
+ "d7y.io/dragonfly/v2/manager/types"
+ "github.com/gin-gonic/gin"
+)
+
+// @Summary Create Config
+// @Description create by json config
+// @Tags Config
+// @Accept json
+// @Produce json
+// @Param Config body types.CreateConfigRequest true "Config"
+// @Success 200 {object} model.Config
+// @Failure 400
+// @Failure 404
+// @Failure 500
+// @Router /configs [post]
+func (h *Handlers) CreateConfig(ctx *gin.Context) {
+ var json types.CreateConfigRequest
+ if err := ctx.ShouldBindJSON(&json); err != nil {
+ ctx.JSON(http.StatusUnprocessableEntity, gin.H{"errors": err.Error()})
+ return
+ }
+
+ config, err := h.service.CreateConfig(ctx.Request.Context(), json)
+ if err != nil {
+ ctx.Error(err)
+ return
+ }
+
+ ctx.JSON(http.StatusOK, config)
+}
+
+// @Summary Destroy Config
+// @Description Destroy by id
+// @Tags Config
+// @Accept json
+// @Produce json
+// @Param id path string true "id"
+// @Success 200
+// @Failure 400
+// @Failure 404
+// @Failure 500
+// @Router /configs/{id} [delete]
+func (h *Handlers) DestroyConfig(ctx *gin.Context) {
+ var params types.ConfigParams
+ if err := ctx.ShouldBindUri(¶ms); err != nil {
+ ctx.JSON(http.StatusUnprocessableEntity, gin.H{"errors": err.Error()})
+ return
+ }
+
+ if err := h.service.DestroyConfig(ctx.Request.Context(), params.ID); err != nil {
+ ctx.Error(err)
+ return
+ }
+
+ ctx.Status(http.StatusOK)
+}
+
+// @Summary Update Config
+// @Description Update by json config
+// @Tags Config
+// @Accept json
+// @Produce json
+// @Param id path string true "id"
+// @Param Config body types.UpdateConfigRequest true "Config"
+// @Success 200 {object} model.Config
+// @Failure 400
+// @Failure 404
+// @Failure 500
+// @Router /configs/{id} [patch]
+func (h *Handlers) UpdateConfig(ctx *gin.Context) {
+ var params types.ConfigParams
+ if err := ctx.ShouldBindUri(¶ms); err != nil {
+ ctx.Error(err)
+ return
+ }
+
+ var json types.UpdateConfigRequest
+ if err := ctx.ShouldBindJSON(&json); err != nil {
+ ctx.Error(err)
+ return
+ }
+
+ config, err := h.service.UpdateConfig(ctx.Request.Context(), params.ID, json)
+ if err != nil {
+ ctx.Error(err)
+ return
+ }
+
+ ctx.JSON(http.StatusOK, config)
+}
+
+// @Summary Get Config
+// @Description Get Config by id
+// @Tags Config
+// @Accept json
+// @Produce json
+// @Param id path string true "id"
+// @Success 200 {object} model.Config
+// @Failure 400
+// @Failure 404
+// @Failure 500
+// @Router /configs/{id} [get]
+func (h *Handlers) GetConfig(ctx *gin.Context) {
+ var params types.ConfigParams
+ if err := ctx.ShouldBindUri(¶ms); err != nil {
+ ctx.JSON(http.StatusUnprocessableEntity, gin.H{"errors": err.Error()})
+ return
+ }
+
+ config, err := h.service.GetConfig(ctx.Request.Context(), params.ID)
+ if err != nil {
+ ctx.Error(err)
+ return
+ }
+
+ ctx.JSON(http.StatusOK, config)
+}
+
+// @Summary Get Configs
+// @Description Get Configs
+// @Tags Config
+// @Accept json
+// @Produce json
+// @Param page query int true "current page" default(0)
+// @Param per_page query int true "return max item count, default 10, max 50" default(10) minimum(2) maximum(50)
+// @Success 200 {object} []model.Config
+// @Failure 400
+// @Failure 404
+// @Failure 500
+// @Router /configs [get]
+func (h *Handlers) GetConfigs(ctx *gin.Context) {
+ var query types.GetConfigsQuery
+ if err := ctx.ShouldBindQuery(&query); err != nil {
+ ctx.JSON(http.StatusUnprocessableEntity, gin.H{"errors": err.Error()})
+ return
+ }
+
+ h.setPaginationDefault(&query.Page, &query.PerPage)
+ configs, err := h.service.GetConfigs(ctx.Request.Context(), query)
+ if err != nil {
+ ctx.Error(err)
+ return
+ }
+
+ totalCount, err := h.service.ConfigTotalCount(ctx.Request.Context(), query)
+ if err != nil {
+ ctx.Error(err)
+ return
+ }
+
+ h.setPaginationLinkHeader(ctx, query.Page, query.PerPage, int(totalCount))
+ ctx.JSON(http.StatusOK, configs)
+}
diff --git a/manager/model/config.go b/manager/model/config.go
new file mode 100644
index 00000000000..f491c1f4d44
--- /dev/null
+++ b/manager/model/config.go
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2020 The Dragonfly Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package model
+
+type Config struct {
+ Model
+ Key string `gorm:"column:key;type:varchar(256);index:uk_config_key,unique;not null;comment:config key" json:"key"`
+ Value string `gorm:"column:value;type:varchar(1024);not null;comment:config value" json:"value"`
+ BIO string `gorm:"column:bio;type:varchar(1024);comment:biography" json:"bio"`
+ UserID uint `gorm:"comment:user id" json:"user_id"`
+ User User `json:"-"`
+}
diff --git a/manager/model/user.go b/manager/model/user.go
index a2d742ac364..aa4a80e9cef 100644
--- a/manager/model/user.go
+++ b/manager/model/user.go
@@ -23,13 +23,14 @@ const (
type User struct {
Model
- Email string `gorm:"column:email;type:varchar(256);index:uk_user_email,unique;not null;comment:email address" json:"email"`
- Name string `gorm:"column:name;type:varchar(256);index:uk_user_name,unique;not null;comment:name" json:"name"`
- EncryptedPassword string `gorm:"column:encrypted_password;size:1024;comment:encrypted password" json:"-"`
- Avatar string `gorm:"column:avatar;type:varchar(256);comment:avatar address" json:"avatar"`
- Phone string `gorm:"column:phone;type:varchar(256);comment:phone number" json:"phone"`
- PrivateToken string `gorm:"column:private_token;type:varchar(256);comment:private token" json:"-"`
- State string `gorm:"column:state;type:varchar(256);default:'enable';comment:state" json:"state"`
- Location string `gorm:"column:location;type:varchar(256);comment:location" json:"location"`
- BIO string `gorm:"column:bio;type:varchar(256);comment:biography" json:"bio"`
+ Email string `gorm:"column:email;type:varchar(256);index:uk_user_email,unique;not null;comment:email address" json:"email"`
+ Name string `gorm:"column:name;type:varchar(256);index:uk_user_name,unique;not null;comment:name" json:"name"`
+ EncryptedPassword string `gorm:"column:encrypted_password;size:1024;comment:encrypted password" json:"-"`
+ Avatar string `gorm:"column:avatar;type:varchar(256);comment:avatar address" json:"avatar"`
+ Phone string `gorm:"column:phone;type:varchar(256);comment:phone number" json:"phone"`
+ PrivateToken string `gorm:"column:private_token;type:varchar(256);comment:private token" json:"-"`
+ State string `gorm:"column:state;type:varchar(256);default:'enable';comment:state" json:"state"`
+ Location string `gorm:"column:location;type:varchar(256);comment:location" json:"location"`
+ BIO string `gorm:"column:bio;type:varchar(256);comment:biography" json:"bio"`
+ Configs []Config `json:"-"`
}
diff --git a/manager/router/router.go b/manager/router/router.go
index 7658346ff49..87dd8870765 100644
--- a/manager/router/router.go
+++ b/manager/router/router.go
@@ -174,6 +174,14 @@ func Init(cfg *config.Config, service service.REST, enforcer *casbin.Enforcer) (
sg.PUT(":id/scheduler-clusters/:scheduler_cluster_id", h.AddSchedulerClusterToSecurityGroup)
sg.PUT(":id/cdn-clusters/:cdn_cluster_id", h.AddCDNClusterToSecurityGroup)
+ // Config
+ config := apiv1.Group("/configs")
+ config.POST("", h.CreateConfig)
+ config.DELETE(":id", h.DestroyConfig)
+ config.PATCH(":id", h.UpdateConfig)
+ config.GET(":id", h.GetConfig)
+ config.GET("", h.GetConfigs)
+
// Preheat
ph := apiv1.Group("/preheats")
ph.POST("", h.CreatePreheat)
diff --git a/manager/service/config.go b/manager/service/config.go
new file mode 100644
index 00000000000..62d63075a96
--- /dev/null
+++ b/manager/service/config.go
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2020 The Dragonfly Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package service
+
+import (
+ "context"
+
+ "d7y.io/dragonfly/v2/manager/model"
+ "d7y.io/dragonfly/v2/manager/types"
+)
+
+func (s *rest) CreateConfig(ctx context.Context, json types.CreateConfigRequest) (*model.Config, error) {
+ config := model.Config{
+ Key: json.Key,
+ Value: json.Value,
+ BIO: json.BIO,
+ UserID: json.UserID,
+ }
+
+ if err := s.db.WithContext(ctx).Create(&config).Error; err != nil {
+ return nil, err
+ }
+
+ return &config, nil
+}
+
+func (s *rest) DestroyConfig(ctx context.Context, id uint) error {
+ config := model.Config{}
+ if err := s.db.WithContext(ctx).First(&config, id).Error; err != nil {
+ return err
+ }
+
+ if err := s.db.WithContext(ctx).Unscoped().Delete(&model.Config{}, id).Error; err != nil {
+ return err
+ }
+
+ return nil
+}
+
+func (s *rest) UpdateConfig(ctx context.Context, id uint, json types.UpdateConfigRequest) (*model.Config, error) {
+ config := model.Config{}
+ if err := s.db.WithContext(ctx).First(&config, id).Updates(model.Config{
+ Key: json.Key,
+ Value: json.Value,
+ BIO: json.BIO,
+ UserID: json.UserID,
+ }).Error; err != nil {
+ return nil, err
+ }
+
+ return &config, nil
+}
+
+func (s *rest) GetConfig(ctx context.Context, id uint) (*model.Config, error) {
+ config := model.Config{}
+ if err := s.db.WithContext(ctx).First(&config, id).Error; err != nil {
+ return nil, err
+ }
+
+ return &config, nil
+}
+
+func (s *rest) GetConfigs(ctx context.Context, q types.GetConfigsQuery) (*[]model.Config, error) {
+ configs := []model.Config{}
+ if err := s.db.WithContext(ctx).Scopes(model.Paginate(q.Page, q.PerPage)).Where(&model.Config{
+ Key: q.Key,
+ Value: q.Value,
+ UserID: q.UserID,
+ }).Find(&configs).Error; err != nil {
+ return nil, err
+ }
+
+ return &configs, nil
+}
+
+func (s *rest) ConfigTotalCount(ctx context.Context, q types.GetConfigsQuery) (int64, error) {
+ var count int64
+ if err := s.db.WithContext(ctx).Model(&model.Config{}).Where(&model.Config{
+ Key: q.Key,
+ Value: q.Value,
+ UserID: q.UserID,
+ }).Count(&count).Error; err != nil {
+ return 0, err
+ }
+
+ return count, nil
+}
diff --git a/manager/service/service.go b/manager/service/service.go
index 0fc50dfb31d..935163fb796 100644
--- a/manager/service/service.go
+++ b/manager/service/service.go
@@ -103,6 +103,13 @@ type REST interface {
AddSchedulerClusterToSecurityGroup(context.Context, uint, uint) error
AddCDNClusterToSecurityGroup(context.Context, uint, uint) error
+ CreateConfig(context.Context, types.CreateConfigRequest) (*model.Config, error)
+ DestroyConfig(context.Context, uint) error
+ UpdateConfig(context.Context, uint, types.UpdateConfigRequest) (*model.Config, error)
+ GetConfig(context.Context, uint) (*model.Config, error)
+ GetConfigs(context.Context, types.GetConfigsQuery) (*[]model.Config, error)
+ ConfigTotalCount(context.Context, types.GetConfigsQuery) (int64, error)
+
CreatePreheat(context.Context, types.CreatePreheatRequest) (*types.Preheat, error)
GetPreheat(context.Context, string) (*types.Preheat, error)
CreateV1Preheat(context.Context, types.CreateV1PreheatRequest) (*types.CreateV1PreheatResponse, error)
diff --git a/manager/types/config.go b/manager/types/config.go
new file mode 100644
index 00000000000..79e8f9dc638
--- /dev/null
+++ b/manager/types/config.go
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2020 The Dragonfly Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package types
+
+type ConfigParams struct {
+ ID uint `uri:"id" binding:"required"`
+}
+
+type CreateConfigRequest struct {
+ Key string `json:"key" binding:"required"`
+ Value string `json:"value" binding:"required"`
+ BIO string `json:"bio" binding:"omitempty"`
+ UserID uint `json:"user_id" binding:"required"`
+}
+
+type UpdateConfigRequest struct {
+ Key string `json:"key" binding:"omitempty"`
+ Value string `json:"value" binding:"omitempty"`
+ BIO string `json:"bio" binding:"omitempty"`
+ UserID uint `json:"user_id" binding:"omitempty"`
+}
+
+type GetConfigsQuery struct {
+ Key string `form:"key" binding:"omitempty"`
+ Value string `form:"value" binding:"omitempty"`
+ UserID uint `form:"user_id" binding:"omitempty"`
+ Page int `form:"page" binding:"omitempty,gte=1"`
+ PerPage int `form:"per_page" binding:"omitempty,gte=1,lte=50"`
+}