Neo oc-workspace
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"encoding/json"
|
||||
|
||||
oclib "cloud.o-forge.io/core/oc-lib"
|
||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||
"cloud.o-forge.io/core/oc-lib/tools"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
@@ -14,6 +13,16 @@ type WorkspaceController struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
var paths = map[tools.DataType]map[tools.METHOD]string{
|
||||
tools.PEER: { // paths to call to status of peers
|
||||
tools.POST: "/oc/peer",
|
||||
},
|
||||
tools.WORKSPACE: { // paths to call to delete/update workspace on peer destination
|
||||
tools.PUT: "/oc/workspace/:id?is_remote=true",
|
||||
tools.DELETE: "/oc/workspace/:id?is_remote=true",
|
||||
},
|
||||
}
|
||||
|
||||
// @Title Search
|
||||
// @Description search workspace
|
||||
// @Param search path string true "the word search you want to get"
|
||||
@@ -34,16 +43,8 @@ func (o *WorkspaceController) Search() {
|
||||
// @router /:id [put]
|
||||
func (o *WorkspaceController) Put() {
|
||||
// store and return Id or post with UUID
|
||||
var paths = map[string]map[tools.METHOD]string{
|
||||
utils.PEER.String(): { // paths to call to status of peers
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.PEER)) + "/oc",
|
||||
},
|
||||
utils.WORKSPACE.String(): { // paths to call to delete/update workspace on peer destination
|
||||
tools.PUT: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workspace/:id",
|
||||
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workspace/:id",
|
||||
},
|
||||
}
|
||||
caller := tools.NewHTTPCaller(paths) // generate a http caller to send to peer shared workspace
|
||||
caller.Disabled = oclib.IsQueryParamsEquals(o.Ctx.Input, "is_remote", true)
|
||||
var res map[string]interface{}
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res)
|
||||
@@ -57,16 +58,8 @@ func (o *WorkspaceController) Put() {
|
||||
// @Success 200 {workspace} models.workspace
|
||||
// @router / [post]
|
||||
func (o *WorkspaceController) Post() {
|
||||
var paths = map[string]map[tools.METHOD]string{
|
||||
utils.PEER.String(): { // paths to call to status of peers
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.PEER)) + "/oc",
|
||||
},
|
||||
utils.WORKSPACE.String(): { // paths to call to delete/update workspace on peer destination
|
||||
tools.PUT: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workspace/:id",
|
||||
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workspace/:id",
|
||||
},
|
||||
}
|
||||
caller := tools.NewHTTPCaller(paths) // generate a http caller to send to peer shared workspace
|
||||
caller.Disabled = oclib.IsQueryParamsEquals(o.Ctx.Input, "is_remote", true)
|
||||
var res map[string]interface{}
|
||||
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res)
|
||||
o.Data["json"] = oclib.StoreOne(oclib.LibDataEnum(oclib.WORKSPACE), res, caller)
|
||||
@@ -100,16 +93,8 @@ func (o *WorkspaceController) Get() {
|
||||
// @router /:id [delete]
|
||||
func (o *WorkspaceController) Delete() {
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
var paths = map[string]map[tools.METHOD]string{
|
||||
utils.PEER.String(): { // paths to call to status of peers
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.PEER)) + "/oc",
|
||||
},
|
||||
utils.WORKSPACE.String(): { // paths to call to delete/update workspace on peer destination
|
||||
tools.PUT: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workspace/:id",
|
||||
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workspace/:id",
|
||||
},
|
||||
}
|
||||
caller := tools.NewHTTPCaller(paths) // generate a http caller to send to peer shared workspace
|
||||
caller.Disabled = oclib.IsQueryParamsEquals(o.Ctx.Input, "is_remote", true)
|
||||
o.Data["json"] = oclib.DeleteOne(oclib.LibDataEnum(oclib.WORKSPACE), id, caller)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user