Resources added to oc-catalog + proto search

This commit is contained in:
mr 2024-07-26 14:39:57 +02:00
parent 053c1ddf31
commit 0fbe14686a
13 changed files with 579 additions and 16 deletions

View File

@ -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]

View File

@ -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"

View File

@ -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
View 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()
}

View File

@ -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)"

View File

@ -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)"

2
go.mod
View File

@ -11,7 +11,7 @@ require (
)
require (
cloud.o-forge.io/core/oc-lib v0.0.0-20240726075154-d5c5b454f4d0 // indirect
cloud.o-forge.io/core/oc-lib v0.0.0-20240726121555-eb1417853a1c // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/beego/bee/v2 v2.1.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect

4
go.sum
View File

@ -90,6 +90,10 @@ cloud.o-forge.io/core/oc-lib v0.0.0-20240726065859-5ad4d523abfe h1:ZDIYobKqkCf+x
cloud.o-forge.io/core/oc-lib v0.0.0-20240726065859-5ad4d523abfe/go.mod h1:V5EL+NV2s9P1/BcFm3/icfLeBYVVMLl1Z0F0eecJZGo=
cloud.o-forge.io/core/oc-lib v0.0.0-20240726075154-d5c5b454f4d0 h1:u27xxSJtc2dYarTRUZKIk82OfNvxFmhYFhR6kco67Jo=
cloud.o-forge.io/core/oc-lib v0.0.0-20240726075154-d5c5b454f4d0/go.mod h1:V5EL+NV2s9P1/BcFm3/icfLeBYVVMLl1Z0F0eecJZGo=
cloud.o-forge.io/core/oc-lib v0.0.0-20240726114510-8c97fca96c85 h1:PPFwnkl9m8WCrW92JgSm1kSV4K8xWOkMeTrqGfwKymI=
cloud.o-forge.io/core/oc-lib v0.0.0-20240726114510-8c97fca96c85/go.mod h1:V5EL+NV2s9P1/BcFm3/icfLeBYVVMLl1Z0F0eecJZGo=
cloud.o-forge.io/core/oc-lib v0.0.0-20240726121555-eb1417853a1c h1:GS1E071bdeKpMgq9i6KMa87zUJkoB7+8miQlvVViHHs=
cloud.o-forge.io/core/oc-lib v0.0.0-20240726121555-eb1417853a1c/go.mod h1:V5EL+NV2s9P1/BcFm3/icfLeBYVVMLl1Z0F0eecJZGo=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=

Binary file not shown.

View File

@ -52,6 +52,15 @@ func init() {
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["oc-catalog/controllers:DataController"] = append(beego.GlobalControllerRouter["oc-catalog/controllers:DataController"],
beego.ControllerComments{
Method: "Search",
Router: `/:search`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["oc-catalog/controllers:DatacenterController"] = append(beego.GlobalControllerRouter["oc-catalog/controllers:DatacenterController"],
beego.ControllerComments{
Method: "Post",
@ -97,6 +106,15 @@ func init() {
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["oc-catalog/controllers:DatacenterController"] = append(beego.GlobalControllerRouter["oc-catalog/controllers:DatacenterController"],
beego.ControllerComments{
Method: "Search",
Router: `/:search`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["oc-catalog/controllers:ProcessingController"] = append(beego.GlobalControllerRouter["oc-catalog/controllers:ProcessingController"],
beego.ControllerComments{
Method: "Post",
@ -142,6 +160,51 @@ func init() {
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["oc-catalog/controllers:ProcessingController"] = append(beego.GlobalControllerRouter["oc-catalog/controllers:ProcessingController"],
beego.ControllerComments{
Method: "Search",
Router: `/:search`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["oc-catalog/controllers:ResourceController"] = append(beego.GlobalControllerRouter["oc-catalog/controllers:ResourceController"],
beego.ControllerComments{
Method: "GetAll",
Router: `/`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["oc-catalog/controllers:ResourceController"] = append(beego.GlobalControllerRouter["oc-catalog/controllers:ResourceController"],
beego.ControllerComments{
Method: "Get",
Router: `/:id`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["oc-catalog/controllers:ResourceController"] = append(beego.GlobalControllerRouter["oc-catalog/controllers:ResourceController"],
beego.ControllerComments{
Method: "Delete",
Router: `/:id`,
AllowHTTPMethods: []string{"delete"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["oc-catalog/controllers:ResourceController"] = append(beego.GlobalControllerRouter["oc-catalog/controllers:ResourceController"],
beego.ControllerComments{
Method: "Search",
Router: `/:search`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["oc-catalog/controllers:StorageController"] = append(beego.GlobalControllerRouter["oc-catalog/controllers:StorageController"],
beego.ControllerComments{
Method: "Post",
@ -187,6 +250,15 @@ func init() {
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["oc-catalog/controllers:StorageController"] = append(beego.GlobalControllerRouter["oc-catalog/controllers:StorageController"],
beego.ControllerComments{
Method: "Search",
Router: `/:search`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["oc-catalog/controllers:VersionController"] = append(beego.GlobalControllerRouter["oc-catalog/controllers:VersionController"],
beego.ControllerComments{
Method: "GetAll",
@ -241,4 +313,13 @@ func init() {
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["oc-catalog/controllers:WorkflowController"] = append(beego.GlobalControllerRouter["oc-catalog/controllers:WorkflowController"],
beego.ControllerComments{
Method: "Search",
Router: `/:search`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
}

View File

@ -15,6 +15,11 @@ import (
func init() {
ns := beego.NewNamespace("/oc/",
beego.NSNamespace("/resource",
beego.NSInclude(
&controllers.ResourceController{},
),
),
beego.NSNamespace("/data",
beego.NSInclude(
&controllers.DataController{},

View File

@ -57,7 +57,7 @@
"tags": [
"data"
],
"description": "find workflow by id\n\u003cbr\u003e",
"description": "find data by id\n\u003cbr\u003e",
"operationId": "DataController.Get",
"parameters": [
{
@ -126,6 +126,29 @@
}
}
},
"/data/{search}": {
"get": {
"tags": [
"data"
],
"description": "find data by key word\n\u003cbr\u003e",
"operationId": "DataController.Get",
"parameters": [
{
"in": "path",
"name": "search",
"description": "the search you want to get",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "{data} models.data"
}
}
}
},
"/datacenter/": {
"get": {
"tags": [
@ -237,6 +260,29 @@
}
}
},
"/datacenter/{search}": {
"get": {
"tags": [
"datacenter"
],
"description": "find datacenter by key word\n\u003cbr\u003e",
"operationId": "DatacenterController.Get",
"parameters": [
{
"in": "path",
"name": "search",
"description": "the search you want to get",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "{datacenter} models.datacenter"
}
}
}
},
"/processing/": {
"get": {
"tags": [
@ -348,6 +394,110 @@
}
}
},
"/processing/{search}": {
"get": {
"tags": [
"processing"
],
"description": "find processing by key word\n\u003cbr\u003e",
"operationId": "ProcessingController.Get",
"parameters": [
{
"in": "path",
"name": "search",
"description": "the search you want to get",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "{processing} models.processing"
}
}
}
},
"/resource/": {
"get": {
"tags": [
"resource"
],
"description": "find resource by id\n\u003cbr\u003e",
"operationId": "ResourceController.GetAll",
"responses": {
"200": {
"description": "{resource} models.resource"
}
}
}
},
"/resource/{id}": {
"get": {
"tags": [
"resource"
],
"description": "find resource by id\n\u003cbr\u003e",
"operationId": "ResourceController.Get",
"parameters": [
{
"in": "path",
"name": "id",
"description": "the id you want to get",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "{resource} models.resource"
}
}
},
"delete": {
"tags": [
"resource"
],
"description": "delete the resource\n\u003cbr\u003e",
"operationId": "ResourceController.Delete",
"parameters": [
{
"in": "path",
"name": "id",
"description": "The id you want to deleteDeleteOne",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "{resource} delete success!"
}
}
}
},
"/resource/{search}": {
"get": {
"tags": [
"resource"
],
"description": "find resource by key word\n\u003cbr\u003e",
"operationId": "ResourceController.Get",
"parameters": [
{
"in": "path",
"name": "search",
"description": "the search you want to get",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "{resource} models.resource"
}
}
}
},
"/storage/": {
"get": {
"tags": [
@ -459,6 +609,29 @@
}
}
},
"/storage/{search}": {
"get": {
"tags": [
"storage"
],
"description": "find storage by key word\n\u003cbr\u003e",
"operationId": "StorageController.Get",
"parameters": [
{
"in": "path",
"name": "search",
"description": "the search you want to get",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "{storage} models.storage"
}
}
}
},
"/version/": {
"get": {
"tags": [
@ -583,6 +756,29 @@
}
}
}
},
"/workflow/{search}": {
"get": {
"tags": [
"workflow"
],
"description": "find workflow by key word\n\u003cbr\u003e",
"operationId": "WorkflowController.Get",
"parameters": [
{
"in": "path",
"name": "search",
"description": "the search you want to get",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "{workflow} models.workflow"
}
}
}
}
},
"definitions": {
@ -612,25 +808,29 @@
}
},
"tags": [
{
"name": "resource",
"description": "Operations about resource\n"
},
{
"name": "data",
"description": "Operations about data\n"
},
{
"name": "datacenter",
"description": "Operations about data\n"
"description": "Operations about datacenter\n"
},
{
"name": "storage",
"description": "Operations about data\n"
"description": "Operations about storage\n"
},
{
"name": "processing",
"description": "Operations about data\n"
"description": "Operations about processing\n"
},
{
"name": "workflow",
"description": "Operations about data\n"
"description": "Operations about workflow\n"
},
{
"name": "version",

View File

@ -45,7 +45,7 @@ paths:
tags:
- data
description: |-
find workflow by id
find data by id
<br>
operationId: DataController.Get
parameters:
@ -95,6 +95,23 @@ paths:
responses:
"200":
description: '{data} delete success!'
/data/{search}:
get:
tags:
- data
description: |-
find data by key word
<br>
operationId: DataController.Get
parameters:
- in: path
name: search
description: the search you want to get
required: true
type: string
responses:
"200":
description: '{data} models.data'
/datacenter/:
get:
tags:
@ -178,6 +195,23 @@ paths:
responses:
"200":
description: '{datacenter} delete success!'
/datacenter/{search}:
get:
tags:
- datacenter
description: |-
find datacenter by key word
<br>
operationId: DatacenterController.Get
parameters:
- in: path
name: search
description: the search you want to get
required: true
type: string
responses:
"200":
description: '{datacenter} models.datacenter'
/processing/:
get:
tags:
@ -261,6 +295,84 @@ paths:
responses:
"200":
description: '{processing} delete success!'
/processing/{search}:
get:
tags:
- processing
description: |-
find processing by key word
<br>
operationId: ProcessingController.Get
parameters:
- in: path
name: search
description: the search you want to get
required: true
type: string
responses:
"200":
description: '{processing} models.processing'
/resource/:
get:
tags:
- resource
description: |-
find resource by id
<br>
operationId: ResourceController.GetAll
responses:
"200":
description: '{resource} models.resource'
/resource/{id}:
get:
tags:
- resource
description: |-
find resource by id
<br>
operationId: ResourceController.Get
parameters:
- in: path
name: id
description: the id you want to get
required: true
type: string
responses:
"200":
description: '{resource} models.resource'
delete:
tags:
- resource
description: |-
delete the resource
<br>
operationId: ResourceController.Delete
parameters:
- in: path
name: id
description: The id you want to deleteDeleteOne
required: true
type: string
responses:
"200":
description: '{resource} delete success!'
/resource/{search}:
get:
tags:
- resource
description: |-
find resource by key word
<br>
operationId: ResourceController.Get
parameters:
- in: path
name: search
description: the search you want to get
required: true
type: string
responses:
"200":
description: '{resource} models.resource'
/storage/:
get:
tags:
@ -344,6 +456,23 @@ paths:
responses:
"200":
description: '{storage} delete success!'
/storage/{search}:
get:
tags:
- storage
description: |-
find storage by key word
<br>
operationId: StorageController.Get
parameters:
- in: path
name: search
description: the search you want to get
required: true
type: string
responses:
"200":
description: '{storage} models.storage'
/version/:
get:
tags:
@ -438,6 +567,23 @@ paths:
responses:
"200":
description: '{workflow} delete success!'
/workflow/{search}:
get:
tags:
- workflow
description: |-
find workflow by key word
<br>
operationId: WorkflowController.Get
parameters:
- in: path
name: search
description: the search you want to get
required: true
type: string
responses:
"200":
description: '{workflow} models.workflow'
definitions:
json:
title: json
@ -458,21 +604,24 @@ definitions:
title: workflow
type: object
tags:
- name: resource
description: |
Operations about resource
- name: data
description: |
Operations about data
- name: datacenter
description: |
Operations about data
Operations about datacenter
- name: storage
description: |
Operations about data
Operations about storage
- name: processing
description: |
Operations about data
Operations about processing
- name: workflow
description: |
Operations about data
Operations about workflow
- name: version
description: |
VersionController operations for Version