diff --git a/api/system/spec.json b/api/system/spec.json index e4ec148ce..2cba74c5e 100644 --- a/api/system/spec.json +++ b/api/system/spec.json @@ -580,7 +580,7 @@ ], "apis": [ { - "name": "get", + "name": "read", "path": "/{roleID}/rules", "method": "GET", "title": "Retrieve role permissions", diff --git a/api/system/spec/permission.json b/api/system/spec/permission.json index cf88ac968..84ff95547 100644 --- a/api/system/spec/permission.json +++ b/api/system/spec/permission.json @@ -17,7 +17,7 @@ "Path": "/permissions", "APIs": [ { - "Name": "get", + "Name": "read", "Method": "GET", "Title": "Retrieve role permissions", "Path": "/{roleID}/rules", diff --git a/system/rest/handlers/permission.go b/system/rest/handlers/permission.go index bd1fdb14f..2b6977839 100644 --- a/system/rest/handlers/permission.go +++ b/system/rest/handlers/permission.go @@ -27,25 +27,25 @@ import ( // Internal API interface type PermissionAPI interface { - Get(context.Context, *request.PermissionGet) (interface{}, error) + Read(context.Context, *request.PermissionRead) (interface{}, error) Delete(context.Context, *request.PermissionDelete) (interface{}, error) Update(context.Context, *request.PermissionUpdate) (interface{}, error) } // HTTP API interface type Permission struct { - Get func(http.ResponseWriter, *http.Request) + Read func(http.ResponseWriter, *http.Request) Delete func(http.ResponseWriter, *http.Request) Update func(http.ResponseWriter, *http.Request) } func NewPermission(ph PermissionAPI) *Permission { return &Permission{ - Get: func(w http.ResponseWriter, r *http.Request) { + Read: func(w http.ResponseWriter, r *http.Request) { defer r.Body.Close() - params := request.NewPermissionGet() + params := request.NewPermissionRead() resputil.JSON(w, params.Fill(r), func() (interface{}, error) { - return ph.Get(r.Context(), params) + return ph.Read(r.Context(), params) }) }, Delete: func(w http.ResponseWriter, r *http.Request) { @@ -69,7 +69,7 @@ func (ph *Permission) MountRoutes(r chi.Router, middlewares ...func(http.Handler r.Group(func(r chi.Router) { r.Use(middlewares...) r.Route("/permissions", func(r chi.Router) { - r.Get("/{roleID}/rules", ph.Get) + r.Get("/{roleID}/rules", ph.Read) r.Delete("/{roleID}/rules", ph.Delete) r.Patch("/{roleID}/rules", ph.Update) }) diff --git a/system/rest/permission.go b/system/rest/permission.go index e81cac387..fdc2733e7 100644 --- a/system/rest/permission.go +++ b/system/rest/permission.go @@ -25,8 +25,8 @@ func (Permission) New() *Permission { return ctrl } -func (ctrl *Permission) Get(ctx context.Context, r *request.PermissionGet) (interface{}, error) { - return ctrl.svc.perm.Get(r.RoleID) +func (ctrl *Permission) Read(ctx context.Context, r *request.PermissionRead) (interface{}, error) { + return ctrl.svc.perm.Read(r.RoleID) } func (ctrl *Permission) Delete(ctx context.Context, r *request.PermissionDelete) (interface{}, error) { diff --git a/system/rest/request/permission.go b/system/rest/request/permission.go index 36aade1c4..23fdc0c14 100644 --- a/system/rest/request/permission.go +++ b/system/rest/request/permission.go @@ -31,16 +31,16 @@ import ( var _ = chi.URLParam var _ = multipart.FileHeader{} -// Permission get request parameters -type PermissionGet struct { +// Permission read request parameters +type PermissionRead struct { RoleID uint64 `json:",string"` } -func NewPermissionGet() *PermissionGet { - return &PermissionGet{} +func NewPermissionRead() *PermissionRead { + return &PermissionRead{} } -func (pe *PermissionGet) Fill(r *http.Request) (err error) { +func (pe *PermissionRead) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(pe) @@ -72,7 +72,7 @@ func (pe *PermissionGet) Fill(r *http.Request) (err error) { return err } -var _ RequestFiller = NewPermissionGet() +var _ RequestFiller = NewPermissionRead() // Permission delete request parameters type PermissionDelete struct { diff --git a/system/service/permission.go b/system/service/permission.go index 004c1725b..4c9effbd6 100644 --- a/system/service/permission.go +++ b/system/service/permission.go @@ -18,7 +18,7 @@ type ( PermissionService interface { With(ctx context.Context) PermissionService - Get(roleID uint64) (interface{}, error) + Read(roleID uint64) (interface{}, error) Update(roleID uint64, rules []rules.Rule) (interface{}, error) Delete(roleID uint64) (interface{}, error) } @@ -38,7 +38,7 @@ func (p *permission) With(ctx context.Context) PermissionService { } } -func (p *permission) Get(roleID uint64) (interface{}, error) { +func (p *permission) Read(roleID uint64) (interface{}, error) { return p.resources.List(roleID) } diff --git a/system/service/permission_test.go b/system/service/permission_test.go index ade3022fc..d619e4bac 100644 --- a/system/service/permission_test.go +++ b/system/service/permission_test.go @@ -93,7 +93,7 @@ func TestPermission(t *testing.T) { // List rules for test role. { - ret, err := permissionSvc.Get(role.ID) + ret, err := permissionSvc.Read(role.ID) NoError(t, err, "expected no error, setting rules") rules := ret.([]rules.Rule) @@ -109,7 +109,7 @@ func TestPermission(t *testing.T) { // List rules for test role. { - ret, err := permissionSvc.Get(role.ID) + ret, err := permissionSvc.Read(role.ID) NoError(t, err, "expected no error, setting rules") rules := ret.([]rules.Rule)