Remove shared
This commit is contained in:
parent
0815f8bd58
commit
4b090ed825
@ -110,6 +110,115 @@ func (o *SharedWorkspaceController) Get() {
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title Add Workspace
|
||||
// @Description find shared workspace by id
|
||||
// @Param id path string true "the id you want to get"
|
||||
// @Param id2 path string true "the id you want to add"
|
||||
// @Success 200 {shared workspace} models.shared_workspace
|
||||
// @router /:id/workspace/:id2 [delete]
|
||||
func (o *SharedWorkspaceController) RemoveWorkspace() {
|
||||
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, id) {
|
||||
for _, w := range shared.Workspaces {
|
||||
if w != id2 {
|
||||
newWorkspace = append(newWorkspace, w)
|
||||
}
|
||||
}
|
||||
shared.Workspaces = newWorkspace
|
||||
}
|
||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), res, id, nil)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title Remove Workflow
|
||||
// @Description find shared workspace by id
|
||||
// @Param id path string true "the id you want to get"
|
||||
// @Param id2 path string true "the id you want to add"
|
||||
// @Success 200 {shared workspace} models.shared_workspace
|
||||
// @router /:id/workflow/:id2 [delete]
|
||||
func (o *SharedWorkspaceController) RemoveWorkflow() {
|
||||
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()
|
||||
newWorkflows := []string{}
|
||||
if slices.Contains(shared.Workflows, id) {
|
||||
for _, w := range shared.Workflows {
|
||||
if w != id2 {
|
||||
newWorkflows = append(newWorkflows, w)
|
||||
}
|
||||
}
|
||||
shared.Workflows = newWorkflows
|
||||
}
|
||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), res, id, nil)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title Remove Peer
|
||||
// @Description find shared workspace by id
|
||||
// @Param id path string true "the id you want to get"
|
||||
// @Param id2 path string true "the id you want to add"
|
||||
// @Success 200 {shared workspace} models.shared_workspace
|
||||
// @router /:id/peer/:id2 [delete]
|
||||
func (o *SharedWorkspaceController) RemovePeer() {
|
||||
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()
|
||||
newPeers := []string{}
|
||||
if shared.CreatorID != id2 {
|
||||
o.Data["json"] = map[string]interface{}{
|
||||
"data": nil,
|
||||
"code": 409,
|
||||
"error": "You can't remove the creator from the shared workspace",
|
||||
}
|
||||
o.ServeJSON()
|
||||
return
|
||||
}
|
||||
if slices.Contains(shared.Peers, id) && shared.CreatorID != id2 {
|
||||
for _, peer := range shared.Peers {
|
||||
if peer != id2 {
|
||||
newPeers = append(newPeers, peer)
|
||||
}
|
||||
}
|
||||
shared.Peers = newPeers
|
||||
}
|
||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), res, id, nil)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title Remove Rule
|
||||
// @Description find shared workspace by id
|
||||
// @Param id path string true "the id you want to get"
|
||||
// @Param id2 path string true "the id you want to add"
|
||||
// @Success 200 {shared workspace} models.shared_workspace
|
||||
// @router /:id/rule/:id2 [delete]
|
||||
func (o *SharedWorkspaceController) RemoveRule() {
|
||||
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 slices.Contains(shared.Rules, id) {
|
||||
for _, rule := range shared.Rules {
|
||||
if rule != id2 {
|
||||
newRules = append(newRules, rule)
|
||||
}
|
||||
}
|
||||
shared.Rules = newRules
|
||||
}
|
||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), res, id, nil)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title Add Workspace
|
||||
// @Description find shared workspace by id
|
||||
// @Param id path string true "the id you want to get"
|
||||
|
2
go.mod
2
go.mod
@ -11,7 +11,7 @@ require (
|
||||
)
|
||||
|
||||
require (
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240826103423-aff9304b1a71 // 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
|
||||
|
2
go.sum
2
go.sum
@ -122,6 +122,8 @@ cloud.o-forge.io/core/oc-lib v0.0.0-20240822065024-fb80e05d6a7b h1:A7NBwTXoHTg/o
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240822065024-fb80e05d6a7b/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240826103423-aff9304b1a71 h1:GodGMXVFgSdd5R1FoUjFAloOS+zOd3j66Wa+jcEPa4c=
|
||||
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=
|
||||
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=
|
||||
|
@ -115,6 +115,15 @@ func init() {
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["oc-shared/controllers:SharedWorkspaceController"] = append(beego.GlobalControllerRouter["oc-shared/controllers:SharedWorkspaceController"],
|
||||
beego.ControllerComments{
|
||||
Method: "RemovePeer",
|
||||
Router: `/:id/peer/:id2`,
|
||||
AllowHTTPMethods: []string{"delete"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["oc-shared/controllers:SharedWorkspaceController"] = append(beego.GlobalControllerRouter["oc-shared/controllers:SharedWorkspaceController"],
|
||||
beego.ControllerComments{
|
||||
Method: "AddRule",
|
||||
@ -124,6 +133,24 @@ func init() {
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["oc-shared/controllers:SharedWorkspaceController"] = append(beego.GlobalControllerRouter["oc-shared/controllers:SharedWorkspaceController"],
|
||||
beego.ControllerComments{
|
||||
Method: "RemoveRule",
|
||||
Router: `/:id/rule/:id2`,
|
||||
AllowHTTPMethods: []string{"delete"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["oc-shared/controllers:SharedWorkspaceController"] = append(beego.GlobalControllerRouter["oc-shared/controllers:SharedWorkspaceController"],
|
||||
beego.ControllerComments{
|
||||
Method: "RemoveWorkflow",
|
||||
Router: `/:id/workflow/:id2`,
|
||||
AllowHTTPMethods: []string{"delete"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["oc-shared/controllers:SharedWorkspaceController"] = append(beego.GlobalControllerRouter["oc-shared/controllers:SharedWorkspaceController"],
|
||||
beego.ControllerComments{
|
||||
Method: "AddWorkflow",
|
||||
@ -142,6 +169,15 @@ func init() {
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["oc-shared/controllers:SharedWorkspaceController"] = append(beego.GlobalControllerRouter["oc-shared/controllers:SharedWorkspaceController"],
|
||||
beego.ControllerComments{
|
||||
Method: "RemoveWorkspace",
|
||||
Router: `/:id/workspace/:id2`,
|
||||
AllowHTTPMethods: []string{"delete"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["oc-shared/controllers:SharedWorkspaceController"] = append(beego.GlobalControllerRouter["oc-shared/controllers:SharedWorkspaceController"],
|
||||
beego.ControllerComments{
|
||||
Method: "Search",
|
||||
|
@ -311,6 +311,34 @@
|
||||
"description": "{shared workspace} models.shared_workspace"
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"tags": [
|
||||
"shared/workspace"
|
||||
],
|
||||
"description": "find shared workspace by id\n\u003cbr\u003e",
|
||||
"operationId": "SharedWorkspaceController.Remove Peer",
|
||||
"parameters": [
|
||||
{
|
||||
"in": "path",
|
||||
"name": "id",
|
||||
"description": "the id you want to get",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"in": "path",
|
||||
"name": "id2",
|
||||
"description": "the id you want to add",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "{shared workspace} models.shared_workspace"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/shared/workspace/{id}/rule/{id2}": {
|
||||
@ -341,6 +369,34 @@
|
||||
"description": "{shared workspace} models.shared_workspace"
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"tags": [
|
||||
"shared/workspace"
|
||||
],
|
||||
"description": "find shared workspace by id\n\u003cbr\u003e",
|
||||
"operationId": "SharedWorkspaceController.Remove Rule",
|
||||
"parameters": [
|
||||
{
|
||||
"in": "path",
|
||||
"name": "id",
|
||||
"description": "the id you want to get",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"in": "path",
|
||||
"name": "id2",
|
||||
"description": "the id you want to add",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "{shared workspace} models.shared_workspace"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/shared/workspace/{id}/workflow/{id2}": {
|
||||
@ -371,6 +427,34 @@
|
||||
"description": "{shared workspace} models.shared_workspace"
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"tags": [
|
||||
"shared/workspace"
|
||||
],
|
||||
"description": "find shared workspace by id\n\u003cbr\u003e",
|
||||
"operationId": "SharedWorkspaceController.Remove Workflow",
|
||||
"parameters": [
|
||||
{
|
||||
"in": "path",
|
||||
"name": "id",
|
||||
"description": "the id you want to get",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"in": "path",
|
||||
"name": "id2",
|
||||
"description": "the id you want to add",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "{shared workspace} models.shared_workspace"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/shared/workspace/{id}/workspace/{id2}": {
|
||||
@ -401,6 +485,34 @@
|
||||
"description": "{shared workspace} models.shared_workspace"
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"tags": [
|
||||
"shared/workspace"
|
||||
],
|
||||
"description": "find shared workspace by id\n\u003cbr\u003e",
|
||||
"operationId": "SharedWorkspaceController.Add Workspace",
|
||||
"parameters": [
|
||||
{
|
||||
"in": "path",
|
||||
"name": "id",
|
||||
"description": "the id you want to get",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"in": "path",
|
||||
"name": "id2",
|
||||
"description": "the id you want to add",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "{shared workspace} models.shared_workspace"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/version/": {
|
||||
|
@ -117,6 +117,27 @@ paths:
|
||||
responses:
|
||||
"200":
|
||||
description: '{shared workspace} models.shared_workspace'
|
||||
delete:
|
||||
tags:
|
||||
- shared/workspace
|
||||
description: |-
|
||||
find shared workspace by id
|
||||
<br>
|
||||
operationId: SharedWorkspaceController.Remove Peer
|
||||
parameters:
|
||||
- in: path
|
||||
name: id
|
||||
description: the id you want to get
|
||||
required: true
|
||||
type: string
|
||||
- in: path
|
||||
name: id2
|
||||
description: the id you want to add
|
||||
required: true
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: '{shared workspace} models.shared_workspace'
|
||||
/shared/workspace/{id}/rule/{id2}:
|
||||
post:
|
||||
tags:
|
||||
@ -139,6 +160,27 @@ paths:
|
||||
responses:
|
||||
"200":
|
||||
description: '{shared workspace} models.shared_workspace'
|
||||
delete:
|
||||
tags:
|
||||
- shared/workspace
|
||||
description: |-
|
||||
find shared workspace by id
|
||||
<br>
|
||||
operationId: SharedWorkspaceController.Remove Rule
|
||||
parameters:
|
||||
- in: path
|
||||
name: id
|
||||
description: the id you want to get
|
||||
required: true
|
||||
type: string
|
||||
- in: path
|
||||
name: id2
|
||||
description: the id you want to add
|
||||
required: true
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: '{shared workspace} models.shared_workspace'
|
||||
/shared/workspace/{id}/workflow/{id2}:
|
||||
post:
|
||||
tags:
|
||||
@ -161,6 +203,27 @@ paths:
|
||||
responses:
|
||||
"200":
|
||||
description: '{shared workspace} models.shared_workspace'
|
||||
delete:
|
||||
tags:
|
||||
- shared/workspace
|
||||
description: |-
|
||||
find shared workspace by id
|
||||
<br>
|
||||
operationId: SharedWorkspaceController.Remove Workflow
|
||||
parameters:
|
||||
- in: path
|
||||
name: id
|
||||
description: the id you want to get
|
||||
required: true
|
||||
type: string
|
||||
- in: path
|
||||
name: id2
|
||||
description: the id you want to add
|
||||
required: true
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: '{shared workspace} models.shared_workspace'
|
||||
/shared/workspace/{id}/workspace/{id2}:
|
||||
post:
|
||||
tags:
|
||||
@ -183,6 +246,27 @@ paths:
|
||||
responses:
|
||||
"200":
|
||||
description: '{shared workspace} models.shared_workspace'
|
||||
delete:
|
||||
tags:
|
||||
- shared/workspace
|
||||
description: |-
|
||||
find shared workspace by id
|
||||
<br>
|
||||
operationId: SharedWorkspaceController.Add Workspace
|
||||
parameters:
|
||||
- in: path
|
||||
name: id
|
||||
description: the id you want to get
|
||||
required: true
|
||||
type: string
|
||||
- in: path
|
||||
name: id2
|
||||
description: the id you want to add
|
||||
required: true
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: '{shared workspace} models.shared_workspace'
|
||||
/shared/workspace/rule/:
|
||||
get:
|
||||
tags:
|
||||
|
Loading…
Reference in New Issue
Block a user