diff --git a/example/embed-interface/main.go b/example/embed-interface/main.go new file mode 100644 index 00000000000..9ec41a5083d --- /dev/null +++ b/example/embed-interface/main.go @@ -0,0 +1,48 @@ +// Copyright 2021 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This embed-interface example is a copy of the "simple" example +// and its purpose is to demonstrate how embedding an interface +// in a struct makes it easy to mock one or more methods. +package main + +import ( + "context" + "fmt" + + "github.com/google/go-github/v35/github" +) + +type myClient struct { + client *github.Client +} + +// Fetch all the public organizations' membership of a user. +// +func (m *myClient) fetchOrganizations(ctx context.Context, username string) ([]*github.Organization, error) { + orgs, _, err := m.client.Organizations.List(ctx, username, nil) + return orgs, err +} + +func main() { + var username string + fmt.Print("Enter GitHub username: ") + fmt.Scanf("%s", &username) + + c := &myClient{ + client: github.NewClient(nil), + } + + ctx := context.Background() + organizations, err := c.fetchOrganizations(ctx, username) + if err != nil { + fmt.Printf("Error: %v\n", err) + return + } + + for i, organization := range organizations { + fmt.Printf("%v. %v\n", i+1, organization.GetLogin()) + } +} diff --git a/example/embed-interface/main_test.go b/example/embed-interface/main_test.go new file mode 100644 index 00000000000..8d8230aafec --- /dev/null +++ b/example/embed-interface/main_test.go @@ -0,0 +1,50 @@ +// Copyright 2021 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import ( + "context" + "errors" + "reflect" + "testing" + + "github.com/google/go-github/v35/github" +) + +type fakeOrgSvc struct { + github.OrganizationsServiceInterface + + orgs []*github.Organization +} + +func (f *fakeOrgSvc) List(ctx context.Context, org string, opts *github.ListOptions) ([]*github.Organization, *github.Response, error) { + if org != "octocat" { + return nil, nil, errors.New("unexpected org") + } + + return f.orgs, nil, nil +} + +func TestFetchOrganizations(t *testing.T) { + want := []*github.Organization{ + {Name: github.String("octocat")}, + } + + c := &myClient{ + client: github.NewClient(nil), + } + c.client.Organizations = &fakeOrgSvc{orgs: want} + + ctx := context.Background() + got, err := c.fetchOrganizations(ctx, "octocat") + if err != nil { + t.Fatal(err) + } + + if !reflect.DeepEqual(got, want) { + t.Errorf("got = %#v, want = %#v", got, want) + } +} diff --git a/github/apps_marketplace.go b/github/apps_marketplace.go index 13d09f2efba..f58c6ff3932 100644 --- a/github/apps_marketplace.go +++ b/github/apps_marketplace.go @@ -75,6 +75,20 @@ type MarketplacePlanAccount struct { MarketplacePendingChange *MarketplacePendingChange `json:"marketplace_pending_change,omitempty"` } +// SetStubbed configures the MarketplaceService Stubbed property. +// +// GitHub API docs: https://docs.github.com/en/developers/github-marketplace/testing-your-app#testing-apis +func (s *MarketplaceService) SetStubbed(stubbed bool) { + s.Stubbed = stubbed +} + +// GetStubbed returns the MarketplaceService Stubbed property. +// +// GitHub API docs: https://docs.github.com/en/developers/github-marketplace/testing-your-app#testing-apis +func (s *MarketplaceService) GetStubbed() bool { + return s.Stubbed +} + // ListPlans lists all plans for your Marketplace listing. // // GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps#list-plans @@ -149,7 +163,7 @@ func (s *MarketplaceService) GetPlanAccountForAccount(ctx context.Context, accou // GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#list-subscriptions-for-the-authenticated-user func (s *MarketplaceService) ListMarketplacePurchasesForUser(ctx context.Context, opts *ListOptions) ([]*MarketplacePurchase, *Response, error) { uri := "user/marketplace_purchases" - if s.Stubbed { + if s.GetStubbed() { uri = "user/marketplace_purchases/stubbed" } @@ -173,7 +187,7 @@ func (s *MarketplaceService) ListMarketplacePurchasesForUser(ctx context.Context func (s *MarketplaceService) marketplaceURI(endpoint string) string { url := "marketplace_listing" - if s.Stubbed { + if s.GetStubbed() { url = "marketplace_listing/stubbed" } return url + "/" + endpoint diff --git a/github/apps_marketplace_test.go b/github/apps_marketplace_test.go index fd2d26cf1fc..f596ff0feec 100644 --- a/github/apps_marketplace_test.go +++ b/github/apps_marketplace_test.go @@ -27,7 +27,7 @@ func TestMarketplaceService_ListPlans(t *testing.T) { }) opt := &ListOptions{Page: 1, PerPage: 2} - client.Marketplace.Stubbed = false + client.Marketplace.SetStubbed(false) ctx := context.Background() plans, _, err := client.Marketplace.ListPlans(ctx, opt) if err != nil { @@ -59,7 +59,7 @@ func TestMarketplaceService_Stubbed_ListPlans(t *testing.T) { }) opt := &ListOptions{Page: 1, PerPage: 2} - client.Marketplace.Stubbed = true + client.Marketplace.SetStubbed(true) ctx := context.Background() plans, _, err := client.Marketplace.ListPlans(ctx, opt) if err != nil { @@ -82,7 +82,7 @@ func TestMarketplaceService_ListPlanAccountsForPlan(t *testing.T) { }) opt := &ListOptions{Page: 1, PerPage: 2} - client.Marketplace.Stubbed = false + client.Marketplace.SetStubbed(false) ctx := context.Background() accounts, _, err := client.Marketplace.ListPlanAccountsForPlan(ctx, 1, opt) if err != nil { @@ -114,7 +114,7 @@ func TestMarketplaceService_Stubbed_ListPlanAccountsForPlan(t *testing.T) { }) opt := &ListOptions{Page: 1, PerPage: 2} - client.Marketplace.Stubbed = true + client.Marketplace.SetStubbed(true) ctx := context.Background() accounts, _, err := client.Marketplace.ListPlanAccountsForPlan(ctx, 1, opt) if err != nil { @@ -136,7 +136,7 @@ func TestMarketplaceService_GetPlanAccountForAccount(t *testing.T) { fmt.Fprint(w, `{"id":1, "marketplace_pending_change": {"id": 77}}`) }) - client.Marketplace.Stubbed = false + client.Marketplace.SetStubbed(false) ctx := context.Background() account, _, err := client.Marketplace.GetPlanAccountForAccount(ctx, 1) if err != nil { @@ -167,7 +167,7 @@ func TestMarketplaceService_Stubbed_GetPlanAccountForAccount(t *testing.T) { fmt.Fprint(w, `{"id":1}`) }) - client.Marketplace.Stubbed = true + client.Marketplace.SetStubbed(true) ctx := context.Background() account, _, err := client.Marketplace.GetPlanAccountForAccount(ctx, 1) if err != nil { @@ -190,7 +190,7 @@ func TestMarketplaceService_ListMarketplacePurchasesForUser(t *testing.T) { }) opt := &ListOptions{Page: 1, PerPage: 2} - client.Marketplace.Stubbed = false + client.Marketplace.SetStubbed(false) ctx := context.Background() purchases, _, err := client.Marketplace.ListMarketplacePurchasesForUser(ctx, opt) if err != nil { @@ -222,7 +222,7 @@ func TestMarketplaceService_Stubbed_ListMarketplacePurchasesForUser(t *testing.T }) opt := &ListOptions{Page: 1, PerPage: 2} - client.Marketplace.Stubbed = true + client.Marketplace.SetStubbed(true) ctx := context.Background() purchases, _, err := client.Marketplace.ListMarketplacePurchasesForUser(ctx, opt) if err != nil { diff --git a/github/gen-interfaces.go b/github/gen-interfaces.go new file mode 100644 index 00000000000..7da99c55273 --- /dev/null +++ b/github/gen-interfaces.go @@ -0,0 +1,317 @@ +// Copyright 2021 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build ignore + +// gen-interfaces generates interfaces for each GitHub service to ease mocking. +// +// Embedding an interface into a struct makes it super-easy to only implement +// the methods that you need when mocking a service, so this auto-generates +// all service interfaces using `go generate ./...`. +// +// It is meant to be used by go-github contributors in conjunction with the +// go generate tool before sending a PR to GitHub. +// Please see the CONTRIBUTING.md file for more information. +package main + +import ( + "bytes" + "flag" + "go/ast" + "go/format" + "go/parser" + "go/printer" + "go/token" + "io/ioutil" + "log" + "os" + "sort" + "strings" + "text/template" +) + +const ( + ignoreFilePrefix1 = "gen-" + ignoreFilePrefix2 = "github-" + outputFileSuffix = "-interfaces.go" +) + +var ( + verbose = flag.Bool("v", false, "Print verbose log messages") + + fset *token.FileSet + + funcMap = template.FuncMap{ + "render": func(fn *ast.FuncDecl) string { + fn.Recv = nil + fn.Body = nil + var buf bytes.Buffer + printer.Fprint(&buf, fset, fn) + return strings.ReplaceAll(buf.String(), "func ", "") + }, + } + + sourceTmpl = template.Must(template.New("source").Funcs(funcMap).Parse(source)) +) + +func main() { + flag.Parse() + fset = token.NewFileSet() + + pkgs, err := parser.ParseDir(fset, ".", sourceFilter, 0) + if err != nil { + log.Fatal(err) + return + } + + for pkgName, pkg := range pkgs { + t := &templateData{ + filename: pkgName + outputFileSuffix, + Year: 2021, // No need to change this once set (even in following years). + Package: pkgName, + Imports: map[string]string{ + "context": "context", + "io": "io", + "net/http": "net/http", + "net/url": "net/url", + "os": "os", + "time": "time", + }, + services: map[string]*service{}, + } + for filename, f := range pkg.Files { + logf("Processing %v...", filename) + if err := t.processAST(f); err != nil { + log.Fatal(err) + } + } + + if len(t.services) == 0 { + log.Printf("No services found in package %q.", pkgName) + continue + } + + t.sortServicesAndMethods() + + if err := t.dump(); err != nil { + log.Fatal(err) + } + } + logf("Done.") +} + +func sourceFilter(fi os.FileInfo) bool { + return !strings.HasSuffix(fi.Name(), "_test.go") && + !strings.HasPrefix(fi.Name(), ignoreFilePrefix1) && + !strings.HasPrefix(fi.Name(), ignoreFilePrefix2) +} + +type templateData struct { + filename string + Year int + Package string + Imports map[string]string + + services map[string]*service + SortedServices []*service +} + +type service struct { + Name string + GenDecl *ast.GenDecl + Methods []*method +} + +type method struct { + Name string + FuncDecl *ast.FuncDecl +} + +func (t *templateData) sortServicesAndMethods() { + t.SortedServices = make([]*service, 0, len(t.services)) + for _, svc := range t.services { + t.SortedServices = append(t.SortedServices, svc) + + sort.Slice(svc.Methods, func(a, b int) bool { return svc.Methods[a].Name < svc.Methods[b].Name }) + } + + sort.Slice(t.SortedServices, func(a, b int) bool { return t.SortedServices[a].Name < t.SortedServices[b].Name }) + +} + +func (t *templateData) processAST(f *ast.File) error { + for _, decl := range f.Decls { + fn, ok := decl.(*ast.FuncDecl) + if ok { + // Skip unexported funcDecl. + if !fn.Name.IsExported() { + continue + } + + if fn.Recv != nil && len(fn.Recv.List) > 0 { + if _, ok := fn.Recv.List[0].Type.(*ast.Ident); ok && fn.Name.Name == "String" { + // logf("Ignoring FuncDecl: Name=%q", fn.Name.Name) + } else { + logf("Found FuncDecl with receiver: Name=%q, Type=%T", fn.Name.Name, fn.Recv.List[0].Type) + t.processFuncDeclWithRecv(fn) + } + } else { + logf("Ignoring FuncDecl without receiver: Name=%q", fn.Name.Name) + } + continue + } + + gd, ok := decl.(*ast.GenDecl) + if !ok { + logf("Ignoring AST decl type %T", decl) + continue + } + for _, spec := range gd.Specs { + ts, ok := spec.(*ast.TypeSpec) + if !ok { + continue + } + // Skip unexported identifiers. + if !ts.Name.IsExported() { + continue + } + + // Skip if this is not a service. + serviceName := ts.Name.String() + if !strings.HasSuffix(serviceName, "Service") { + logf("Ignoring GenDecl with ts.Type=%T ts.Name=%q", ts.Type, serviceName) + continue + } + + v, ok := t.services[serviceName] + if !ok { + v = &service{Name: serviceName} + t.services[serviceName] = v + } + v.GenDecl = gd + logf("Found service %q", serviceName) + } + } + return nil +} + +func (t *templateData) processFuncDeclWithRecv(fn *ast.FuncDecl) { + serviceName := t.recvServiceName(fn) + if serviceName == "" { + return + } + + svc, ok := t.services[serviceName] + if !ok { + svc = &service{Name: serviceName} + t.services[serviceName] = svc + } + + svc.Methods = append(svc.Methods, &method{Name: fn.Name.Name, FuncDecl: fn}) +} + +func (t *templateData) recvServiceName(fn *ast.FuncDecl) string { + starExpr, ok := fn.Recv.List[0].Type.(*ast.StarExpr) + if !ok { + logf("Ignoring FuncDecl where Type=%T (want *ast.StarExpr): Name=%q", fn.Recv.List[0].Type, fn.Name.Name) + return "" + } + + xIdent, ok := starExpr.X.(*ast.Ident) + if !ok { + logf("Ignoring FuncDecl where X=%T (want *ast.Ident): Name=%q", starExpr.X, fn.Name.Name) + return "" + } + + if xIdent.Obj == nil { + if strings.HasSuffix(xIdent.Name, "Service") { + return xIdent.Name + } + return "" + } + + typeSpec, ok := xIdent.Obj.Decl.(*ast.TypeSpec) + if !ok { + logf("Ignoring FuncDecl where Decl=%T (want *ast.TypeSpec): Name=%q", xIdent.Obj.Decl, fn.Name.Name) + return "" + } + + typeIdent, ok := typeSpec.Type.(*ast.Ident) + if !ok { + if strings.HasSuffix(xIdent.Name, "Service") { + return xIdent.Name + } + logf("Ignoring FuncDecl where Type=%T (want *ast.Ident): Name=%q", typeSpec.Type, fn.Name.Name) + return "" + } + + recvType := typeIdent.Name + if recvType != "service" { + logf("Ignoring FuncDecl where recvType=%q (want service): Name=%q", recvType, fn.Name.Name) + return "" + } + + return xIdent.Name +} + +func (t *templateData) dump() error { + if len(t.services) == 0 { + logf("No services for %v; skipping.", t.filename) + return nil + } + + var buf bytes.Buffer + if err := sourceTmpl.Execute(&buf, t); err != nil { + return err + } + clean, err := format.Source(buf.Bytes()) + if err != nil { + log.Printf("failed-to-format source:\n%v", buf.String()) + return err + } + + logf("Writing %v...", t.filename) + return ioutil.WriteFile(t.filename, clean, 0644) +} + +func logf(fmt string, args ...interface{}) { + if *verbose { + log.Printf(fmt, args...) + } +} + +const source = `// Copyright {{.Year}} The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Code generated by gen-interfaces; DO NOT EDIT. +// Instead, please run "go generate ./...". See CONTRIBUTING.md for details. + +package {{ $package := .Package }}{{ $package }} +{{ with .Imports }} +import ( + {{- range . -}} + "{{.}}" + {{ end -}} +) +{{ end }} +{{ range $index, $svc := .SortedServices }} +// {{ $svc.Name }}Interface defines the interface for the {{ $svc.Name }} for easy mocking. +{{ if and $svc.GenDecl $svc.GenDecl.Doc }} +{{- range $i2, $line := $svc.GenDecl.Doc.List }} +{{- $line.Text }} +{{ end -}} +{{ end -}} +type {{ $svc.Name }}Interface interface { +{{ range $i3, $mthd := $svc.Methods }} +{{ $mthd.FuncDecl | render }} +{{ end }} +} + +// {{ $svc.Name }} implements the {{ $svc.Name }}Interface. +var _ {{ $svc.Name }}Interface = &{{ $svc.Name }}{} +{{ end }} +` diff --git a/github/github-interfaces.go b/github/github-interfaces.go new file mode 100644 index 00000000000..7474fb848c9 --- /dev/null +++ b/github/github-interfaces.go @@ -0,0 +1,1418 @@ +// Copyright 2021 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Code generated by gen-interfaces; DO NOT EDIT. +// Instead, please run "go generate ./...". See CONTRIBUTING.md for details. + +package github + +import ( + "context" + "io" + "net/http" + "net/url" + "os" + "time" +) + +// ActionsServiceInterface defines the interface for the ActionsService for easy mocking. +type ActionsServiceInterface interface { + AddRepositoryAccessRunnerGroup(ctx context.Context, org string, groupID, repoID int64) (*Response, error) + + AddRunerGroupRunners(ctx context.Context, org string, groupID, runnerID int64) (*Response, error) + + AddSelectedRepoToOrgSecret(ctx context.Context, org, name string, repo *Repository) (*Response, error) + + CancelWorkflowRunByID(ctx context.Context, owner, repo string, runID int64) (*Response, error) + + CreateOrUpdateEnvSecret(ctx context.Context, repoID int, env string, eSecret *EncryptedSecret) (*Response, error) + + CreateOrUpdateOrgSecret(ctx context.Context, org string, eSecret *EncryptedSecret) (*Response, error) + + CreateOrUpdateRepoSecret(ctx context.Context, owner, repo string, eSecret *EncryptedSecret) (*Response, error) + + CreateOrganizationRegistrationToken(ctx context.Context, owner string) (*RegistrationToken, *Response, error) + + CreateOrganizationRemoveToken(ctx context.Context, owner string) (*RemoveToken, *Response, error) + + CreateOrganizationRunnerGroup(ctx context.Context, org string, createReq CreateRunnerGroupRequest) (*RunnerGroup, *Response, error) + + CreateRegistrationToken(ctx context.Context, owner, repo string) (*RegistrationToken, *Response, error) + + CreateRemoveToken(ctx context.Context, owner, repo string) (*RemoveToken, *Response, error) + + CreateWorkflowDispatchEventByFileName(ctx context.Context, owner, repo, workflowFileName string, event CreateWorkflowDispatchEventRequest) (*Response, error) + + CreateWorkflowDispatchEventByID(ctx context.Context, owner, repo string, workflowID int64, event CreateWorkflowDispatchEventRequest) (*Response, error) + + DeleteArtifact(ctx context.Context, owner, repo string, artifactID int64) (*Response, error) + + DeleteEnvSecret(ctx context.Context, repoID int, env, secretName string) (*Response, error) + + DeleteOrgSecret(ctx context.Context, org, name string) (*Response, error) + + DeleteOrganizationRunnerGroup(ctx context.Context, org string, groupID int64) (*Response, error) + + DeleteRepoSecret(ctx context.Context, owner, repo, name string) (*Response, error) + + DeleteWorkflowRunLogs(ctx context.Context, owner, repo string, runID int64) (*Response, error) + + DisableWorkflowByFileName(ctx context.Context, owner, repo, workflowFileName string) (*Response, error) + + DisableWorkflowByID(ctx context.Context, owner, repo string, workflowID int64) (*Response, error) + + DownloadArtifact(ctx context.Context, owner, repo string, artifactID int64, followRedirects bool) (*url.URL, *Response, error) + + EnableWorkflowByFileName(ctx context.Context, owner, repo, workflowFileName string) (*Response, error) + + EnableWorkflowByID(ctx context.Context, owner, repo string, workflowID int64) (*Response, error) + + GetArtifact(ctx context.Context, owner, repo string, artifactID int64) (*Artifact, *Response, error) + + GetEnvPublicKey(ctx context.Context, repoID int, env string) (*PublicKey, *Response, error) + + GetEnvSecret(ctx context.Context, repoID int, env, secretName string) (*Secret, *Response, error) + + GetOrgPublicKey(ctx context.Context, org string) (*PublicKey, *Response, error) + + GetOrgSecret(ctx context.Context, org, name string) (*Secret, *Response, error) + + GetOrganizationRunner(ctx context.Context, owner string, runnerID int64) (*Runner, *Response, error) + + GetOrganizationRunnerGroup(ctx context.Context, org string, groupID int64) (*RunnerGroup, *Response, error) + + GetRepoPublicKey(ctx context.Context, owner, repo string) (*PublicKey, *Response, error) + + GetRepoSecret(ctx context.Context, owner, repo, name string) (*Secret, *Response, error) + + GetRunner(ctx context.Context, owner, repo string, runnerID int64) (*Runner, *Response, error) + + GetWorkflowByFileName(ctx context.Context, owner, repo, workflowFileName string) (*Workflow, *Response, error) + + GetWorkflowByID(ctx context.Context, owner, repo string, workflowID int64) (*Workflow, *Response, error) + + GetWorkflowJobByID(ctx context.Context, owner, repo string, jobID int64) (*WorkflowJob, *Response, error) + + GetWorkflowJobLogs(ctx context.Context, owner, repo string, jobID int64, followRedirects bool) (*url.URL, *Response, error) + + GetWorkflowRunByID(ctx context.Context, owner, repo string, runID int64) (*WorkflowRun, *Response, error) + + GetWorkflowRunLogs(ctx context.Context, owner, repo string, runID int64, followRedirects bool) (*url.URL, *Response, error) + + GetWorkflowRunUsageByID(ctx context.Context, owner, repo string, runID int64) (*WorkflowRunUsage, *Response, error) + + GetWorkflowUsageByFileName(ctx context.Context, owner, repo, workflowFileName string) (*WorkflowUsage, *Response, error) + + GetWorkflowUsageByID(ctx context.Context, owner, repo string, workflowID int64) (*WorkflowUsage, *Response, error) + + ListArtifacts(ctx context.Context, owner, repo string, opts *ListOptions) (*ArtifactList, *Response, error) + + ListEnabledReposInOrg(ctx context.Context, owner string, opts *ListOptions) (*ActionsEnabledOnOrgRepos, *Response, error) + + ListEnvSecrets(ctx context.Context, repoID int, env string, opts *ListOptions) (*Secrets, *Response, error) + + ListOrgSecrets(ctx context.Context, org string, opts *ListOptions) (*Secrets, *Response, error) + + ListOrganizationRunnerApplicationDownloads(ctx context.Context, owner string) ([]*RunnerApplicationDownload, *Response, error) + + ListOrganizationRunnerGroups(ctx context.Context, org string, opts *ListOptions) (*RunnerGroups, *Response, error) + + ListOrganizationRunners(ctx context.Context, owner string, opts *ListOptions) (*Runners, *Response, error) + + ListRepoSecrets(ctx context.Context, owner, repo string, opts *ListOptions) (*Secrets, *Response, error) + + ListRepositoryAccessRunnerGroup(ctx context.Context, org string, groupID int64) (*ListRepositories, *Response, error) + + ListRepositoryWorkflowRuns(ctx context.Context, owner, repo string, opts *ListWorkflowRunsOptions) (*WorkflowRuns, *Response, error) + + ListRunerGroupRunners(ctx context.Context, org string, groupID int64, opts *ListOptions) (*Runners, *Response, error) + + ListRunnerApplicationDownloads(ctx context.Context, owner, repo string) ([]*RunnerApplicationDownload, *Response, error) + + ListRunners(ctx context.Context, owner, repo string, opts *ListOptions) (*Runners, *Response, error) + + ListSelectedReposForOrgSecret(ctx context.Context, org, name string) (*SelectedReposList, *Response, error) + + ListWorkflowJobs(ctx context.Context, owner, repo string, runID int64, opts *ListWorkflowJobsOptions) (*Jobs, *Response, error) + + ListWorkflowRunArtifacts(ctx context.Context, owner, repo string, runID int64, opts *ListOptions) (*ArtifactList, *Response, error) + + ListWorkflowRunsByFileName(ctx context.Context, owner, repo, workflowFileName string, opts *ListWorkflowRunsOptions) (*WorkflowRuns, *Response, error) + + ListWorkflowRunsByID(ctx context.Context, owner, repo string, workflowID int64, opts *ListWorkflowRunsOptions) (*WorkflowRuns, *Response, error) + + ListWorkflows(ctx context.Context, owner, repo string, opts *ListOptions) (*Workflows, *Response, error) + + RemoveOrganizationRunner(ctx context.Context, owner string, runnerID int64) (*Response, error) + + RemoveRepositoryAccessRunnerGroup(ctx context.Context, org string, groupID, repoID int64) (*Response, error) + + RemoveRunerGroupRunners(ctx context.Context, org string, groupID, runnerID int64) (*Response, error) + + RemoveRunner(ctx context.Context, owner, repo string, runnerID int64) (*Response, error) + + RemoveSelectedRepoFromOrgSecret(ctx context.Context, org, name string, repo *Repository) (*Response, error) + + RerunWorkflowByID(ctx context.Context, owner, repo string, runID int64) (*Response, error) + + SetRepositoryAccessRunnerGroup(ctx context.Context, org string, groupID int64, ids SetRepoAccessRunnerGroupRequest) (*Response, error) + + SetRunerGroupRunners(ctx context.Context, org string, groupID int64, ids SetRunnerGroupRunnersRequest) (*Response, error) + + SetSelectedReposForOrgSecret(ctx context.Context, org, name string, ids SelectedRepoIDs) (*Response, error) + + UpdateOrganizationRunnerGroup(ctx context.Context, org string, groupID int64, updateReq UpdateRunnerGroupRequest) (*RunnerGroup, *Response, error) +} + +// ActionsService implements the ActionsServiceInterface. +var _ ActionsServiceInterface = &ActionsService{} + +// ActivityServiceInterface defines the interface for the ActivityService for easy mocking. +type ActivityServiceInterface interface { + DeleteRepositorySubscription(ctx context.Context, owner, repo string) (*Response, error) + + DeleteThreadSubscription(ctx context.Context, id string) (*Response, error) + + GetRepositorySubscription(ctx context.Context, owner, repo string) (*Subscription, *Response, error) + + GetThread(ctx context.Context, id string) (*Notification, *Response, error) + + GetThreadSubscription(ctx context.Context, id string) (*Subscription, *Response, error) + + IsStarred(ctx context.Context, owner, repo string) (bool, *Response, error) + + ListEvents(ctx context.Context, opts *ListOptions) ([]*Event, *Response, error) + + ListEventsForOrganization(ctx context.Context, org string, opts *ListOptions) ([]*Event, *Response, error) + + ListEventsForRepoNetwork(ctx context.Context, owner, repo string, opts *ListOptions) ([]*Event, *Response, error) + + ListEventsPerformedByUser(ctx context.Context, user string, publicOnly bool, opts *ListOptions) ([]*Event, *Response, error) + + ListEventsReceivedByUser(ctx context.Context, user string, publicOnly bool, opts *ListOptions) ([]*Event, *Response, error) + + ListFeeds(ctx context.Context) (*Feeds, *Response, error) + + ListIssueEventsForRepository(ctx context.Context, owner, repo string, opts *ListOptions) ([]*IssueEvent, *Response, error) + + ListNotifications(ctx context.Context, opts *NotificationListOptions) ([]*Notification, *Response, error) + + ListRepositoryEvents(ctx context.Context, owner, repo string, opts *ListOptions) ([]*Event, *Response, error) + + ListRepositoryNotifications(ctx context.Context, owner, repo string, opts *NotificationListOptions) ([]*Notification, *Response, error) + + ListStargazers(ctx context.Context, owner, repo string, opts *ListOptions) ([]*Stargazer, *Response, error) + + ListStarred(ctx context.Context, user string, opts *ActivityListStarredOptions) ([]*StarredRepository, *Response, error) + + ListUserEventsForOrganization(ctx context.Context, org, user string, opts *ListOptions) ([]*Event, *Response, error) + + ListWatched(ctx context.Context, user string, opts *ListOptions) ([]*Repository, *Response, error) + + ListWatchers(ctx context.Context, owner, repo string, opts *ListOptions) ([]*User, *Response, error) + + MarkNotificationsRead(ctx context.Context, lastRead time.Time) (*Response, error) + + MarkRepositoryNotificationsRead(ctx context.Context, owner, repo string, lastRead time.Time) (*Response, error) + + MarkThreadRead(ctx context.Context, id string) (*Response, error) + + SetRepositorySubscription(ctx context.Context, owner, repo string, subscription *Subscription) (*Subscription, *Response, error) + + SetThreadSubscription(ctx context.Context, id string, subscription *Subscription) (*Subscription, *Response, error) + + Star(ctx context.Context, owner, repo string) (*Response, error) + + Unstar(ctx context.Context, owner, repo string) (*Response, error) +} + +// ActivityService implements the ActivityServiceInterface. +var _ ActivityServiceInterface = &ActivityService{} + +// AdminServiceInterface defines the interface for the AdminService for easy mocking. +type AdminServiceInterface interface { + CreateOrg(ctx context.Context, org *Organization, admin string) (*Organization, *Response, error) + + CreateUser(ctx context.Context, login, email string) (*User, *Response, error) + + CreateUserImpersonation(ctx context.Context, username string, opts *ImpersonateUserOptions) (*UserAuthorization, *Response, error) + + DeleteUser(ctx context.Context, username string) (*Response, error) + + DeleteUserImpersonation(ctx context.Context, username string) (*Response, error) + + GetAdminStats(ctx context.Context) (*AdminStats, *Response, error) + + RenameOrg(ctx context.Context, org *Organization, newName string) (*RenameOrgResponse, *Response, error) + + RenameOrgByName(ctx context.Context, org, newName string) (*RenameOrgResponse, *Response, error) + + UpdateTeamLDAPMapping(ctx context.Context, team int64, mapping *TeamLDAPMapping) (*TeamLDAPMapping, *Response, error) + + UpdateUserLDAPMapping(ctx context.Context, user string, mapping *UserLDAPMapping) (*UserLDAPMapping, *Response, error) +} + +// AdminService implements the AdminServiceInterface. +var _ AdminServiceInterface = &AdminService{} + +// AppsServiceInterface defines the interface for the AppsService for easy mocking. +type AppsServiceInterface interface { + AddRepository(ctx context.Context, instID, repoID int64) (*Repository, *Response, error) + + CompleteAppManifest(ctx context.Context, code string) (*AppConfig, *Response, error) + + CreateAttachment(ctx context.Context, contentReferenceID int64, title, body string) (*Attachment, *Response, error) + + CreateInstallationToken(ctx context.Context, id int64, opts *InstallationTokenOptions) (*InstallationToken, *Response, error) + + DeleteInstallation(ctx context.Context, id int64) (*Response, error) + + FindOrganizationInstallation(ctx context.Context, org string) (*Installation, *Response, error) + + FindRepositoryInstallation(ctx context.Context, owner, repo string) (*Installation, *Response, error) + + FindRepositoryInstallationByID(ctx context.Context, id int64) (*Installation, *Response, error) + + FindUserInstallation(ctx context.Context, user string) (*Installation, *Response, error) + + Get(ctx context.Context, appSlug string) (*App, *Response, error) + + GetInstallation(ctx context.Context, id int64) (*Installation, *Response, error) + + ListInstallations(ctx context.Context, opts *ListOptions) ([]*Installation, *Response, error) + + ListRepos(ctx context.Context, opts *ListOptions) (*ListRepositories, *Response, error) + + ListUserInstallations(ctx context.Context, opts *ListOptions) ([]*Installation, *Response, error) + + ListUserRepos(ctx context.Context, id int64, opts *ListOptions) (*ListRepositories, *Response, error) + + RemoveRepository(ctx context.Context, instID, repoID int64) (*Response, error) + + RevokeInstallationToken(ctx context.Context) (*Response, error) + + SuspendInstallation(ctx context.Context, id int64) (*Response, error) + + UnsuspendInstallation(ctx context.Context, id int64) (*Response, error) +} + +// AppsService implements the AppsServiceInterface. +var _ AppsServiceInterface = &AppsService{} + +// AuthorizationsServiceInterface defines the interface for the AuthorizationsService for easy mocking. +type AuthorizationsServiceInterface interface { + Check(ctx context.Context, clientID, accessToken string) (*Authorization, *Response, error) + + CreateImpersonation(ctx context.Context, username string, authReq *AuthorizationRequest) (*Authorization, *Response, error) + + DeleteGrant(ctx context.Context, clientID, accessToken string) (*Response, error) + + DeleteImpersonation(ctx context.Context, username string) (*Response, error) + + Reset(ctx context.Context, clientID, accessToken string) (*Authorization, *Response, error) + + Revoke(ctx context.Context, clientID, accessToken string) (*Response, error) +} + +// AuthorizationsService implements the AuthorizationsServiceInterface. +var _ AuthorizationsServiceInterface = &AuthorizationsService{} + +// BillingServiceInterface defines the interface for the BillingService for easy mocking. +type BillingServiceInterface interface { + GetActionsBillingOrg(ctx context.Context, org string) (*ActionBilling, *Response, error) + + GetActionsBillingUser(ctx context.Context, user string) (*ActionBilling, *Response, error) + + GetPackagesBillingOrg(ctx context.Context, org string) (*PackageBilling, *Response, error) + + GetPackagesBillingUser(ctx context.Context, user string) (*PackageBilling, *Response, error) + + GetStorageBillingOrg(ctx context.Context, org string) (*StorageBilling, *Response, error) + + GetStorageBillingUser(ctx context.Context, user string) (*StorageBilling, *Response, error) +} + +// BillingService implements the BillingServiceInterface. +var _ BillingServiceInterface = &BillingService{} + +// ChecksServiceInterface defines the interface for the ChecksService for easy mocking. +type ChecksServiceInterface interface { + CreateCheckRun(ctx context.Context, owner, repo string, opts CreateCheckRunOptions) (*CheckRun, *Response, error) + + CreateCheckSuite(ctx context.Context, owner, repo string, opts CreateCheckSuiteOptions) (*CheckSuite, *Response, error) + + GetCheckRun(ctx context.Context, owner, repo string, checkRunID int64) (*CheckRun, *Response, error) + + GetCheckSuite(ctx context.Context, owner, repo string, checkSuiteID int64) (*CheckSuite, *Response, error) + + ListCheckRunAnnotations(ctx context.Context, owner, repo string, checkRunID int64, opts *ListOptions) ([]*CheckRunAnnotation, *Response, error) + + ListCheckRunsCheckSuite(ctx context.Context, owner, repo string, checkSuiteID int64, opts *ListCheckRunsOptions) (*ListCheckRunsResults, *Response, error) + + ListCheckRunsForRef(ctx context.Context, owner, repo, ref string, opts *ListCheckRunsOptions) (*ListCheckRunsResults, *Response, error) + + ListCheckSuitesForRef(ctx context.Context, owner, repo, ref string, opts *ListCheckSuiteOptions) (*ListCheckSuiteResults, *Response, error) + + ReRequestCheckSuite(ctx context.Context, owner, repo string, checkSuiteID int64) (*Response, error) + + SetCheckSuitePreferences(ctx context.Context, owner, repo string, opts CheckSuitePreferenceOptions) (*CheckSuitePreferenceResults, *Response, error) + + UpdateCheckRun(ctx context.Context, owner, repo string, checkRunID int64, opts UpdateCheckRunOptions) (*CheckRun, *Response, error) +} + +// ChecksService implements the ChecksServiceInterface. +var _ ChecksServiceInterface = &ChecksService{} + +// CodeScanningServiceInterface defines the interface for the CodeScanningService for easy mocking. +type CodeScanningServiceInterface interface { + GetAlert(ctx context.Context, owner, repo string, id int64) (*Alert, *Response, error) + + ListAlertsForRepo(ctx context.Context, owner, repo string, opts *AlertListOptions) ([]*Alert, *Response, error) +} + +// CodeScanningService implements the CodeScanningServiceInterface. +var _ CodeScanningServiceInterface = &CodeScanningService{} + +// EnterpriseServiceInterface defines the interface for the EnterpriseService for easy mocking. +type EnterpriseServiceInterface interface { + CreateRegistrationToken(ctx context.Context, enterprise string) (*RegistrationToken, *Response, error) + + GetAuditLog(ctx context.Context, enterprise string, opts *GetAuditLogOptions) ([]*AuditEntry, *Response, error) + + ListRunners(ctx context.Context, enterprise string, opts *ListOptions) (*Runners, *Response, error) + + RemoveRunner(ctx context.Context, enterprise string, runnerID int64) (*Response, error) +} + +// EnterpriseService implements the EnterpriseServiceInterface. +var _ EnterpriseServiceInterface = &EnterpriseService{} + +// GistsServiceInterface defines the interface for the GistsService for easy mocking. +type GistsServiceInterface interface { + Create(ctx context.Context, gist *Gist) (*Gist, *Response, error) + + CreateComment(ctx context.Context, gistID string, comment *GistComment) (*GistComment, *Response, error) + + Delete(ctx context.Context, id string) (*Response, error) + + DeleteComment(ctx context.Context, gistID string, commentID int64) (*Response, error) + + Edit(ctx context.Context, id string, gist *Gist) (*Gist, *Response, error) + + EditComment(ctx context.Context, gistID string, commentID int64, comment *GistComment) (*GistComment, *Response, error) + + Fork(ctx context.Context, id string) (*Gist, *Response, error) + + Get(ctx context.Context, id string) (*Gist, *Response, error) + + GetComment(ctx context.Context, gistID string, commentID int64) (*GistComment, *Response, error) + + GetRevision(ctx context.Context, id, sha string) (*Gist, *Response, error) + + IsStarred(ctx context.Context, id string) (bool, *Response, error) + + List(ctx context.Context, user string, opts *GistListOptions) ([]*Gist, *Response, error) + + ListAll(ctx context.Context, opts *GistListOptions) ([]*Gist, *Response, error) + + ListComments(ctx context.Context, gistID string, opts *ListOptions) ([]*GistComment, *Response, error) + + ListCommits(ctx context.Context, id string, opts *ListOptions) ([]*GistCommit, *Response, error) + + ListForks(ctx context.Context, id string, opts *ListOptions) ([]*GistFork, *Response, error) + + ListStarred(ctx context.Context, opts *GistListOptions) ([]*Gist, *Response, error) + + Star(ctx context.Context, id string) (*Response, error) + + Unstar(ctx context.Context, id string) (*Response, error) +} + +// GistsService implements the GistsServiceInterface. +var _ GistsServiceInterface = &GistsService{} + +// GitServiceInterface defines the interface for the GitService for easy mocking. +type GitServiceInterface interface { + CreateBlob(ctx context.Context, owner string, repo string, blob *Blob) (*Blob, *Response, error) + + CreateCommit(ctx context.Context, owner string, repo string, commit *Commit) (*Commit, *Response, error) + + CreateRef(ctx context.Context, owner string, repo string, ref *Reference) (*Reference, *Response, error) + + CreateTag(ctx context.Context, owner string, repo string, tag *Tag) (*Tag, *Response, error) + + CreateTree(ctx context.Context, owner string, repo string, baseTree string, entries []*TreeEntry) (*Tree, *Response, error) + + DeleteRef(ctx context.Context, owner string, repo string, ref string) (*Response, error) + + GetBlob(ctx context.Context, owner string, repo string, sha string) (*Blob, *Response, error) + + GetBlobRaw(ctx context.Context, owner, repo, sha string) ([]byte, *Response, error) + + GetCommit(ctx context.Context, owner string, repo string, sha string) (*Commit, *Response, error) + + GetRef(ctx context.Context, owner string, repo string, ref string) (*Reference, *Response, error) + + GetTag(ctx context.Context, owner string, repo string, sha string) (*Tag, *Response, error) + + GetTree(ctx context.Context, owner string, repo string, sha string, recursive bool) (*Tree, *Response, error) + + ListMatchingRefs(ctx context.Context, owner, repo string, opts *ReferenceListOptions) ([]*Reference, *Response, error) + + UpdateRef(ctx context.Context, owner string, repo string, ref *Reference, force bool) (*Reference, *Response, error) +} + +// GitService implements the GitServiceInterface. +var _ GitServiceInterface = &GitService{} + +// GitignoresServiceInterface defines the interface for the GitignoresService for easy mocking. +type GitignoresServiceInterface interface { + Get(ctx context.Context, name string) (*Gitignore, *Response, error) + + List(ctx context.Context) ([]string, *Response, error) +} + +// GitignoresService implements the GitignoresServiceInterface. +var _ GitignoresServiceInterface = &GitignoresService{} + +// InteractionsServiceInterface defines the interface for the InteractionsService for easy mocking. +type InteractionsServiceInterface interface { + GetRestrictionsForOrg(ctx context.Context, organization string) (*InteractionRestriction, *Response, error) + + GetRestrictionsForRepo(ctx context.Context, owner, repo string) (*InteractionRestriction, *Response, error) + + RemoveRestrictionsFromOrg(ctx context.Context, organization string) (*Response, error) + + RemoveRestrictionsFromRepo(ctx context.Context, owner, repo string) (*Response, error) + + UpdateRestrictionsForOrg(ctx context.Context, organization, limit string) (*InteractionRestriction, *Response, error) + + UpdateRestrictionsForRepo(ctx context.Context, owner, repo, limit string) (*InteractionRestriction, *Response, error) +} + +// InteractionsService implements the InteractionsServiceInterface. +var _ InteractionsServiceInterface = &InteractionsService{} + +// IssueImportServiceInterface defines the interface for the IssueImportService for easy mocking. +type IssueImportServiceInterface interface { + CheckStatus(ctx context.Context, owner, repo string, issueID int64) (*IssueImportResponse, *Response, error) + + CheckStatusSince(ctx context.Context, owner, repo string, since time.Time) ([]*IssueImportResponse, *Response, error) + + Create(ctx context.Context, owner, repo string, issue *IssueImportRequest) (*IssueImportResponse, *Response, error) +} + +// IssueImportService implements the IssueImportServiceInterface. +var _ IssueImportServiceInterface = &IssueImportService{} + +// IssuesServiceInterface defines the interface for the IssuesService for easy mocking. +type IssuesServiceInterface interface { + AddAssignees(ctx context.Context, owner, repo string, number int, assignees []string) (*Issue, *Response, error) + + AddLabelsToIssue(ctx context.Context, owner string, repo string, number int, labels []string) ([]*Label, *Response, error) + + Create(ctx context.Context, owner string, repo string, issue *IssueRequest) (*Issue, *Response, error) + + CreateComment(ctx context.Context, owner string, repo string, number int, comment *IssueComment) (*IssueComment, *Response, error) + + CreateLabel(ctx context.Context, owner string, repo string, label *Label) (*Label, *Response, error) + + CreateMilestone(ctx context.Context, owner string, repo string, milestone *Milestone) (*Milestone, *Response, error) + + DeleteComment(ctx context.Context, owner string, repo string, commentID int64) (*Response, error) + + DeleteLabel(ctx context.Context, owner string, repo string, name string) (*Response, error) + + DeleteMilestone(ctx context.Context, owner string, repo string, number int) (*Response, error) + + Edit(ctx context.Context, owner string, repo string, number int, issue *IssueRequest) (*Issue, *Response, error) + + EditComment(ctx context.Context, owner string, repo string, commentID int64, comment *IssueComment) (*IssueComment, *Response, error) + + EditLabel(ctx context.Context, owner string, repo string, name string, label *Label) (*Label, *Response, error) + + EditMilestone(ctx context.Context, owner string, repo string, number int, milestone *Milestone) (*Milestone, *Response, error) + + Get(ctx context.Context, owner string, repo string, number int) (*Issue, *Response, error) + + GetComment(ctx context.Context, owner string, repo string, commentID int64) (*IssueComment, *Response, error) + + GetEvent(ctx context.Context, owner, repo string, id int64) (*IssueEvent, *Response, error) + + GetLabel(ctx context.Context, owner string, repo string, name string) (*Label, *Response, error) + + GetMilestone(ctx context.Context, owner string, repo string, number int) (*Milestone, *Response, error) + + IsAssignee(ctx context.Context, owner, repo, user string) (bool, *Response, error) + + List(ctx context.Context, all bool, opts *IssueListOptions) ([]*Issue, *Response, error) + + ListAssignees(ctx context.Context, owner, repo string, opts *ListOptions) ([]*User, *Response, error) + + ListByOrg(ctx context.Context, org string, opts *IssueListOptions) ([]*Issue, *Response, error) + + ListByRepo(ctx context.Context, owner string, repo string, opts *IssueListByRepoOptions) ([]*Issue, *Response, error) + + ListComments(ctx context.Context, owner string, repo string, number int, opts *IssueListCommentsOptions) ([]*IssueComment, *Response, error) + + ListIssueEvents(ctx context.Context, owner, repo string, number int, opts *ListOptions) ([]*IssueEvent, *Response, error) + + ListIssueTimeline(ctx context.Context, owner, repo string, number int, opts *ListOptions) ([]*Timeline, *Response, error) + + ListLabels(ctx context.Context, owner string, repo string, opts *ListOptions) ([]*Label, *Response, error) + + ListLabelsByIssue(ctx context.Context, owner string, repo string, number int, opts *ListOptions) ([]*Label, *Response, error) + + ListLabelsForMilestone(ctx context.Context, owner string, repo string, number int, opts *ListOptions) ([]*Label, *Response, error) + + ListMilestones(ctx context.Context, owner string, repo string, opts *MilestoneListOptions) ([]*Milestone, *Response, error) + + ListRepositoryEvents(ctx context.Context, owner, repo string, opts *ListOptions) ([]*IssueEvent, *Response, error) + + Lock(ctx context.Context, owner string, repo string, number int, opts *LockIssueOptions) (*Response, error) + + RemoveAssignees(ctx context.Context, owner, repo string, number int, assignees []string) (*Issue, *Response, error) + + RemoveLabelForIssue(ctx context.Context, owner string, repo string, number int, label string) (*Response, error) + + RemoveLabelsForIssue(ctx context.Context, owner string, repo string, number int) (*Response, error) + + ReplaceLabelsForIssue(ctx context.Context, owner string, repo string, number int, labels []string) ([]*Label, *Response, error) + + Unlock(ctx context.Context, owner string, repo string, number int) (*Response, error) +} + +// IssuesService implements the IssuesServiceInterface. +var _ IssuesServiceInterface = &IssuesService{} + +// LicensesServiceInterface defines the interface for the LicensesService for easy mocking. +type LicensesServiceInterface interface { + Get(ctx context.Context, licenseName string) (*License, *Response, error) + + List(ctx context.Context) ([]*License, *Response, error) +} + +// LicensesService implements the LicensesServiceInterface. +var _ LicensesServiceInterface = &LicensesService{} + +// MarketplaceServiceInterface defines the interface for the MarketplaceService for easy mocking. +type MarketplaceServiceInterface interface { + GetPlanAccountForAccount(ctx context.Context, accountID int64) (*MarketplacePlanAccount, *Response, error) + + GetStubbed() bool + + ListMarketplacePurchasesForUser(ctx context.Context, opts *ListOptions) ([]*MarketplacePurchase, *Response, error) + + ListPlanAccountsForPlan(ctx context.Context, planID int64, opts *ListOptions) ([]*MarketplacePlanAccount, *Response, error) + + ListPlans(ctx context.Context, opts *ListOptions) ([]*MarketplacePlan, *Response, error) + + SetStubbed(stubbed bool) +} + +// MarketplaceService implements the MarketplaceServiceInterface. +var _ MarketplaceServiceInterface = &MarketplaceService{} + +// MigrationServiceInterface defines the interface for the MigrationService for easy mocking. +type MigrationServiceInterface interface { + CancelImport(ctx context.Context, owner, repo string) (*Response, error) + + CommitAuthors(ctx context.Context, owner, repo string) ([]*SourceImportAuthor, *Response, error) + + DeleteMigration(ctx context.Context, org string, id int64) (*Response, error) + + DeleteUserMigration(ctx context.Context, id int64) (*Response, error) + + ImportProgress(ctx context.Context, owner, repo string) (*Import, *Response, error) + + LargeFiles(ctx context.Context, owner, repo string) ([]*LargeFile, *Response, error) + + ListMigrations(ctx context.Context, org string, opts *ListOptions) ([]*Migration, *Response, error) + + ListUserMigrations(ctx context.Context) ([]*UserMigration, *Response, error) + + MapCommitAuthor(ctx context.Context, owner, repo string, id int64, author *SourceImportAuthor) (*SourceImportAuthor, *Response, error) + + MigrationArchiveURL(ctx context.Context, org string, id int64) (url string, err error) + + MigrationStatus(ctx context.Context, org string, id int64) (*Migration, *Response, error) + + SetLFSPreference(ctx context.Context, owner, repo string, in *Import) (*Import, *Response, error) + + StartImport(ctx context.Context, owner, repo string, in *Import) (*Import, *Response, error) + + StartMigration(ctx context.Context, org string, repos []string, opts *MigrationOptions) (*Migration, *Response, error) + + StartUserMigration(ctx context.Context, repos []string, opts *UserMigrationOptions) (*UserMigration, *Response, error) + + UnlockRepo(ctx context.Context, org string, id int64, repo string) (*Response, error) + + UnlockUserRepo(ctx context.Context, id int64, repo string) (*Response, error) + + UpdateImport(ctx context.Context, owner, repo string, in *Import) (*Import, *Response, error) + + UserMigrationArchiveURL(ctx context.Context, id int64) (string, error) + + UserMigrationStatus(ctx context.Context, id int64) (*UserMigration, *Response, error) +} + +// MigrationService implements the MigrationServiceInterface. +var _ MigrationServiceInterface = &MigrationService{} + +// OrganizationsServiceInterface defines the interface for the OrganizationsService for easy mocking. +type OrganizationsServiceInterface interface { + BlockUser(ctx context.Context, org string, user string) (*Response, error) + + ConcealMembership(ctx context.Context, org, user string) (*Response, error) + + ConvertMemberToOutsideCollaborator(ctx context.Context, org string, user string) (*Response, error) + + CreateHook(ctx context.Context, org string, hook *Hook) (*Hook, *Response, error) + + CreateOrgInvitation(ctx context.Context, org string, opts *CreateOrgInvitationOptions) (*Invitation, *Response, error) + + CreateProject(ctx context.Context, org string, opts *ProjectOptions) (*Project, *Response, error) + + DeleteHook(ctx context.Context, org string, id int64) (*Response, error) + + Edit(ctx context.Context, name string, org *Organization) (*Organization, *Response, error) + + EditActionsAllowed(ctx context.Context, org string, actionsAllowed ActionsAllowed) (*ActionsAllowed, *Response, error) + + EditActionsPermissions(ctx context.Context, org string, actionsPermissions ActionsPermissions) (*ActionsPermissions, *Response, error) + + EditHook(ctx context.Context, org string, id int64, hook *Hook) (*Hook, *Response, error) + + EditOrgMembership(ctx context.Context, user, org string, membership *Membership) (*Membership, *Response, error) + + Get(ctx context.Context, org string) (*Organization, *Response, error) + + GetActionsAllowed(ctx context.Context, org string) (*ActionsAllowed, *Response, error) + + GetActionsPermissions(ctx context.Context, org string) (*ActionsPermissions, *Response, error) + + GetAuditLog(ctx context.Context, org string, opts *GetAuditLogOptions) ([]*AuditEntry, *Response, error) + + GetByID(ctx context.Context, id int64) (*Organization, *Response, error) + + GetHook(ctx context.Context, org string, id int64) (*Hook, *Response, error) + + GetOrgMembership(ctx context.Context, user, org string) (*Membership, *Response, error) + + IsBlocked(ctx context.Context, org string, user string) (bool, *Response, error) + + IsMember(ctx context.Context, org, user string) (bool, *Response, error) + + IsPublicMember(ctx context.Context, org, user string) (bool, *Response, error) + + List(ctx context.Context, user string, opts *ListOptions) ([]*Organization, *Response, error) + + ListAll(ctx context.Context, opts *OrganizationsListOptions) ([]*Organization, *Response, error) + + ListBlockedUsers(ctx context.Context, org string, opts *ListOptions) ([]*User, *Response, error) + + ListHooks(ctx context.Context, org string, opts *ListOptions) ([]*Hook, *Response, error) + + ListInstallations(ctx context.Context, org string, opts *ListOptions) (*OrganizationInstallations, *Response, error) + + ListMembers(ctx context.Context, org string, opts *ListMembersOptions) ([]*User, *Response, error) + + ListOrgInvitationTeams(ctx context.Context, org, invitationID string, opts *ListOptions) ([]*Team, *Response, error) + + ListOrgMemberships(ctx context.Context, opts *ListOrgMembershipsOptions) ([]*Membership, *Response, error) + + ListOutsideCollaborators(ctx context.Context, org string, opts *ListOutsideCollaboratorsOptions) ([]*User, *Response, error) + + ListPendingOrgInvitations(ctx context.Context, org string, opts *ListOptions) ([]*Invitation, *Response, error) + + ListProjects(ctx context.Context, org string, opts *ProjectListOptions) ([]*Project, *Response, error) + + PingHook(ctx context.Context, org string, id int64) (*Response, error) + + PublicizeMembership(ctx context.Context, org, user string) (*Response, error) + + RemoveMember(ctx context.Context, org, user string) (*Response, error) + + RemoveOrgMembership(ctx context.Context, user, org string) (*Response, error) + + RemoveOutsideCollaborator(ctx context.Context, org string, user string) (*Response, error) + + UnblockUser(ctx context.Context, org string, user string) (*Response, error) +} + +// OrganizationsService implements the OrganizationsServiceInterface. +var _ OrganizationsServiceInterface = &OrganizationsService{} + +// ProjectsServiceInterface defines the interface for the ProjectsService for easy mocking. +type ProjectsServiceInterface interface { + AddProjectCollaborator(ctx context.Context, id int64, username string, opts *ProjectCollaboratorOptions) (*Response, error) + + CreateProjectCard(ctx context.Context, columnID int64, opts *ProjectCardOptions) (*ProjectCard, *Response, error) + + CreateProjectColumn(ctx context.Context, projectID int64, opts *ProjectColumnOptions) (*ProjectColumn, *Response, error) + + DeleteProject(ctx context.Context, id int64) (*Response, error) + + DeleteProjectCard(ctx context.Context, cardID int64) (*Response, error) + + DeleteProjectColumn(ctx context.Context, columnID int64) (*Response, error) + + GetProject(ctx context.Context, id int64) (*Project, *Response, error) + + GetProjectCard(ctx context.Context, cardID int64) (*ProjectCard, *Response, error) + + GetProjectColumn(ctx context.Context, id int64) (*ProjectColumn, *Response, error) + + ListProjectCards(ctx context.Context, columnID int64, opts *ProjectCardListOptions) ([]*ProjectCard, *Response, error) + + ListProjectCollaborators(ctx context.Context, id int64, opts *ListCollaboratorOptions) ([]*User, *Response, error) + + ListProjectColumns(ctx context.Context, projectID int64, opts *ListOptions) ([]*ProjectColumn, *Response, error) + + MoveProjectCard(ctx context.Context, cardID int64, opts *ProjectCardMoveOptions) (*Response, error) + + MoveProjectColumn(ctx context.Context, columnID int64, opts *ProjectColumnMoveOptions) (*Response, error) + + RemoveProjectCollaborator(ctx context.Context, id int64, username string) (*Response, error) + + ReviewProjectCollaboratorPermission(ctx context.Context, id int64, username string) (*ProjectPermissionLevel, *Response, error) + + UpdateProject(ctx context.Context, id int64, opts *ProjectOptions) (*Project, *Response, error) + + UpdateProjectCard(ctx context.Context, cardID int64, opts *ProjectCardOptions) (*ProjectCard, *Response, error) + + UpdateProjectColumn(ctx context.Context, columnID int64, opts *ProjectColumnOptions) (*ProjectColumn, *Response, error) +} + +// ProjectsService implements the ProjectsServiceInterface. +var _ ProjectsServiceInterface = &ProjectsService{} + +// PullRequestsServiceInterface defines the interface for the PullRequestsService for easy mocking. +type PullRequestsServiceInterface interface { + Create(ctx context.Context, owner string, repo string, pull *NewPullRequest) (*PullRequest, *Response, error) + + CreateComment(ctx context.Context, owner, repo string, number int, comment *PullRequestComment) (*PullRequestComment, *Response, error) + + CreateCommentInReplyTo(ctx context.Context, owner, repo string, number int, body string, commentID int64) (*PullRequestComment, *Response, error) + + CreateReview(ctx context.Context, owner, repo string, number int, review *PullRequestReviewRequest) (*PullRequestReview, *Response, error) + + DeleteComment(ctx context.Context, owner, repo string, commentID int64) (*Response, error) + + DeletePendingReview(ctx context.Context, owner, repo string, number int, reviewID int64) (*PullRequestReview, *Response, error) + + DismissReview(ctx context.Context, owner, repo string, number int, reviewID int64, review *PullRequestReviewDismissalRequest) (*PullRequestReview, *Response, error) + + Edit(ctx context.Context, owner string, repo string, number int, pull *PullRequest) (*PullRequest, *Response, error) + + EditComment(ctx context.Context, owner, repo string, commentID int64, comment *PullRequestComment) (*PullRequestComment, *Response, error) + + Get(ctx context.Context, owner string, repo string, number int) (*PullRequest, *Response, error) + + GetComment(ctx context.Context, owner, repo string, commentID int64) (*PullRequestComment, *Response, error) + + GetRaw(ctx context.Context, owner string, repo string, number int, opts RawOptions) (string, *Response, error) + + GetReview(ctx context.Context, owner, repo string, number int, reviewID int64) (*PullRequestReview, *Response, error) + + IsMerged(ctx context.Context, owner string, repo string, number int) (bool, *Response, error) + + List(ctx context.Context, owner string, repo string, opts *PullRequestListOptions) ([]*PullRequest, *Response, error) + + ListComments(ctx context.Context, owner, repo string, number int, opts *PullRequestListCommentsOptions) ([]*PullRequestComment, *Response, error) + + ListCommits(ctx context.Context, owner string, repo string, number int, opts *ListOptions) ([]*RepositoryCommit, *Response, error) + + ListFiles(ctx context.Context, owner string, repo string, number int, opts *ListOptions) ([]*CommitFile, *Response, error) + + ListPullRequestsWithCommit(ctx context.Context, owner, repo, sha string, opts *PullRequestListOptions) ([]*PullRequest, *Response, error) + + ListReviewComments(ctx context.Context, owner, repo string, number int, reviewID int64, opts *ListOptions) ([]*PullRequestComment, *Response, error) + + ListReviewers(ctx context.Context, owner, repo string, number int, opts *ListOptions) (*Reviewers, *Response, error) + + ListReviews(ctx context.Context, owner, repo string, number int, opts *ListOptions) ([]*PullRequestReview, *Response, error) + + Merge(ctx context.Context, owner string, repo string, number int, commitMessage string, options *PullRequestOptions) (*PullRequestMergeResult, *Response, error) + + RemoveReviewers(ctx context.Context, owner, repo string, number int, reviewers ReviewersRequest) (*Response, error) + + RequestReviewers(ctx context.Context, owner, repo string, number int, reviewers ReviewersRequest) (*PullRequest, *Response, error) + + SubmitReview(ctx context.Context, owner, repo string, number int, reviewID int64, review *PullRequestReviewRequest) (*PullRequestReview, *Response, error) + + UpdateBranch(ctx context.Context, owner, repo string, number int, opts *PullRequestBranchUpdateOptions) (*PullRequestBranchUpdateResponse, *Response, error) + + UpdateReview(ctx context.Context, owner, repo string, number int, reviewID int64, body string) (*PullRequestReview, *Response, error) +} + +// PullRequestsService implements the PullRequestsServiceInterface. +var _ PullRequestsServiceInterface = &PullRequestsService{} + +// ReactionsServiceInterface defines the interface for the ReactionsService for easy mocking. +type ReactionsServiceInterface interface { + CreateCommentReaction(ctx context.Context, owner, repo string, id int64, content string) (*Reaction, *Response, error) + + CreateIssueCommentReaction(ctx context.Context, owner, repo string, id int64, content string) (*Reaction, *Response, error) + + CreateIssueReaction(ctx context.Context, owner, repo string, number int, content string) (*Reaction, *Response, error) + + CreatePullRequestCommentReaction(ctx context.Context, owner, repo string, id int64, content string) (*Reaction, *Response, error) + + CreateTeamDiscussionCommentReaction(ctx context.Context, teamID int64, discussionNumber, commentNumber int, content string) (*Reaction, *Response, error) + + CreateTeamDiscussionReaction(ctx context.Context, teamID int64, discussionNumber int, content string) (*Reaction, *Response, error) + + DeleteCommentReaction(ctx context.Context, owner, repo string, commentID, reactionID int64) (*Response, error) + + DeleteCommentReactionByID(ctx context.Context, repoID, commentID, reactionID int64) (*Response, error) + + DeleteIssueCommentReaction(ctx context.Context, owner, repo string, commentID, reactionID int64) (*Response, error) + + DeleteIssueCommentReactionByID(ctx context.Context, repoID, commentID, reactionID int64) (*Response, error) + + DeleteIssueReaction(ctx context.Context, owner, repo string, issueNumber int, reactionID int64) (*Response, error) + + DeleteIssueReactionByID(ctx context.Context, repoID, issueNumber int, reactionID int64) (*Response, error) + + DeletePullRequestCommentReaction(ctx context.Context, owner, repo string, commentID, reactionID int64) (*Response, error) + + DeletePullRequestCommentReactionByID(ctx context.Context, repoID, commentID, reactionID int64) (*Response, error) + + DeleteTeamDiscussionCommentReaction(ctx context.Context, org, teamSlug string, discussionNumber, commentNumber int, reactionID int64) (*Response, error) + + DeleteTeamDiscussionCommentReactionByOrgIDAndTeamID(ctx context.Context, orgID, teamID, discussionNumber, commentNumber int, reactionID int64) (*Response, error) + + DeleteTeamDiscussionReaction(ctx context.Context, org, teamSlug string, discussionNumber int, reactionID int64) (*Response, error) + + DeleteTeamDiscussionReactionByOrgIDAndTeamID(ctx context.Context, orgID, teamID, discussionNumber int, reactionID int64) (*Response, error) + + ListCommentReactions(ctx context.Context, owner, repo string, id int64, opts *ListCommentReactionOptions) ([]*Reaction, *Response, error) + + ListIssueCommentReactions(ctx context.Context, owner, repo string, id int64, opts *ListOptions) ([]*Reaction, *Response, error) + + ListIssueReactions(ctx context.Context, owner, repo string, number int, opts *ListOptions) ([]*Reaction, *Response, error) + + ListPullRequestCommentReactions(ctx context.Context, owner, repo string, id int64, opts *ListOptions) ([]*Reaction, *Response, error) + + ListTeamDiscussionCommentReactions(ctx context.Context, teamID int64, discussionNumber, commentNumber int, opts *ListOptions) ([]*Reaction, *Response, error) + + ListTeamDiscussionReactions(ctx context.Context, teamID int64, discussionNumber int, opts *ListOptions) ([]*Reaction, *Response, error) +} + +// ReactionsService implements the ReactionsServiceInterface. +var _ ReactionsServiceInterface = &ReactionsService{} + +// RepositoriesServiceInterface defines the interface for the RepositoriesService for easy mocking. +type RepositoriesServiceInterface interface { + AddAdminEnforcement(ctx context.Context, owner, repo, branch string) (*AdminEnforcement, *Response, error) + + AddAppRestrictions(ctx context.Context, owner, repo, branch string, slug []string) ([]*App, *Response, error) + + AddCollaborator(ctx context.Context, owner, repo, user string, opts *RepositoryAddCollaboratorOptions) (*CollaboratorInvitation, *Response, error) + + CompareCommits(ctx context.Context, owner, repo string, base, head string) (*CommitsComparison, *Response, error) + + CompareCommitsRaw(ctx context.Context, owner, repo, base, head string, opts RawOptions) (string, *Response, error) + + Create(ctx context.Context, org string, repo *Repository) (*Repository, *Response, error) + + CreateComment(ctx context.Context, owner, repo, sha string, comment *RepositoryComment) (*RepositoryComment, *Response, error) + + CreateDeployment(ctx context.Context, owner, repo string, request *DeploymentRequest) (*Deployment, *Response, error) + + CreateDeploymentStatus(ctx context.Context, owner, repo string, deployment int64, request *DeploymentStatusRequest) (*DeploymentStatus, *Response, error) + + CreateFile(ctx context.Context, owner, repo, path string, opts *RepositoryContentFileOptions) (*RepositoryContentResponse, *Response, error) + + CreateFork(ctx context.Context, owner, repo string, opts *RepositoryCreateForkOptions) (*Repository, *Response, error) + + CreateFromTemplate(ctx context.Context, templateOwner, templateRepo string, templateRepoReq *TemplateRepoRequest) (*Repository, *Response, error) + + CreateHook(ctx context.Context, owner, repo string, hook *Hook) (*Hook, *Response, error) + + CreateKey(ctx context.Context, owner string, repo string, key *Key) (*Key, *Response, error) + + CreateProject(ctx context.Context, owner, repo string, opts *ProjectOptions) (*Project, *Response, error) + + CreateRelease(ctx context.Context, owner, repo string, release *RepositoryRelease) (*RepositoryRelease, *Response, error) + + CreateStatus(ctx context.Context, owner, repo, ref string, status *RepoStatus) (*RepoStatus, *Response, error) + + CreateUpdateEnvironment(ctx context.Context, owner, repo, name string, environment *CreateUpdateEnvironment) (*Environment, *Response, error) + + Delete(ctx context.Context, owner, repo string) (*Response, error) + + DeleteComment(ctx context.Context, owner, repo string, id int64) (*Response, error) + + DeleteDeployment(ctx context.Context, owner, repo string, deploymentID int64) (*Response, error) + + DeleteEnvironment(ctx context.Context, owner, repo, name string) (*Response, error) + + DeleteFile(ctx context.Context, owner, repo, path string, opts *RepositoryContentFileOptions) (*RepositoryContentResponse, *Response, error) + + DeleteHook(ctx context.Context, owner, repo string, id int64) (*Response, error) + + DeleteInvitation(ctx context.Context, owner, repo string, invitationID int64) (*Response, error) + + DeleteKey(ctx context.Context, owner string, repo string, id int64) (*Response, error) + + DeletePreReceiveHook(ctx context.Context, owner, repo string, id int64) (*Response, error) + + DeleteRelease(ctx context.Context, owner, repo string, id int64) (*Response, error) + + DeleteReleaseAsset(ctx context.Context, owner, repo string, id int64) (*Response, error) + + DisableAutomatedSecurityFixes(ctx context.Context, owner, repository string) (*Response, error) + + DisableDismissalRestrictions(ctx context.Context, owner, repo, branch string) (*PullRequestReviewsEnforcement, *Response, error) + + DisablePages(ctx context.Context, owner, repo string) (*Response, error) + + DisableVulnerabilityAlerts(ctx context.Context, owner, repository string) (*Response, error) + + Dispatch(ctx context.Context, owner, repo string, opts DispatchRequestOptions) (*Repository, *Response, error) + + DownloadContents(ctx context.Context, owner, repo, filepath string, opts *RepositoryContentGetOptions) (io.ReadCloser, *Response, error) + + DownloadContentsWithMeta(ctx context.Context, owner, repo, filepath string, opts *RepositoryContentGetOptions) (io.ReadCloser, *RepositoryContent, *Response, error) + + DownloadReleaseAsset(ctx context.Context, owner, repo string, id int64, followRedirectsClient *http.Client) (rc io.ReadCloser, redirectURL string, err error) + + Edit(ctx context.Context, owner, repo string, repository *Repository) (*Repository, *Response, error) + + EditHook(ctx context.Context, owner, repo string, id int64, hook *Hook) (*Hook, *Response, error) + + EditRelease(ctx context.Context, owner, repo string, id int64, release *RepositoryRelease) (*RepositoryRelease, *Response, error) + + EditReleaseAsset(ctx context.Context, owner, repo string, id int64, release *ReleaseAsset) (*ReleaseAsset, *Response, error) + + EnableAutomatedSecurityFixes(ctx context.Context, owner, repository string) (*Response, error) + + EnablePages(ctx context.Context, owner, repo string, pages *Pages) (*Pages, *Response, error) + + EnableVulnerabilityAlerts(ctx context.Context, owner, repository string) (*Response, error) + + Get(ctx context.Context, owner, repo string) (*Repository, *Response, error) + + GetAdminEnforcement(ctx context.Context, owner, repo, branch string) (*AdminEnforcement, *Response, error) + + GetArchiveLink(ctx context.Context, owner, repo string, archiveformat ArchiveFormat, opts *RepositoryContentGetOptions, followRedirects bool) (*url.URL, *Response, error) + + GetBranch(ctx context.Context, owner, repo, branch string) (*Branch, *Response, error) + + GetBranchProtection(ctx context.Context, owner, repo, branch string) (*Protection, *Response, error) + + GetByID(ctx context.Context, id int64) (*Repository, *Response, error) + + GetCodeOfConduct(ctx context.Context, owner, repo string) (*CodeOfConduct, *Response, error) + + GetCombinedStatus(ctx context.Context, owner, repo, ref string, opts *ListOptions) (*CombinedStatus, *Response, error) + + GetComment(ctx context.Context, owner, repo string, id int64) (*RepositoryComment, *Response, error) + + GetCommit(ctx context.Context, owner, repo, sha string) (*RepositoryCommit, *Response, error) + + GetCommitRaw(ctx context.Context, owner string, repo string, sha string, opts RawOptions) (string, *Response, error) + + GetCommitSHA1(ctx context.Context, owner, repo, ref, lastSHA string) (string, *Response, error) + + GetCommunityHealthMetrics(ctx context.Context, owner, repo string) (*CommunityHealthMetrics, *Response, error) + + GetContents(ctx context.Context, owner, repo, path string, opts *RepositoryContentGetOptions) (fileContent *RepositoryContent, directoryContent []*RepositoryContent, resp *Response, err error) + + GetDeployment(ctx context.Context, owner, repo string, deploymentID int64) (*Deployment, *Response, error) + + GetDeploymentStatus(ctx context.Context, owner, repo string, deploymentID, deploymentStatusID int64) (*DeploymentStatus, *Response, error) + + GetEnvironment(ctx context.Context, owner, repo, name string) (*Environment, *Response, error) + + GetHook(ctx context.Context, owner, repo string, id int64) (*Hook, *Response, error) + + GetKey(ctx context.Context, owner string, repo string, id int64) (*Key, *Response, error) + + GetLatestPagesBuild(ctx context.Context, owner, repo string) (*PagesBuild, *Response, error) + + GetLatestRelease(ctx context.Context, owner, repo string) (*RepositoryRelease, *Response, error) + + GetPageBuild(ctx context.Context, owner, repo string, id int64) (*PagesBuild, *Response, error) + + GetPagesInfo(ctx context.Context, owner, repo string) (*Pages, *Response, error) + + GetPermissionLevel(ctx context.Context, owner, repo, user string) (*RepositoryPermissionLevel, *Response, error) + + GetPreReceiveHook(ctx context.Context, owner, repo string, id int64) (*PreReceiveHook, *Response, error) + + GetPullRequestReviewEnforcement(ctx context.Context, owner, repo, branch string) (*PullRequestReviewsEnforcement, *Response, error) + + GetReadme(ctx context.Context, owner, repo string, opts *RepositoryContentGetOptions) (*RepositoryContent, *Response, error) + + GetRelease(ctx context.Context, owner, repo string, id int64) (*RepositoryRelease, *Response, error) + + GetReleaseAsset(ctx context.Context, owner, repo string, id int64) (*ReleaseAsset, *Response, error) + + GetReleaseByTag(ctx context.Context, owner, repo, tag string) (*RepositoryRelease, *Response, error) + + GetRequiredStatusChecks(ctx context.Context, owner, repo, branch string) (*RequiredStatusChecks, *Response, error) + + GetSignaturesProtectedBranch(ctx context.Context, owner, repo, branch string) (*SignaturesProtectedBranch, *Response, error) + + GetVulnerabilityAlerts(ctx context.Context, owner, repository string) (bool, *Response, error) + + IsCollaborator(ctx context.Context, owner, repo, user string) (bool, *Response, error) + + License(ctx context.Context, owner, repo string) (*RepositoryLicense, *Response, error) + + List(ctx context.Context, user string, opts *RepositoryListOptions) ([]*Repository, *Response, error) + + ListAll(ctx context.Context, opts *RepositoryListAllOptions) ([]*Repository, *Response, error) + + ListAllTopics(ctx context.Context, owner, repo string) ([]string, *Response, error) + + ListApps(ctx context.Context, owner, repo, branch string) ([]*App, *Response, error) + + ListBranches(ctx context.Context, owner string, repo string, opts *BranchListOptions) ([]*Branch, *Response, error) + + ListBranchesHeadCommit(ctx context.Context, owner, repo, sha string) ([]*BranchCommit, *Response, error) + + ListByOrg(ctx context.Context, org string, opts *RepositoryListByOrgOptions) ([]*Repository, *Response, error) + + ListCodeFrequency(ctx context.Context, owner, repo string) ([]*WeeklyStats, *Response, error) + + ListCollaborators(ctx context.Context, owner, repo string, opts *ListCollaboratorsOptions) ([]*User, *Response, error) + + ListComments(ctx context.Context, owner, repo string, opts *ListOptions) ([]*RepositoryComment, *Response, error) + + ListCommitActivity(ctx context.Context, owner, repo string) ([]*WeeklyCommitActivity, *Response, error) + + ListCommitComments(ctx context.Context, owner, repo, sha string, opts *ListOptions) ([]*RepositoryComment, *Response, error) + + ListCommits(ctx context.Context, owner, repo string, opts *CommitsListOptions) ([]*RepositoryCommit, *Response, error) + + ListContributors(ctx context.Context, owner string, repository string, opts *ListContributorsOptions) ([]*Contributor, *Response, error) + + ListContributorsStats(ctx context.Context, owner, repo string) ([]*ContributorStats, *Response, error) + + ListDeploymentStatuses(ctx context.Context, owner, repo string, deployment int64, opts *ListOptions) ([]*DeploymentStatus, *Response, error) + + ListDeployments(ctx context.Context, owner, repo string, opts *DeploymentsListOptions) ([]*Deployment, *Response, error) + + ListEnvironments(ctx context.Context, owner, repo string) (*EnvResponse, *Response, error) + + ListForks(ctx context.Context, owner, repo string, opts *RepositoryListForksOptions) ([]*Repository, *Response, error) + + ListHooks(ctx context.Context, owner, repo string, opts *ListOptions) ([]*Hook, *Response, error) + + ListInvitations(ctx context.Context, owner, repo string, opts *ListOptions) ([]*RepositoryInvitation, *Response, error) + + ListKeys(ctx context.Context, owner string, repo string, opts *ListOptions) ([]*Key, *Response, error) + + ListLanguages(ctx context.Context, owner string, repo string) (map[string]int, *Response, error) + + ListPagesBuilds(ctx context.Context, owner, repo string, opts *ListOptions) ([]*PagesBuild, *Response, error) + + ListParticipation(ctx context.Context, owner, repo string) (*RepositoryParticipation, *Response, error) + + ListPreReceiveHooks(ctx context.Context, owner, repo string, opts *ListOptions) ([]*PreReceiveHook, *Response, error) + + ListProjects(ctx context.Context, owner, repo string, opts *ProjectListOptions) ([]*Project, *Response, error) + + ListPunchCard(ctx context.Context, owner, repo string) ([]*PunchCard, *Response, error) + + ListReleaseAssets(ctx context.Context, owner, repo string, id int64, opts *ListOptions) ([]*ReleaseAsset, *Response, error) + + ListReleases(ctx context.Context, owner, repo string, opts *ListOptions) ([]*RepositoryRelease, *Response, error) + + ListRequiredStatusChecksContexts(ctx context.Context, owner, repo, branch string) (contexts []string, resp *Response, err error) + + ListStatuses(ctx context.Context, owner, repo, ref string, opts *ListOptions) ([]*RepoStatus, *Response, error) + + ListTags(ctx context.Context, owner string, repo string, opts *ListOptions) ([]*RepositoryTag, *Response, error) + + ListTeams(ctx context.Context, owner string, repo string, opts *ListOptions) ([]*Team, *Response, error) + + ListTrafficClones(ctx context.Context, owner, repo string, opts *TrafficBreakdownOptions) (*TrafficClones, *Response, error) + + ListTrafficPaths(ctx context.Context, owner, repo string) ([]*TrafficPath, *Response, error) + + ListTrafficReferrers(ctx context.Context, owner, repo string) ([]*TrafficReferrer, *Response, error) + + ListTrafficViews(ctx context.Context, owner, repo string, opts *TrafficBreakdownOptions) (*TrafficViews, *Response, error) + + Merge(ctx context.Context, owner, repo string, request *RepositoryMergeRequest) (*RepositoryCommit, *Response, error) + + OptionalSignaturesOnProtectedBranch(ctx context.Context, owner, repo, branch string) (*Response, error) + + PingHook(ctx context.Context, owner, repo string, id int64) (*Response, error) + + RemoveAdminEnforcement(ctx context.Context, owner, repo, branch string) (*Response, error) + + RemoveAppRestrictions(ctx context.Context, owner, repo, branch string, slug []string) ([]*App, *Response, error) + + RemoveBranchProtection(ctx context.Context, owner, repo, branch string) (*Response, error) + + RemoveCollaborator(ctx context.Context, owner, repo, user string) (*Response, error) + + RemovePullRequestReviewEnforcement(ctx context.Context, owner, repo, branch string) (*Response, error) + + RemoveRequiredStatusChecks(ctx context.Context, owner, repo, branch string) (*Response, error) + + ReplaceAllTopics(ctx context.Context, owner, repo string, topics []string) ([]string, *Response, error) + + ReplaceAppRestrictions(ctx context.Context, owner, repo, branch string, slug []string) ([]*App, *Response, error) + + RequestPageBuild(ctx context.Context, owner, repo string) (*PagesBuild, *Response, error) + + RequireSignaturesOnProtectedBranch(ctx context.Context, owner, repo, branch string) (*SignaturesProtectedBranch, *Response, error) + + TestHook(ctx context.Context, owner, repo string, id int64) (*Response, error) + + Transfer(ctx context.Context, owner, repo string, transfer TransferRequest) (*Repository, *Response, error) + + UpdateBranchProtection(ctx context.Context, owner, repo, branch string, preq *ProtectionRequest) (*Protection, *Response, error) + + UpdateComment(ctx context.Context, owner, repo string, id int64, comment *RepositoryComment) (*RepositoryComment, *Response, error) + + UpdateFile(ctx context.Context, owner, repo, path string, opts *RepositoryContentFileOptions) (*RepositoryContentResponse, *Response, error) + + UpdateInvitation(ctx context.Context, owner, repo string, invitationID int64, permissions string) (*RepositoryInvitation, *Response, error) + + UpdatePages(ctx context.Context, owner, repo string, opts *PagesUpdate) (*Response, error) + + UpdatePreReceiveHook(ctx context.Context, owner, repo string, id int64, hook *PreReceiveHook) (*PreReceiveHook, *Response, error) + + UpdatePullRequestReviewEnforcement(ctx context.Context, owner, repo, branch string, patch *PullRequestReviewsEnforcementUpdate) (*PullRequestReviewsEnforcement, *Response, error) + + UpdateRequiredStatusChecks(ctx context.Context, owner, repo, branch string, sreq *RequiredStatusChecksRequest) (*RequiredStatusChecks, *Response, error) + + UploadReleaseAsset(ctx context.Context, owner, repo string, id int64, opts *UploadOptions, file *os.File) (*ReleaseAsset, *Response, error) +} + +// RepositoriesService implements the RepositoriesServiceInterface. +var _ RepositoriesServiceInterface = &RepositoriesService{} + +// SearchServiceInterface defines the interface for the SearchService for easy mocking. +type SearchServiceInterface interface { + Code(ctx context.Context, query string, opts *SearchOptions) (*CodeSearchResult, *Response, error) + + Commits(ctx context.Context, query string, opts *SearchOptions) (*CommitsSearchResult, *Response, error) + + Issues(ctx context.Context, query string, opts *SearchOptions) (*IssuesSearchResult, *Response, error) + + Labels(ctx context.Context, repoID int64, query string, opts *SearchOptions) (*LabelsSearchResult, *Response, error) + + Repositories(ctx context.Context, query string, opts *SearchOptions) (*RepositoriesSearchResult, *Response, error) + + Topics(ctx context.Context, query string, opts *SearchOptions) (*TopicsSearchResult, *Response, error) + + Users(ctx context.Context, query string, opts *SearchOptions) (*UsersSearchResult, *Response, error) +} + +// SearchService implements the SearchServiceInterface. +var _ SearchServiceInterface = &SearchService{} + +// TeamsServiceInterface defines the interface for the TeamsService for easy mocking. +type TeamsServiceInterface interface { + AddTeamMembershipByID(ctx context.Context, orgID, teamID int64, user string, opts *TeamAddTeamMembershipOptions) (*Membership, *Response, error) + + AddTeamMembershipBySlug(ctx context.Context, org, slug, user string, opts *TeamAddTeamMembershipOptions) (*Membership, *Response, error) + + AddTeamProjectByID(ctx context.Context, orgID, teamID, projectID int64, opts *TeamProjectOptions) (*Response, error) + + AddTeamProjectBySlug(ctx context.Context, org, slug string, projectID int64, opts *TeamProjectOptions) (*Response, error) + + AddTeamRepoByID(ctx context.Context, orgID, teamID int64, owner, repo string, opts *TeamAddTeamRepoOptions) (*Response, error) + + AddTeamRepoBySlug(ctx context.Context, org, slug, owner, repo string, opts *TeamAddTeamRepoOptions) (*Response, error) + + CreateCommentByID(ctx context.Context, orgID, teamID int64, discsusionNumber int, comment DiscussionComment) (*DiscussionComment, *Response, error) + + CreateCommentBySlug(ctx context.Context, org, slug string, discsusionNumber int, comment DiscussionComment) (*DiscussionComment, *Response, error) + + CreateDiscussionByID(ctx context.Context, orgID, teamID int64, discussion TeamDiscussion) (*TeamDiscussion, *Response, error) + + CreateDiscussionBySlug(ctx context.Context, org, slug string, discussion TeamDiscussion) (*TeamDiscussion, *Response, error) + + CreateOrUpdateIDPGroupConnectionsByID(ctx context.Context, orgID, teamID int64, opts IDPGroupList) (*IDPGroupList, *Response, error) + + CreateOrUpdateIDPGroupConnectionsBySlug(ctx context.Context, org, slug string, opts IDPGroupList) (*IDPGroupList, *Response, error) + + CreateTeam(ctx context.Context, org string, team NewTeam) (*Team, *Response, error) + + DeleteCommentByID(ctx context.Context, orgID, teamID int64, discussionNumber, commentNumber int) (*Response, error) + + DeleteCommentBySlug(ctx context.Context, org, slug string, discussionNumber, commentNumber int) (*Response, error) + + DeleteDiscussionByID(ctx context.Context, orgID, teamID int64, discussionNumber int) (*Response, error) + + DeleteDiscussionBySlug(ctx context.Context, org, slug string, discussionNumber int) (*Response, error) + + DeleteTeamByID(ctx context.Context, orgID, teamID int64) (*Response, error) + + DeleteTeamBySlug(ctx context.Context, org, slug string) (*Response, error) + + EditCommentByID(ctx context.Context, orgID, teamID int64, discussionNumber, commentNumber int, comment DiscussionComment) (*DiscussionComment, *Response, error) + + EditCommentBySlug(ctx context.Context, org, slug string, discussionNumber, commentNumber int, comment DiscussionComment) (*DiscussionComment, *Response, error) + + EditDiscussionByID(ctx context.Context, orgID, teamID int64, discussionNumber int, discussion TeamDiscussion) (*TeamDiscussion, *Response, error) + + EditDiscussionBySlug(ctx context.Context, org, slug string, discussionNumber int, discussion TeamDiscussion) (*TeamDiscussion, *Response, error) + + EditTeamByID(ctx context.Context, orgID, teamID int64, team NewTeam, removeParent bool) (*Team, *Response, error) + + EditTeamBySlug(ctx context.Context, org, slug string, team NewTeam, removeParent bool) (*Team, *Response, error) + + GetCommentByID(ctx context.Context, orgID, teamID int64, discussionNumber, commentNumber int) (*DiscussionComment, *Response, error) + + GetCommentBySlug(ctx context.Context, org, slug string, discussionNumber, commentNumber int) (*DiscussionComment, *Response, error) + + GetDiscussionByID(ctx context.Context, orgID, teamID int64, discussionNumber int) (*TeamDiscussion, *Response, error) + + GetDiscussionBySlug(ctx context.Context, org, slug string, discussionNumber int) (*TeamDiscussion, *Response, error) + + GetTeamByID(ctx context.Context, orgID, teamID int64) (*Team, *Response, error) + + GetTeamBySlug(ctx context.Context, org, slug string) (*Team, *Response, error) + + GetTeamMembershipByID(ctx context.Context, orgID, teamID int64, user string) (*Membership, *Response, error) + + GetTeamMembershipBySlug(ctx context.Context, org, slug, user string) (*Membership, *Response, error) + + IsTeamRepoByID(ctx context.Context, orgID, teamID int64, owner, repo string) (*Repository, *Response, error) + + IsTeamRepoBySlug(ctx context.Context, org, slug, owner, repo string) (*Repository, *Response, error) + + ListChildTeamsByParentID(ctx context.Context, orgID, teamID int64, opts *ListOptions) ([]*Team, *Response, error) + + ListChildTeamsByParentSlug(ctx context.Context, org, slug string, opts *ListOptions) ([]*Team, *Response, error) + + ListCommentsByID(ctx context.Context, orgID, teamID int64, discussionNumber int, options *DiscussionCommentListOptions) ([]*DiscussionComment, *Response, error) + + ListCommentsBySlug(ctx context.Context, org, slug string, discussionNumber int, options *DiscussionCommentListOptions) ([]*DiscussionComment, *Response, error) + + ListDiscussionsByID(ctx context.Context, orgID, teamID int64, opts *DiscussionListOptions) ([]*TeamDiscussion, *Response, error) + + ListDiscussionsBySlug(ctx context.Context, org, slug string, opts *DiscussionListOptions) ([]*TeamDiscussion, *Response, error) + + ListIDPGroupsForTeamByID(ctx context.Context, orgID, teamID int64) (*IDPGroupList, *Response, error) + + ListIDPGroupsForTeamBySlug(ctx context.Context, org, slug string) (*IDPGroupList, *Response, error) + + ListIDPGroupsInOrganization(ctx context.Context, org string, opts *ListCursorOptions) (*IDPGroupList, *Response, error) + + ListPendingTeamInvitationsByID(ctx context.Context, orgID, teamID int64, opts *ListOptions) ([]*Invitation, *Response, error) + + ListPendingTeamInvitationsBySlug(ctx context.Context, org, slug string, opts *ListOptions) ([]*Invitation, *Response, error) + + ListTeamMembersByID(ctx context.Context, orgID, teamID int64, opts *TeamListTeamMembersOptions) ([]*User, *Response, error) + + ListTeamMembersBySlug(ctx context.Context, org, slug string, opts *TeamListTeamMembersOptions) ([]*User, *Response, error) + + ListTeamProjectsByID(ctx context.Context, orgID, teamID int64) ([]*Project, *Response, error) + + ListTeamProjectsBySlug(ctx context.Context, org, slug string) ([]*Project, *Response, error) + + ListTeamReposByID(ctx context.Context, orgID, teamID int64, opts *ListOptions) ([]*Repository, *Response, error) + + ListTeamReposBySlug(ctx context.Context, org, slug string, opts *ListOptions) ([]*Repository, *Response, error) + + ListTeams(ctx context.Context, org string, opts *ListOptions) ([]*Team, *Response, error) + + ListUserTeams(ctx context.Context, opts *ListOptions) ([]*Team, *Response, error) + + RemoveTeamMembershipByID(ctx context.Context, orgID, teamID int64, user string) (*Response, error) + + RemoveTeamMembershipBySlug(ctx context.Context, org, slug, user string) (*Response, error) + + RemoveTeamProjectByID(ctx context.Context, orgID, teamID, projectID int64) (*Response, error) + + RemoveTeamProjectBySlug(ctx context.Context, org, slug string, projectID int64) (*Response, error) + + RemoveTeamRepoByID(ctx context.Context, orgID, teamID int64, owner, repo string) (*Response, error) + + RemoveTeamRepoBySlug(ctx context.Context, org, slug, owner, repo string) (*Response, error) + + ReviewTeamProjectsByID(ctx context.Context, orgID, teamID, projectID int64) (*Project, *Response, error) + + ReviewTeamProjectsBySlug(ctx context.Context, org, slug string, projectID int64) (*Project, *Response, error) +} + +// TeamsService implements the TeamsServiceInterface. +var _ TeamsServiceInterface = &TeamsService{} + +// UsersServiceInterface defines the interface for the UsersService for easy mocking. +type UsersServiceInterface interface { + AcceptInvitation(ctx context.Context, invitationID int64) (*Response, error) + + AddEmails(ctx context.Context, emails []string) ([]*UserEmail, *Response, error) + + BlockUser(ctx context.Context, user string) (*Response, error) + + CreateGPGKey(ctx context.Context, armoredPublicKey string) (*GPGKey, *Response, error) + + CreateKey(ctx context.Context, key *Key) (*Key, *Response, error) + + CreateProject(ctx context.Context, opts *CreateUserProjectOptions) (*Project, *Response, error) + + DeclineInvitation(ctx context.Context, invitationID int64) (*Response, error) + + DeleteEmails(ctx context.Context, emails []string) (*Response, error) + + DeleteGPGKey(ctx context.Context, id int64) (*Response, error) + + DeleteKey(ctx context.Context, id int64) (*Response, error) + + DemoteSiteAdmin(ctx context.Context, user string) (*Response, error) + + Edit(ctx context.Context, user *User) (*User, *Response, error) + + Follow(ctx context.Context, user string) (*Response, error) + + Get(ctx context.Context, user string) (*User, *Response, error) + + GetByID(ctx context.Context, id int64) (*User, *Response, error) + + GetGPGKey(ctx context.Context, id int64) (*GPGKey, *Response, error) + + GetHovercard(ctx context.Context, user string, opts *HovercardOptions) (*Hovercard, *Response, error) + + GetKey(ctx context.Context, id int64) (*Key, *Response, error) + + IsBlocked(ctx context.Context, user string) (bool, *Response, error) + + IsFollowing(ctx context.Context, user, target string) (bool, *Response, error) + + ListAll(ctx context.Context, opts *UserListOptions) ([]*User, *Response, error) + + ListBlockedUsers(ctx context.Context, opts *ListOptions) ([]*User, *Response, error) + + ListEmails(ctx context.Context, opts *ListOptions) ([]*UserEmail, *Response, error) + + ListFollowers(ctx context.Context, user string, opts *ListOptions) ([]*User, *Response, error) + + ListFollowing(ctx context.Context, user string, opts *ListOptions) ([]*User, *Response, error) + + ListGPGKeys(ctx context.Context, user string, opts *ListOptions) ([]*GPGKey, *Response, error) + + ListInvitations(ctx context.Context, opts *ListOptions) ([]*RepositoryInvitation, *Response, error) + + ListKeys(ctx context.Context, user string, opts *ListOptions) ([]*Key, *Response, error) + + ListProjects(ctx context.Context, user string, opts *ProjectListOptions) ([]*Project, *Response, error) + + PromoteSiteAdmin(ctx context.Context, user string) (*Response, error) + + Suspend(ctx context.Context, user string, opts *UserSuspendOptions) (*Response, error) + + UnblockUser(ctx context.Context, user string) (*Response, error) + + Unfollow(ctx context.Context, user string) (*Response, error) + + Unsuspend(ctx context.Context, user string) (*Response, error) +} + +// UsersService implements the UsersServiceInterface. +var _ UsersServiceInterface = &UsersService{} diff --git a/github/github.go b/github/github.go index efde8f8dbab..32fe1011706 100644 --- a/github/github.go +++ b/github/github.go @@ -4,6 +4,7 @@ // license that can be found in the LICENSE file. //go:generate go run gen-accessors.go +//go:generate go run gen-interfaces.go //go:generate go run gen-stringify-test.go package github @@ -156,32 +157,32 @@ type Client struct { common service // Reuse a single struct instead of allocating one for each service on the heap. // Services used for talking to different parts of the GitHub API. - Actions *ActionsService - Activity *ActivityService - Admin *AdminService - Apps *AppsService - Authorizations *AuthorizationsService - Billing *BillingService - Checks *ChecksService - CodeScanning *CodeScanningService - Enterprise *EnterpriseService - Gists *GistsService - Git *GitService - Gitignores *GitignoresService - Interactions *InteractionsService - IssueImport *IssueImportService - Issues *IssuesService - Licenses *LicensesService - Marketplace *MarketplaceService - Migrations *MigrationService - Organizations *OrganizationsService - Projects *ProjectsService - PullRequests *PullRequestsService - Reactions *ReactionsService - Repositories *RepositoriesService - Search *SearchService - Teams *TeamsService - Users *UsersService + Actions ActionsServiceInterface + Activity ActivityServiceInterface + Admin AdminServiceInterface + Apps AppsServiceInterface + Authorizations AuthorizationsServiceInterface + Billing BillingServiceInterface + Checks ChecksServiceInterface + CodeScanning CodeScanningServiceInterface + Enterprise EnterpriseServiceInterface + Gists GistsServiceInterface + Git GitServiceInterface + Gitignores GitignoresServiceInterface + Interactions InteractionsServiceInterface + IssueImport IssueImportServiceInterface + Issues IssuesServiceInterface + Licenses LicensesServiceInterface + Marketplace MarketplaceServiceInterface + Migrations MigrationServiceInterface + Organizations OrganizationsServiceInterface + Projects ProjectsServiceInterface + PullRequests PullRequestsServiceInterface + Reactions ReactionsServiceInterface + Repositories RepositoriesServiceInterface + Search SearchServiceInterface + Teams TeamsServiceInterface + Users UsersServiceInterface } type service struct {