Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renaming and expanding on the getRoles methods #139

Open
jpastoor opened this issue Aug 18, 2016 · 5 comments
Open

Renaming and expanding on the getRoles methods #139

jpastoor opened this issue Aug 18, 2016 · 5 comments

Comments

@jpastoor
Copy link
Collaborator

jpastoor commented Aug 18, 2016

This is were it gets a bit wonky :)

There are 2 types of Roles, Project Roles and Application Roles. Currently we only have support for Project Roles.

Project Roles can be fetched on 2 levels, using the global API call and one on a project layer.
https://docs.atlassian.com/jira/REST/cloud/#api/2/role-getProjectRoles
https://docs.atlassian.com/jira/REST/cloud/#api/2/project/{projectIdOrKey}/role-getProjectRoles

Im proposing to:

  • Rename Api::getRoles to Api::getProjectRoles and Api::getRoleDetails to Api::getProjectRolesById
  • Deprecate the old method names
  • Add Api::getProjectRolesOfProject call for getting Project Roles of a specific project
  • Add Api::getProjectRoleOfProjectById call for getting a specific Project Role of a specific project
@jpastoor
Copy link
Collaborator Author

Already written the code but leaving it open for discussion first

    /**
     * Returns all roles.
     *
     * @return array|false
     */
    public function getProjectRoles()
    {
        return $this->api(self::REQUEST_GET, '/rest/api/2/role');
    }

    /**
     * Returns role details.
     *
     * @param string $role_id Role ID.
     *
     * @return array|false
     */
    public function getProjectRoleById($role_id)
    {
        return $this->api(self::REQUEST_GET, sprintf('/rest/api/2/role/%s', $role_id));
    }

    /**
     * Returns all roles of a project.
     *
     * @param string $project_id_or_key Project ID or key.
     *
     * @return array|false
     */
    public function getProjectRolesOfProject($project_id_or_key)
    {
        return $this->api(self::REQUEST_GET, sprintf('/rest/api/2/project/%s/role', $project_id_or_key));
    }

    /**
     * Returns role details.
     *
     * @param string $project_id_or_key Project ID or key.
     * @param string $role_id           Role ID.
     *
     * @return array|false
     */
    public function getProjectRoleOfProjectById($project_id_or_key, $role_id)
    {
        return $this->api(self::REQUEST_GET, sprintf('/rest/api/2/project/%s/role/%s', $project_id_or_key, $role_id));
    }

@jpastoor
Copy link
Collaborator Author

Also noticed that there is quite a difference between the output of the two portal role list calls. The one called on a project returns far less data

{
    "Administrators": "http://www.example.com/jira/rest/api/2/project/MKY/role/10002",
    "Users": "http://www.example.com/jira/rest/api/2/project/MKY/role/10001",
    "Developers": "http://www.example.com/jira/rest/api/2/project/MKY/role/10000"
}

@aik099
Copy link
Collaborator

aik099 commented Aug 18, 2016

#139 (comment)

Don't see any difference.

There are 2 types of Roles, Portal Roles and Application Roles. Currently we only have support for Portal Roles.

Portal roles. First time I hear about them. Are you sure this isn't a mistake. The mentioned links also doesn't use portal word.

@jpastoor
Copy link
Collaborator Author

Oh replace everywhere I said Portal with Project
I will update my original post and you can remove yours and this to not clutter the discussion if you like/

@aik099
Copy link
Collaborator

aik099 commented Aug 18, 2016

Better to send a PR so that we can comment on actual code. I see you mention project and application roles, but no methods added to access application roles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants