add verification flow
This commit is contained in:
30
models/execution_verification/execution_verification.go
Executable file
30
models/execution_verification/execution_verification.go
Executable file
@@ -0,0 +1,30 @@
|
||||
package execution_verification
|
||||
|
||||
import (
|
||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||
"cloud.o-forge.io/core/oc-lib/tools"
|
||||
)
|
||||
|
||||
/*
|
||||
* ExecutionVerification is a struct that represents a list of workflow executions
|
||||
* Warning: No user can write (del, post, put) a workflow execution, it is only used by the system
|
||||
* workflows generate their own executions
|
||||
*/
|
||||
type ExecutionVerification struct {
|
||||
utils.AbstractObject // AbstractObject contains the basic fields of an object (id, name)
|
||||
WorkflowID string `json:"workflow_id" bson:"workflow_id,omitempty"` // WorkflowID is the ID of the workflow
|
||||
IsVerified bool `json:"is_verified" bson:"is_verified,omitempty"`
|
||||
Validate bool `json:"validate" bson:"validate,omitempty"`
|
||||
}
|
||||
|
||||
func (r *ExecutionVerification) StoreDraftDefault() {
|
||||
r.IsDraft = false // TODO: TEMPORARY
|
||||
}
|
||||
|
||||
func (d *ExecutionVerification) GetAccessor(request *tools.APIRequest) utils.Accessor {
|
||||
return NewAccessor(request) // Create a new instance of the accessor
|
||||
}
|
||||
|
||||
func (d *ExecutionVerification) VerifyAuth(callName string, request *tools.APIRequest) bool {
|
||||
return true
|
||||
}
|
||||
35
models/execution_verification/execution_verification_mongo_accessor.go
Executable file
35
models/execution_verification/execution_verification_mongo_accessor.go
Executable file
@@ -0,0 +1,35 @@
|
||||
package execution_verification
|
||||
|
||||
import (
|
||||
"cloud.o-forge.io/core/oc-lib/logs"
|
||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||
"cloud.o-forge.io/core/oc-lib/tools"
|
||||
)
|
||||
|
||||
type ExecutionVerificationMongoAccessor struct {
|
||||
utils.AbstractAccessor[*ExecutionVerification]
|
||||
shallow bool
|
||||
}
|
||||
|
||||
func NewAccessor(request *tools.APIRequest) *ExecutionVerificationMongoAccessor {
|
||||
return &ExecutionVerificationMongoAccessor{
|
||||
shallow: false,
|
||||
AbstractAccessor: utils.AbstractAccessor[*ExecutionVerification]{
|
||||
Logger: logs.CreateLogger(tools.WORKFLOW_EXECUTION.String()), // Create a logger with the data type
|
||||
Request: request,
|
||||
Type: tools.WORKFLOW_EXECUTION,
|
||||
New: func() *ExecutionVerification { return &ExecutionVerification{} },
|
||||
NotImplemented: []string{"DeleteOne", "StoreOne", "CopyOne"},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (wfa *ExecutionVerificationMongoAccessor) StoreOne(set utils.DBObject) (utils.DBObject, int, error) {
|
||||
set.(*ExecutionVerification).IsVerified = false
|
||||
return utils.GenericStoreOne(set, wfa)
|
||||
}
|
||||
|
||||
func (wfa *ExecutionVerificationMongoAccessor) UpdateOne(set map[string]interface{}, id string) (utils.DBObject, int, error) {
|
||||
set["is_verified"] = true
|
||||
return utils.GenericUpdateOne(set, id, wfa)
|
||||
}
|
||||
Reference in New Issue
Block a user