Skip to content

feat!: Support querying organization custom roles - #3129

Merged
gmlewis merged 3 commits into
google:masterfrom
tomfeigin:handle-organization-roles
May 15, 2024
Merged

feat!: Support querying organization custom roles#3129
gmlewis merged 3 commits into
google:masterfrom
tomfeigin:handle-organization-roles

Conversation

@tomfeigin

@tomfeigintomfeigin commented Apr 16, 2024

Copy link
Copy Markdown
Contributor

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.

@codecov

codecovBot commented Apr 16, 2024

Copy link
Copy Markdown

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.
@tomfeigin
tomfeiginforce-pushed the handle-organization-roles branch from 1e8c944 to 83cac3cCompareApril 16, 2024 06:21

@gmlewisgmlewis left a comment

Copy link
Copy Markdown
Collaborator

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.

Comment threadgithub/orgs_custom_roles_test.go
@gmlewisgmlewis 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
@gmlewisgmlewis changed the title Support querying organization custom rolesfeat!: Support querying organization custom rolesApr 16, 2024
@gmlewis

Copy link
Copy Markdown
Collaborator

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

Comment threadgithub/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) {

Copy link
Copy Markdown
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, roleIDstring, opts*CreateOrUpdateOrgRoleOptions) (*CustomOrgRoles, *Response, error) {
func (s*OrganizationsService) UpdateCustomOrgRole(ctx context.Context, orgstring, roleIDint64, opts*CreateOrUpdateOrgRoleOptions) (*CustomOrgRoles, *Response, error) {

Comment threadgithub/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) {

Copy link
Copy Markdown
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, roleIDstring) (*Response, error) {
func (s*OrganizationsService) DeleteCustomOrgRole(ctx context.Context, orgstring, roleIDint64) (*Response, error) {

Copy link
Copy Markdown
ContributorAuthor

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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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 gmlewisApril 16, 2024 12:32

@gmlewisgmlewis left a comment

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
ContributorAuthor

@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?

//
//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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Copy Markdown
ContributorAuthor

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
Copy Markdown
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.

@gmlewisgmlewis left a comment

Copy link
Copy Markdown
Collaborator

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.

@gsarafgsaraf left a comment

Copy link
Copy Markdown

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
Copy Markdown
Collaborator

Thank you, @gsaraf !
Merging.

@gmlewisgmlewis removed the NeedsReview PR is awaiting a review before merging. label May 15, 2024
@gmlewis
gmlewis merged commit 4b16015 into google:masterMay 15, 2024
jlaportebot added a commit to jlaportebot/go-github that referenced this pull request Jun 28, 2026
BREAKING CHANGE: `CreateOrUpdateCustomRoleOptions` has been renamed to `CreateOrUpdateCustomRepoRoleOptions` and `roleID` has been changed from type `string` to `int64`.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Breaking API ChangePR 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

@tomfeigin@gmlewis@gsaraf