MM-32396 Create endpoint for listing all the roles (#16988)
* Create an endpoint for listing roles * Add function to client model * Create tests for listing roles endpoint * Apply code review suggestions * Restore GetAllRoles app method * Use AppContext instead of App * Minor fix * Refactor according to new changes Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
25257d6ef6
Коммит
e70c5a605a
@@ -6483,6 +6483,20 @@ func (c *Client4) DownloadJob(jobId string) ([]byte, *Response, error) {
|
||||
|
||||
// Roles Section
|
||||
|
||||
// GetAllRoles returns a list of all the roles.
|
||||
func (c *Client4) GetAllRoles() ([]*Role, *Response, error) {
|
||||
r, err := c.DoAPIGet(c.rolesRoute(), "")
|
||||
if err != nil {
|
||||
return nil, BuildResponse(r), err
|
||||
}
|
||||
defer closeBody(r)
|
||||
var list []*Role
|
||||
if jsonErr := json.NewDecoder(r.Body).Decode(&list); jsonErr != nil {
|
||||
return nil, nil, NewAppError("GetAllRoles", "api.unmarshal_error", nil, jsonErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
return list, BuildResponse(r), nil
|
||||
}
|
||||
|
||||
// GetRole gets a single role by ID.
|
||||
func (c *Client4) GetRole(id string) (*Role, *Response, error) {
|
||||
r, err := c.DoAPIGet(c.rolesRoute()+fmt.Sprintf("/%v", id), "")
|
||||
|
||||
Ссылка в новой задаче
Block a user