diff --git a/controllers/workflow_execution.go b/controllers/workflow_execution.go index 1350d89..ccee668 100644 --- a/controllers/workflow_execution.go +++ b/controllers/workflow_execution.go @@ -9,18 +9,21 @@ import ( "go.mongodb.org/mongo-driver/bson/primitive" ) +var collection = oclib.LibDataEnum(oclib.WORKFLOW_EXECUTION) + // Operations about workflow type WorkflowExecutionController struct { beego.Controller } -// @Title Search +// @Title SearchPerDate // @Description search workspace // @Param start_date path string true "the word search you want to get" // @Param end_date path string true "the word search you want to get" +// @Param is_draft query string false "draft wished" // @Success 200 {workspace} models.workspace // @router /search/:start_date/:end_date [get] -func (o *WorkflowExecutionController) Search() { +func (o *WorkflowExecutionController) SearchPerDate() { /* * This is a sample of how to use the search function * The search function is used to search for data in the database @@ -30,6 +33,7 @@ func (o *WorkflowExecutionController) Search() { * The search function returns a list of data that matches the filter * The data is then returned as a json object */ + user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request) // store and return Id or post with UUID start_date, _ := time.Parse("2006-01-02", o.Ctx.Input.Param(":start_date")) end_date, _ := time.Parse("2006-01-02", o.Ctx.Input.Param(":end_date")) @@ -40,16 +44,20 @@ func (o *WorkflowExecutionController) Search() { "execution_date": {{Operator: "gte", Value: sd}, {Operator: "lte", Value: ed}}, }, } - o.Data["json"] = oclib.Search(&f, "", oclib.LibDataEnum(oclib.WORKFLOW_EXECUTION)) + isDraft := o.Ctx.Input.Query("is_draft") + o.Data["json"] = oclib.NewRequest(collection, user, peerID, groups, nil).Search(&f, "", isDraft == "true") o.ServeJSON() } // @Title GetAll // @Description find workflow by workflowid +// @Param is_draft query string false "draft wished" // @Success 200 {workflow} models.workflow // @router / [get] func (o *WorkflowExecutionController) GetAll() { - o.Data["json"] = oclib.LoadAll(oclib.LibDataEnum(oclib.WORKFLOW_EXECUTION)) + user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request) + isDraft := o.Ctx.Input.Query("is_draft") + o.Data["json"] = oclib.NewRequest(collection, user, peerID, groups, nil).LoadAll(isDraft == "true") o.ServeJSON() } @@ -59,7 +67,22 @@ func (o *WorkflowExecutionController) GetAll() { // @Success 200 {workflow} models.workflow // @router /:id [get] func (o *WorkflowExecutionController) Get() { + user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request) id := o.Ctx.Input.Param(":id") - o.Data["json"] = oclib.LoadOne(oclib.LibDataEnum(oclib.WORKFLOW_EXECUTION), id) + o.Data["json"] = oclib.NewRequest(collection, user, peerID, groups, nil).LoadOne(id) + o.ServeJSON() +} + +// @Title Search +// @Description find compute by key word +// @Param search path string true "the search you want to get" +// @Param is_draft query string false "draft wished" +// @Success 200 {compute} models.compute +// @router /search/:search [get] +func (o *WorkflowExecutionController) Search() { + user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request) + isDraft := o.Ctx.Input.Query("is_draft") + search := o.Ctx.Input.Param(":search") + o.Data["json"] = oclib.NewRequest(collection, user, peerID, groups, nil).Search(nil, search, isDraft == "true") o.ServeJSON() } diff --git a/controllers/workflow_sheduler.go b/controllers/workflow_sheduler.go new file mode 100644 index 0000000..555686a --- /dev/null +++ b/controllers/workflow_sheduler.go @@ -0,0 +1,103 @@ +package controllers + +import ( + "encoding/json" + "fmt" + + oclib "cloud.o-forge.io/core/oc-lib" + "cloud.o-forge.io/core/oc-lib/dbs" + "cloud.o-forge.io/core/oc-lib/models/workflow_execution" + "cloud.o-forge.io/core/oc-lib/tools" + beego "github.com/beego/beego/v2/server/web" + "github.com/google/uuid" +) + +var orderCollection = oclib.LibDataEnum(oclib.ORDER) + +// Operations about workflow +type WorkflowSchedulerController struct { + beego.Controller +} + +// @Title Schedule +// @Description schedule workflow +// @Param id path string true "id execution" +// @Param body body models.compute true "The compute content" +// @Success 200 {workspace} models.workspace +// @router /:id [post] +func (o *WorkflowSchedulerController) Schedule() { + code := 200 + e := "" + user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request) + id := o.Ctx.Input.Param(":id") + var resp *workflow_execution.WorkflowSchedule + json.Unmarshal(o.Ctx.Input.CopyBody(100000), &resp) + caller := tools.NewHTTPCaller(map[tools.DataType]map[tools.METHOD]string{ // paths to call other OC services + tools.PEER: { + tools.POST: "/status/", + }, + tools.BOOKING: { + tools.GET: "/booking/check/:id/:start_date/:end_date", + tools.POST: "/booking/", + }, + }) + req := oclib.NewRequest(collection, user, peerID, groups, caller) + resp.UUID = uuid.New().String() + sch, err := req.Schedule(id, resp) + fmt.Println("SCHEDULE", sch, err) + if err != nil { + for _, w := range sch.WorkflowExecution { + req.DeleteOne(w.GetID()) + } + o.Data["json"] = map[string]interface{}{ + "data": nil, + "code": 409, + "error": err.Error(), + } + o.ServeJSON() + return + } + o.Data["json"] = map[string]interface{}{ + "data": sch, + "code": code, + "error": e, + } + o.ServeJSON() +} + +// @Title UnSchedule +// @Description schedule workflow +// @Param id path string true "id execution" +// @Param body body models.compute true "The compute content" +// @Success 200 {workspace} models.workspace +// @router /:id [delete] +func (o *WorkflowSchedulerController) UnSchedule() { + user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request) + id := o.Ctx.Input.Param(":id") + // TODO UNSCHEDULER + filter := &dbs.Filters{ + And: map[string][]dbs.Filter{ + "workflow_id": {{Operator: dbs.EQUAL.String(), Value: id}}, + }, + } + o.Data["json"] = oclib.NewRequest(collection, user, peerID, groups, nil).Search(filter, "", true) + o.ServeJSON() +} + +// @Title SearchScheduledDraftOrder +// @Description schedule workflow +// @Param id path string true "id execution" +// @Success 200 {workspace} models.workspace +// @router /:id/order [get] +func (o *WorkflowSchedulerController) SearchScheduledDraftOrder() { + user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request) + id := o.Ctx.Input.Param(":id") + filter := &dbs.Filters{ + And: map[string][]dbs.Filter{ + "workflow_id": {{Operator: dbs.EQUAL.String(), Value: id}}, + "order_by": {{Operator: dbs.EQUAL.String(), Value: peerID}}, + }, + } + o.Data["json"] = oclib.NewRequest(orderCollection, user, peerID, groups, nil).Search(filter, "", true) + o.ServeJSON() +} diff --git a/go.mod b/go.mod index 2fdebc3..2fe460c 100644 --- a/go.mod +++ b/go.mod @@ -5,22 +5,23 @@ go 1.22.0 toolchain go1.22.4 require ( - cloud.o-forge.io/core/oc-lib v0.0.0-20250108155542-0f4adeea86be + cloud.o-forge.io/core/oc-lib v0.0.0-20250212130857-4833bcb7103e github.com/beego/beego/v2 v2.3.4 + github.com/google/uuid v1.6.0 github.com/smartystreets/goconvey v1.7.2 - go.mongodb.org/mongo-driver v1.17.1 + go.mongodb.org/mongo-driver v1.17.2 ) require ( github.com/beorn7/perks v1.0.1 // indirect + github.com/biter777/countries v1.7.5 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect - github.com/gabriel-vasile/mimetype v1.4.6 // indirect + github.com/gabriel-vasile/mimetype v1.4.8 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-playground/validator/v10 v10.22.1 // indirect + github.com/go-playground/validator/v10 v10.24.0 // indirect github.com/golang/snappy v0.0.4 // indirect - github.com/google/uuid v1.6.0 // indirect github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 // indirect github.com/goraz/onion v0.1.3 // indirect github.com/hashicorp/golang-lru v1.0.2 // indirect @@ -28,20 +29,20 @@ require ( github.com/klauspost/compress v1.17.11 // indirect github.com/kr/text v0.2.0 // indirect github.com/leodido/go-urn v1.4.0 // indirect - github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/montanaflynn/stats v0.7.1 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect - github.com/nats-io/nats.go v1.37.0 // indirect - github.com/nats-io/nkeys v0.4.7 // indirect + github.com/nats-io/nats.go v1.39.0 // indirect + github.com/nats-io/nkeys v0.4.10 // indirect github.com/nats-io/nuid v1.0.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/prometheus/client_golang v1.20.5 // indirect github.com/prometheus/client_model v0.6.1 // indirect - github.com/prometheus/common v0.60.1 // indirect + github.com/prometheus/common v0.62.0 // indirect github.com/prometheus/procfs v0.15.1 // indirect - github.com/robfig/cron/v3 v3.0.1 // indirect + github.com/robfig/cron v1.2.0 // indirect github.com/rogpeppe/go-internal v1.11.0 // indirect github.com/rs/zerolog v1.33.0 // indirect github.com/shiena/ansicolor v0.0.0-20230509054315-a9deabde6e02 // indirect @@ -50,11 +51,11 @@ require ( github.com/xdg-go/scram v1.1.2 // indirect github.com/xdg-go/stringprep v1.0.4 // indirect github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect - golang.org/x/crypto v0.28.0 // indirect - golang.org/x/net v0.30.0 // indirect - golang.org/x/sync v0.8.0 // indirect - golang.org/x/sys v0.26.0 // indirect - golang.org/x/text v0.19.0 // indirect - google.golang.org/protobuf v1.35.1 // indirect + golang.org/x/crypto v0.33.0 // indirect + golang.org/x/net v0.35.0 // indirect + golang.org/x/sync v0.11.0 // indirect + golang.org/x/sys v0.30.0 // indirect + golang.org/x/text v0.22.0 // indirect + google.golang.org/protobuf v1.36.5 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 359acbd..eafe73e 100644 --- a/go.sum +++ b/go.sum @@ -1,10 +1,12 @@ -cloud.o-forge.io/core/oc-lib v0.0.0-20250108155542-0f4adeea86be h1:1Yf8ihUxXjOEPqcfgtXJpJ/slxBUHhf7AgS7DZI3iUk= -cloud.o-forge.io/core/oc-lib v0.0.0-20250108155542-0f4adeea86be/go.mod h1:ya7Q+zHhaKM+XF6sAJ+avqHEVzaMnFJQih2X3TlTlGo= +cloud.o-forge.io/core/oc-lib v0.0.0-20250212130857-4833bcb7103e h1:a4eVChOa20MFCCnSZr72h3n8P6E5IZdePJhYizUDMZs= +cloud.o-forge.io/core/oc-lib v0.0.0-20250212130857-4833bcb7103e/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/beego/beego/v2 v2.3.4 h1:HurQEOGIEhLlPFCTR6ZDuQkybrUl2Ag2i6CdVD2rGiI= github.com/beego/beego/v2 v2.3.4/go.mod h1:5cqHsOHJIxkq44tBpRvtDe59GuVRVv/9/tyVDxd5ce4= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/biter777/countries v1.7.5 h1:MJ+n3+rSxWQdqVJU8eBy9RqcdH6ePPn4PJHocVWUa+Q= +github.com/biter777/countries v1.7.5/go.mod h1:1HSpZ526mYqKJcpT5Ti1kcGQ0L0SrXWIaptUWjFfv2E= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/coreos/etcd v3.3.17+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= @@ -19,16 +21,16 @@ github.com/elazarl/go-bindata-assetfs v1.0.1 h1:m0kkaHRKEu7tUIUFVwhGGGYClXvyl4RE github.com/elazarl/go-bindata-assetfs v1.0.1/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= github.com/etcd-io/etcd v3.3.17+incompatible/go.mod h1:cdZ77EstHBwVtD6iTgzgvogwcjo9m4iOqoijouPJ4bs= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/gabriel-vasile/mimetype v1.4.6 h1:3+PzJTKLkvgjeTbts6msPJt4DixhT4YtFNf1gtGe3zc= -github.com/gabriel-vasile/mimetype v1.4.6/go.mod h1:JX1qVKqZd40hUPpAfiNTe0Sne7hdfKSbOqqmkq8GCXc= +github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM= +github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.22.1 h1:40JcKH+bBNGFczGuoBYgX4I6m/i27HYW8P9FDk5PbgA= -github.com/go-playground/validator/v10 v10.22.1/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= +github.com/go-playground/validator/v10 v10.24.0 h1:KHQckvo8G6hlWnrPX4NJJ+aBfWNAE/HH+qdL2cBpCmg= +github.com/go-playground/validator/v10 v10.24.0/go.mod h1:GGzBIJMuE98Ic/kJsBXbz1x/7cByt++cQ+YOuDM5wus= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= @@ -58,8 +60,9 @@ github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+ github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= +github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= @@ -75,10 +78,10 @@ github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8 github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= -github.com/nats-io/nats.go v1.37.0 h1:07rauXbVnnJvv1gfIyghFEo6lUcYRY0WXc3x7x0vUxE= -github.com/nats-io/nats.go v1.37.0/go.mod h1:Ubdu4Nh9exXdSz0RVWRFBbRfrbSxOYd26oF0wkWclB8= -github.com/nats-io/nkeys v0.4.7 h1:RwNJbbIdYCoClSDNY7QVKZlyb/wfT6ugvFCiKy6vDvI= -github.com/nats-io/nkeys v0.4.7/go.mod h1:kqXRgRDPlGy7nGaEDMuYzmiJCIAAWDK0IMBtDmGD0nc= +github.com/nats-io/nats.go v1.39.0 h1:2/yg2JQjiYYKLwDuBzV0FbB2sIV+eFNkEevlRi4n9lI= +github.com/nats-io/nats.go v1.39.0/go.mod h1:MgRb8oOdigA6cYpEPhXJuRVH6UE/V4jblJ2jQ27IXYM= +github.com/nats-io/nkeys v0.4.10 h1:glmRrpCmYLHByYcePvnTBEAwawwapjCPMjy2huw20wc= +github.com/nats-io/nkeys v0.4.10/go.mod h1:OjRrnIKnWBFl+s4YK5ChQfvHP2fxqZexrKJoVVyWB3U= github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= github.com/ogier/pflag v0.0.1/go.mod h1:zkFki7tvTa0tafRvTBIZTvzYyAu6kQhPZFnshFFPE+g= @@ -91,12 +94,12 @@ github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+ github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= -github.com/prometheus/common v0.60.1 h1:FUas6GcOw66yB/73KC+BOZoFJmbo/1pojoILArPAaSc= -github.com/prometheus/common v0.60.1/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw= +github.com/prometheus/common v0.62.0 h1:xasJaQlnWAeyHdUBeGjXmutelfJHWMRr+Fg4QszZ2Io= +github.com/prometheus/common v0.62.0/go.mod h1:vyBcEuLSvWos9B1+CyL7JZ2up+uFzXhkqml0W5zIY1I= github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= -github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= -github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= +github.com/robfig/cron v1.2.0 h1:ZjScXvvxeQ63Dbyxy76Fj3AT3Ut0aKsyd2/tl3DTMuQ= +github.com/robfig/cron v1.2.0/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= @@ -113,8 +116,8 @@ github.com/smartystreets/goconvey v1.7.2 h1:9RBaZCeXEQ3UselpuwUQHltGVXvdwm6cv1hg github.com/smartystreets/goconvey v1.7.2/go.mod h1:Vw0tHAZW6lzCRk3xgdin6fKYcG+G3Pg9vgXWeJpQFMM= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY= @@ -124,25 +127,25 @@ github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gi github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM= github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -go.mongodb.org/mongo-driver v1.17.1 h1:Wic5cJIwJgSpBhe3lx3+/RybR5PiYRMpVFgO7cOHyIM= -go.mongodb.org/mongo-driver v1.17.1/go.mod h1:wwWm/+BuOddhcq3n68LKRmgk2wXzmF6s0SFOa0GINL4= +go.mongodb.org/mongo-driver v1.17.2 h1:gvZyk8352qSfzyZ2UMWcpDpMSGEr1eqE4T793SqyhzM= +go.mongodb.org/mongo-driver v1.17.2/go.mod h1:Hy04i7O2kC4RS06ZrhPRqj/u4DTYkFDAAccj+rVKqgQ= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191112222119-e1110fd1c708/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= -golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= +golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus= +golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= -golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= +golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8= +golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= -golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w= +golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191115151921-52ab43148777/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -153,23 +156,23 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= -golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= +golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= -golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= +golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= -google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM= +google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= diff --git a/routers/commentsRouter.go b/routers/commentsRouter.go index 9d7e75d..d8ac9dd 100644 --- a/routers/commentsRouter.go +++ b/routers/commentsRouter.go @@ -46,10 +46,46 @@ func init() { beego.GlobalControllerRouter["oc-scheduler/controllers:WorkflowExecutionController"] = append(beego.GlobalControllerRouter["oc-scheduler/controllers:WorkflowExecutionController"], beego.ControllerComments{ Method: "Search", + Router: `/search/:search`, + AllowHTTPMethods: []string{"get"}, + MethodParams: param.Make(), + Filters: nil, + Params: nil}) + + beego.GlobalControllerRouter["oc-scheduler/controllers:WorkflowExecutionController"] = append(beego.GlobalControllerRouter["oc-scheduler/controllers:WorkflowExecutionController"], + beego.ControllerComments{ + Method: "SearchPerDate", Router: `/search/:start_date/:end_date`, AllowHTTPMethods: []string{"get"}, MethodParams: param.Make(), Filters: nil, Params: nil}) + beego.GlobalControllerRouter["oc-scheduler/controllers:WorkflowSchedulerController"] = append(beego.GlobalControllerRouter["oc-scheduler/controllers:WorkflowSchedulerController"], + beego.ControllerComments{ + Method: "Schedule", + Router: `/:id`, + AllowHTTPMethods: []string{"post"}, + MethodParams: param.Make(), + Filters: nil, + Params: nil}) + + beego.GlobalControllerRouter["oc-scheduler/controllers:WorkflowSchedulerController"] = append(beego.GlobalControllerRouter["oc-scheduler/controllers:WorkflowSchedulerController"], + beego.ControllerComments{ + Method: "UnSchedule", + Router: `/:id`, + AllowHTTPMethods: []string{"delete"}, + MethodParams: param.Make(), + Filters: nil, + Params: nil}) + + beego.GlobalControllerRouter["oc-scheduler/controllers:WorkflowSchedulerController"] = append(beego.GlobalControllerRouter["oc-scheduler/controllers:WorkflowSchedulerController"], + beego.ControllerComments{ + Method: "SearchScheduledDraftOrder", + Router: `/:id/order`, + AllowHTTPMethods: []string{"get"}, + MethodParams: param.Make(), + Filters: nil, + Params: nil}) + } diff --git a/routers/router.go b/routers/router.go index b908054..f0feb53 100644 --- a/routers/router.go +++ b/routers/router.go @@ -16,7 +16,12 @@ import ( func init() { ns := beego.NewNamespace("/oc/", beego.NSInclude( - &controllers.WorkflowExecutionController{}, + &controllers.WorkflowSchedulerController{}, + ), + beego.NSNamespace("/execution", + beego.NSInclude( + &controllers.WorkflowExecutionController{}, + ), ), beego.NSNamespace("/version", beego.NSInclude( diff --git a/swagger/swagger.json b/swagger/swagger.json index 02c728f..67c8cd0 100644 --- a/swagger/swagger.json +++ b/swagger/swagger.json @@ -15,13 +15,21 @@ }, "basePath": "/oc/", "paths": { - "/": { + "/execution/": { "get": { "tags": [ - "oc-scheduler/controllersWorkflowExecutionController" + "execution" ], "description": "find workflow by workflowid\n\u003cbr\u003e", "operationId": "WorkflowExecutionController.GetAll", + "parameters": [ + { + "in": "query", + "name": "is_draft", + "description": "draft wished", + "type": "string" + } + ], "responses": { "200": { "description": "{workflow} models.workflow" @@ -29,13 +37,42 @@ } } }, - "/search/{start_date}/{end_date}": { + "/execution/search/{search}": { "get": { "tags": [ - "oc-scheduler/controllersWorkflowExecutionController" + "execution" + ], + "description": "find compute by key word\n\u003cbr\u003e", + "operationId": "WorkflowExecutionController.Search", + "parameters": [ + { + "in": "path", + "name": "search", + "description": "the search you want to get", + "required": true, + "type": "string" + }, + { + "in": "query", + "name": "is_draft", + "description": "draft wished", + "type": "string" + } + ], + "responses": { + "200": { + "description": "{compute} models.compute" + } + } + } + }, + "/execution/search/{start_date}/{end_date}": { + "get": { + "tags": [ + "execution" ], "description": "search workspace\n\u003cbr\u003e", - "operationId": "WorkflowExecutionController.Search", + "operationId": "WorkflowExecutionController.SearchPerDate", "parameters": [ { "in": "path", @@ -50,6 +87,12 @@ "description": "the word search you want to get", "required": true, "type": "string" + }, + { + "in": "query", + "name": "is_draft", + "description": "draft wished", + "type": "string" } ], "responses": { @@ -59,6 +102,29 @@ } } }, + "/execution/{id}": { + "get": { + "tags": [ + "execution" + ], + "description": "find workflow by workflowid\n\u003cbr\u003e", + "operationId": "WorkflowExecutionController.Get", + "parameters": [ + { + "in": "path", + "name": "id", + "description": "the workflowid you want to get", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "{workflow} models.workflow" + } + } + } + }, "/version/": { "get": { "tags": [ @@ -88,32 +154,104 @@ } }, "/{id}": { - "get": { + "post": { "tags": [ - "oc-scheduler/controllersWorkflowExecutionController" + "oc-scheduler/controllersWorkflowSchedulerController" ], - "description": "find workflow by workflowid\n\u003cbr\u003e", - "operationId": "WorkflowExecutionController.Get", + "description": "schedule workflow\n\u003cbr\u003e", + "operationId": "WorkflowSchedulerController.Schedule", "parameters": [ { "in": "path", "name": "id", - "description": "the workflowid you want to get", + "description": "id execution", + "required": true, + "type": "string" + }, + { + "in": "body", + "name": "body", + "description": "The compute content", + "required": true, + "schema": { + "$ref": "#/definitions/models.compute" + } + } + ], + "responses": { + "200": { + "description": "{workspace} models.workspace" + } + } + }, + "delete": { + "tags": [ + "oc-scheduler/controllersWorkflowSchedulerController" + ], + "description": "schedule workflow\n\u003cbr\u003e", + "operationId": "WorkflowSchedulerController.UnSchedule", + "parameters": [ + { + "in": "path", + "name": "id", + "description": "id execution", + "required": true, + "type": "string" + }, + { + "in": "body", + "name": "body", + "description": "The compute content", + "required": true, + "schema": { + "$ref": "#/definitions/models.compute" + } + } + ], + "responses": { + "200": { + "description": "{workspace} models.workspace" + } + } + } + }, + "/{id}/order": { + "get": { + "tags": [ + "oc-scheduler/controllersWorkflowSchedulerController" + ], + "description": "schedule workflow\n\u003cbr\u003e", + "operationId": "WorkflowSchedulerController.SearchScheduledDraftOrder", + "parameters": [ + { + "in": "path", + "name": "id", + "description": "id execution", "required": true, "type": "string" } ], "responses": { "200": { - "description": "{workflow} models.workflow" + "description": "{workspace} models.workspace" } } } } }, + "definitions": { + "models.compute": { + "title": "compute", + "type": "object" + } + }, "tags": [ { - "name": "oc-scheduler/controllersWorkflowExecutionController", + "name": "oc-scheduler/controllersWorkflowSchedulerController", + "description": "Operations about workflow\n" + }, + { + "name": "execution", "description": "Operations about workflow\n" }, { diff --git a/swagger/swagger.yml b/swagger/swagger.yml index 3614dea..439a582 100644 --- a/swagger/swagger.yml +++ b/swagger/swagger.yml @@ -12,21 +12,88 @@ info: url: https://www.gnu.org/licenses/agpl-3.0.html basePath: /oc/ paths: - /: + /{id}: + post: + tags: + - oc-scheduler/controllersWorkflowSchedulerController + description: |- + schedule workflow +
+ operationId: WorkflowSchedulerController.Schedule + parameters: + - in: path + name: id + description: id execution + required: true + type: string + - in: body + name: body + description: The compute content + required: true + schema: + $ref: '#/definitions/models.compute' + responses: + "200": + description: '{workspace} models.workspace' + delete: + tags: + - oc-scheduler/controllersWorkflowSchedulerController + description: |- + schedule workflow +
+ operationId: WorkflowSchedulerController.UnSchedule + parameters: + - in: path + name: id + description: id execution + required: true + type: string + - in: body + name: body + description: The compute content + required: true + schema: + $ref: '#/definitions/models.compute' + responses: + "200": + description: '{workspace} models.workspace' + /{id}/order: get: tags: - - oc-scheduler/controllersWorkflowExecutionController + - oc-scheduler/controllersWorkflowSchedulerController + description: |- + schedule workflow +
+ operationId: WorkflowSchedulerController.SearchScheduledDraftOrder + parameters: + - in: path + name: id + description: id execution + required: true + type: string + responses: + "200": + description: '{workspace} models.workspace' + /execution/: + get: + tags: + - execution description: |- find workflow by workflowid
operationId: WorkflowExecutionController.GetAll + parameters: + - in: query + name: is_draft + description: draft wished + type: string responses: "200": description: '{workflow} models.workflow' - /{id}: + /execution/{id}: get: tags: - - oc-scheduler/controllersWorkflowExecutionController + - execution description: |- find workflow by workflowid
@@ -40,14 +107,35 @@ paths: responses: "200": description: '{workflow} models.workflow' - /search/{start_date}/{end_date}: + /execution/search/{search}: get: tags: - - oc-scheduler/controllersWorkflowExecutionController + - execution + description: |- + find compute by key word +
+ operationId: WorkflowExecutionController.Search + parameters: + - in: path + name: search + description: the search you want to get + required: true + type: string + - in: query + name: is_draft + description: draft wished + type: string + responses: + "200": + description: '{compute} models.compute' + /execution/search/{start_date}/{end_date}: + get: + tags: + - execution description: |- search workspace
- operationId: WorkflowExecutionController.Search + operationId: WorkflowExecutionController.SearchPerDate parameters: - in: path name: start_date @@ -59,6 +147,10 @@ paths: description: the word search you want to get required: true type: string + - in: query + name: is_draft + description: draft wished + type: string responses: "200": description: '{workspace} models.workspace' @@ -84,8 +176,15 @@ paths: responses: "200": description: "" +definitions: + models.compute: + title: compute + type: object tags: -- name: oc-scheduler/controllersWorkflowExecutionController +- name: oc-scheduler/controllersWorkflowSchedulerController + description: | + Operations about workflow +- name: execution description: | Operations about workflow - name: version