@@ -15,6 +15,7 @@ import (
1515 "golang.org/x/text/language"
1616
1717 "github.com/bcmi-labs/orchestrator/internal/api/handlers"
18+ "github.com/bcmi-labs/orchestrator/internal/api/models"
1819 "github.com/bcmi-labs/orchestrator/internal/orchestrator"
1920 "github.com/bcmi-labs/orchestrator/internal/orchestrator/app"
2021 "github.com/bcmi-labs/orchestrator/internal/orchestrator/bricks"
@@ -28,6 +29,7 @@ const (
2829 BrickTag Tag = "Brick"
2930 AIModelsTag Tag = "AIModels"
3031 SystemTag Tag = "System"
32+ Property Tag = "Property"
3133)
3234
3335var validTags = []Tag {ApplicationTag , BrickTag , AIModelsTag , SystemTag }
@@ -187,6 +189,7 @@ func NewOpenApiGenerator(version string) *Generator {
187189 // to manually remove the pkg prefix.
188190 reflector .DefaultOptions = append (reflector .DefaultOptions ,
189191 jsonschema .InterceptSchema (func (params jsonschema.InterceptSchemaParams ) (stop bool , err error ) {
192+
190193 if params .Value .Type () == reflect .TypeOf (orchestrator .Status ("" )) {
191194 params .Schema .WithRef ("#/components/schemas/Status" )
192195 return true , nil
@@ -249,6 +252,90 @@ type ErrorResponse struct {
249252func (g * Generator ) InitOperations () {
250253
251254 operations := []OperationConfig {
255+ {
256+ OperationId : "DeleteProperty" ,
257+ Method : http .MethodDelete ,
258+ Path : "/v1/properties/{key}" ,
259+ Request : (* struct {
260+ ID string `path:"key" description:"property key."`
261+ })(nil ),
262+ CustomSuccessResponse : & CustomResponseDef {
263+ ContentType : "application/json" ,
264+ DataStructure : nil ,
265+ Description : "Successful response" ,
266+ StatusCode : http .StatusNoContent ,
267+ },
268+ Description : "Delete the property by the provided key." ,
269+ Summary : "Delete property by key" ,
270+ Tags : []Tag {Property },
271+ PossibleErrors : []ErrorResponse {
272+ {StatusCode : http .StatusNotFound , Reference : "#/components/responses/NotFound" },
273+ {StatusCode : http .StatusBadRequest , Reference : "#/components/responses/BadRequest" },
274+ {StatusCode : http .StatusInternalServerError , Reference : "#/components/responses/InternalServerError" },
275+ },
276+ },
277+ {
278+ OperationId : "UpdateProperty" ,
279+ Method : http .MethodPut ,
280+ Path : "/v1/properties/{key}" ,
281+ Parameters : (* struct {
282+ ID string `path:"key" description:"property key."`
283+ })(nil ),
284+ Request : []byte {},
285+ CustomSuccessResponse : & CustomResponseDef {
286+ ContentType : "application/octet-stream" ,
287+ DataStructure : []byte {},
288+ Description : "Successful response" ,
289+ StatusCode : http .StatusOK ,
290+ },
291+ Description : "Update or create a new property." ,
292+ Summary : "Upsert property" ,
293+ Tags : []Tag {Property },
294+ PossibleErrors : []ErrorResponse {
295+ {StatusCode : http .StatusNotFound , Reference : "#/components/responses/NotFound" },
296+ {StatusCode : http .StatusBadRequest , Reference : "#/components/responses/BadRequest" },
297+ {StatusCode : http .StatusInternalServerError , Reference : "#/components/responses/InternalServerError" },
298+ },
299+ },
300+ {
301+ OperationId : "GetProperty" ,
302+ Method : http .MethodGet ,
303+ Path : "/v1/properties/{key}" ,
304+ Parameters : (* struct {
305+ ID string `path:"key" description:"property key."`
306+ })(nil ),
307+ CustomSuccessResponse : & CustomResponseDef {
308+ ContentType : "application/octet-stream" ,
309+ DataStructure : []byte {},
310+ Description : "Successful response" ,
311+ StatusCode : http .StatusOK ,
312+ },
313+ Description : "Return a single property by the provided key." ,
314+ Summary : "Get property by key" ,
315+ Tags : []Tag {Property },
316+ PossibleErrors : []ErrorResponse {
317+ {StatusCode : http .StatusNotFound , Reference : "#/components/responses/NotFound" },
318+ {StatusCode : http .StatusBadRequest , Reference : "#/components/responses/BadRequest" },
319+ {StatusCode : http .StatusInternalServerError , Reference : "#/components/responses/InternalServerError" },
320+ },
321+ },
322+ {
323+ OperationId : "GetPropertyKeys" ,
324+ Method : http .MethodGet ,
325+ Path : "/v1/properties" ,
326+ CustomSuccessResponse : & CustomResponseDef {
327+ ContentType : "application/json" ,
328+ DataStructure : models.PropertyKeysResponse {},
329+ Description : "Successful response" ,
330+ StatusCode : http .StatusOK ,
331+ },
332+ Description : "Return the list of system properties." ,
333+ Summary : "Get system properties" ,
334+ Tags : []Tag {Property },
335+ PossibleErrors : []ErrorResponse {
336+ {StatusCode : http .StatusInternalServerError , Reference : "#/components/responses/InternalServerError" },
337+ },
338+ },
252339 {
253340 OperationId : "getAppPorts" ,
254341 Method : http .MethodGet ,
0 commit comments