-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat: Add GitHub Enterprise App installation repository management APIs #3831
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
base: master
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3831 +/- ##
==========================================
+ Coverage 92.41% 92.44% +0.02%
==========================================
Files 197 198 +1
Lines 14152 14195 +43
==========================================
+ Hits 13079 13122 +43
Misses 884 884
Partials 189 189 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
gmlewis
left a comment
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, @nithish-95!
One minor tweak, please, then we should be ready to merge after a second LGTM+Approval from any other contributor to this repo.
cc: @stevehipwell - @alexandear - @zyfy29
- Use EnterpriseService instead of creating new service - Add EnterpriseInstallationRepositoriesOptions for consistency - Update method signatures to Required
…orOrgInstallation` to return a slice of it
915cfbf to
da913d0
Compare
…tead of ListRepositories and adjust its test expectations.
0173838 to
1a69bbf
Compare
|
I've rebased on master to use the existing AccessibleRepository struct and removed the duplicate definition from this PR. I feel sorry for the way I use Git!! |
gmlewis
left a comment
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, @nithish-95!
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.
cc: @stevehipwell - @alexandear - @zyfy29 - @Not-Dhananjay-Mishra
| // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/organization-installations#grant-repository-access-to-an-organization-installation | ||
| // | ||
| //meta:operation PATCH /enterprises/{enterprise}/apps/organizations/{org}/installations/{installation_id}/repositories/add | ||
| func (s *EnterpriseService) AddRepositoriesToInstallation(ctx context.Context, enterprise, org string, installationID int64, opts EnterpriseInstallationRepositoriesOptions) (*ListRepositories, *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.
| func (s *EnterpriseService) AddRepositoriesToInstallation(ctx context.Context, enterprise, org string, installationID int64, opts EnterpriseInstallationRepositoriesOptions) (*ListRepositories, *Response, error) { | |
| func (s *EnterpriseService) AddRepositoriesToInstallation(ctx context.Context, enterprise, org string, installationID int64, opts EnterpriseInstallationRepositoriesOptions) ([]*AccessibleRepository, *Response, error) { |
/enterprises/{enterprise}/apps/organizations/{org}/installations/{installation_id}/repositories/add
This endpoint has this response schema
{
"type": "array",
"items": {
"title": "Accessible Repository",
"description": "A repository that may be made accessible to a GitHub App.",
"type": "object",
"properties": {
"id": {
"description": "Unique identifier of the repository",
"type": "integer",
"format": "int64",
"examples": [
1
]
},
"name": {
"description": "The name of the repository.",
"type": "string",
"examples": [
"Team Environment"
]
},
"full_name": {
"type": "string",
"examples": [
"octocat/Hello-World"
]
}
},
"required": [
"full_name",
"id",
"name"
]
}
}It should retrun []*AccessibleRepository not *ListRepositories
type AccessibleRepository struct {
ID int64 `json:"id"`
Name string `json:"name"`
FullName string `json:"full_name"`
}| // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/organization-installations#remove-repository-access-from-an-organization-installation | ||
| // | ||
| //meta:operation PATCH /enterprises/{enterprise}/apps/organizations/{org}/installations/{installation_id}/repositories/remove | ||
| func (s *EnterpriseService) RemoveRepositoriesFromInstallation(ctx context.Context, enterprise, org string, installationID int64, opts EnterpriseInstallationRepositoriesOptions) (*ListRepositories, *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.
| func (s *EnterpriseService) RemoveRepositoriesFromInstallation(ctx context.Context, enterprise, org string, installationID int64, opts EnterpriseInstallationRepositoriesOptions) (*ListRepositories, *Response, error) { | |
| func (s *EnterpriseService) RemoveRepositoriesFromInstallation(ctx context.Context, enterprise, org string, installationID int64, opts EnterpriseInstallationRepositoriesOptions) ([]*AccessibleRepository, *Response, error) { |
same here
stevehipwell
left a comment
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've added some naming suggestions, happy to discuss the "why".
| // EnterpriseInstallationRepositoriesOptions specifies the parameters for | ||
| // EnterpriseService.AddRepositoriesToInstallation and | ||
| // EnterpriseService.RemoveRepositoriesFromInstallation. | ||
| type EnterpriseInstallationRepositoriesOptions struct { | ||
| SelectedRepositoryIDs []int64 `json:"selected_repository_ids"` | ||
| } | ||
|
|
||
| // EnterpriseInstallationRepositoriesToggleOptions specifies the parameters for | ||
| // EnterpriseService.ToggleInstallationRepositories. | ||
| type EnterpriseInstallationRepositoriesToggleOptions struct { | ||
| RepositorySelection *string `json:"repository_selection,omitempty"` // Can be "all" or "selected" | ||
| SelectedRepositoryIDs []int64 `json:"selected_repository_ids,omitempty"` | ||
| } |
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.
Do these types need to be scoped to the enterprise, they look pretty generic? And should they not use AppInstallation instead of just Installation?
| // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/organization-installations#get-the-repositories-accessible-to-a-given-github-app-installation | ||
| // | ||
| //meta:operation GET /enterprises/{enterprise}/apps/organizations/{org}/installations/{installation_id}/repositories | ||
| func (s *EnterpriseService) ListRepositoriesForOrgInstallation(ctx context.Context, enterprise, org string, installationID int64, opts *ListOptions) ([]*AccessibleRepository, *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.
| func (s *EnterpriseService) ListRepositoriesForOrgInstallation(ctx context.Context, enterprise, org string, installationID int64, opts *ListOptions) ([]*AccessibleRepository, *Response, error) { | |
| func (s *EnterpriseService) ListRepositoriesForOrgAppInstallation(ctx context.Context, enterprise, org string, installationID int64, opts *ListOptions) ([]*AccessibleRepository, *Response, error) { |
| // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/organization-installations#toggle-installation-repository-access-between-selected-and-all-repositories | ||
| // | ||
| //meta:operation PATCH /enterprises/{enterprise}/apps/organizations/{org}/installations/{installation_id}/repositories | ||
| func (s *EnterpriseService) ToggleInstallationRepositories(ctx context.Context, enterprise, org string, installationID int64, opts EnterpriseInstallationRepositoriesToggleOptions) (*Installation, *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 think this would make more sense and be more consistent if it was named UpdateAppInstallationRepositories?
| // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/organization-installations#grant-repository-access-to-an-organization-installation | ||
| // | ||
| //meta:operation PATCH /enterprises/{enterprise}/apps/organizations/{org}/installations/{installation_id}/repositories/add | ||
| func (s *EnterpriseService) AddRepositoriesToInstallation(ctx context.Context, enterprise, org string, installationID int64, opts EnterpriseInstallationRepositoriesOptions) (*ListRepositories, *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.
| func (s *EnterpriseService) AddRepositoriesToInstallation(ctx context.Context, enterprise, org string, installationID int64, opts EnterpriseInstallationRepositoriesOptions) (*ListRepositories, *Response, error) { | |
| func (s *EnterpriseService) AddRepositoriesToAppInstallation(ctx context.Context, enterprise, org string, installationID int64, opts EnterpriseInstallationRepositoriesOptions) (*ListRepositories, *Response, error) { |
| // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/organization-installations#remove-repository-access-from-an-organization-installation | ||
| // | ||
| //meta:operation PATCH /enterprises/{enterprise}/apps/organizations/{org}/installations/{installation_id}/repositories/remove | ||
| func (s *EnterpriseService) RemoveRepositoriesFromInstallation(ctx context.Context, enterprise, org string, installationID int64, opts EnterpriseInstallationRepositoriesOptions) (*ListRepositories, *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.
| func (s *EnterpriseService) RemoveRepositoriesFromInstallation(ctx context.Context, enterprise, org string, installationID int64, opts EnterpriseInstallationRepositoriesOptions) (*ListRepositories, *Response, error) { | |
| func (s *EnterpriseService) RemoveRepositoriesFromAppInstallation(ctx context.Context, enterprise, org string, installationID int64, opts EnterpriseInstallationRepositoriesOptions) (*ListRepositories, *Response, error) { |
Description
Implements enterprise GitHub App installation repository management endpoints for issue #3829.
This PR adds the following endpoints:
Changes
ListRepositoriesForOrgInstallationmethod to list repositories accessible to an app installationToggleInstallationRepositoriesmethod to update repository selectionAddRepositoriesToInstallationmethod to add repositories to an installationRemoveRepositoriesFromInstallationmethod to remove repositories from an installationTesting
cc @gmlewis @Not-Dhananjay-Mishra