init oc-catalog
This commit is contained in:
71
controllers/data.go
Normal file
71
controllers/data.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
oclib "cloud.o-forge.io/core/oc-lib"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
// Operations about data
|
||||
type DataController struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
// @Title Update
|
||||
// @Description create datas
|
||||
// @Param id path string true "the data id you want to get"
|
||||
// @Param body body models.data true "The data content"
|
||||
// @Success 200 {data} models.data
|
||||
// @router /:id [put]
|
||||
func (o *DataController) Put() {
|
||||
// store and return Id or post with UUID
|
||||
var res map[string]interface{}
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res)
|
||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.DATA_RESOURCE), res, id)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title Create
|
||||
// @Description create data
|
||||
// @Param data body json true "body for data content (Json format)"
|
||||
// @Success 200 {data} models.data
|
||||
// @router / [post]
|
||||
func (o *DataController) Post() {
|
||||
var res map[string]interface{}
|
||||
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res)
|
||||
o.Data["json"] = oclib.StoreOne(oclib.LibDataEnum(oclib.DATA_RESOURCE), res)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title GetAll
|
||||
// @Description find data by id
|
||||
// @Success 200 {data} models.data
|
||||
// @router / [get]
|
||||
func (o *DataController) GetAll() {
|
||||
o.Data["json"] = oclib.LoadAll(oclib.LibDataEnum(oclib.DATA_RESOURCE))
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title Get
|
||||
// @Description find workflow by id
|
||||
// @Param id path string true "the id you want to get"
|
||||
// @Success 200 {data} models.data
|
||||
// @router /:id [get]
|
||||
func (o *DataController) Get() {
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
o.Data["json"] = oclib.LoadOne(oclib.LibDataEnum(oclib.DATA_RESOURCE), id)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title Delete
|
||||
// @Description delete the data
|
||||
// @Param id path string true "The id you want to delete"
|
||||
// @Success 200 {data} delete success!
|
||||
// @router /:id [delete]
|
||||
func (o *DataController) Delete() {
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
o.Data["json"] = oclib.DeleteOne(oclib.LibDataEnum(oclib.DATA_RESOURCE), id)
|
||||
o.ServeJSON()
|
||||
}
|
||||
71
controllers/datacenter.go
Normal file
71
controllers/datacenter.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
oclib "cloud.o-forge.io/core/oc-lib"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
// Operations about data
|
||||
type DatacenterController struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
// @Title Update
|
||||
// @Description create datacenters
|
||||
// @Param id path string true "the datacenter id you want to get"
|
||||
// @Param body body models.datacenter true "The datacenter content"
|
||||
// @Success 200 {datacenter} models.datacenter
|
||||
// @router /:id [put]
|
||||
func (o *DatacenterController) Put() {
|
||||
// store and return Id or post with UUID
|
||||
var res map[string]interface{}
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res)
|
||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.DATACENTER_RESOURCE), res, id)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title Create
|
||||
// @Description create datacenter
|
||||
// @Param datacenter body json true "body for datacenter content (Json format)"
|
||||
// @Success 200 {datacenter} models.datacenter
|
||||
// @router / [post]
|
||||
func (o *DatacenterController) Post() {
|
||||
var res map[string]interface{}
|
||||
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res)
|
||||
o.Data["json"] = oclib.StoreOne(oclib.LibDataEnum(oclib.DATACENTER_RESOURCE), res)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title GetAll
|
||||
// @Description find datacenter by id
|
||||
// @Success 200 {datacenter} models.datacenter
|
||||
// @router / [get]
|
||||
func (o *DatacenterController) GetAll() {
|
||||
o.Data["json"] = oclib.LoadAll(oclib.LibDataEnum(oclib.DATACENTER_RESOURCE))
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title Get
|
||||
// @Description find datacenter by id
|
||||
// @Param id path string true "the id you want to get"
|
||||
// @Success 200 {datacenter} models.datacenter
|
||||
// @router /:id [get]
|
||||
func (o *DatacenterController) Get() {
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
o.Data["json"] = oclib.LoadOne(oclib.LibDataEnum(oclib.DATACENTER_RESOURCE), id)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title Delete
|
||||
// @Description delete the datacenter
|
||||
// @Param id path string true "The id you want to delete"
|
||||
// @Success 200 {datacenter} delete success!
|
||||
// @router /:id [delete]
|
||||
func (o *DatacenterController) Delete() {
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
o.Data["json"] = oclib.DeleteOne(oclib.LibDataEnum(oclib.DATACENTER_RESOURCE), id)
|
||||
o.ServeJSON()
|
||||
}
|
||||
71
controllers/processing.go
Normal file
71
controllers/processing.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
oclib "cloud.o-forge.io/core/oc-lib"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
// Operations about data
|
||||
type ProcessingController struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
// @Title Update
|
||||
// @Description create processings
|
||||
// @Param id path string true "the processing id you want to get"
|
||||
// @Param body body models.processing true "The processing content"
|
||||
// @Success 200 {processing} models.processing
|
||||
// @router /:id [put]
|
||||
func (o *ProcessingController) Put() {
|
||||
// store and return Id or post with UUID
|
||||
var res map[string]interface{}
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res)
|
||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.PROCESSING_RESOURCE), res, id)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title Create
|
||||
// @Description create processing
|
||||
// @Param processing body json true "body for processing content (Json format)"
|
||||
// @Success 200 {processing} models.processing
|
||||
// @router / [post]
|
||||
func (o *ProcessingController) Post() {
|
||||
var res map[string]interface{}
|
||||
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res)
|
||||
o.Data["json"] = oclib.StoreOne(oclib.LibDataEnum(oclib.PROCESSING_RESOURCE), res)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title GetAll
|
||||
// @Description find processing by id
|
||||
// @Success 200 {processing} models.processing
|
||||
// @router / [get]
|
||||
func (o *ProcessingController) GetAll() {
|
||||
o.Data["json"] = oclib.LoadAll(oclib.LibDataEnum(oclib.PROCESSING_RESOURCE))
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title Get
|
||||
// @Description find processing by id
|
||||
// @Param id path string true "the id you want to get"
|
||||
// @Success 200 {processing} models.processing
|
||||
// @router /:id [get]
|
||||
func (o *ProcessingController) Get() {
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
o.Data["json"] = oclib.LoadOne(oclib.LibDataEnum(oclib.PROCESSING_RESOURCE), id)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title Delete
|
||||
// @Description delete the processing
|
||||
// @Param id path string true "The id you want to delete"
|
||||
// @Success 200 {processing} delete success!
|
||||
// @router /:id [delete]
|
||||
func (o *ProcessingController) Delete() {
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
o.Data["json"] = oclib.DeleteOne(oclib.LibDataEnum(oclib.PROCESSING_RESOURCE), id)
|
||||
o.ServeJSON()
|
||||
}
|
||||
71
controllers/storage.go
Normal file
71
controllers/storage.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
oclib "cloud.o-forge.io/core/oc-lib"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
// Operations about data
|
||||
type StorageController struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
// @Title Update
|
||||
// @Description create storages
|
||||
// @Param id path string true "the storage id you want to get"
|
||||
// @Param body body models.storage true "The storage content"
|
||||
// @Success 200 {storage} models.storage
|
||||
// @router /:id [put]
|
||||
func (o *StorageController) Put() {
|
||||
// store and return Id or post with UUID
|
||||
var res map[string]interface{}
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res)
|
||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.STORAGE_RESOURCE), res, id)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title Create
|
||||
// @Description create storage
|
||||
// @Param storage body json true "body for storage content (Json format)"
|
||||
// @Success 200 {storage} models.storage
|
||||
// @router / [post]
|
||||
func (o *StorageController) Post() {
|
||||
var res map[string]interface{}
|
||||
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res)
|
||||
o.Data["json"] = oclib.StoreOne(oclib.LibDataEnum(oclib.STORAGE_RESOURCE), res)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title GetAll
|
||||
// @Description find storage by id
|
||||
// @Success 200 {storage} models.storage
|
||||
// @router / [get]
|
||||
func (o *StorageController) GetAll() {
|
||||
o.Data["json"] = oclib.LoadAll(oclib.LibDataEnum(oclib.STORAGE_RESOURCE))
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title Get
|
||||
// @Description find storage by id
|
||||
// @Param id path string true "the id you want to get"
|
||||
// @Success 200 {storage} models.storage
|
||||
// @router /:id [get]
|
||||
func (o *StorageController) Get() {
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
o.Data["json"] = oclib.LoadOne(oclib.LibDataEnum(oclib.STORAGE_RESOURCE), id)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title Delete
|
||||
// @Description delete the storage
|
||||
// @Param id path string true "The id you want to delete"
|
||||
// @Success 200 {storage} delete success!
|
||||
// @router /:id [delete]
|
||||
func (o *StorageController) Delete() {
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
o.Data["json"] = oclib.DeleteOne(oclib.LibDataEnum(oclib.STORAGE_RESOURCE), id)
|
||||
o.ServeJSON()
|
||||
}
|
||||
19
controllers/version.go
Normal file
19
controllers/version.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
// VersionController operations for Version
|
||||
type VersionController struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
// @Title GetAll
|
||||
// @Description get version
|
||||
// @Success 200
|
||||
// @router / [get]
|
||||
func (c *VersionController) GetAll() {
|
||||
c.Data["json"] = map[string]string{"version": "1"}
|
||||
c.ServeJSON()
|
||||
}
|
||||
71
controllers/workflow.go
Normal file
71
controllers/workflow.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
oclib "cloud.o-forge.io/core/oc-lib"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
// Operations about data
|
||||
type WorkflowController struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
// @Title Update
|
||||
// @Description create workflows
|
||||
// @Param id path string true "the workflow id you want to get"
|
||||
// @Param body body models.workflow true "The workflow content"
|
||||
// @Success 200 {workflow} models.workflow
|
||||
// @router /:id [put]
|
||||
func (o *WorkflowController) Put() {
|
||||
// store and return Id or post with UUID
|
||||
var res map[string]interface{}
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res)
|
||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.WORKFLOW_RESOURCE), res, id)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title Create
|
||||
// @Description create workflow
|
||||
// @Param workflow body json true "body for workflow content (Json format)"
|
||||
// @Success 200 {workflow} models.workflow
|
||||
// @router / [post]
|
||||
func (o *WorkflowController) Post() {
|
||||
var res map[string]interface{}
|
||||
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res)
|
||||
o.Data["json"] = oclib.StoreOne(oclib.LibDataEnum(oclib.WORKFLOW_RESOURCE), res)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title GetAll
|
||||
// @Description find workflow by id
|
||||
// @Success 200 {workflow} models.workflow
|
||||
// @router / [get]
|
||||
func (o *WorkflowController) GetAll() {
|
||||
o.Data["json"] = oclib.LoadAll(oclib.LibDataEnum(oclib.WORKFLOW_RESOURCE))
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title Get
|
||||
// @Description find workflow by id
|
||||
// @Param id path string true "the id you want to get"
|
||||
// @Success 200 {workflow} models.workflow
|
||||
// @router /:id [get]
|
||||
func (o *WorkflowController) Get() {
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
o.Data["json"] = oclib.LoadOne(oclib.LibDataEnum(oclib.WORKFLOW_RESOURCE), id)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title Delete
|
||||
// @Description delete the workflow
|
||||
// @Param id path string true "The id you want to delete"
|
||||
// @Success 200 {workflow} delete success!
|
||||
// @router /:id [delete]
|
||||
func (o *WorkflowController) Delete() {
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
o.Data["json"] = oclib.DeleteOne(oclib.LibDataEnum(oclib.WORKFLOW_RESOURCE), id)
|
||||
o.ServeJSON()
|
||||
}
|
||||
Reference in New Issue
Block a user