Resources added to oc-catalog + proto search
This commit is contained in:
@@ -49,7 +49,18 @@ func (o *DataController) GetAll() {
|
||||
}
|
||||
|
||||
// @Title Get
|
||||
// @Description find workflow by id
|
||||
// @Description find data by key word
|
||||
// @Param search path string true "the search you want to get"
|
||||
// @Success 200 {data} models.data
|
||||
// @router /:search [get]
|
||||
func (o *DataController) Search() {
|
||||
search := o.Ctx.Input.Param(":search")
|
||||
o.Data["json"] = oclib.Search(search, oclib.LibDataEnum(oclib.DATA_RESOURCE))
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title Get
|
||||
// @Description find data by id
|
||||
// @Param id path string true "the id you want to get"
|
||||
// @Success 200 {data} models.data
|
||||
// @router /:id [get]
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
// Operations about data
|
||||
// Operations about datacenter
|
||||
type DatacenterController struct {
|
||||
beego.Controller
|
||||
}
|
||||
@@ -48,6 +48,17 @@ func (o *DatacenterController) GetAll() {
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title Get
|
||||
// @Description find datacenter by key word
|
||||
// @Param search path string true "the search you want to get"
|
||||
// @Success 200 {datacenter} models.datacenter
|
||||
// @router /:search [get]
|
||||
func (o *DatacenterController) Search() {
|
||||
search := o.Ctx.Input.Param(":search")
|
||||
o.Data["json"] = oclib.Search(search, 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"
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
// Operations about data
|
||||
// Operations about processing
|
||||
type ProcessingController struct {
|
||||
beego.Controller
|
||||
}
|
||||
@@ -48,6 +48,17 @@ func (o *ProcessingController) GetAll() {
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title Get
|
||||
// @Description find processing by key word
|
||||
// @Param search path string true "the search you want to get"
|
||||
// @Success 200 {processing} models.processing
|
||||
// @router /:search [get]
|
||||
func (o *ProcessingController) Search() {
|
||||
search := o.Ctx.Input.Param(":search")
|
||||
o.Data["json"] = oclib.Search(search, 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"
|
||||
|
||||
69
controllers/resource.go
Normal file
69
controllers/resource.go
Normal file
@@ -0,0 +1,69 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
oclib "cloud.o-forge.io/core/oc-lib"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
// Operations about resource
|
||||
type ResourceController struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
// @Title GetAll
|
||||
// @Description find resource by id
|
||||
// @Success 200 {resource} models.resource
|
||||
// @router / [get]
|
||||
func (o *ResourceController) GetAll() {
|
||||
results := map[string]interface{}{}
|
||||
for _, resource := range []oclib.LibDataEnum{oclib.LibDataEnum(oclib.DATACENTER_RESOURCE), oclib.LibDataEnum(oclib.DATACENTER_RESOURCE), oclib.LibDataEnum(oclib.STORAGE_RESOURCE), oclib.LibDataEnum(oclib.PROCESSING_RESOURCE), oclib.LibDataEnum(oclib.WORKFLOW_RESOURCE)} {
|
||||
results[resource.String()] = oclib.LoadAll(resource)
|
||||
}
|
||||
o.Data["json"] = results
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title Get
|
||||
// @Description find resource by key word
|
||||
// @Param search path string true "the search you want to get"
|
||||
// @Success 200 {resource} models.resource
|
||||
// @router /:search [get]
|
||||
func (o *ResourceController) Search() {
|
||||
search := o.Ctx.Input.Param(":search")
|
||||
results := map[string]interface{}{}
|
||||
for _, resource := range []oclib.LibDataEnum{oclib.LibDataEnum(oclib.DATACENTER_RESOURCE), oclib.LibDataEnum(oclib.DATACENTER_RESOURCE), oclib.LibDataEnum(oclib.STORAGE_RESOURCE), oclib.LibDataEnum(oclib.PROCESSING_RESOURCE), oclib.LibDataEnum(oclib.WORKFLOW_RESOURCE)} {
|
||||
results[resource.String()] = oclib.Search(search, resource)
|
||||
}
|
||||
o.Data["json"] = results
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title Get
|
||||
// @Description find resource by id
|
||||
// @Param id path string true "the id you want to get"
|
||||
// @Success 200 {resource} models.resource
|
||||
// @router /:id [get]
|
||||
func (o *ResourceController) Get() {
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
results := map[string]interface{}{}
|
||||
for _, resource := range []oclib.LibDataEnum{oclib.LibDataEnum(oclib.DATACENTER_RESOURCE), oclib.LibDataEnum(oclib.DATACENTER_RESOURCE), oclib.LibDataEnum(oclib.STORAGE_RESOURCE), oclib.LibDataEnum(oclib.PROCESSING_RESOURCE), oclib.LibDataEnum(oclib.WORKFLOW_RESOURCE)} {
|
||||
results[resource.String()] = oclib.LoadOne(resource, id)
|
||||
}
|
||||
o.Data["json"] = results
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title Delete
|
||||
// @Description delete the resource
|
||||
// @Param id path string true "The id you want to delete"DeleteOne
|
||||
// @Success 200 {resource} delete success!
|
||||
// @router /:id [delete]
|
||||
func (o *ResourceController) Delete() {
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
results := map[string]interface{}{}
|
||||
for _, resource := range []oclib.LibDataEnum{oclib.LibDataEnum(oclib.DATACENTER_RESOURCE), oclib.LibDataEnum(oclib.DATACENTER_RESOURCE), oclib.LibDataEnum(oclib.STORAGE_RESOURCE), oclib.LibDataEnum(oclib.PROCESSING_RESOURCE), oclib.LibDataEnum(oclib.WORKFLOW_RESOURCE)} {
|
||||
results[resource.String()] = oclib.DeleteOne(resource, id)
|
||||
}
|
||||
o.Data["json"] = results
|
||||
o.ServeJSON()
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
// Operations about data
|
||||
// Operations about storage
|
||||
type StorageController struct {
|
||||
beego.Controller
|
||||
}
|
||||
@@ -27,6 +27,17 @@ func (o *StorageController) Put() {
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title Get
|
||||
// @Description find storage by key word
|
||||
// @Param search path string true "the search you want to get"
|
||||
// @Success 200 {storage} models.storage
|
||||
// @router /:search [get]
|
||||
func (o *StorageController) Search() {
|
||||
search := o.Ctx.Input.Param(":search")
|
||||
o.Data["json"] = oclib.Search(search, oclib.LibDataEnum(oclib.STORAGE_RESOURCE))
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title Create
|
||||
// @Description create storage
|
||||
// @Param storage body json true "body for storage content (Json format)"
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
// Operations about data
|
||||
// Operations about workflow
|
||||
type WorkflowController struct {
|
||||
beego.Controller
|
||||
}
|
||||
@@ -27,6 +27,17 @@ func (o *WorkflowController) Put() {
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title Get
|
||||
// @Description find workflow by key word
|
||||
// @Param search path string true "the search you want to get"
|
||||
// @Success 200 {workflow} models.workflow
|
||||
// @router /:search [get]
|
||||
func (o *WorkflowController) Search() {
|
||||
search := o.Ctx.Input.Param(":search")
|
||||
o.Data["json"] = oclib.Search(search, oclib.LibDataEnum(oclib.WORKFLOW_RESOURCE))
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title Create
|
||||
// @Description create workflow
|
||||
// @Param workflow body json true "body for workflow content (Json format)"
|
||||
|
||||
Reference in New Issue
Block a user