-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
feat!: Support querying organization custom roles #3129
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3129 +/- ##
==========================================
- Coverage 97.72% 92.90% -4.82%
==========================================
Files 153 170 +17
Lines 13390 11463 -1927
==========================================
- Hits 13085 10650 -2435
- Misses 215 723 +508
Partials 90 90 ☔ View full report in Codecov by Sentry. |
Added support for querying, creating, updating and deleting organization custom roles.
1e8c944
to
83cac3c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @tomfeigin !
Just one addition, please, then I think we will be ready for a second LGTM+Approval before merging.
(Also, there is no need to force push in this repo - we always squash&merge - see CONTRIBUTING.md for details.) |
github/orgs_custom_roles.go
Outdated
// GitHub API docs: https://docs.github.com/rest/orgs/organization-roles#update-a-custom-organization-role | ||
// | ||
//meta:operation PATCH /orgs/{org}/organization-roles/{role_id} | ||
func (s *OrganizationsService) UpdateCustomOrgRole(ctx context.Context, org, roleID string, opts *CreateOrUpdateOrgRoleOptions) (*CustomOrgRoles, *Response, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to: https://docs.github.com/en/rest/orgs/organization-roles?apiVersion=2022-11-28#update-a-custom-organization-role
roleID
should be an integer.
func (s *OrganizationsService) UpdateCustomOrgRole(ctx context.Context, org, roleID string, opts *CreateOrUpdateOrgRoleOptions) (*CustomOrgRoles, *Response, error) { | |
func (s *OrganizationsService) UpdateCustomOrgRole(ctx context.Context, org string, roleID int64, opts *CreateOrUpdateOrgRoleOptions) (*CustomOrgRoles, *Response, error) { |
github/orgs_custom_roles.go
Outdated
// GitHub API docs: https://docs.github.com/rest/orgs/organization-roles#delete-a-custom-organization-role | ||
// | ||
//meta:operation DELETE /orgs/{org}/organization-roles/{role_id} | ||
func (s *OrganizationsService) DeleteCustomOrgRole(ctx context.Context, org, roleID string) (*Response, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here: https://docs.github.com/rest/orgs/organization-roles#delete-a-custom-organization-role
func (s *OrganizationsService) DeleteCustomOrgRole(ctx context.Context, org, roleID string) (*Response, error) { | |
func (s *OrganizationsService) DeleteCustomOrgRole(ctx context.Context, org string, roleID int64) (*Response, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll change it but it is aligned with DeleteCustomRepoRole
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, bummer. Looks like I didn't catch it before on the other one. 😞
Well, since this is already a breaking API change, do you want to go ahead and make it consistent and fix the older one(s) too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to do that in another PR because here I am just introducing new stuff so it won't break existing usage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @tomfeigin !
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.
@gmlewis this specific PR is not a breaking a change as it only introduces new API wrappers (I am pretty sure 🙃 ) can you remove the label please? |
// CreateCustomRepoRole creates a custom repository role in this organization. | ||
// In order to create custom repository roles in an organization, the authenticated user must be an organization owner. | ||
// | ||
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/orgs/custom-roles#create-a-custom-repository-role | ||
// | ||
//meta:operation POST /orgs/{org}/custom-repository-roles | ||
func (s *OrganizationsService) CreateCustomRepoRole(ctx context.Context, org string, opts *CreateOrUpdateCustomRoleOptions) (*CustomRepoRoles, *Response, error) { | ||
func (s *OrganizationsService) CreateCustomRepoRole(ctx context.Context, org string, opts *CreateOrUpdateCustomRepoRoleOptions) (*CustomRepoRoles, *Response, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tomfeigin - if I'm not mistaken, this line and line 203 below are both breaking API changes, as code written by a user of this repo that calls one or both of these endpoints will no longer compile correctly without changing their code. Agreed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh you are right, should I keep the previous naming then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's just have the breaking change, I'll fix the other APIs to use the int64 ID
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, honestly I don't have a problem making breaking API changes, which I suppose might be obvious from the current version number of this repo. 😂
Also, I think it is always a good idea to make things clearer and easier-to-understand for users of this repo... so I think your name change here was perfectly appropriate and that's also why I recommended fixing the bad field type while we are making a breaking API change.
So I'll leave it up to you, but I think the breaking API change is appropriate and am willing to move forward with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @tomfeigin !
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me :)
Thank you, @gsaraf ! |
Added support for querying, creating, updating and deleting organization custom roles.
BREAKING CHANGE:
CreateOrUpdateCustomRoleOptions
has been renamed toCreateOrUpdateCustomRepoRoleOptions
androleID
has been changed from typestring
toint64
.