Skip to content

Commit

Permalink
disable resource api.
Browse files Browse the repository at this point in the history
Signed-off-by: morvencao <[email protected]>
  • Loading branch information
morvencao committed Feb 19, 2025
1 parent adb7e90 commit 9858b42
Show file tree
Hide file tree
Showing 54 changed files with 1,554 additions and 5,445 deletions.
3 changes: 1 addition & 2 deletions cmd/maestro/server/grpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,6 @@ func decodeResourceSpec(evt *ce.Event) (*api.Resource, error) {
return nil, fmt.Errorf("failed to convert cloudevent to resource payload: %v", err)
}
resource.Payload = payload
// set the resource type to bundle from grpc source
resource.Type = api.ResourceTypeBundle

return resource, nil
}
Expand All @@ -337,6 +335,7 @@ func encodeResourceStatus(resource *api.Resource) (*ce.Event, error) {
return nil, err
}

// fill the resource status with resource payload
if len(resource.Payload) > 0 {
specEvt, err := api.JSONMAPToCloudEvent(resource.Payload)
if err != nil {
Expand Down
11 changes: 5 additions & 6 deletions cmd/maestro/server/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func (s *apiServer) routes() *mux.Router {
}

resourceHandler := handlers.NewResourceHandler(services.Resources(), services.Generic())
resourceBundleHandler := handlers.NewResourceBundleHandler(services.Resources(), services.Generic())
consumerHandler := handlers.NewConsumerHandler(services.Consumers(), services.Resources(), services.Generic())
errorsHandler := handlers.NewErrorsHandler()

Expand Down Expand Up @@ -71,20 +72,18 @@ func (s *apiServer) routes() *mux.Router {
apiV1ErrorsRouter.HandleFunc("", errorsHandler.List).Methods(http.MethodGet)
apiV1ErrorsRouter.HandleFunc("/{id}", errorsHandler.Get).Methods(http.MethodGet)

// /api/maestro/v1/resources
// /api/maestro/v1/resources
apiV1ResourceRouter := apiV1Router.PathPrefix("/resources").Subrouter()
apiV1ResourceRouter.HandleFunc("", resourceHandler.List).Methods(http.MethodGet)
apiV1ResourceRouter.HandleFunc("/{id}", resourceHandler.Get).Methods(http.MethodGet)
apiV1ResourceRouter.HandleFunc("", resourceHandler.Create).Methods(http.MethodPost)
apiV1ResourceRouter.HandleFunc("/{id}", resourceHandler.Patch).Methods(http.MethodPatch)
apiV1ResourceRouter.HandleFunc("/{id}", resourceHandler.Delete).Methods(http.MethodDelete)
apiV1ResourceRouter.Use(authMiddleware.AuthenticateAccountJWT)
apiV1ResourceRouter.Use(authzMiddleware.AuthorizeApi)

// /api/maestro/v1/resource-bundles
// /api/maestro/v1/resource-bundles (deprecated)
apiV1ResourceBundleRouter := apiV1Router.PathPrefix("/resource-bundles").Subrouter()
apiV1ResourceBundleRouter.HandleFunc("", resourceHandler.ListBundle).Methods(http.MethodGet)
apiV1ResourceBundleRouter.HandleFunc("/{id}", resourceHandler.GetBundle).Methods(http.MethodGet)
apiV1ResourceBundleRouter.HandleFunc("", resourceBundleHandler.List).Methods(http.MethodGet)
apiV1ResourceBundleRouter.HandleFunc("/{id}", resourceBundleHandler.Get).Methods(http.MethodGet)
apiV1ResourceBundleRouter.Use(authMiddleware.AuthenticateAccountJWT)
apiV1ResourceBundleRouter.Use(authzMiddleware.AuthorizeApi)

Expand Down
4 changes: 2 additions & 2 deletions data/generated/openapi/openapi.go

Large diffs are not rendered by default.

159 changes: 27 additions & 132 deletions openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,57 +47,9 @@ paths:
- $ref: '#/components/parameters/search'
- $ref: '#/components/parameters/orderBy'
- $ref: '#/components/parameters/fields'
post:
summary: Create a new resource
security:
- Bearer: []
requestBody:
description: Resource data
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Resource'
responses:
'201':
description: Created
content:
application/json:
schema:
$ref: '#/components/schemas/Resource'
'400':
description: Validation errors occurred
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'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'
'409':
description: Resource already exists
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: An unexpected error occurred creating the resource
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/api/maestro/v1/resources/{id}:
get:
summary: Get an resource by id
summary: Get a resource by id
security:
- Bearer: []
responses:
Expand Down Expand Up @@ -131,60 +83,8 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Error'
patch:
summary: Update an resource
security:
- Bearer: []
requestBody:
description: Updated resource data
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ResourcePatchRequest'
responses:
'200':
description: Resource updated successfully
content:
application/json:
schema:
$ref: '#/components/schemas/Resource'
'400':
description: Validation errors occurred
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'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'
'404':
description: No resource with specified id exists
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'409':
description: Resource already exists
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Unexpected error updating resource
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
parameters:
- $ref: '#/components/parameters/id'
delete:
summary: Delete a resource
security:
Expand Down Expand Up @@ -222,10 +122,11 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Error'
parameters:
- $ref: '#/components/parameters/id'
parameters:
- $ref: '#/components/parameters/id'
/api/maestro/v1/resource-bundles:
get:
deprecated: true
summary: Returns a list of resource bundles
security:
- Bearer: []
Expand Down Expand Up @@ -262,7 +163,8 @@ paths:
- $ref: '#/components/parameters/fields'
/api/maestro/v1/resource-bundles/{id}:
get:
summary: Get an resource bundle by id
deprecated: true
summary: Get a resource bundle by id
security:
- Bearer: []
responses:
Expand Down Expand Up @@ -384,7 +286,7 @@ paths:
$ref: '#/components/schemas/Error'
/api/maestro/v1/consumers/{id}:
get:
summary: Get an consumer by id
summary: Get a consumer by id
security:
- Bearer: []
responses:
Expand Down Expand Up @@ -584,14 +486,18 @@ components:
deleted_at:
type: string
format: date-time
manifest:
type: object
group_resource:
metadata:
type: object
manifests:
type: array
items:
type: object
delete_option:
type: object
update_strategy:
type: object
manifest_configs:
type: array
items:
type: object
status:
type: object
ResourceList:
Expand All @@ -603,26 +509,6 @@ components:
type: array
items:
$ref: '#/components/schemas/Resource'
ResourcePatchRequest:
type: object
properties:
version:
type: integer
manifest:
type: object
delete_option:
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'
Expand Down Expand Up @@ -657,6 +543,15 @@ components:
type: object
status:
type: object
ResourceBundleList:
allOf:
- $ref: '#/components/schemas/List'
- type: object
properties:
items:
type: array
items:
$ref: '#/components/schemas/ResourceBundle'
Consumer:
allOf:
- $ref: '#/components/schemas/ObjectReference'
Expand Down
4 changes: 0 additions & 4 deletions pkg/api/openapi/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ 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
git_push.sh
go.mod
go.sum
Expand All @@ -44,12 +42,10 @@ 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
response.go
test/api_default_test.go
utils.go
10 changes: 3 additions & 7 deletions pkg/api/openapi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,14 @@ Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*DefaultApi* | [**ApiMaestroV1ConsumersGet**](docs/DefaultApi.md#apimaestrov1consumersget) | **Get** /api/maestro/v1/consumers | Returns a list of consumers
*DefaultApi* | [**ApiMaestroV1ConsumersIdDelete**](docs/DefaultApi.md#apimaestrov1consumersiddelete) | **Delete** /api/maestro/v1/consumers/{id} | Delete a consumer
*DefaultApi* | [**ApiMaestroV1ConsumersIdGet**](docs/DefaultApi.md#apimaestrov1consumersidget) | **Get** /api/maestro/v1/consumers/{id} | Get an consumer by id
*DefaultApi* | [**ApiMaestroV1ConsumersIdGet**](docs/DefaultApi.md#apimaestrov1consumersidget) | **Get** /api/maestro/v1/consumers/{id} | Get a 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/resource-bundles | Returns a list of resource bundles
*DefaultApi* | [**ApiMaestroV1ResourceBundlesIdGet**](docs/DefaultApi.md#apimaestrov1resourcebundlesidget) | **Get** /api/maestro/v1/resource-bundles/{id} | Get an resource bundle by id
*DefaultApi* | [**ApiMaestroV1ResourceBundlesIdGet**](docs/DefaultApi.md#apimaestrov1resourcebundlesidget) | **Get** /api/maestro/v1/resource-bundles/{id} | Get a resource bundle by id
*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
*DefaultApi* | [**ApiMaestroV1ResourcesIdPatch**](docs/DefaultApi.md#apimaestrov1resourcesidpatch) | **Patch** /api/maestro/v1/resources/{id} | Update an resource
*DefaultApi* | [**ApiMaestroV1ResourcesPost**](docs/DefaultApi.md#apimaestrov1resourcespost) | **Post** /api/maestro/v1/resources | Create a new resource
*DefaultApi* | [**ApiMaestroV1ResourcesIdGet**](docs/DefaultApi.md#apimaestrov1resourcesidget) | **Get** /api/maestro/v1/resources/{id} | Get a resource by id


## Documentation For Models
Expand All @@ -107,12 +105,10 @@ Class | Method | HTTP request | Description
- [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)


## Documentation For Authorization
Expand Down
Loading

0 comments on commit 9858b42

Please sign in to comment.