-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Need a way to list custom roles for organizations #2327
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
Comments
Can the GitHub v3 API do that? Are you talking about this? 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? |
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. 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 Thank you! |
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. |
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. 😄 |
Hi @gmlewis Please correct me if my proposed solution is wrong
|
For those of us following along at home does this look remotely close to the correct answer? 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
} |
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. |
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. 😄 |
@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. |
Sure @gmlewis Thanks for guidance. Will raise a PR soon. |
Hi @gmlewis I have raised a PR for the same. Can you please review the code. Thank you for this opportunity. |
It would be great to have a way to list custom roles create in an organization.
The text was updated successfully, but these errors were encountered: