implement remote call for remote action
This commit is contained in:
@@ -1,17 +1,18 @@
|
||||
package rule
|
||||
|
||||
package rule
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||
"cloud.o-forge.io/core/oc-lib/tools"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type Rule struct {
|
||||
utils.AbstractObject
|
||||
Description string `json:"description,omitempty" bson:"description,omitempty"`
|
||||
Condition string `json:"condition,omitempty" bson:"condition,omitempty"`
|
||||
Actions []string `json:"actions,omitempty" bson:"actions,omitempty"`
|
||||
Description string `json:"description,omitempty" bson:"description,omitempty"`
|
||||
Condition string `json:"condition,omitempty" bson:"condition,omitempty"`
|
||||
Actions []string `json:"actions,omitempty" bson:"actions,omitempty"`
|
||||
}
|
||||
|
||||
func (ao *Rule) GetID() string {
|
||||
@@ -26,9 +27,9 @@ func (d *Rule) GetName() string {
|
||||
return d.Name
|
||||
}
|
||||
|
||||
func (d *Rule) GetAccessor() utils.Accessor {
|
||||
func (d *Rule) GetAccessor(caller *tools.HTTPCaller) utils.Accessor {
|
||||
data := New()
|
||||
data.SetLogger(utils.RULE)
|
||||
data.Init(utils.RULE, caller)
|
||||
return data
|
||||
}
|
||||
|
||||
|
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
|
||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||
"cloud.o-forge.io/core/oc-lib/tools"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
@@ -30,9 +31,9 @@ func (d *SharedWorkspace) GetName() string {
|
||||
return d.Name
|
||||
}
|
||||
|
||||
func (d *SharedWorkspace) GetAccessor() utils.Accessor {
|
||||
func (d *SharedWorkspace) GetAccessor(caller *tools.HTTPCaller) utils.Accessor {
|
||||
data := New()
|
||||
data.SetLogger(utils.SHARED_WORKSPACE)
|
||||
data.Init(utils.SHARED_WORKSPACE, caller)
|
||||
return data
|
||||
}
|
||||
|
||||
|
@@ -28,7 +28,7 @@ func (wfa *sharedWorkspaceMongoAccessor) sharedWorkspace(shared *SharedWorkspace
|
||||
eldest, code, _ := wfa.LoadOne(id)
|
||||
if code == 200 {
|
||||
eld := eldest.(*SharedWorkspace)
|
||||
accessor := (&workspace.Workspace{}).GetAccessor()
|
||||
accessor := (&workspace.Workspace{}).GetAccessor(nil)
|
||||
if eld.Workspaces != nil {
|
||||
for _, v := range eld.Workspaces {
|
||||
accessor.UpdateOne(&workspace.Workspace{Shared: false}, v)
|
||||
@@ -43,7 +43,7 @@ func (wfa *sharedWorkspaceMongoAccessor) sharedWorkspace(shared *SharedWorkspace
|
||||
}
|
||||
|
||||
func (wfa *sharedWorkspaceMongoAccessor) sharedWorkflow(shared *SharedWorkspace, id string) {
|
||||
accessor := (&w.Workflow{}).GetAccessor()
|
||||
accessor := (&w.Workflow{}).GetAccessor(nil)
|
||||
eldest, code, _ := wfa.LoadOne(id)
|
||||
if code == 200 {
|
||||
eld := eldest.(*SharedWorkspace)
|
||||
|
@@ -5,6 +5,7 @@ import (
|
||||
|
||||
"cloud.o-forge.io/core/oc-lib/models/resources"
|
||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||
"cloud.o-forge.io/core/oc-lib/tools"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
@@ -28,9 +29,9 @@ func (d *Workspace) GetName() string {
|
||||
return d.Name
|
||||
}
|
||||
|
||||
func (d *Workspace) GetAccessor() utils.Accessor {
|
||||
func (d *Workspace) GetAccessor(caller *tools.HTTPCaller) utils.Accessor {
|
||||
data := New()
|
||||
data.SetLogger(utils.WORKSPACE)
|
||||
data.Init(utils.WORKSPACE, caller)
|
||||
return data
|
||||
}
|
||||
|
||||
|
@@ -60,7 +60,7 @@ func (wfa *workspaceMongoAccessor) CopyOne(data utils.DBObject) (utils.DBObject,
|
||||
|
||||
func (wfa *workspaceMongoAccessor) fill(workflow *Workspace) *Workspace {
|
||||
if workflow.Datas != nil && len(workflow.Datas) > 0 {
|
||||
dataAccessor := (&data.DataResource{}).GetAccessor()
|
||||
dataAccessor := (&data.DataResource{}).GetAccessor(nil)
|
||||
for _, id := range workflow.Datas {
|
||||
d, _, e := dataAccessor.LoadOne(id)
|
||||
if e == nil {
|
||||
@@ -69,7 +69,7 @@ func (wfa *workspaceMongoAccessor) fill(workflow *Workspace) *Workspace {
|
||||
}
|
||||
}
|
||||
if workflow.Datacenters != nil && len(workflow.Datacenters) > 0 {
|
||||
dataAccessor := (&datacenter.DatacenterResource{}).GetAccessor()
|
||||
dataAccessor := (&datacenter.DatacenterResource{}).GetAccessor(nil)
|
||||
for _, id := range workflow.Datacenters {
|
||||
d, _, e := dataAccessor.LoadOne(id)
|
||||
if e == nil {
|
||||
@@ -78,7 +78,7 @@ func (wfa *workspaceMongoAccessor) fill(workflow *Workspace) *Workspace {
|
||||
}
|
||||
}
|
||||
if workflow.Storages != nil && len(workflow.Storages) > 0 {
|
||||
dataAccessor := (&storage.StorageResource{}).GetAccessor()
|
||||
dataAccessor := (&storage.StorageResource{}).GetAccessor(nil)
|
||||
for _, id := range workflow.Storages {
|
||||
d, _, e := dataAccessor.LoadOne(id)
|
||||
if e == nil {
|
||||
@@ -87,7 +87,7 @@ func (wfa *workspaceMongoAccessor) fill(workflow *Workspace) *Workspace {
|
||||
}
|
||||
}
|
||||
if workflow.Processings != nil && len(workflow.Processings) > 0 {
|
||||
dataAccessor := (&processing.ProcessingResource{}).GetAccessor()
|
||||
dataAccessor := (&processing.ProcessingResource{}).GetAccessor(nil)
|
||||
for _, id := range workflow.Processings {
|
||||
d, _, e := dataAccessor.LoadOne(id)
|
||||
if e == nil {
|
||||
@@ -96,7 +96,7 @@ func (wfa *workspaceMongoAccessor) fill(workflow *Workspace) *Workspace {
|
||||
}
|
||||
}
|
||||
if workflow.Workflows != nil && len(workflow.Workflows) > 0 {
|
||||
dataAccessor := (&w.WorkflowResource{}).GetAccessor()
|
||||
dataAccessor := (&w.WorkflowResource{}).GetAccessor(nil)
|
||||
for _, id := range workflow.Workflows {
|
||||
d, _, e := dataAccessor.LoadOne(id)
|
||||
if e == nil {
|
||||
|
Reference in New Issue
Block a user