basicly implement acl crud ops with roles and resources
This commit is contained in:
94
api/acl_admin/resources_models.go
Normal file
94
api/acl_admin/resources_models.go
Normal file
@@ -0,0 +1,94 @@
|
||||
package api_acladmin
|
||||
|
||||
/*******************************************************************/
|
||||
// used in getResources()
|
||||
type getResourcesResponse []struct {
|
||||
ID uint `json:"id" example:"1"`
|
||||
Key string `json:"key" example:"html.view"`
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
// used in getResource()
|
||||
type getResourceResponse struct {
|
||||
ID uint `json:"id" example:"1"`
|
||||
Key string `json:"key" example:"html.view"`
|
||||
}
|
||||
|
||||
type getResourceErrorInvalidResourceID struct {
|
||||
Error string `json:"error" example:"INVALID_RESOURCE_ID"`
|
||||
Details string `json:"details" example:"Resource ID must be positive integer"`
|
||||
}
|
||||
|
||||
type getResourceErrorResourceNotFound struct {
|
||||
Error string `json:"error" example:"RESOURCE_NOT_FOUND"`
|
||||
Details string `json:"details" example:"No resource with ID 123"`
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
// used in createResource()
|
||||
type createResourceRequest struct {
|
||||
Key string `json:"key" example:"html.view"`
|
||||
}
|
||||
|
||||
type createResourceResponse struct {
|
||||
ID uint `json:"id" example:"1"`
|
||||
Key string `json:"key" example:"html.view"`
|
||||
}
|
||||
|
||||
type createResourceErrorResourceAlreadyExists struct {
|
||||
Error string `json:"error" example:"FAILED_TO_CREATE_RESOURCE"`
|
||||
Details string `json:"details" example:"Resource with key 'html.view' already exists"`
|
||||
}
|
||||
|
||||
type createResourceErrorInvalidResourceKey struct {
|
||||
Error string `json:"error" example:"FAILED_TO_CREATE_RESOURCE"`
|
||||
Details string `json:"details" example:"Invalid resource key"`
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
// used in updateResource()
|
||||
type updateResourceRequest struct {
|
||||
Key string `json:"key" example:"html.view"`
|
||||
}
|
||||
|
||||
type updateResourceResponse struct {
|
||||
ID uint `json:"id" example:"1"`
|
||||
Key string `json:"key" example:"html.view"`
|
||||
}
|
||||
|
||||
type updateResourceErrorResourceNotFound struct {
|
||||
Error string `json:"error" example:"RESOURCE_NOT_FOUND"`
|
||||
Details string `json:"details" example:"No resource with ID 123"`
|
||||
}
|
||||
|
||||
type updateResourceErrorInvalidResourceID struct {
|
||||
Error string `json:"error" example:"INVALID_RESOURCE_ID"`
|
||||
Details string `json:"details" example:"Resource ID must be positive integer"`
|
||||
}
|
||||
|
||||
type updateResourceErrorInvalidResourceKey struct {
|
||||
Error string `json:"error" example:"FAILED_TO_UPDATE_RESOURCE"`
|
||||
Details string `json:"details" example:"Invalid resource key"`
|
||||
}
|
||||
|
||||
type updateResourceErrorResourceKeyAlreadyExists struct {
|
||||
Error string `json:"error" example:"FAILED_TO_UPDATE_RESOURCE"`
|
||||
Details string `json:"details" example:"Resource with key 'html.view' already exists"`
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
// used in deleteResource()
|
||||
type deleteResourceErrorResourceNotFound struct {
|
||||
Error string `json:"error" example:"RESOURCE_NOT_FOUND"`
|
||||
Details string `json:"details" example:"No resource with ID 123"`
|
||||
}
|
||||
|
||||
type deleteResourceErrorInvalidResourceID struct {
|
||||
Error string `json:"error" example:"INVALID_RESOURCE_ID"`
|
||||
Details string `json:"details" example:"Resource ID must be positive integer"`
|
||||
}
|
||||
|
||||
type deleteResourceErrorResourceInUse struct {
|
||||
Error string `json:"error" example:"FAILED_TO_DELETE_RESOURCE"`
|
||||
Details string `json:"details" example:"Resource with ID 123 is used and cannot be deleted"`
|
||||
}
|
||||
Reference in New Issue
Block a user