Catalog updated

This commit is contained in:
mr
2026-04-07 11:51:52 +02:00
parent 31e8a2589f
commit ffa7dfe87d
6 changed files with 93 additions and 2 deletions

View File

@@ -57,6 +57,8 @@ func (o *ResourceController) notFound() {
// @Description list all resources across all types // @Description list all resources across all types
// @Param type path string true "the type you want to get" // @Param type path string true "the type you want to get"
// @Param is_draft query string false "draft wished" // @Param is_draft query string false "draft wished"
// @Param offset query string false "offset wished"
// @Param limit query string false "limit wished"
// @Success 200 {resource} models.resource // @Success 200 {resource} models.resource
// @router /:type [get] // @router /:type [get]
func (o *ResourceController) GetAll() { func (o *ResourceController) GetAll() {
@@ -86,6 +88,8 @@ func (o *ResourceController) GetAll() {
// @Param type path string true "the type you want to get" // @Param type path string true "the type you want to get"
// @Param search path string true "the search you want to get" // @Param search path string true "the search you want to get"
// @Param is_draft query string false "draft wished" // @Param is_draft query string false "draft wished"
// @Param offset query string false "offset wished"
// @Param limit query string false "limit wished"
// @Success 200 {resource} models.resource // @Success 200 {resource} models.resource
// @router /:type/search/:search [get] // @router /:type/search/:search [get]
func (o *ResourceController) Search() { func (o *ResourceController) Search() {
@@ -151,8 +155,9 @@ func (o *ResourceController) Post() {
} }
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request) user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
var res map[string]interface{} var res map[string]interface{}
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res) json.Unmarshal(o.Ctx.Input.CopyBody(100000), &res)
data := oclib.NewRequest(libs[0], user, peerID, groups, nil).StoreOne(res) data := oclib.NewRequest(libs[0], user, peerID, groups, nil).StoreOne(res)
fmt.Println(data.Data, res["name"], libs[0])
if data.Err == "" { if data.Err == "" {
payload, _ := json.Marshal(data.Data.Serialize(data.Data)) payload, _ := json.Marshal(data.Data.Serialize(data.Data))
infrastructure.EmitNATS(user, groups, tools.PropalgationMessage{ infrastructure.EmitNATS(user, groups, tools.PropalgationMessage{
@@ -206,10 +211,12 @@ func (o *ResourceController) Put() {
// @Success 200 {resource} models.resource // @Success 200 {resource} models.resource
// @router /:type/:id [delete] // @router /:type/:id [delete]
func (o *ResourceController) Delete() { func (o *ResourceController) Delete() {
fmt.Println("THERE")
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request) user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
id := o.Ctx.Input.Param(":id") id := o.Ctx.Input.Param(":id")
for _, col := range o.collection(false) { for _, col := range o.collection(false) {
data := oclib.NewRequest(col, user, peerID, groups, nil).DeleteOne(id) data := oclib.NewRequest(col, user, peerID, groups, nil).DeleteOne(id)
fmt.Println(col, data, id)
if data.Err == "" { if data.Err == "" {
o.Data["json"] = data o.Data["json"] = data
payload, _ := json.Marshal(data.Data.Serialize(data.Data)) payload, _ := json.Marshal(data.Data.Serialize(data.Data))

2
go.mod
View File

@@ -3,7 +3,7 @@ module oc-catalog
go 1.25.0 go 1.25.0
require ( require (
cloud.o-forge.io/core/oc-lib v0.0.0-20260403121807-913d9b3dfb0a cloud.o-forge.io/core/oc-lib v0.0.0-20260407073631-5dbe55e63081
github.com/beego/beego/v2 v2.3.8 github.com/beego/beego/v2 v2.3.8
github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674 github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674
github.com/smartystreets/goconvey v1.7.2 github.com/smartystreets/goconvey v1.7.2

4
go.sum
View File

@@ -10,6 +10,10 @@ cloud.o-forge.io/core/oc-lib v0.0.0-20260402080126-2bc45557938b h1:jkvJ1+aiitFPl
cloud.o-forge.io/core/oc-lib v0.0.0-20260402080126-2bc45557938b/go.mod h1:+ENuvBfZdESSvecoqGY/wSvRlT3vinEolxKgwbOhUpA= cloud.o-forge.io/core/oc-lib v0.0.0-20260402080126-2bc45557938b/go.mod h1:+ENuvBfZdESSvecoqGY/wSvRlT3vinEolxKgwbOhUpA=
cloud.o-forge.io/core/oc-lib v0.0.0-20260403121807-913d9b3dfb0a h1:H7K91js08Vyx307MW6BwQ/kqNGTrQVMaR3xvrIrc2W8= cloud.o-forge.io/core/oc-lib v0.0.0-20260403121807-913d9b3dfb0a h1:H7K91js08Vyx307MW6BwQ/kqNGTrQVMaR3xvrIrc2W8=
cloud.o-forge.io/core/oc-lib v0.0.0-20260403121807-913d9b3dfb0a/go.mod h1:+ENuvBfZdESSvecoqGY/wSvRlT3vinEolxKgwbOhUpA= cloud.o-forge.io/core/oc-lib v0.0.0-20260403121807-913d9b3dfb0a/go.mod h1:+ENuvBfZdESSvecoqGY/wSvRlT3vinEolxKgwbOhUpA=
cloud.o-forge.io/core/oc-lib v0.0.0-20260407063242-2e9f4cb9f466 h1:1xy9pZenAkT1eHY+3ruzYimaLrCKRzYovJgjO61QSok=
cloud.o-forge.io/core/oc-lib v0.0.0-20260407063242-2e9f4cb9f466/go.mod h1:+ENuvBfZdESSvecoqGY/wSvRlT3vinEolxKgwbOhUpA=
cloud.o-forge.io/core/oc-lib v0.0.0-20260407073631-5dbe55e63081 h1:Fl08ZK6LrzkyFxxhTS+GAyEGiNR8kPvoBefo4iUVP/M=
cloud.o-forge.io/core/oc-lib v0.0.0-20260407073631-5dbe55e63081/go.mod h1:+ENuvBfZdESSvecoqGY/wSvRlT3vinEolxKgwbOhUpA=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0= github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0=
github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=

Binary file not shown.

View File

@@ -236,6 +236,18 @@
"name": "is_draft", "name": "is_draft",
"description": "draft wished", "description": "draft wished",
"type": "string" "type": "string"
},
{
"in": "query",
"name": "offset",
"description": "offset wished",
"type": "string"
},
{
"in": "query",
"name": "limit",
"description": "limit wished",
"type": "string"
} }
], ],
"responses": { "responses": {
@@ -288,6 +300,18 @@
"name": "is_draft", "name": "is_draft",
"description": "draft wished", "description": "draft wished",
"type": "string" "type": "string"
},
{
"in": "query",
"name": "offset",
"description": "offset wished",
"type": "string"
},
{
"in": "query",
"name": "limit",
"description": "limit wished",
"type": "string"
} }
], ],
"responses": { "responses": {
@@ -340,6 +364,18 @@
"name": "is_draft", "name": "is_draft",
"description": "draft wished", "description": "draft wished",
"type": "string" "type": "string"
},
{
"in": "query",
"name": "offset",
"description": "offset wished",
"type": "string"
},
{
"in": "query",
"name": "limit",
"description": "limit wished",
"type": "string"
} }
], ],
"responses": { "responses": {
@@ -406,6 +442,18 @@
"name": "is_draft", "name": "is_draft",
"description": "draft wished", "description": "draft wished",
"type": "string" "type": "string"
},
{
"in": "query",
"name": "offset",
"description": "offset wished",
"type": "string"
},
{
"in": "query",
"name": "limit",
"description": "limit wished",
"type": "string"
} }
], ],
"responses": { "responses": {

View File

@@ -187,6 +187,14 @@ paths:
name: is_draft name: is_draft
description: draft wished description: draft wished
type: string type: string
- in: query
name: offset
description: offset wished
type: string
- in: query
name: limit
description: limit wished
type: string
responses: responses:
"200": "200":
description: '{compute} models.compute' description: '{compute} models.compute'
@@ -242,6 +250,14 @@ paths:
name: is_draft name: is_draft
description: draft wished description: draft wished
type: string type: string
- in: query
name: offset
description: offset wished
type: string
- in: query
name: limit
description: limit wished
type: string
responses: responses:
"200": "200":
description: '{compute} models.compute' description: '{compute} models.compute'
@@ -263,6 +279,14 @@ paths:
name: is_draft name: is_draft
description: draft wished description: draft wished
type: string type: string
- in: query
name: offset
description: offset wished
type: string
- in: query
name: limit
description: limit wished
type: string
responses: responses:
"200": "200":
description: '{resource} models.resource' description: '{resource} models.resource'
@@ -389,6 +413,14 @@ paths:
name: is_draft name: is_draft
description: draft wished description: draft wished
type: string type: string
- in: query
name: offset
description: offset wished
type: string
- in: query
name: limit
description: limit wished
type: string
responses: responses:
"200": "200":
description: '{resource} models.resource' description: '{resource} models.resource'