Skip to content

Commit

Permalink
add resource bundle api.
Browse files Browse the repository at this point in the history
Signed-off-by: morvencao <[email protected]>
  • Loading branch information
morvencao committed May 30, 2024
1 parent 253a300 commit 991a08a
Show file tree
Hide file tree
Showing 24 changed files with 2,835 additions and 16 deletions.
7 changes: 6 additions & 1 deletion cmd/maestro/server/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,14 @@ func (s *apiServer) routes() *mux.Router {
apiV1ResourceRouter.HandleFunc("/{id}", resourceHandler.Patch).Methods(http.MethodPatch)
apiV1ResourceRouter.HandleFunc("/{id}", resourceHandler.Delete).Methods(http.MethodDelete)
apiV1ResourceRouter.Use(authMiddleware.AuthenticateAccountJWT)

apiV1ResourceRouter.Use(authzMiddleware.AuthorizeApi)

apiV1ResourceBundleRouter := apiV1Router.PathPrefix("/resourcebundles").Subrouter()
apiV1ResourceBundleRouter.HandleFunc("", resourceHandler.ListBundle).Methods(http.MethodGet)
apiV1ResourceBundleRouter.HandleFunc("/{id}", resourceHandler.GetBundle).Methods(http.MethodGet)
apiV1ResourceBundleRouter.Use(authMiddleware.AuthenticateAccountJWT)
apiV1ResourceBundleRouter.Use(authzMiddleware.AuthorizeApi)

// /api/maestro/v1/consumers
apiV1ConsumersRouter := apiV1Router.PathPrefix("/consumers").Subrouter()
apiV1ConsumersRouter.HandleFunc("", consumerHandler.List).Methods(http.MethodGet)
Expand Down
4 changes: 2 additions & 2 deletions data/generated/openapi/openapi.go

Large diffs are not rendered by default.

74 changes: 74 additions & 0 deletions openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,42 @@ paths:
$ref: '#/components/schemas/Error'
parameters:
- $ref: '#/components/parameters/id'
/api/maestro/v1/resourcebundles:
get:
summary: Returns a list of resourcebundles
security:
- Bearer: []
responses:
'200':
description: A JSON array of resourcebundle objects
content:
application/json:
schema:
$ref: '#/components/schemas/ResourceBundleList'
'401':
description: Auth token is invalid
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'403':
description: Unauthorized to perform operation
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Unexpected error occurred
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
parameters:
- $ref: '#/components/parameters/page'
- $ref: '#/components/parameters/size'
- $ref: '#/components/parameters/search'
- $ref: '#/components/parameters/orderBy'
- $ref: '#/components/parameters/fields'
/api/maestro/v1/consumers:
get:
summary: Returns a list of consumers
Expand Down Expand Up @@ -535,6 +571,44 @@ components:
type: object
update_strategy:
type: object
ResourceBundleList:
allOf:
- $ref: '#/components/schemas/List'
- type: object
properties:
items:
type: array
items:
$ref: '#/components/schemas/ResourceBundle'
ResourceBundle:
allOf:
- $ref: '#/components/schemas/ObjectReference'
- type: object
properties:
name:
type: string
consumer_name:
type: string
version:
type: integer
created_at:
type: string
format: date-time
updated_at:
type: string
format: date-time
manifests:
type: array
items:
type: object
delete_option:
type: object
manifest_configs:
type: array
items:
type: object
status:
type: object
Consumer:
allOf:
- $ref: '#/components/schemas/ObjectReference'
Expand Down
8 changes: 8 additions & 0 deletions pkg/api/openapi/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ docs/List.md
docs/ObjectReference.md
docs/Resource.md
docs/ResourceAllOf.md
docs/ResourceBundle.md
docs/ResourceBundleAllOf.md
docs/ResourceBundleList.md
docs/ResourceBundleListAllOf.md
docs/ResourceList.md
docs/ResourceListAllOf.md
docs/ResourcePatchRequest.md
Expand All @@ -39,6 +43,10 @@ model_list.go
model_object_reference.go
model_resource.go
model_resource_all_of.go
model_resource_bundle.go
model_resource_bundle_all_of.go
model_resource_bundle_list.go
model_resource_bundle_list_all_of.go
model_resource_list.go
model_resource_list_all_of.go
model_resource_patch_request.go
Expand Down
5 changes: 5 additions & 0 deletions pkg/api/openapi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ Class | Method | HTTP request | Description
*DefaultApi* | [**ApiMaestroV1ConsumersIdGet**](docs/DefaultApi.md#apimaestrov1consumersidget) | **Get** /api/maestro/v1/consumers/{id} | Get an consumer by id
*DefaultApi* | [**ApiMaestroV1ConsumersIdPatch**](docs/DefaultApi.md#apimaestrov1consumersidpatch) | **Patch** /api/maestro/v1/consumers/{id} | Update an consumer
*DefaultApi* | [**ApiMaestroV1ConsumersPost**](docs/DefaultApi.md#apimaestrov1consumerspost) | **Post** /api/maestro/v1/consumers | Create a new consumer
*DefaultApi* | [**ApiMaestroV1ResourcebundlesGet**](docs/DefaultApi.md#apimaestrov1resourcebundlesget) | **Get** /api/maestro/v1/resourcebundles | Returns a list of resourcebundles
*DefaultApi* | [**ApiMaestroV1ResourcesGet**](docs/DefaultApi.md#apimaestrov1resourcesget) | **Get** /api/maestro/v1/resources | Returns a list of resources
*DefaultApi* | [**ApiMaestroV1ResourcesIdDelete**](docs/DefaultApi.md#apimaestrov1resourcesiddelete) | **Delete** /api/maestro/v1/resources/{id} | Delete a resource
*DefaultApi* | [**ApiMaestroV1ResourcesIdGet**](docs/DefaultApi.md#apimaestrov1resourcesidget) | **Get** /api/maestro/v1/resources/{id} | Get an resource by id
Expand All @@ -104,6 +105,10 @@ Class | Method | HTTP request | Description
- [ObjectReference](docs/ObjectReference.md)
- [Resource](docs/Resource.md)
- [ResourceAllOf](docs/ResourceAllOf.md)
- [ResourceBundle](docs/ResourceBundle.md)
- [ResourceBundleAllOf](docs/ResourceBundleAllOf.md)
- [ResourceBundleList](docs/ResourceBundleList.md)
- [ResourceBundleListAllOf](docs/ResourceBundleListAllOf.md)
- [ResourceList](docs/ResourceList.md)
- [ResourceListAllOf](docs/ResourceListAllOf.md)
- [ResourcePatchRequest](docs/ResourcePatchRequest.md)
Expand Down
154 changes: 154 additions & 0 deletions pkg/api/openapi/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,116 @@ paths:
security:
- Bearer: []
summary: Update an resource
/api/maestro/v1/resourcebundles:
get:
parameters:
- description: Page number of record list when record list exceeds specified
page size
explode: true
in: query
name: page
required: false
schema:
default: 1
minimum: 1
type: integer
style: form
- description: Maximum number of records to return
explode: true
in: query
name: size
required: false
schema:
default: 100
minimum: 0
type: integer
style: form
- description: "Specifies the search criteria. The syntax of this parameter\
\ is\nsimilar to the syntax of the _where_ clause of an SQL statement,\n\
using the names of the json attributes / column names of the account. \n\
For example, in order to retrieve all the accounts with a username\nstarting\
\ with `my`:\n\n```sql\nusername like 'my%'\n```\n\nThe search criteria\
\ can also be applied on related resource.\nFor example, in order to retrieve\
\ all the subscriptions labeled by `foo=bar`,\n\n```sql\nsubscription_labels.key\
\ = 'foo' and subscription_labels.value = 'bar'\n```\n\nIf the parameter\
\ isn't provided, or if the value is empty, then\nall the accounts that\
\ the user has permission to see will be\nreturned."
explode: true
in: query
name: search
required: false
schema:
type: string
style: form
- description: |-
Specifies the order by criteria. The syntax of this parameter is
similar to the syntax of the _order by_ clause of an SQL statement,
but using the names of the json attributes / column of the account.
For example, in order to retrieve all accounts ordered by username:
```sql
username asc
```
Or in order to retrieve all accounts ordered by username _and_ first name:
```sql
username asc, firstName asc
```
If the parameter isn't provided, or if the value is empty, then
no explicit ordering will be applied.
explode: true
in: query
name: orderBy
required: false
schema:
type: string
style: form
- description: |-
Supplies a comma-separated list of fields to be returned.
Fields of sub-structures and of arrays use <structure>.<field> notation.
<stucture>.* means all field of a structure
Example: For each Subscription to get id, href, plan(id and kind) and labels (all fields)
```
ocm get subscriptions --parameter fields=id,href,plan.id,plan.kind,labels.* --parameter fetchLabels=true
```
explode: true
in: query
name: fields
required: false
schema:
type: string
style: form
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/ResourceBundleList'
description: A JSON array of resourcebundle objects
"401":
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
description: Auth token is invalid
"403":
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
description: Unauthorized to perform operation
"500":
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
description: Unexpected error occurred
security:
- Bearer: []
summary: Returns a list of resourcebundles
/api/maestro/v1/consumers:
get:
parameters:
Expand Down Expand Up @@ -788,6 +898,14 @@ components:
update_strategy:
type: object
type: object
ResourceBundleList:
allOf:
- $ref: '#/components/schemas/List'
- $ref: '#/components/schemas/ResourceBundleList_allOf'
ResourceBundle:
allOf:
- $ref: '#/components/schemas/ObjectReference'
- $ref: '#/components/schemas/ResourceBundle_allOf'
Consumer:
allOf:
- $ref: '#/components/schemas/ObjectReference'
Expand Down Expand Up @@ -856,6 +974,42 @@ components:
type: array
type: object
example: null
ResourceBundleList_allOf:
properties:
items:
items:
$ref: '#/components/schemas/ResourceBundle'
type: array
type: object
example: null
ResourceBundle_allOf:
properties:
name:
type: string
consumer_name:
type: string
version:
type: integer
created_at:
format: date-time
type: string
updated_at:
format: date-time
type: string
manifests:
items:
type: object
type: array
delete_option:
type: object
manifest_configs:
items:
type: object
type: array
status:
type: object
type: object
example: null
Consumer_allOf:
properties:
name:
Expand Down
Loading

0 comments on commit 991a08a

Please sign in to comment.