Compare commits
No commits in common. "5a532ae192f7357201e10253fa2de3a30833fdae" and "4b090ed825cfb6102496844ffd952d92a0b321eb" have entirely different histories.
5a532ae192
...
4b090ed825
@ -1,9 +1,8 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"slices"
|
||||
"encoding/json"
|
||||
|
||||
oclib "cloud.o-forge.io/core/oc-lib"
|
||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||
@ -36,7 +35,7 @@ func (o *SharedWorkspaceController) Search() {
|
||||
// @router /:id [put]
|
||||
func (o *SharedWorkspaceController) Put() {
|
||||
// store and return Id or post with UUID
|
||||
var paths = map[string]map[tools.METHOD]string{ // paths used to send to peers
|
||||
var paths = map[string]map[tools.METHOD]string{
|
||||
utils.SHARED_WORKSPACE.String(): {
|
||||
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/:id",
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/",
|
||||
@ -56,8 +55,7 @@ func (o *SharedWorkspaceController) Put() {
|
||||
var res map[string]interface{}
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res)
|
||||
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
|
||||
fmt.Println("UPDATE", res)
|
||||
caller := tools.NewHTTPCaller(paths)
|
||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), res, id, caller)
|
||||
o.ServeJSON()
|
||||
}
|
||||
@ -68,7 +66,7 @@ func (o *SharedWorkspaceController) Put() {
|
||||
// @Success 200 {shared workspace} models.shared_workspace
|
||||
// @router / [post]
|
||||
func (o *SharedWorkspaceController) Post() {
|
||||
var paths = map[string]map[tools.METHOD]string{ // paths used to call other OC services
|
||||
var paths = map[string]map[tools.METHOD]string{
|
||||
utils.SHARED_WORKSPACE.String(): {
|
||||
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/:id",
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/",
|
||||
@ -85,10 +83,9 @@ func (o *SharedWorkspaceController) Post() {
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.PEER)) + "/oc/peer",
|
||||
},
|
||||
}
|
||||
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
|
||||
var res map[string]interface{}
|
||||
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res)
|
||||
|
||||
caller := tools.NewHTTPCaller(paths)
|
||||
o.Data["json"] = oclib.StoreOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), res, caller)
|
||||
o.ServeJSON()
|
||||
}
|
||||
@ -120,30 +117,13 @@ func (o *SharedWorkspaceController) Get() {
|
||||
// @Success 200 {shared workspace} models.shared_workspace
|
||||
// @router /:id/workspace/:id2 [delete]
|
||||
func (o *SharedWorkspaceController) RemoveWorkspace() {
|
||||
var paths = map[string]map[tools.METHOD]string{ // paths used to call other OC services
|
||||
utils.SHARED_WORKSPACE.String(): {
|
||||
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/:id",
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/",
|
||||
},
|
||||
utils.WORKSPACE.String(): {
|
||||
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/:id",
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/",
|
||||
},
|
||||
utils.WORKFLOW.String(): {
|
||||
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/:id",
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/",
|
||||
},
|
||||
utils.PEER.String(): {
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.PEER)) + "/oc/peer",
|
||||
},
|
||||
}
|
||||
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
|
||||
var res map[string]interface{}
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
id2 := o.Ctx.Input.Param(":id2")
|
||||
r := oclib.LoadOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), id)
|
||||
shared := r.ToSharedWorkspace()
|
||||
newWorkspace := []string{}
|
||||
if slices.Contains(shared.Workspaces, id2) {
|
||||
if slices.Contains(shared.Workspaces, id) {
|
||||
for _, w := range shared.Workspaces {
|
||||
if w != id2 {
|
||||
newWorkspace = append(newWorkspace, w)
|
||||
@ -151,7 +131,7 @@ func (o *SharedWorkspaceController) RemoveWorkspace() {
|
||||
}
|
||||
shared.Workspaces = newWorkspace
|
||||
}
|
||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), shared.Serialize(), id, caller)
|
||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), res, id, nil)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
@ -162,31 +142,13 @@ func (o *SharedWorkspaceController) RemoveWorkspace() {
|
||||
// @Success 200 {shared workspace} models.shared_workspace
|
||||
// @router /:id/workflow/:id2 [delete]
|
||||
func (o *SharedWorkspaceController) RemoveWorkflow() {
|
||||
var paths = map[string]map[tools.METHOD]string{ // paths used to call other OC services
|
||||
utils.SHARED_WORKSPACE.String(): {
|
||||
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/:id",
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/",
|
||||
},
|
||||
utils.WORKSPACE.String(): {
|
||||
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/:id",
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/",
|
||||
},
|
||||
utils.WORKFLOW.String(): {
|
||||
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/:id",
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/",
|
||||
},
|
||||
utils.PEER.String(): {
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.PEER)) + "/oc/peer",
|
||||
},
|
||||
}
|
||||
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
|
||||
var res map[string]interface{}
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
id2 := o.Ctx.Input.Param(":id2")
|
||||
r := oclib.LoadOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), id)
|
||||
fmt.Println("RemoveWorkflow", r)
|
||||
shared := r.ToSharedWorkspace()
|
||||
newWorkflows := []string{}
|
||||
if slices.Contains(shared.Workflows, id2) {
|
||||
if slices.Contains(shared.Workflows, id) {
|
||||
for _, w := range shared.Workflows {
|
||||
if w != id2 {
|
||||
newWorkflows = append(newWorkflows, w)
|
||||
@ -194,7 +156,7 @@ func (o *SharedWorkspaceController) RemoveWorkflow() {
|
||||
}
|
||||
shared.Workflows = newWorkflows
|
||||
}
|
||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), shared.Serialize(), id, caller)
|
||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), res, id, nil)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
@ -205,24 +167,7 @@ func (o *SharedWorkspaceController) RemoveWorkflow() {
|
||||
// @Success 200 {shared workspace} models.shared_workspace
|
||||
// @router /:id/peer/:id2 [delete]
|
||||
func (o *SharedWorkspaceController) RemovePeer() {
|
||||
var paths = map[string]map[tools.METHOD]string{ // paths used to call other OC services
|
||||
utils.SHARED_WORKSPACE.String(): {
|
||||
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/:id",
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/",
|
||||
},
|
||||
utils.WORKSPACE.String(): {
|
||||
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/:id",
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/",
|
||||
},
|
||||
utils.WORKFLOW.String(): {
|
||||
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/:id",
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/",
|
||||
},
|
||||
utils.PEER.String(): {
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.PEER)) + "/oc/peer",
|
||||
},
|
||||
}
|
||||
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
|
||||
var res map[string]interface{}
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
id2 := o.Ctx.Input.Param(":id2")
|
||||
r := oclib.LoadOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), id)
|
||||
@ -245,7 +190,7 @@ func (o *SharedWorkspaceController) RemovePeer() {
|
||||
}
|
||||
shared.Peers = newPeers
|
||||
}
|
||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), shared.Serialize(), id, caller)
|
||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), res, id, nil)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
@ -256,30 +201,13 @@ func (o *SharedWorkspaceController) RemovePeer() {
|
||||
// @Success 200 {shared workspace} models.shared_workspace
|
||||
// @router /:id/rule/:id2 [delete]
|
||||
func (o *SharedWorkspaceController) RemoveRule() {
|
||||
var paths = map[string]map[tools.METHOD]string{ // paths used to call other OC services
|
||||
utils.SHARED_WORKSPACE.String(): {
|
||||
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/:id",
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/",
|
||||
},
|
||||
utils.WORKSPACE.String(): {
|
||||
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/:id",
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/",
|
||||
},
|
||||
utils.WORKFLOW.String(): {
|
||||
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/:id",
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/",
|
||||
},
|
||||
utils.PEER.String(): {
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.PEER)) + "/oc/peer",
|
||||
},
|
||||
}
|
||||
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
|
||||
var res map[string]interface{}
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
id2 := o.Ctx.Input.Param(":id2")
|
||||
r := oclib.LoadOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), id)
|
||||
shared := r.ToSharedWorkspace()
|
||||
newRules := []string{}
|
||||
if shared != nil && slices.Contains(shared.Rules, id2) {
|
||||
if slices.Contains(shared.Rules, id) {
|
||||
for _, rule := range shared.Rules {
|
||||
if rule != id2 {
|
||||
newRules = append(newRules, rule)
|
||||
@ -287,7 +215,7 @@ func (o *SharedWorkspaceController) RemoveRule() {
|
||||
}
|
||||
shared.Rules = newRules
|
||||
}
|
||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), shared.Serialize(), id, caller)
|
||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), res, id, nil)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
@ -298,37 +226,15 @@ func (o *SharedWorkspaceController) RemoveRule() {
|
||||
// @Success 200 {shared workspace} models.shared_workspace
|
||||
// @router /:id/workspace/:id2 [post]
|
||||
func (o *SharedWorkspaceController) AddWorkspace() {
|
||||
var paths = map[string]map[tools.METHOD]string{ // paths used to call other OC services
|
||||
utils.SHARED_WORKSPACE.String(): {
|
||||
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/:id",
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/",
|
||||
},
|
||||
utils.WORKSPACE.String(): {
|
||||
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/:id",
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/",
|
||||
},
|
||||
utils.WORKFLOW.String(): {
|
||||
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/:id",
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/",
|
||||
},
|
||||
utils.PEER.String(): {
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.PEER)) + "/oc/peer",
|
||||
},
|
||||
}
|
||||
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
|
||||
var res map[string]interface{}
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
id2 := o.Ctx.Input.Param(":id2")
|
||||
r := oclib.LoadOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), id)
|
||||
if r.Code != 200 {
|
||||
o.Data["json"] = r
|
||||
o.ServeJSON()
|
||||
return
|
||||
}
|
||||
shared := r.ToSharedWorkspace()
|
||||
if shared != nil && !slices.Contains(shared.Workspaces, id2) {
|
||||
if !slices.Contains(shared.Workspaces, id) {
|
||||
shared.Workspaces = append(shared.Workspaces, id2)
|
||||
}
|
||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), shared.Serialize(), id, caller)
|
||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), res, id, nil)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
@ -339,35 +245,15 @@ func (o *SharedWorkspaceController) AddWorkspace() {
|
||||
// @Success 200 {shared workspace} models.shared_workspace
|
||||
// @router /:id/workflow/:id2 [post]
|
||||
func (o *SharedWorkspaceController) AddWorkflow() {
|
||||
var paths = map[string]map[tools.METHOD]string{ // paths used to call other OC services
|
||||
utils.SHARED_WORKSPACE.String(): {
|
||||
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/:id",
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/",
|
||||
},
|
||||
utils.WORKSPACE.String(): {
|
||||
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/:id",
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/",
|
||||
},
|
||||
utils.WORKFLOW.String(): {
|
||||
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/:id",
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/",
|
||||
},
|
||||
utils.PEER.String(): {
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.PEER)) + "/oc/peer",
|
||||
},
|
||||
}
|
||||
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
|
||||
var res map[string]interface{}
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
id2 := o.Ctx.Input.Param(":id2")
|
||||
fmt.Println("AddWorkflow", id, id2)
|
||||
r := oclib.LoadOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), id)
|
||||
shared := r.ToSharedWorkspace()
|
||||
if shared != nil && !slices.Contains(shared.Workflows, id2) {
|
||||
if !slices.Contains(shared.Workflows, id) {
|
||||
shared.Workflows = append(shared.Workflows, id2)
|
||||
}
|
||||
fmt.Println("AddWorkflow", shared.Workflows)
|
||||
|
||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), shared.Serialize(), id, caller)
|
||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), res, id, nil)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
@ -378,32 +264,15 @@ func (o *SharedWorkspaceController) AddWorkflow() {
|
||||
// @Success 200 {shared workspace} models.shared_workspace
|
||||
// @router /:id/peer/:id2 [post]
|
||||
func (o *SharedWorkspaceController) AddPeer() {
|
||||
var paths = map[string]map[tools.METHOD]string{ // paths used to call other OC services
|
||||
utils.SHARED_WORKSPACE.String(): {
|
||||
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/:id",
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/",
|
||||
},
|
||||
utils.WORKSPACE.String(): {
|
||||
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/:id",
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/",
|
||||
},
|
||||
utils.WORKFLOW.String(): {
|
||||
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/:id",
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/",
|
||||
},
|
||||
utils.PEER.String(): {
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.PEER)) + "/oc/peer",
|
||||
},
|
||||
}
|
||||
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
|
||||
var res map[string]interface{}
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
id2 := o.Ctx.Input.Param(":id2")
|
||||
r := oclib.LoadOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), id)
|
||||
shared := r.ToSharedWorkspace()
|
||||
if shared != nil && !slices.Contains(shared.Peers, id2) {
|
||||
if !slices.Contains(shared.Peers, id) {
|
||||
shared.Peers = append(shared.Peers, id2)
|
||||
}
|
||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), shared.Serialize(), id, caller)
|
||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), res, id, nil)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
@ -414,32 +283,15 @@ func (o *SharedWorkspaceController) AddPeer() {
|
||||
// @Success 200 {shared workspace} models.shared_workspace
|
||||
// @router /:id/rule/:id2 [post]
|
||||
func (o *SharedWorkspaceController) AddRule() {
|
||||
var paths = map[string]map[tools.METHOD]string{ // paths used to send to peers
|
||||
utils.SHARED_WORKSPACE.String(): {
|
||||
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/:id",
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/",
|
||||
},
|
||||
utils.WORKSPACE.String(): {
|
||||
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/:id",
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/",
|
||||
},
|
||||
utils.WORKFLOW.String(): {
|
||||
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/:id",
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/",
|
||||
},
|
||||
utils.PEER.String(): {
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.PEER)) + "/oc/peer",
|
||||
},
|
||||
}
|
||||
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
|
||||
var res map[string]interface{}
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
id2 := o.Ctx.Input.Param(":id2")
|
||||
r := oclib.LoadOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), id)
|
||||
shared := r.ToSharedWorkspace()
|
||||
if shared != nil && !slices.Contains(shared.Rules, id2) {
|
||||
if !slices.Contains(shared.Rules, id) {
|
||||
shared.Rules = append(shared.Rules, id2)
|
||||
}
|
||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), shared.Serialize(), id, caller)
|
||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), res, id, nil)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
@ -449,7 +301,7 @@ func (o *SharedWorkspaceController) AddRule() {
|
||||
// @Success 200 {shared workspace} delete success!
|
||||
// @router /:id [delete]
|
||||
func (o *SharedWorkspaceController) Delete() {
|
||||
var paths = map[string]map[tools.METHOD]string{ // paths used to send to peers
|
||||
var paths = map[string]map[tools.METHOD]string{
|
||||
utils.SHARED_WORKSPACE.String(): {
|
||||
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/:id",
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/",
|
||||
@ -467,7 +319,7 @@ func (o *SharedWorkspaceController) Delete() {
|
||||
},
|
||||
}
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
|
||||
caller := tools.NewHTTPCaller(paths)
|
||||
o.Data["json"] = oclib.DeleteOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), id, caller)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
2
go.mod
2
go.mod
@ -11,7 +11,7 @@ require (
|
||||
)
|
||||
|
||||
require (
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240830071403-db78c70dc349 // indirect
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240826125854-050e6022cb8d // indirect
|
||||
filippo.io/edwards25519 v1.1.0 // indirect
|
||||
github.com/beego/bee/v2 v2.1.0 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
|
20
go.sum
20
go.sum
@ -124,26 +124,6 @@ cloud.o-forge.io/core/oc-lib v0.0.0-20240826103423-aff9304b1a71 h1:GodGMXVFgSdd5
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240826103423-aff9304b1a71/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240826125854-050e6022cb8d h1:CPwBFl2ecnHMi9sxubA9/peTKn4BVBVpHkCCwRTXUik=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240826125854-050e6022cb8d/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240826132851-63b02199f62f h1:gQ7mCNs1yK99SY6ilA9J5Ng+hsKhbFfDBtELNzLK6eM=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240826132851-63b02199f62f/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240826141022-00625eabd631 h1:FYMS7QWERjvjAcdsmYRaq1Ms/PDfWv7Pr+OTKkwJSXQ=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240826141022-00625eabd631/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240826145224-767c14044f51 h1:rUeRWR3ckK7KKqRabE+HBOLXG+35Tv0jBbhpfrR8c2g=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240826145224-767c14044f51/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240826155958-463144a0625b h1:wjqnBe8WFxG0jDmSAxRWm2FJsXvLGwAO24JhdDzPm1M=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240826155958-463144a0625b/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240827080713-091cbb9e7fab h1:x3brpRs6nfv9549rvJMxeacYFqnpe1TrlM2qw5kzsXU=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240827080713-091cbb9e7fab/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240827104028-772287225f44 h1:7jmT3iSzHJuJ2d1vJYTcwXeiDGv4SUOqQ8p4W04HIDY=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240827104028-772287225f44/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240827112206-45d53fc9a985 h1:4OzzVFOaI/QR/D5+qJiP4si6QsOggFFIPFmGwZ7cbeQ=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240827112206-45d53fc9a985/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240827121739-3c5c065b8d24 h1:naqxVtN3ew0eYVir+z2aagL13gCe1MdKv3Dp/sIBLxw=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240827121739-3c5c065b8d24/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240828114159-ede91cde4583 h1:5DVFZLJ4tySspQwk0H1HRR+arWSRsYsujP4N8zxvy2Q=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240828114159-ede91cde4583/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240830071403-db78c70dc349 h1:bEIY1lCsA78/mJqFE0gV6likAv5ZifH3RMnLJxiSk3o=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240830071403-db78c70dc349/go.mod h1:FIJD0taWLJ5pjQLJ6sfE2KlTkvbmk5SMcyrxdjsaVz0=
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
||||
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
||||
|
5
main.go
5
main.go
@ -29,12 +29,7 @@ func main() {
|
||||
o.GetStringDefault("MONGO_DATABASE", "DC_myDC"),
|
||||
"",
|
||||
)
|
||||
// Init OC with hostname and port for discovery purpose
|
||||
oclib.Init("oc-shared", o.GetStringDefault("HOSTNAME", "localhost"), o.GetStringDefault("PORT", "8091"))
|
||||
/* PATHS ARE REFERENCE FOR INNER SERVICE OF DISTANT OC
|
||||
* PATHS ARE USED TO CALL OTHER OC SERVICES
|
||||
* NAMES ARE CANONICAL NAMES OF THE SERVICES
|
||||
*/
|
||||
oclib.AddPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), o.GetStringDefault("SHARED_WORKSPACE_URL", ":8091"))
|
||||
oclib.AddPath(oclib.LibDataEnum(oclib.WORKSPACE), o.GetStringDefault("WORKSPACE_URL", ":8089"))
|
||||
oclib.AddPath(oclib.LibDataEnum(oclib.WORKFLOW), o.GetStringDefault("WORKFLOW_URL", ":8088"))
|
||||
|
Loading…
Reference in New Issue
Block a user