diff --git a/controllers/data.go b/controllers/data.go index ff3ef56..ff5d458 100644 --- a/controllers/data.go +++ b/controllers/data.go @@ -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] diff --git a/controllers/datacenter.go b/controllers/datacenter.go index 522e4c4..f916e57 100644 --- a/controllers/datacenter.go +++ b/controllers/datacenter.go @@ -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" diff --git a/controllers/processing.go b/controllers/processing.go index 14bed54..ca84e7b 100644 --- a/controllers/processing.go +++ b/controllers/processing.go @@ -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" diff --git a/controllers/resource.go b/controllers/resource.go new file mode 100644 index 0000000..b0a5c88 --- /dev/null +++ b/controllers/resource.go @@ -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() +} diff --git a/controllers/storage.go b/controllers/storage.go index 45eb599..51f12a4 100644 --- a/controllers/storage.go +++ b/controllers/storage.go @@ -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)" diff --git a/controllers/workflow.go b/controllers/workflow.go index 84af1f5..0130554 100644 --- a/controllers/workflow.go +++ b/controllers/workflow.go @@ -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)" diff --git a/go.mod b/go.mod index 9fcc19a..1cff6e0 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 4d43b31..3a32119 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/oc-catalog b/oc-catalog index 91a6758..4d7e3ad 100755 Binary files a/oc-catalog and b/oc-catalog differ diff --git a/routers/commentsRouter.go b/routers/commentsRouter.go index 0c1efaa..0dceb88 100644 --- a/routers/commentsRouter.go +++ b/routers/commentsRouter.go @@ -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}) + } diff --git a/routers/router.go b/routers/router.go index 012548b..8b957a2 100644 --- a/routers/router.go +++ b/routers/router.go @@ -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{}, diff --git a/swagger/swagger.json b/swagger/swagger.json index 420ecf4..ff342fa 100644 --- a/swagger/swagger.json +++ b/swagger/swagger.json @@ -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", diff --git a/swagger/swagger.yml b/swagger/swagger.yml index 256e6e0..d0d6ff3 100644 --- a/swagger/swagger.yml +++ b/swagger/swagger.yml @@ -45,7 +45,7 @@ paths: tags: - data description: |- - find workflow by id + find data by id
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 +
+ 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 +
+ 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 +
+ 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 +
+ operationId: ResourceController.GetAll + responses: + "200": + description: '{resource} models.resource' + /resource/{id}: + get: + tags: + - resource + description: |- + find resource by id +
+ 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 +
+ 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 +
+ 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 +
+ 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 +
+ 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