-
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.38% 91.79% -0.60%
==========================================
Files 196 197 +1
Lines 14094 17645 +3551
==========================================
+ Hits 13021 16197 +3176
- Misses 884 1259 +375
Partials 189 189 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Use EnterpriseService instead of creating new service - Add EnterpriseInstallationRepositoriesOptions for consistency - Update method signatures to Required
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
| // 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) (*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) ToggleInstallationRepositories(ctx context.Context, enterprise, org string, installationID int64, opts *EnterpriseInstallationRepositoriesToggleOptions) (*ListRepositories, *Response, error) { | |
| func (s *EnterpriseService) ToggleInstallationRepositories(ctx context.Context, enterprise, org string, installationID int64, opts EnterpriseInstallationRepositoriesToggleOptions) (*ListRepositories, *Response, error) { |
| // 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) (*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.
This endpoint return this response
{
"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"
]
}
}But the function currently returns ListRepositories, which has this struct:
type ListRepositories struct {
TotalCount *int `json:"total_count,omitempty"`
Repositories []*Repository `json:"repositories"`
}I made a struct named AccessibleRepository in PR #3830, you can re-use it and update this function to return []*AccessibleRepository once my PR is merged.
| // 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) (*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.
This endpoint does not return a schema similar to ListRepositories.
| func (s *EnterpriseService) ToggleInstallationRepositories(ctx context.Context, enterprise, org string, installationID int64, opts *EnterpriseInstallationRepositoriesToggleOptions) (*ListRepositories, *Response, error) { | |
| func (s *EnterpriseService) ToggleInstallationRepositories(ctx context.Context, enterprise, org string, installationID int64, opts *EnterpriseInstallationRepositoriesToggleOptions) (*Installation, *Response, error) { |
| // 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.
same here, it should return []*AccessibleRepository (the struct is in my PR, which hasn’t been merged yet).
| // 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.
same here, it should return []*AccessibleRepository (the struct is in my PR, which hasn’t been merged yet).
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