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

feat!: Support querying organization custom roles #3129

Merged
merged 3 commits into from
May 15, 2024

Conversation

tomfeigin
Copy link
Contributor

@tomfeigin tomfeigin commented Apr 16, 2024

Added support for querying, creating, updating and deleting organization custom roles.

BREAKING CHANGE: CreateOrUpdateCustomRoleOptions has been renamed to CreateOrUpdateCustomRepoRoleOptions and roleID has been changed from type string to int64.

Copy link

codecov bot commented Apr 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.90%. Comparing base (2b8c7fa) to head (1c5ad01).
Report is 41 commits behind head on master.

❗ Current head 1c5ad01 differs from pull request most recent head 41c96d8. Consider uploading reports for the commit 41c96d8 to get more accurate results

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.
📢 Have feedback on the report? Share it here.

Added support for querying, creating, updating and deleting organization
custom roles.
Copy link
Collaborator

@gmlewis gmlewis left a 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.

github/orgs_custom_roles_test.go Show resolved Hide resolved
@gmlewis gmlewis added NeedsReview PR is awaiting a review before merging. Breaking API Change PR will require a bump to the major version num in next release. Look here to see the change(s). labels Apr 16, 2024
@gmlewis gmlewis changed the title Support querying organization custom roles feat!: Support querying organization custom roles Apr 16, 2024
@gmlewis
Copy link
Collaborator

gmlewis commented Apr 16, 2024

(Also, there is no need to force push in this repo - we always squash&merge - see CONTRIBUTING.md for details.)

// 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) {
Copy link
Collaborator

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.

Suggested change
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 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) {
Copy link
Collaborator

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

Suggested change
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) {

Copy link
Contributor Author

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

Copy link
Collaborator

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?

Copy link
Contributor Author

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

@tomfeigin tomfeigin requested a review from gmlewis April 16, 2024 12:32
Copy link
Collaborator

@gmlewis gmlewis left a 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.

@tomfeigin
Copy link
Contributor Author

@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) {
Copy link
Collaborator

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?

Copy link
Contributor Author

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?

Copy link
Contributor Author

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

Copy link
Collaborator

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.

Copy link
Collaborator

@gmlewis gmlewis left a 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.

Copy link

@gsaraf gsaraf left a 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 :)

@gmlewis
Copy link
Collaborator

gmlewis commented May 15, 2024

Thank you, @gsaraf !
Merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking API Change PR will require a bump to the major version num in next release. Look here to see the change(s).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants