Skip to content

Need a way to list custom roles for organizations #2327

Closed

Description

@btsteve

It would be great to have a way to list custom roles create in an organization.

Activity

  1. gmlewis commented on Apr 7, 2022

    @gmlewis
    Collaborator

    Can the GitHub v3 API do that?
    If so, this repo (which is a Go client for the GitHub v3 API) should be able to.

    Are you talking about this?
    https://docs.github.com/en/rest/reference/orgs#custom-repository-roles

    If so, yes. Would you like to submit a PR, or would you like me to open this issue up to any of our contributors to work on?

  2. btsteve commented on Apr 7, 2022

    @btsteve
    Author

    Yes that is what i am talking about. I don't think i know enough go to add it.

  3. gmlewis commented on Apr 7, 2022

    @gmlewis
    Collaborator

    Yes that is what i am talking about. I don't think i know enough go to add it.

    No problem, thank you, @btsteve , for the report.

    This would be a great PR for any new contributor to this repo or a new Go developer.
    All contributions are greatly appreciated!

    Feel free to volunteer for any issue and the issue can be assigned to you so that others don't attempt to duplicate the work.

    Please check out our CONTRIBUTING.md guide to get started. (In particular, please remember to go generate ./... and don't use force-push to your PRs.)

    Thank you!

  4. tamboliasir1 commented on Apr 8, 2022

    @tamboliasir1
    Contributor

    Hi @gmlewis I'm new contributor. Can you give me little bit of insights like from where can I start and what should I know to get it right. Thanks.

  5. gmlewis commented on Apr 8, 2022

    @gmlewis
    Collaborator

    Hi @gmlewis I'm new contributor. Can you give me little bit of insights like from where can I start and what should I know to get it right. Thanks.

    Hi @tamboliasir1 , and welcome to this repo. 😄

    We try as much as possible to make this repo welcoming to new contributors, and as such, we have attempted to document valuable information in our CONTRIBUTING.md guide... if you feel there are any omissions or corrections needed, PRs are welcome. 😄

    As for this specific issue, and whenever implementing new endpoints, it is a great idea to browse around, both in the code, and also in past (successfully closed) PRs, to see how new features like this have been added, and base your solution on well-known and working past solutions.

    If you still have questions after that, please try to be as specific as possible, and I will attempt to help out.
    Best wishes to you, and thank you in advance for your contributions!

  6. tamboliasir1 commented on Apr 8, 2022

    @tamboliasir1
    Contributor

    Got it.. Thank you @gmlewis I would love to give it a try.. Can you please assign it to me?

  7. gmlewis commented on Apr 8, 2022

    @gmlewis
    Collaborator

    Got it.. Thank you @gmlewis I would love to give it a try.. Can you please assign it to me?

    Awesome, @tamboliasir1 ! It is yours. 😄

  8. tamboliasir1 commented on Apr 10, 2022

    @tamboliasir1
    Contributor

    Hi @gmlewis Please correct me if my proposed solution is wrong

    1. I need to create new file org_custom_role.go
    2. Create new endpoint ListCustomRole
    3. Send request to /organizations/{organization_id}/custom_roles
    4. Return roles
  9. btsteve commented on Apr 10, 2022

    @btsteve
    Author

    For those of us following along at home does this look remotely close to the correct answer?
    I am not sure how to test this locally.

    package github
    
    import (
    	"context"
    	"fmt"
    )
    
    type OrginizationCustomeRoles struct {
    	TotalCount  int `json:"total_count"`
    	CustomRoles []struct {
    		ID   int    `json:"id"`
    		Name string `json:"name"`
    	} `json:"custom_roles"`
    }
    
    type CustomRolesListOptions struct {
    	ListOptions
    }
    
    // List Custome Roles in Org
    //
    // GitHub API docs: https://docs.github.com/en/rest/reference/orgs#custom-repository-roles
    func (s *OrganizationsService) ListCustomRole(ctx context.Context, org string, opts *CustomRolesListOptions) (*OrginizationCustomeRoles, *Response, error) {
    	u := fmt.Sprintf("organizations/%v/custom_roles", org)
    	u, err := addOptions(u, opts)
    	if err != nil {
    		return nil, nil, err
    	}
    
    	req, err := s.client.NewRequest("GET", u, nil)
    	if err != nil {
    		return nil, nil, err
    	}
    
    	// TODO: remove custom Accept header when this API fully launches.
    	req.Header.Set("Accept", mediaTypeProjectsPreview)
    
    	var custome_roles *OrginizationCustomeRoles
    	resp, err := s.client.Do(ctx, req, &custome_roles)
    	if err != nil {
    		return nil, resp, err
    	}
    
    	return custome_roles, resp, nil
    }
  10. gmlewis commented on Apr 11, 2022

    @gmlewis
    Collaborator

    Hi @gmlewis Please correct me if my proposed solution is wrong

    1. I need to create new file org_custom_role.go
    2. Create new endpoint ListCustomRole
    3. Send request to /organizations/{organization_id}/custom_roles
    4. Return roles

    That seems like a good plan, @tamboliasir1 - the only things I would change at this point, probably, are to make the "role" plural ("roles") both in step 1 and step 2 above.

  11. gmlewis commented on Apr 11, 2022

    @gmlewis
    Collaborator

    For those of us following along at home does this look remotely close to the correct answer?

    Thanks, @btsteve - that is a good start, but does have some minor issues. Let's allow @tamboliasir1 to put together a PR, and then we will do an actual code review on the PR, which is much easier than a code review on a discussion thread. 😄

  12. gmlewis commented on Apr 11, 2022

    @gmlewis
    Collaborator

    That seems like a good plan, @tamboliasir1 - the only things I would change at this point, probably, are to make the "role" plural ("roles") both in step 1 and step 2 above.

    @tamboliasir1 - note that I meant to mention that unit tests need to be added for every new endpoint, following the current pattern found in the repo.

  13. tamboliasir1 commented on Apr 12, 2022

    @tamboliasir1
    Contributor

    Sure @gmlewis Thanks for guidance. Will raise a PR soon.

  14. tamboliasir1 commented on Apr 18, 2022

    @tamboliasir1
    Contributor

    Hi @gmlewis I have raised a PR for the same. Can you please review the code. Thank you for this opportunity.

  15. added a commit that references this issue on Apr 26, 2022
    448e04d
  16. added a commit that references this issue on Jun 28, 2026
    2f61410
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions