chobie / jira-api-restclient

php JIRA REST API
MIT License
217 stars 123 forks source link

Renaming and expanding on the getRoles methods #139

Open jpastoor opened 8 years ago

jpastoor commented 8 years ago

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:

jpastoor commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

https://github.com/chobie/jira-api-restclient/issues/139#issuecomment-240838304

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 commented 8 years ago

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 commented 8 years ago

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.