Skip to content

Commit 7cf7474

Browse files
Add codegen for RepositoriesService (#1800)
1 parent 94eb482 commit 7cf7474

File tree

3 files changed

+246
-4
lines changed

3 files changed

+246
-4
lines changed

github/github.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,11 @@ type Client struct {
176176
Projects *ProjectsService
177177
PullRequests *PullRequestsService
178178
Reactions *ReactionsService
179-
Repositories *RepositoriesService
180-
Search *SearchService
181-
Teams *TeamsService
182-
Users *UsersService
179+
// Repositories *RepositoriesService
180+
Repositories RepositoriesServiceInterface
181+
Search *SearchService
182+
Teams *TeamsService
183+
Users *UsersService
183184
}
184185

185186
type service struct {

github/repos.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
// methods of the GitHub API.
1717
//
1818
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/
19+
//go:generate ifacemaker -f repos.go -i RepositoriesServiceInterface -s RepositoriesService -p github -y "RepositoriesServiceInterface AUTO GENERATED DO NOT EDIT" -c "AUTO GENERATED FILE DO NOT EDIT" -o repos_generated.go
1920
type RepositoriesService service
2021

2122
// Repository represents a GitHub repository.

github/repos_generated.go

Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
// AUTO GENERATED FILE DO NOT EDIT
2+
3+
package github
4+
5+
import (
6+
"context"
7+
)
8+
9+
// RepositoriesServiceInterface AUTO GENERATED DO NOT EDIT
10+
type RepositoriesServiceInterface interface {
11+
// List the repositories for a user. Passing the empty string will list
12+
// repositories for the authenticated user.
13+
//
14+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-repositories-for-the-authenticated-user
15+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-repositories-for-a-user
16+
List(ctx context.Context, user string, opts *RepositoryListOptions) ([]*Repository, *Response, error)
17+
// ListByOrg lists the repositories for an organization.
18+
//
19+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-organization-repositories
20+
ListByOrg(ctx context.Context, org string, opts *RepositoryListByOrgOptions) ([]*Repository, *Response, error)
21+
// ListAll lists all GitHub repositories in the order that they were created.
22+
//
23+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-public-repositories
24+
ListAll(ctx context.Context, opts *RepositoryListAllOptions) ([]*Repository, *Response, error)
25+
// Create a new repository. If an organization is specified, the new
26+
// repository will be created under that org. If the empty string is
27+
// specified, it will be created for the authenticated user.
28+
//
29+
// Note that only a subset of the repo fields are used and repo must
30+
// not be nil.
31+
//
32+
// Also note that this method will return the response without actually
33+
// waiting for GitHub to finish creating the repository and letting the
34+
// changes propagate throughout its servers. You may set up a loop with
35+
// exponential back-off to verify repository's creation.
36+
//
37+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#create-a-repository-for-the-authenticated-user
38+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#create-an-organization-repository
39+
Create(ctx context.Context, org string, repo *Repository) (*Repository, *Response, error)
40+
// CreateFromTemplate generates a repository from a template.
41+
//
42+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#create-a-repository-using-a-template
43+
CreateFromTemplate(ctx context.Context, templateOwner, templateRepo string, templateRepoReq *TemplateRepoRequest) (*Repository, *Response, error)
44+
// Get fetches a repository.
45+
//
46+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-a-repository
47+
Get(ctx context.Context, owner, repo string) (*Repository, *Response, error)
48+
// GetCodeOfConduct gets the contents of a repository's code of conduct.
49+
//
50+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/codes-of-conduct/#get-the-code-of-conduct-for-a-repository
51+
GetCodeOfConduct(ctx context.Context, owner, repo string) (*CodeOfConduct, *Response, error)
52+
// GetByID fetches a repository.
53+
//
54+
// Note: GetByID uses the undocumented GitHub API endpoint /repositories/:id.
55+
GetByID(ctx context.Context, id int64) (*Repository, *Response, error)
56+
// Edit updates a repository.
57+
//
58+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#update-a-repository
59+
Edit(ctx context.Context, owner, repo string, repository *Repository) (*Repository, *Response, error)
60+
// Delete a repository.
61+
//
62+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#delete-a-repository
63+
Delete(ctx context.Context, owner, repo string) (*Response, error)
64+
// GetVulnerabilityAlerts checks if vulnerability alerts are enabled for a repository.
65+
//
66+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#check-if-vulnerability-alerts-are-enabled-for-a-repository
67+
GetVulnerabilityAlerts(ctx context.Context, owner, repository string) (bool, *Response, error)
68+
// EnableVulnerabilityAlerts enables vulnerability alerts and the dependency graph for a repository.
69+
//
70+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#enable-vulnerability-alerts
71+
EnableVulnerabilityAlerts(ctx context.Context, owner, repository string) (*Response, error)
72+
// DisableVulnerabilityAlerts disables vulnerability alerts and the dependency graph for a repository.
73+
//
74+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#disable-vulnerability-alerts
75+
DisableVulnerabilityAlerts(ctx context.Context, owner, repository string) (*Response, error)
76+
// EnableAutomatedSecurityFixes enables the automated security fixes for a repository.
77+
//
78+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#enable-automated-security-fixes
79+
EnableAutomatedSecurityFixes(ctx context.Context, owner, repository string) (*Response, error)
80+
// DisableAutomatedSecurityFixes disables vulnerability alerts and the dependency graph for a repository.
81+
//
82+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#disable-automated-security-fixes
83+
DisableAutomatedSecurityFixes(ctx context.Context, owner, repository string) (*Response, error)
84+
// ListContributors lists contributors for a repository.
85+
//
86+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-repository-contributors
87+
ListContributors(ctx context.Context, owner string, repository string, opts *ListContributorsOptions) ([]*Contributor, *Response, error)
88+
// ListLanguages lists languages for the specified repository. The returned map
89+
// specifies the languages and the number of bytes of code written in that
90+
// language. For example:
91+
//
92+
// {
93+
// "C": 78769,
94+
// "Python": 7769
95+
// }
96+
//
97+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-repository-languages
98+
ListLanguages(ctx context.Context, owner string, repo string) (map[string]int, *Response, error)
99+
// ListTeams lists the teams for the specified repository.
100+
//
101+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-repository-teams
102+
ListTeams(ctx context.Context, owner string, repo string, opts *ListOptions) ([]*Team, *Response, error)
103+
// ListTags lists tags for the specified repository.
104+
//
105+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-repository-tags
106+
ListTags(ctx context.Context, owner string, repo string, opts *ListOptions) ([]*RepositoryTag, *Response, error)
107+
// ListBranches lists branches for the specified repository.
108+
//
109+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-branches
110+
ListBranches(ctx context.Context, owner string, repo string, opts *BranchListOptions) ([]*Branch, *Response, error)
111+
// GetBranch gets the specified branch for a repository.
112+
//
113+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-a-branch
114+
GetBranch(ctx context.Context, owner, repo, branch string) (*Branch, *Response, error)
115+
// GetBranchProtection gets the protection of a given branch.
116+
//
117+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-branch-protection
118+
GetBranchProtection(ctx context.Context, owner, repo, branch string) (*Protection, *Response, error)
119+
// GetRequiredStatusChecks gets the required status checks for a given protected branch.
120+
//
121+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-status-checks-protection
122+
GetRequiredStatusChecks(ctx context.Context, owner, repo, branch string) (*RequiredStatusChecks, *Response, error)
123+
// ListRequiredStatusChecksContexts lists the required status checks contexts for a given protected branch.
124+
//
125+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-all-status-check-contexts
126+
ListRequiredStatusChecksContexts(ctx context.Context, owner, repo, branch string) (contexts []string, resp *Response, err error)
127+
// UpdateBranchProtection updates the protection of a given branch.
128+
//
129+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#update-branch-protection
130+
UpdateBranchProtection(ctx context.Context, owner, repo, branch string, preq *ProtectionRequest) (*Protection, *Response, error)
131+
// RemoveBranchProtection removes the protection of a given branch.
132+
//
133+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#delete-branch-protection
134+
RemoveBranchProtection(ctx context.Context, owner, repo, branch string) (*Response, error)
135+
// GetSignaturesProtectedBranch gets required signatures of protected branch.
136+
//
137+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-commit-signature-protection
138+
GetSignaturesProtectedBranch(ctx context.Context, owner, repo, branch string) (*SignaturesProtectedBranch, *Response, error)
139+
// RequireSignaturesOnProtectedBranch makes signed commits required on a protected branch.
140+
// It requires admin access and branch protection to be enabled.
141+
//
142+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#create-commit-signature-protection
143+
RequireSignaturesOnProtectedBranch(ctx context.Context, owner, repo, branch string) (*SignaturesProtectedBranch, *Response, error)
144+
// OptionalSignaturesOnProtectedBranch removes required signed commits on a given branch.
145+
//
146+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#delete-commit-signature-protection
147+
OptionalSignaturesOnProtectedBranch(ctx context.Context, owner, repo, branch string) (*Response, error)
148+
// UpdateRequiredStatusChecks updates the required status checks for a given protected branch.
149+
//
150+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#update-status-check-protection
151+
UpdateRequiredStatusChecks(ctx context.Context, owner, repo, branch string, sreq *RequiredStatusChecksRequest) (*RequiredStatusChecks, *Response, error)
152+
// RemoveRequiredStatusChecks removes the required status checks for a given protected branch.
153+
//
154+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#remove-status-check-protection
155+
RemoveRequiredStatusChecks(ctx context.Context, owner, repo, branch string) (*Response, error)
156+
// License gets the contents of a repository's license if one is detected.
157+
//
158+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/licenses/#get-the-license-for-a-repository
159+
License(ctx context.Context, owner, repo string) (*RepositoryLicense, *Response, error)
160+
// GetPullRequestReviewEnforcement gets pull request review enforcement of a protected branch.
161+
//
162+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-pull-request-review-protection
163+
GetPullRequestReviewEnforcement(ctx context.Context, owner, repo, branch string) (*PullRequestReviewsEnforcement, *Response, error)
164+
// UpdatePullRequestReviewEnforcement patches pull request review enforcement of a protected branch.
165+
// It requires admin access and branch protection to be enabled.
166+
//
167+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#update-pull-request-review-protection
168+
UpdatePullRequestReviewEnforcement(ctx context.Context, owner, repo, branch string, patch *PullRequestReviewsEnforcementUpdate) (*PullRequestReviewsEnforcement, *Response, error)
169+
// DisableDismissalRestrictions disables dismissal restrictions of a protected branch.
170+
// It requires admin access and branch protection to be enabled.
171+
//
172+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#update-pull-request-review-protection
173+
DisableDismissalRestrictions(ctx context.Context, owner, repo, branch string) (*PullRequestReviewsEnforcement, *Response, error)
174+
// RemovePullRequestReviewEnforcement removes pull request enforcement of a protected branch.
175+
//
176+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#delete-pull-request-review-protection
177+
RemovePullRequestReviewEnforcement(ctx context.Context, owner, repo, branch string) (*Response, error)
178+
// GetAdminEnforcement gets admin enforcement information of a protected branch.
179+
//
180+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-admin-branch-protection
181+
GetAdminEnforcement(ctx context.Context, owner, repo, branch string) (*AdminEnforcement, *Response, error)
182+
// AddAdminEnforcement adds admin enforcement to a protected branch.
183+
// It requires admin access and branch protection to be enabled.
184+
//
185+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#set-admin-branch-protection
186+
AddAdminEnforcement(ctx context.Context, owner, repo, branch string) (*AdminEnforcement, *Response, error)
187+
// RemoveAdminEnforcement removes admin enforcement from a protected branch.
188+
//
189+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#delete-admin-branch-protection
190+
RemoveAdminEnforcement(ctx context.Context, owner, repo, branch string) (*Response, error)
191+
// ListAllTopics lists topics for a repository.
192+
//
193+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-all-repository-topics
194+
ListAllTopics(ctx context.Context, owner, repo string) ([]string, *Response, error)
195+
// ReplaceAllTopics replaces topics for a repository.
196+
//
197+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#replace-all-repository-topics
198+
ReplaceAllTopics(ctx context.Context, owner, repo string, topics []string) ([]string, *Response, error)
199+
// ListApps lists the GitHub apps that have push access to a given protected branch.
200+
// It requires the GitHub apps to have `write` access to the `content` permission.
201+
//
202+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-apps-with-access-to-the-protected-branch
203+
ListApps(ctx context.Context, owner, repo, branch string) ([]*App, *Response, error)
204+
// ReplaceAppRestrictions replaces the apps that have push access to a given protected branch.
205+
// It removes all apps that previously had push access and grants push access to the new list of apps.
206+
// It requires the GitHub apps to have `write` access to the `content` permission.
207+
//
208+
// Note: The list of users, apps, and teams in total is limited to 100 items.
209+
//
210+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#set-app-access-restrictions
211+
ReplaceAppRestrictions(ctx context.Context, owner, repo, branch string, slug []string) ([]*App, *Response, error)
212+
// AddAppRestrictions grants the specified apps push access to a given protected branch.
213+
// It requires the GitHub apps to have `write` access to the `content` permission.
214+
//
215+
// Note: The list of users, apps, and teams in total is limited to 100 items.
216+
//
217+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#add-app-access-restrictions
218+
AddAppRestrictions(ctx context.Context, owner, repo, branch string, slug []string) ([]*App, *Response, error)
219+
// RemoveAppRestrictions removes the ability of an app to push to this branch.
220+
// It requires the GitHub apps to have `write` access to the `content` permission.
221+
//
222+
// Note: The list of users, apps, and teams in total is limited to 100 items.
223+
//
224+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#remove-app-access-restrictions
225+
RemoveAppRestrictions(ctx context.Context, owner, repo, branch string, slug []string) ([]*App, *Response, error)
226+
// Transfer transfers a repository from one account or organization to another.
227+
//
228+
// This method might return an *AcceptedError and a status code of
229+
// 202. This is because this is the status that GitHub returns to signify that
230+
// it has now scheduled the transfer of the repository in a background task.
231+
// A follow up request, after a delay of a second or so, should result
232+
// in a successful request.
233+
//
234+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#transfer-a-repository
235+
Transfer(ctx context.Context, owner, repo string, transfer TransferRequest) (*Repository, *Response, error)
236+
// Dispatch triggers a repository_dispatch event in a GitHub Actions workflow.
237+
//
238+
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#create-a-repository-dispatch-event
239+
Dispatch(ctx context.Context, owner, repo string, opts DispatchRequestOptions) (*Repository, *Response, error)
240+
}

0 commit comments

Comments
 (0)