diff --git a/github/example_iterators_test.go b/github/example_iterators_test.go new file mode 100644 index 00000000000..27b138ad403 --- /dev/null +++ b/github/example_iterators_test.go @@ -0,0 +1,30 @@ +// Copyright 2026 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 github_test + +import ( + "context" + "fmt" + "log" + + "github.com/google/go-github/v81/github" +) + +func ExampleRepositoriesService_ListByUserIter() { + client := github.NewClient(nil) + ctx := context.Background() + + // List all repositories for a user using the iterator. + // This automatically handles pagination. + // Note that if `opts` is `nil`, a new empty `opts` will be created and used within the iterator. + opts := &github.RepositoryListByUserOptions{Type: "public"} + for repo, err := range client.Repositories.ListByUserIter(ctx, "octocat", opts) { + if err != nil { + log.Fatalf("Error listing repos: %v", err) + } + fmt.Println(repo.GetName()) + } +} diff --git a/github/gen-iterators.go b/github/gen-iterators.go new file mode 100644 index 00000000000..fcbbdb8e184 --- /dev/null +++ b/github/gen-iterators.go @@ -0,0 +1,460 @@ +// Copyright 2026 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. + +//go:build ignore + +// gen-iterators generates iterator methods for List methods. +package main + +import ( + "bytes" + "flag" + "fmt" + "go/ast" + "go/format" + "go/parser" + "go/token" + "log" + "os" + "slices" + "strings" + "text/template" +) + +const ( + fileSuffix = "iterators.go" +) + +var ( + verbose = flag.Bool("v", false, "Print verbose log messages") + + sourceTmpl = template.Must(template.New("source").Funcs(template.FuncMap{ + "hasPrefix": strings.HasPrefix, + }).Parse(source)) + + testTmpl = template.Must(template.New("test").Parse(test)) +) + +func logf(fmt string, args ...any) { + if *verbose { + log.Printf(fmt, args...) + } +} + +func main() { + flag.Parse() + fset := token.NewFileSet() + + // Parse the current directory + pkgs, err := parser.ParseDir(fset, ".", sourceFilter, 0) + if err != nil { + log.Fatal(err) + return + } + + for pkgName, pkg := range pkgs { + t := &templateData{ + Package: pkgName, + Methods: []*method{}, + Structs: make(map[string]*structDef), + } + + for _, f := range pkg.Files { + t.processStructs(f) + } + + for _, f := range pkg.Files { + if err := t.processMethods(f); err != nil { + log.Fatal(err) + } + } + + 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.HasSuffix(fi.Name(), fileSuffix) && !strings.HasPrefix(fi.Name(), "gen-") +} + +type templateData struct { + Package string + Methods []*method + Structs map[string]*structDef +} + +type structDef struct { + Name string + Fields map[string]string + Embeds []string +} + +type method struct { + RecvType string + RecvVar string + ClientField string + MethodName string + IterMethod string + Args string + CallArgs string + ZeroArgs string + ReturnType string + OptsType string + OptsName string + OptsIsPtr bool + UseListOptions bool + UsePage bool + TestJSON string +} + +// customTestJSON maps method names to the JSON response they expect in tests. +// This is needed for methods that internally unmarshal a wrapper struct +// even though they return a slice. +var customTestJSON = map[string]string{ + "ListUserInstallations": `{"installations": []}`, +} + +func (t *templateData) processStructs(f *ast.File) { + for _, decl := range f.Decls { + gd, ok := decl.(*ast.GenDecl) + if !ok || gd.Tok != token.TYPE { + continue + } + for _, spec := range gd.Specs { + ts, ok := spec.(*ast.TypeSpec) + if !ok { + continue + } + st, ok := ts.Type.(*ast.StructType) + if !ok { + continue + } + + sd := &structDef{ + Name: ts.Name.Name, + Fields: make(map[string]string), + } + + for _, field := range st.Fields.List { + typeStr := typeToString(field.Type) + if len(field.Names) == 0 { + sd.Embeds = append(sd.Embeds, strings.TrimPrefix(typeStr, "*")) + } else { + for _, name := range field.Names { + sd.Fields[name.Name] = typeStr + } + } + } + t.Structs[sd.Name] = sd + } + } +} + +func (t *templateData) hasListOptions(structName string) bool { + sd, ok := t.Structs[structName] + if !ok { + return false + } + for _, embed := range sd.Embeds { + if embed == "ListOptions" { + return true + } + if t.hasListOptions(embed) { + return true + } + } + return false +} + +func (t *templateData) hasIntPage(structName string) bool { + sd, ok := t.Structs[structName] + if !ok { + return false + } + if typeStr, ok := sd.Fields["Page"]; ok { + return typeStr == "int" + } + for _, embed := range sd.Embeds { + if t.hasIntPage(embed) { + return true + } + } + return false +} + +func getZeroValue(typeStr string) string { + switch typeStr { + case "int", "int64", "int32": + return "0" + case "string": + return `""` + case "bool": + return "false" + case "context.Context": + return "context.Background()" + default: + return "nil" + } +} + +func (t *templateData) processMethods(f *ast.File) error { + for _, decl := range f.Decls { + fd, ok := decl.(*ast.FuncDecl) + if !ok || fd.Recv == nil { + continue + } + + if !fd.Name.IsExported() || !strings.HasPrefix(fd.Name.Name, "List") { + continue + } + + if strings.Contains(fd.Name.Name, "MatchingRefs") { + continue + } + + if fd.Type.Results == nil || len(fd.Type.Results.List) != 3 { + continue + } + + sliceRet, ok := fd.Type.Results.List[0].Type.(*ast.ArrayType) + if !ok { + continue + } + eltType := typeToString(sliceRet.Elt) + + if typeToString(fd.Type.Results.List[1].Type) != "*Response" { + continue + } + if typeToString(fd.Type.Results.List[2].Type) != "error" { + continue + } + + recvType := typeToString(fd.Recv.List[0].Type) + if !strings.HasPrefix(recvType, "*") || !strings.HasSuffix(recvType, "Service") { + continue + } + recvVar := "" + if len(fd.Recv.List[0].Names) > 0 { + recvVar = fd.Recv.List[0].Names[0].Name + } + + args := []string{} + callArgs := []string{} + zeroArgs := []string{} + var optsType string + var optsName string + hasOpts := false + optsIsPtr := false + + for _, field := range fd.Type.Params.List { + typeStr := typeToString(field.Type) + for _, name := range field.Names { + args = append(args, fmt.Sprintf("%s %s", name.Name, typeStr)) + callArgs = append(callArgs, name.Name) + zeroArgs = append(zeroArgs, getZeroValue(typeStr)) + + if strings.HasSuffix(typeStr, "Options") { + optsType = strings.TrimPrefix(typeStr, "*") + optsName = name.Name + hasOpts = true + optsIsPtr = strings.HasPrefix(typeStr, "*") + } + } + } + + if !hasOpts { + continue + } + + useListOptions := t.hasListOptions(optsType) + usePage := t.hasIntPage(optsType) + + if !useListOptions && !usePage { + logf("Skipping %s.%s: opts %s does not have ListOptions or Page int", recvType, fd.Name.Name, optsType) + continue + } + + recType := strings.TrimPrefix(recvType, "*") + clientField := strings.TrimSuffix(recType, "Service") + if clientField == "Migration" { + clientField = "Migrations" + } + if clientField == "s" { + logf("WARNING: clientField is 's' for %s.%s (recvType=%s)", recvType, fd.Name.Name, recType) + } + + testJSON := "[]" + if val, ok := customTestJSON[fd.Name.Name]; ok { + testJSON = val + } + + m := &method{ + RecvType: recType, + RecvVar: recvVar, + ClientField: clientField, + MethodName: fd.Name.Name, + IterMethod: fd.Name.Name + "Iter", + Args: strings.Join(args, ", "), + CallArgs: strings.Join(callArgs, ", "), + ZeroArgs: strings.Join(zeroArgs, ", "), + ReturnType: eltType, + OptsType: optsType, + OptsName: optsName, + OptsIsPtr: optsIsPtr, + UseListOptions: useListOptions, + UsePage: usePage, + TestJSON: testJSON, + } + t.Methods = append(t.Methods, m) + } + return nil +} + +func typeToString(expr ast.Expr) string { + switch x := expr.(type) { + case *ast.Ident: + return x.Name + case *ast.StarExpr: + return "*" + typeToString(x.X) + case *ast.SelectorExpr: + return typeToString(x.X) + "." + x.Sel.Name + case *ast.ArrayType: + return "[]" + typeToString(x.Elt) + case *ast.MapType: + return fmt.Sprintf("map[%s]%s", typeToString(x.Key), typeToString(x.Value)) + default: + return "" + } +} + +func (t *templateData) dump() error { + if len(t.Methods) == 0 { + return nil + } + + slices.SortStableFunc(t.Methods, func(a, b *method) int { + if a.RecvType != b.RecvType { + return strings.Compare(a.RecvType, b.RecvType) + } + return strings.Compare(a.MethodName, b.MethodName) + }) + + processTemplate := func(tmpl *template.Template, filename string) error { + var buf bytes.Buffer + if err := tmpl.Execute(&buf, t); err != nil { + return err + } + clean, err := format.Source(buf.Bytes()) + if err != nil { + return fmt.Errorf("format.Source: %v\n%s", err, buf.String()) + } + logf("Writing %v...", filename) + return os.WriteFile(filename, clean, 0644) + } + + if err := processTemplate(sourceTmpl, "iterators.go"); err != nil { + return err + } + return processTemplate(testTmpl, "iterators_gen_test.go") +} + +const source = `// Code generated by gen-iterators; DO NOT EDIT. + +// Copyright 2026 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 {{.Package}} + +import ( + "context" + "iter" +) + +{{range .Methods}} +// {{.IterMethod}} returns an iterator that paginates through all results of {{.MethodName}}. +func ({{.RecvVar}} *{{.RecvType}}) {{.IterMethod}}({{.Args}}) iter.Seq2[{{.ReturnType}}, error] { + return func(yield func({{.ReturnType}}, error) bool) { + {{if .OptsIsPtr}} + // Create a copy of opts to avoid mutating the caller's struct + if {{.OptsName}} == nil { + {{.OptsName}} = &{{.OptsType}}{} + } else { + optsCopy := *{{.OptsName}} + {{.OptsName}} = &optsCopy + } + {{else}} + // Opts is value type, already a copy + {{end}} + + for { + items, resp, err := {{.RecvVar}}.{{.MethodName}}({{.CallArgs}}) + if err != nil { + yield({{if hasPrefix .ReturnType "*"}}nil{{else}}*new({{.ReturnType}}){{end}}, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + {{if .UseListOptions}} + {{.OptsName}}.ListOptions.Page = resp.NextPage + {{else}} + {{.OptsName}}.Page = resp.NextPage + {{end}} + } + } +} +{{end}} +` + +const test = `// Code generated by gen-iterators; DO NOT EDIT. + +// Copyright 2026 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 {{.Package}} + +import ( + "context" + "fmt" + "net/http" + "testing" +) + +{{range .Methods}} +func Test{{.RecvType}}_{{.IterMethod}}(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, ` + "`" + `{{.TestJSON}}` + "`" + `) + }) + + + + // Call iterator with zero values + iter := client.{{.ClientField}}.{{.IterMethod}}({{.ZeroArgs}}) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} +{{end}} +` diff --git a/github/iterators.go b/github/iterators.go new file mode 100644 index 00000000000..126a690a22c --- /dev/null +++ b/github/iterators.go @@ -0,0 +1,5018 @@ +// Code generated by gen-iterators; DO NOT EDIT. + +// Copyright 2026 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 github + +import ( + "context" + "iter" +) + +// ListEventsIter returns an iterator that paginates through all results of ListEvents. +func (s *ActivityService) ListEventsIter(ctx context.Context, opts *ListOptions) iter.Seq2[*Event, error] { + return func(yield func(*Event, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListEvents(ctx, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListEventsForOrganizationIter returns an iterator that paginates through all results of ListEventsForOrganization. +func (s *ActivityService) ListEventsForOrganizationIter(ctx context.Context, org string, opts *ListOptions) iter.Seq2[*Event, error] { + return func(yield func(*Event, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListEventsForOrganization(ctx, org, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListEventsForRepoNetworkIter returns an iterator that paginates through all results of ListEventsForRepoNetwork. +func (s *ActivityService) ListEventsForRepoNetworkIter(ctx context.Context, owner string, repo string, opts *ListOptions) iter.Seq2[*Event, error] { + return func(yield func(*Event, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListEventsForRepoNetwork(ctx, owner, repo, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListEventsPerformedByUserIter returns an iterator that paginates through all results of ListEventsPerformedByUser. +func (s *ActivityService) ListEventsPerformedByUserIter(ctx context.Context, user string, publicOnly bool, opts *ListOptions) iter.Seq2[*Event, error] { + return func(yield func(*Event, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListEventsPerformedByUser(ctx, user, publicOnly, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListEventsReceivedByUserIter returns an iterator that paginates through all results of ListEventsReceivedByUser. +func (s *ActivityService) ListEventsReceivedByUserIter(ctx context.Context, user string, publicOnly bool, opts *ListOptions) iter.Seq2[*Event, error] { + return func(yield func(*Event, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListEventsReceivedByUser(ctx, user, publicOnly, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListIssueEventsForRepositoryIter returns an iterator that paginates through all results of ListIssueEventsForRepository. +func (s *ActivityService) ListIssueEventsForRepositoryIter(ctx context.Context, owner string, repo string, opts *ListOptions) iter.Seq2[*IssueEvent, error] { + return func(yield func(*IssueEvent, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListIssueEventsForRepository(ctx, owner, repo, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListNotificationsIter returns an iterator that paginates through all results of ListNotifications. +func (s *ActivityService) ListNotificationsIter(ctx context.Context, opts *NotificationListOptions) iter.Seq2[*Notification, error] { + return func(yield func(*Notification, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &NotificationListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListNotifications(ctx, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListRepositoryEventsIter returns an iterator that paginates through all results of ListRepositoryEvents. +func (s *ActivityService) ListRepositoryEventsIter(ctx context.Context, owner string, repo string, opts *ListOptions) iter.Seq2[*Event, error] { + return func(yield func(*Event, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListRepositoryEvents(ctx, owner, repo, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListRepositoryNotificationsIter returns an iterator that paginates through all results of ListRepositoryNotifications. +func (s *ActivityService) ListRepositoryNotificationsIter(ctx context.Context, owner string, repo string, opts *NotificationListOptions) iter.Seq2[*Notification, error] { + return func(yield func(*Notification, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &NotificationListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListRepositoryNotifications(ctx, owner, repo, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListStargazersIter returns an iterator that paginates through all results of ListStargazers. +func (s *ActivityService) ListStargazersIter(ctx context.Context, owner string, repo string, opts *ListOptions) iter.Seq2[*Stargazer, error] { + return func(yield func(*Stargazer, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListStargazers(ctx, owner, repo, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListStarredIter returns an iterator that paginates through all results of ListStarred. +func (s *ActivityService) ListStarredIter(ctx context.Context, user string, opts *ActivityListStarredOptions) iter.Seq2[*StarredRepository, error] { + return func(yield func(*StarredRepository, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ActivityListStarredOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListStarred(ctx, user, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListUserEventsForOrganizationIter returns an iterator that paginates through all results of ListUserEventsForOrganization. +func (s *ActivityService) ListUserEventsForOrganizationIter(ctx context.Context, org string, user string, opts *ListOptions) iter.Seq2[*Event, error] { + return func(yield func(*Event, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListUserEventsForOrganization(ctx, org, user, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListWatchedIter returns an iterator that paginates through all results of ListWatched. +func (s *ActivityService) ListWatchedIter(ctx context.Context, user string, opts *ListOptions) iter.Seq2[*Repository, error] { + return func(yield func(*Repository, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListWatched(ctx, user, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListWatchersIter returns an iterator that paginates through all results of ListWatchers. +func (s *ActivityService) ListWatchersIter(ctx context.Context, owner string, repo string, opts *ListOptions) iter.Seq2[*User, error] { + return func(yield func(*User, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListWatchers(ctx, owner, repo, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListInstallationRequestsIter returns an iterator that paginates through all results of ListInstallationRequests. +func (s *AppsService) ListInstallationRequestsIter(ctx context.Context, opts *ListOptions) iter.Seq2[*InstallationRequest, error] { + return func(yield func(*InstallationRequest, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListInstallationRequests(ctx, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListInstallationsIter returns an iterator that paginates through all results of ListInstallations. +func (s *AppsService) ListInstallationsIter(ctx context.Context, opts *ListOptions) iter.Seq2[*Installation, error] { + return func(yield func(*Installation, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListInstallations(ctx, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListUserInstallationsIter returns an iterator that paginates through all results of ListUserInstallations. +func (s *AppsService) ListUserInstallationsIter(ctx context.Context, opts *ListOptions) iter.Seq2[*Installation, error] { + return func(yield func(*Installation, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListUserInstallations(ctx, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListCheckRunAnnotationsIter returns an iterator that paginates through all results of ListCheckRunAnnotations. +func (s *ChecksService) ListCheckRunAnnotationsIter(ctx context.Context, owner string, repo string, checkRunID int64, opts *ListOptions) iter.Seq2[*CheckRunAnnotation, error] { + return func(yield func(*CheckRunAnnotation, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListCheckRunAnnotations(ctx, owner, repo, checkRunID, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListAcceptedAssignmentsIter returns an iterator that paginates through all results of ListAcceptedAssignments. +func (s *ClassroomService) ListAcceptedAssignmentsIter(ctx context.Context, assignmentID int64, opts *ListOptions) iter.Seq2[*AcceptedAssignment, error] { + return func(yield func(*AcceptedAssignment, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListAcceptedAssignments(ctx, assignmentID, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListClassroomAssignmentsIter returns an iterator that paginates through all results of ListClassroomAssignments. +func (s *ClassroomService) ListClassroomAssignmentsIter(ctx context.Context, classroomID int64, opts *ListOptions) iter.Seq2[*ClassroomAssignment, error] { + return func(yield func(*ClassroomAssignment, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListClassroomAssignments(ctx, classroomID, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListClassroomsIter returns an iterator that paginates through all results of ListClassrooms. +func (s *ClassroomService) ListClassroomsIter(ctx context.Context, opts *ListOptions) iter.Seq2[*Classroom, error] { + return func(yield func(*Classroom, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListClassrooms(ctx, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListAlertInstancesIter returns an iterator that paginates through all results of ListAlertInstances. +func (s *CodeScanningService) ListAlertInstancesIter(ctx context.Context, owner string, repo string, id int64, opts *AlertInstancesListOptions) iter.Seq2[*MostRecentInstance, error] { + return func(yield func(*MostRecentInstance, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &AlertInstancesListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListAlertInstances(ctx, owner, repo, id, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListAlertsForOrgIter returns an iterator that paginates through all results of ListAlertsForOrg. +func (s *CodeScanningService) ListAlertsForOrgIter(ctx context.Context, org string, opts *AlertListOptions) iter.Seq2[*Alert, error] { + return func(yield func(*Alert, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &AlertListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListAlertsForOrg(ctx, org, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListAlertsForRepoIter returns an iterator that paginates through all results of ListAlertsForRepo. +func (s *CodeScanningService) ListAlertsForRepoIter(ctx context.Context, owner string, repo string, opts *AlertListOptions) iter.Seq2[*Alert, error] { + return func(yield func(*Alert, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &AlertListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListAlertsForRepo(ctx, owner, repo, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListAnalysesForRepoIter returns an iterator that paginates through all results of ListAnalysesForRepo. +func (s *CodeScanningService) ListAnalysesForRepoIter(ctx context.Context, owner string, repo string, opts *AnalysesListOptions) iter.Seq2[*ScanningAnalysis, error] { + return func(yield func(*ScanningAnalysis, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &AnalysesListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListAnalysesForRepo(ctx, owner, repo, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListOrgAlertsIter returns an iterator that paginates through all results of ListOrgAlerts. +func (s *DependabotService) ListOrgAlertsIter(ctx context.Context, org string, opts *ListAlertsOptions) iter.Seq2[*DependabotAlert, error] { + return func(yield func(*DependabotAlert, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListAlertsOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListOrgAlerts(ctx, org, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListRepoAlertsIter returns an iterator that paginates through all results of ListRepoAlerts. +func (s *DependabotService) ListRepoAlertsIter(ctx context.Context, owner string, repo string, opts *ListAlertsOptions) iter.Seq2[*DependabotAlert, error] { + return func(yield func(*DependabotAlert, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListAlertsOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListRepoAlerts(ctx, owner, repo, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListAppAccessibleOrganizationRepositoriesIter returns an iterator that paginates through all results of ListAppAccessibleOrganizationRepositories. +func (s *EnterpriseService) ListAppAccessibleOrganizationRepositoriesIter(ctx context.Context, enterprise string, org string, opts *ListOptions) iter.Seq2[*AccessibleRepository, error] { + return func(yield func(*AccessibleRepository, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListAppAccessibleOrganizationRepositories(ctx, enterprise, org, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListAppInstallableOrganizationsIter returns an iterator that paginates through all results of ListAppInstallableOrganizations. +func (s *EnterpriseService) ListAppInstallableOrganizationsIter(ctx context.Context, enterprise string, opts *ListOptions) iter.Seq2[*InstallableOrganization, error] { + return func(yield func(*InstallableOrganization, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListAppInstallableOrganizations(ctx, enterprise, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListAppInstallationsIter returns an iterator that paginates through all results of ListAppInstallations. +func (s *EnterpriseService) ListAppInstallationsIter(ctx context.Context, enterprise string, org string, opts *ListOptions) iter.Seq2[*Installation, error] { + return func(yield func(*Installation, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListAppInstallations(ctx, enterprise, org, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListAssignmentsIter returns an iterator that paginates through all results of ListAssignments. +func (s *EnterpriseService) ListAssignmentsIter(ctx context.Context, enterprise string, enterpriseTeam string, opts *ListOptions) iter.Seq2[*Organization, error] { + return func(yield func(*Organization, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListAssignments(ctx, enterprise, enterpriseTeam, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListOrganizationCustomPropertyValuesIter returns an iterator that paginates through all results of ListOrganizationCustomPropertyValues. +func (s *EnterpriseService) ListOrganizationCustomPropertyValuesIter(ctx context.Context, enterprise string, opts *ListOptions) iter.Seq2[*EnterpriseCustomPropertiesValues, error] { + return func(yield func(*EnterpriseCustomPropertiesValues, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListOrganizationCustomPropertyValues(ctx, enterprise, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListRepositoriesForOrgAppInstallationIter returns an iterator that paginates through all results of ListRepositoriesForOrgAppInstallation. +func (s *EnterpriseService) ListRepositoriesForOrgAppInstallationIter(ctx context.Context, enterprise string, org string, installationID int64, opts *ListOptions) iter.Seq2[*AccessibleRepository, error] { + return func(yield func(*AccessibleRepository, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListRepositoriesForOrgAppInstallation(ctx, enterprise, org, installationID, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListTeamMembersIter returns an iterator that paginates through all results of ListTeamMembers. +func (s *EnterpriseService) ListTeamMembersIter(ctx context.Context, enterprise string, enterpriseTeam string, opts *ListOptions) iter.Seq2[*User, error] { + return func(yield func(*User, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListTeamMembers(ctx, enterprise, enterpriseTeam, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListTeamsIter returns an iterator that paginates through all results of ListTeams. +func (s *EnterpriseService) ListTeamsIter(ctx context.Context, enterprise string, opts *ListOptions) iter.Seq2[*EnterpriseTeam, error] { + return func(yield func(*EnterpriseTeam, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListTeams(ctx, enterprise, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListIter returns an iterator that paginates through all results of List. +func (s *GistsService) ListIter(ctx context.Context, user string, opts *GistListOptions) iter.Seq2[*Gist, error] { + return func(yield func(*Gist, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &GistListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.List(ctx, user, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListAllIter returns an iterator that paginates through all results of ListAll. +func (s *GistsService) ListAllIter(ctx context.Context, opts *GistListOptions) iter.Seq2[*Gist, error] { + return func(yield func(*Gist, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &GistListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListAll(ctx, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListCommentsIter returns an iterator that paginates through all results of ListComments. +func (s *GistsService) ListCommentsIter(ctx context.Context, gistID string, opts *ListOptions) iter.Seq2[*GistComment, error] { + return func(yield func(*GistComment, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListComments(ctx, gistID, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListCommitsIter returns an iterator that paginates through all results of ListCommits. +func (s *GistsService) ListCommitsIter(ctx context.Context, id string, opts *ListOptions) iter.Seq2[*GistCommit, error] { + return func(yield func(*GistCommit, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListCommits(ctx, id, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListForksIter returns an iterator that paginates through all results of ListForks. +func (s *GistsService) ListForksIter(ctx context.Context, id string, opts *ListOptions) iter.Seq2[*GistFork, error] { + return func(yield func(*GistFork, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListForks(ctx, id, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListStarredIter returns an iterator that paginates through all results of ListStarred. +func (s *GistsService) ListStarredIter(ctx context.Context, opts *GistListOptions) iter.Seq2[*Gist, error] { + return func(yield func(*Gist, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &GistListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListStarred(ctx, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListIter returns an iterator that paginates through all results of List. +func (s *IssuesService) ListIter(ctx context.Context, all bool, opts *IssueListOptions) iter.Seq2[*Issue, error] { + return func(yield func(*Issue, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &IssueListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.List(ctx, all, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListAssigneesIter returns an iterator that paginates through all results of ListAssignees. +func (s *IssuesService) ListAssigneesIter(ctx context.Context, owner string, repo string, opts *ListOptions) iter.Seq2[*User, error] { + return func(yield func(*User, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListAssignees(ctx, owner, repo, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListByOrgIter returns an iterator that paginates through all results of ListByOrg. +func (s *IssuesService) ListByOrgIter(ctx context.Context, org string, opts *IssueListOptions) iter.Seq2[*Issue, error] { + return func(yield func(*Issue, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &IssueListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListByOrg(ctx, org, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListByRepoIter returns an iterator that paginates through all results of ListByRepo. +func (s *IssuesService) ListByRepoIter(ctx context.Context, owner string, repo string, opts *IssueListByRepoOptions) iter.Seq2[*Issue, error] { + return func(yield func(*Issue, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &IssueListByRepoOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListByRepo(ctx, owner, repo, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListCommentsIter returns an iterator that paginates through all results of ListComments. +func (s *IssuesService) ListCommentsIter(ctx context.Context, owner string, repo string, number int, opts *IssueListCommentsOptions) iter.Seq2[*IssueComment, error] { + return func(yield func(*IssueComment, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &IssueListCommentsOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListComments(ctx, owner, repo, number, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListIssueEventsIter returns an iterator that paginates through all results of ListIssueEvents. +func (s *IssuesService) ListIssueEventsIter(ctx context.Context, owner string, repo string, number int, opts *ListOptions) iter.Seq2[*IssueEvent, error] { + return func(yield func(*IssueEvent, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListIssueEvents(ctx, owner, repo, number, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListIssueTimelineIter returns an iterator that paginates through all results of ListIssueTimeline. +func (s *IssuesService) ListIssueTimelineIter(ctx context.Context, owner string, repo string, number int, opts *ListOptions) iter.Seq2[*Timeline, error] { + return func(yield func(*Timeline, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListIssueTimeline(ctx, owner, repo, number, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListLabelsIter returns an iterator that paginates through all results of ListLabels. +func (s *IssuesService) ListLabelsIter(ctx context.Context, owner string, repo string, opts *ListOptions) iter.Seq2[*Label, error] { + return func(yield func(*Label, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListLabels(ctx, owner, repo, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListLabelsByIssueIter returns an iterator that paginates through all results of ListLabelsByIssue. +func (s *IssuesService) ListLabelsByIssueIter(ctx context.Context, owner string, repo string, number int, opts *ListOptions) iter.Seq2[*Label, error] { + return func(yield func(*Label, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListLabelsByIssue(ctx, owner, repo, number, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListLabelsForMilestoneIter returns an iterator that paginates through all results of ListLabelsForMilestone. +func (s *IssuesService) ListLabelsForMilestoneIter(ctx context.Context, owner string, repo string, number int, opts *ListOptions) iter.Seq2[*Label, error] { + return func(yield func(*Label, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListLabelsForMilestone(ctx, owner, repo, number, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListMilestonesIter returns an iterator that paginates through all results of ListMilestones. +func (s *IssuesService) ListMilestonesIter(ctx context.Context, owner string, repo string, opts *MilestoneListOptions) iter.Seq2[*Milestone, error] { + return func(yield func(*Milestone, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &MilestoneListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListMilestones(ctx, owner, repo, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListRepositoryEventsIter returns an iterator that paginates through all results of ListRepositoryEvents. +func (s *IssuesService) ListRepositoryEventsIter(ctx context.Context, owner string, repo string, opts *ListOptions) iter.Seq2[*IssueEvent, error] { + return func(yield func(*IssueEvent, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListRepositoryEvents(ctx, owner, repo, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListMarketplacePurchasesForUserIter returns an iterator that paginates through all results of ListMarketplacePurchasesForUser. +func (s *MarketplaceService) ListMarketplacePurchasesForUserIter(ctx context.Context, opts *ListOptions) iter.Seq2[*MarketplacePurchase, error] { + return func(yield func(*MarketplacePurchase, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListMarketplacePurchasesForUser(ctx, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListPlanAccountsForPlanIter returns an iterator that paginates through all results of ListPlanAccountsForPlan. +func (s *MarketplaceService) ListPlanAccountsForPlanIter(ctx context.Context, planID int64, opts *ListOptions) iter.Seq2[*MarketplacePlanAccount, error] { + return func(yield func(*MarketplacePlanAccount, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListPlanAccountsForPlan(ctx, planID, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListPlansIter returns an iterator that paginates through all results of ListPlans. +func (s *MarketplaceService) ListPlansIter(ctx context.Context, opts *ListOptions) iter.Seq2[*MarketplacePlan, error] { + return func(yield func(*MarketplacePlan, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListPlans(ctx, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListMigrationsIter returns an iterator that paginates through all results of ListMigrations. +func (s *MigrationService) ListMigrationsIter(ctx context.Context, org string, opts *ListOptions) iter.Seq2[*Migration, error] { + return func(yield func(*Migration, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListMigrations(ctx, org, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListUserMigrationsIter returns an iterator that paginates through all results of ListUserMigrations. +func (s *MigrationService) ListUserMigrationsIter(ctx context.Context, opts *ListOptions) iter.Seq2[*UserMigration, error] { + return func(yield func(*UserMigration, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListUserMigrations(ctx, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListIter returns an iterator that paginates through all results of List. +func (s *OrganizationsService) ListIter(ctx context.Context, user string, opts *ListOptions) iter.Seq2[*Organization, error] { + return func(yield func(*Organization, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.List(ctx, user, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListAllIter returns an iterator that paginates through all results of ListAll. +func (s *OrganizationsService) ListAllIter(ctx context.Context, opts *OrganizationsListOptions) iter.Seq2[*Organization, error] { + return func(yield func(*Organization, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &OrganizationsListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListAll(ctx, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListBlockedUsersIter returns an iterator that paginates through all results of ListBlockedUsers. +func (s *OrganizationsService) ListBlockedUsersIter(ctx context.Context, org string, opts *ListOptions) iter.Seq2[*User, error] { + return func(yield func(*User, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListBlockedUsers(ctx, org, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListCredentialAuthorizationsIter returns an iterator that paginates through all results of ListCredentialAuthorizations. +func (s *OrganizationsService) ListCredentialAuthorizationsIter(ctx context.Context, org string, opts *CredentialAuthorizationsListOptions) iter.Seq2[*CredentialAuthorization, error] { + return func(yield func(*CredentialAuthorization, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &CredentialAuthorizationsListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListCredentialAuthorizations(ctx, org, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListCustomPropertyValuesIter returns an iterator that paginates through all results of ListCustomPropertyValues. +func (s *OrganizationsService) ListCustomPropertyValuesIter(ctx context.Context, org string, opts *ListCustomPropertyValuesOptions) iter.Seq2[*RepoCustomPropertyValue, error] { + return func(yield func(*RepoCustomPropertyValue, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListCustomPropertyValuesOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListCustomPropertyValues(ctx, org, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListFailedOrgInvitationsIter returns an iterator that paginates through all results of ListFailedOrgInvitations. +func (s *OrganizationsService) ListFailedOrgInvitationsIter(ctx context.Context, org string, opts *ListOptions) iter.Seq2[*Invitation, error] { + return func(yield func(*Invitation, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListFailedOrgInvitations(ctx, org, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListFineGrainedPersonalAccessTokensIter returns an iterator that paginates through all results of ListFineGrainedPersonalAccessTokens. +func (s *OrganizationsService) ListFineGrainedPersonalAccessTokensIter(ctx context.Context, org string, opts *ListFineGrainedPATOptions) iter.Seq2[*PersonalAccessToken, error] { + return func(yield func(*PersonalAccessToken, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListFineGrainedPATOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListFineGrainedPersonalAccessTokens(ctx, org, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListHooksIter returns an iterator that paginates through all results of ListHooks. +func (s *OrganizationsService) ListHooksIter(ctx context.Context, org string, opts *ListOptions) iter.Seq2[*Hook, error] { + return func(yield func(*Hook, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListHooks(ctx, org, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListMembersIter returns an iterator that paginates through all results of ListMembers. +func (s *OrganizationsService) ListMembersIter(ctx context.Context, org string, opts *ListMembersOptions) iter.Seq2[*User, error] { + return func(yield func(*User, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListMembersOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListMembers(ctx, org, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListOrgInvitationTeamsIter returns an iterator that paginates through all results of ListOrgInvitationTeams. +func (s *OrganizationsService) ListOrgInvitationTeamsIter(ctx context.Context, org string, invitationID string, opts *ListOptions) iter.Seq2[*Team, error] { + return func(yield func(*Team, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListOrgInvitationTeams(ctx, org, invitationID, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListOrgMembershipsIter returns an iterator that paginates through all results of ListOrgMemberships. +func (s *OrganizationsService) ListOrgMembershipsIter(ctx context.Context, opts *ListOrgMembershipsOptions) iter.Seq2[*Membership, error] { + return func(yield func(*Membership, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOrgMembershipsOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListOrgMemberships(ctx, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListOutsideCollaboratorsIter returns an iterator that paginates through all results of ListOutsideCollaborators. +func (s *OrganizationsService) ListOutsideCollaboratorsIter(ctx context.Context, org string, opts *ListOutsideCollaboratorsOptions) iter.Seq2[*User, error] { + return func(yield func(*User, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOutsideCollaboratorsOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListOutsideCollaborators(ctx, org, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListPackagesIter returns an iterator that paginates through all results of ListPackages. +func (s *OrganizationsService) ListPackagesIter(ctx context.Context, org string, opts *PackageListOptions) iter.Seq2[*Package, error] { + return func(yield func(*Package, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &PackageListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListPackages(ctx, org, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListPendingOrgInvitationsIter returns an iterator that paginates through all results of ListPendingOrgInvitations. +func (s *OrganizationsService) ListPendingOrgInvitationsIter(ctx context.Context, org string, opts *ListOptions) iter.Seq2[*Invitation, error] { + return func(yield func(*Invitation, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListPendingOrgInvitations(ctx, org, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListTeamsAssignedToOrgRoleIter returns an iterator that paginates through all results of ListTeamsAssignedToOrgRole. +func (s *OrganizationsService) ListTeamsAssignedToOrgRoleIter(ctx context.Context, org string, roleID int64, opts *ListOptions) iter.Seq2[*Team, error] { + return func(yield func(*Team, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListTeamsAssignedToOrgRole(ctx, org, roleID, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListUsersAssignedToOrgRoleIter returns an iterator that paginates through all results of ListUsersAssignedToOrgRole. +func (s *OrganizationsService) ListUsersAssignedToOrgRoleIter(ctx context.Context, org string, roleID int64, opts *ListOptions) iter.Seq2[*User, error] { + return func(yield func(*User, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListUsersAssignedToOrgRole(ctx, org, roleID, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListIter returns an iterator that paginates through all results of List. +func (s *PullRequestsService) ListIter(ctx context.Context, owner string, repo string, opts *PullRequestListOptions) iter.Seq2[*PullRequest, error] { + return func(yield func(*PullRequest, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &PullRequestListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.List(ctx, owner, repo, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListCommentsIter returns an iterator that paginates through all results of ListComments. +func (s *PullRequestsService) ListCommentsIter(ctx context.Context, owner string, repo string, number int, opts *PullRequestListCommentsOptions) iter.Seq2[*PullRequestComment, error] { + return func(yield func(*PullRequestComment, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &PullRequestListCommentsOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListComments(ctx, owner, repo, number, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListCommitsIter returns an iterator that paginates through all results of ListCommits. +func (s *PullRequestsService) ListCommitsIter(ctx context.Context, owner string, repo string, number int, opts *ListOptions) iter.Seq2[*RepositoryCommit, error] { + return func(yield func(*RepositoryCommit, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListCommits(ctx, owner, repo, number, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListFilesIter returns an iterator that paginates through all results of ListFiles. +func (s *PullRequestsService) ListFilesIter(ctx context.Context, owner string, repo string, number int, opts *ListOptions) iter.Seq2[*CommitFile, error] { + return func(yield func(*CommitFile, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListFiles(ctx, owner, repo, number, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListPullRequestsWithCommitIter returns an iterator that paginates through all results of ListPullRequestsWithCommit. +func (s *PullRequestsService) ListPullRequestsWithCommitIter(ctx context.Context, owner string, repo string, sha string, opts *ListOptions) iter.Seq2[*PullRequest, error] { + return func(yield func(*PullRequest, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListPullRequestsWithCommit(ctx, owner, repo, sha, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListReviewCommentsIter returns an iterator that paginates through all results of ListReviewComments. +func (s *PullRequestsService) ListReviewCommentsIter(ctx context.Context, owner string, repo string, number int, reviewID int64, opts *ListOptions) iter.Seq2[*PullRequestComment, error] { + return func(yield func(*PullRequestComment, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListReviewComments(ctx, owner, repo, number, reviewID, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListReviewsIter returns an iterator that paginates through all results of ListReviews. +func (s *PullRequestsService) ListReviewsIter(ctx context.Context, owner string, repo string, number int, opts *ListOptions) iter.Seq2[*PullRequestReview, error] { + return func(yield func(*PullRequestReview, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListReviews(ctx, owner, repo, number, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListCommentReactionsIter returns an iterator that paginates through all results of ListCommentReactions. +func (s *ReactionsService) ListCommentReactionsIter(ctx context.Context, owner string, repo string, id int64, opts *ListReactionOptions) iter.Seq2[*Reaction, error] { + return func(yield func(*Reaction, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListReactionOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListCommentReactions(ctx, owner, repo, id, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListIssueCommentReactionsIter returns an iterator that paginates through all results of ListIssueCommentReactions. +func (s *ReactionsService) ListIssueCommentReactionsIter(ctx context.Context, owner string, repo string, id int64, opts *ListReactionOptions) iter.Seq2[*Reaction, error] { + return func(yield func(*Reaction, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListReactionOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListIssueCommentReactions(ctx, owner, repo, id, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListIssueReactionsIter returns an iterator that paginates through all results of ListIssueReactions. +func (s *ReactionsService) ListIssueReactionsIter(ctx context.Context, owner string, repo string, number int, opts *ListReactionOptions) iter.Seq2[*Reaction, error] { + return func(yield func(*Reaction, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListReactionOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListIssueReactions(ctx, owner, repo, number, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListPullRequestCommentReactionsIter returns an iterator that paginates through all results of ListPullRequestCommentReactions. +func (s *ReactionsService) ListPullRequestCommentReactionsIter(ctx context.Context, owner string, repo string, id int64, opts *ListReactionOptions) iter.Seq2[*Reaction, error] { + return func(yield func(*Reaction, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListReactionOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListPullRequestCommentReactions(ctx, owner, repo, id, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListReleaseReactionsIter returns an iterator that paginates through all results of ListReleaseReactions. +func (s *ReactionsService) ListReleaseReactionsIter(ctx context.Context, owner string, repo string, releaseID int64, opts *ListReactionOptions) iter.Seq2[*Reaction, error] { + return func(yield func(*Reaction, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListReactionOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListReleaseReactions(ctx, owner, repo, releaseID, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListTeamDiscussionCommentReactionsIter returns an iterator that paginates through all results of ListTeamDiscussionCommentReactions. +func (s *ReactionsService) ListTeamDiscussionCommentReactionsIter(ctx context.Context, teamID int64, discussionNumber int, commentNumber int, opts *ListReactionOptions) iter.Seq2[*Reaction, error] { + return func(yield func(*Reaction, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListReactionOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListTeamDiscussionCommentReactions(ctx, teamID, discussionNumber, commentNumber, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListTeamDiscussionReactionsIter returns an iterator that paginates through all results of ListTeamDiscussionReactions. +func (s *ReactionsService) ListTeamDiscussionReactionsIter(ctx context.Context, teamID int64, discussionNumber int, opts *ListReactionOptions) iter.Seq2[*Reaction, error] { + return func(yield func(*Reaction, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListReactionOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListTeamDiscussionReactions(ctx, teamID, discussionNumber, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListIter returns an iterator that paginates through all results of List. +func (s *RepositoriesService) ListIter(ctx context.Context, user string, opts *RepositoryListOptions) iter.Seq2[*Repository, error] { + return func(yield func(*Repository, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &RepositoryListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.List(ctx, user, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListAutolinksIter returns an iterator that paginates through all results of ListAutolinks. +func (s *RepositoriesService) ListAutolinksIter(ctx context.Context, owner string, repo string, opts *ListOptions) iter.Seq2[*Autolink, error] { + return func(yield func(*Autolink, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListAutolinks(ctx, owner, repo, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListBranchesIter returns an iterator that paginates through all results of ListBranches. +func (s *RepositoriesService) ListBranchesIter(ctx context.Context, owner string, repo string, opts *BranchListOptions) iter.Seq2[*Branch, error] { + return func(yield func(*Branch, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &BranchListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListBranches(ctx, owner, repo, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListByAuthenticatedUserIter returns an iterator that paginates through all results of ListByAuthenticatedUser. +func (s *RepositoriesService) ListByAuthenticatedUserIter(ctx context.Context, opts *RepositoryListByAuthenticatedUserOptions) iter.Seq2[*Repository, error] { + return func(yield func(*Repository, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &RepositoryListByAuthenticatedUserOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListByAuthenticatedUser(ctx, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListByOrgIter returns an iterator that paginates through all results of ListByOrg. +func (s *RepositoriesService) ListByOrgIter(ctx context.Context, org string, opts *RepositoryListByOrgOptions) iter.Seq2[*Repository, error] { + return func(yield func(*Repository, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &RepositoryListByOrgOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListByOrg(ctx, org, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListByUserIter returns an iterator that paginates through all results of ListByUser. +func (s *RepositoriesService) ListByUserIter(ctx context.Context, user string, opts *RepositoryListByUserOptions) iter.Seq2[*Repository, error] { + return func(yield func(*Repository, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &RepositoryListByUserOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListByUser(ctx, user, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListCollaboratorsIter returns an iterator that paginates through all results of ListCollaborators. +func (s *RepositoriesService) ListCollaboratorsIter(ctx context.Context, owner string, repo string, opts *ListCollaboratorsOptions) iter.Seq2[*User, error] { + return func(yield func(*User, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListCollaboratorsOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListCollaborators(ctx, owner, repo, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListCommentsIter returns an iterator that paginates through all results of ListComments. +func (s *RepositoriesService) ListCommentsIter(ctx context.Context, owner string, repo string, opts *ListOptions) iter.Seq2[*RepositoryComment, error] { + return func(yield func(*RepositoryComment, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListComments(ctx, owner, repo, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListCommitCommentsIter returns an iterator that paginates through all results of ListCommitComments. +func (s *RepositoriesService) ListCommitCommentsIter(ctx context.Context, owner string, repo string, sha string, opts *ListOptions) iter.Seq2[*RepositoryComment, error] { + return func(yield func(*RepositoryComment, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListCommitComments(ctx, owner, repo, sha, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListCommitsIter returns an iterator that paginates through all results of ListCommits. +func (s *RepositoriesService) ListCommitsIter(ctx context.Context, owner string, repo string, opts *CommitsListOptions) iter.Seq2[*RepositoryCommit, error] { + return func(yield func(*RepositoryCommit, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &CommitsListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListCommits(ctx, owner, repo, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListContributorsIter returns an iterator that paginates through all results of ListContributors. +func (s *RepositoriesService) ListContributorsIter(ctx context.Context, owner string, repository string, opts *ListContributorsOptions) iter.Seq2[*Contributor, error] { + return func(yield func(*Contributor, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListContributorsOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListContributors(ctx, owner, repository, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListDeploymentStatusesIter returns an iterator that paginates through all results of ListDeploymentStatuses. +func (s *RepositoriesService) ListDeploymentStatusesIter(ctx context.Context, owner string, repo string, deployment int64, opts *ListOptions) iter.Seq2[*DeploymentStatus, error] { + return func(yield func(*DeploymentStatus, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListDeploymentStatuses(ctx, owner, repo, deployment, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListDeploymentsIter returns an iterator that paginates through all results of ListDeployments. +func (s *RepositoriesService) ListDeploymentsIter(ctx context.Context, owner string, repo string, opts *DeploymentsListOptions) iter.Seq2[*Deployment, error] { + return func(yield func(*Deployment, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &DeploymentsListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListDeployments(ctx, owner, repo, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListForksIter returns an iterator that paginates through all results of ListForks. +func (s *RepositoriesService) ListForksIter(ctx context.Context, owner string, repo string, opts *RepositoryListForksOptions) iter.Seq2[*Repository, error] { + return func(yield func(*Repository, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &RepositoryListForksOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListForks(ctx, owner, repo, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListHooksIter returns an iterator that paginates through all results of ListHooks. +func (s *RepositoriesService) ListHooksIter(ctx context.Context, owner string, repo string, opts *ListOptions) iter.Seq2[*Hook, error] { + return func(yield func(*Hook, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListHooks(ctx, owner, repo, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListInvitationsIter returns an iterator that paginates through all results of ListInvitations. +func (s *RepositoriesService) ListInvitationsIter(ctx context.Context, owner string, repo string, opts *ListOptions) iter.Seq2[*RepositoryInvitation, error] { + return func(yield func(*RepositoryInvitation, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListInvitations(ctx, owner, repo, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListKeysIter returns an iterator that paginates through all results of ListKeys. +func (s *RepositoriesService) ListKeysIter(ctx context.Context, owner string, repo string, opts *ListOptions) iter.Seq2[*Key, error] { + return func(yield func(*Key, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListKeys(ctx, owner, repo, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListPagesBuildsIter returns an iterator that paginates through all results of ListPagesBuilds. +func (s *RepositoriesService) ListPagesBuildsIter(ctx context.Context, owner string, repo string, opts *ListOptions) iter.Seq2[*PagesBuild, error] { + return func(yield func(*PagesBuild, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListPagesBuilds(ctx, owner, repo, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListPreReceiveHooksIter returns an iterator that paginates through all results of ListPreReceiveHooks. +func (s *RepositoriesService) ListPreReceiveHooksIter(ctx context.Context, owner string, repo string, opts *ListOptions) iter.Seq2[*PreReceiveHook, error] { + return func(yield func(*PreReceiveHook, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListPreReceiveHooks(ctx, owner, repo, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListReleaseAssetsIter returns an iterator that paginates through all results of ListReleaseAssets. +func (s *RepositoriesService) ListReleaseAssetsIter(ctx context.Context, owner string, repo string, id int64, opts *ListOptions) iter.Seq2[*ReleaseAsset, error] { + return func(yield func(*ReleaseAsset, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListReleaseAssets(ctx, owner, repo, id, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListReleasesIter returns an iterator that paginates through all results of ListReleases. +func (s *RepositoriesService) ListReleasesIter(ctx context.Context, owner string, repo string, opts *ListOptions) iter.Seq2[*RepositoryRelease, error] { + return func(yield func(*RepositoryRelease, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListReleases(ctx, owner, repo, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListStatusesIter returns an iterator that paginates through all results of ListStatuses. +func (s *RepositoriesService) ListStatusesIter(ctx context.Context, owner string, repo string, ref string, opts *ListOptions) iter.Seq2[*RepoStatus, error] { + return func(yield func(*RepoStatus, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListStatuses(ctx, owner, repo, ref, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListTagsIter returns an iterator that paginates through all results of ListTags. +func (s *RepositoriesService) ListTagsIter(ctx context.Context, owner string, repo string, opts *ListOptions) iter.Seq2[*RepositoryTag, error] { + return func(yield func(*RepositoryTag, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListTags(ctx, owner, repo, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListTeamsIter returns an iterator that paginates through all results of ListTeams. +func (s *RepositoriesService) ListTeamsIter(ctx context.Context, owner string, repo string, opts *ListOptions) iter.Seq2[*Team, error] { + return func(yield func(*Team, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListTeams(ctx, owner, repo, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListAlertsForEnterpriseIter returns an iterator that paginates through all results of ListAlertsForEnterprise. +func (s *SecretScanningService) ListAlertsForEnterpriseIter(ctx context.Context, enterprise string, opts *SecretScanningAlertListOptions) iter.Seq2[*SecretScanningAlert, error] { + return func(yield func(*SecretScanningAlert, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &SecretScanningAlertListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListAlertsForEnterprise(ctx, enterprise, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListAlertsForOrgIter returns an iterator that paginates through all results of ListAlertsForOrg. +func (s *SecretScanningService) ListAlertsForOrgIter(ctx context.Context, org string, opts *SecretScanningAlertListOptions) iter.Seq2[*SecretScanningAlert, error] { + return func(yield func(*SecretScanningAlert, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &SecretScanningAlertListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListAlertsForOrg(ctx, org, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListAlertsForRepoIter returns an iterator that paginates through all results of ListAlertsForRepo. +func (s *SecretScanningService) ListAlertsForRepoIter(ctx context.Context, owner string, repo string, opts *SecretScanningAlertListOptions) iter.Seq2[*SecretScanningAlert, error] { + return func(yield func(*SecretScanningAlert, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &SecretScanningAlertListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListAlertsForRepo(ctx, owner, repo, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListLocationsForAlertIter returns an iterator that paginates through all results of ListLocationsForAlert. +func (s *SecretScanningService) ListLocationsForAlertIter(ctx context.Context, owner string, repo string, number int64, opts *ListOptions) iter.Seq2[*SecretScanningAlertLocation, error] { + return func(yield func(*SecretScanningAlertLocation, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListLocationsForAlert(ctx, owner, repo, number, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListByIssueIter returns an iterator that paginates through all results of ListByIssue. +func (s *SubIssueService) ListByIssueIter(ctx context.Context, owner string, repo string, issueNumber int64, opts *IssueListOptions) iter.Seq2[*SubIssue, error] { + return func(yield func(*SubIssue, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &IssueListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListByIssue(ctx, owner, repo, issueNumber, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListChildTeamsByParentIDIter returns an iterator that paginates through all results of ListChildTeamsByParentID. +func (s *TeamsService) ListChildTeamsByParentIDIter(ctx context.Context, orgID int64, teamID int64, opts *ListOptions) iter.Seq2[*Team, error] { + return func(yield func(*Team, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListChildTeamsByParentID(ctx, orgID, teamID, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListChildTeamsByParentSlugIter returns an iterator that paginates through all results of ListChildTeamsByParentSlug. +func (s *TeamsService) ListChildTeamsByParentSlugIter(ctx context.Context, org string, slug string, opts *ListOptions) iter.Seq2[*Team, error] { + return func(yield func(*Team, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListChildTeamsByParentSlug(ctx, org, slug, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListCommentsByIDIter returns an iterator that paginates through all results of ListCommentsByID. +func (s *TeamsService) ListCommentsByIDIter(ctx context.Context, orgID int64, teamID int64, discussionNumber int, options *DiscussionCommentListOptions) iter.Seq2[*DiscussionComment, error] { + return func(yield func(*DiscussionComment, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if options == nil { + options = &DiscussionCommentListOptions{} + } else { + optsCopy := *options + options = &optsCopy + } + + for { + items, resp, err := s.ListCommentsByID(ctx, orgID, teamID, discussionNumber, options) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + options.ListOptions.Page = resp.NextPage + + } + } +} + +// ListCommentsBySlugIter returns an iterator that paginates through all results of ListCommentsBySlug. +func (s *TeamsService) ListCommentsBySlugIter(ctx context.Context, org string, slug string, discussionNumber int, options *DiscussionCommentListOptions) iter.Seq2[*DiscussionComment, error] { + return func(yield func(*DiscussionComment, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if options == nil { + options = &DiscussionCommentListOptions{} + } else { + optsCopy := *options + options = &optsCopy + } + + for { + items, resp, err := s.ListCommentsBySlug(ctx, org, slug, discussionNumber, options) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + options.ListOptions.Page = resp.NextPage + + } + } +} + +// ListDiscussionsByIDIter returns an iterator that paginates through all results of ListDiscussionsByID. +func (s *TeamsService) ListDiscussionsByIDIter(ctx context.Context, orgID int64, teamID int64, opts *DiscussionListOptions) iter.Seq2[*TeamDiscussion, error] { + return func(yield func(*TeamDiscussion, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &DiscussionListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListDiscussionsByID(ctx, orgID, teamID, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListDiscussionsBySlugIter returns an iterator that paginates through all results of ListDiscussionsBySlug. +func (s *TeamsService) ListDiscussionsBySlugIter(ctx context.Context, org string, slug string, opts *DiscussionListOptions) iter.Seq2[*TeamDiscussion, error] { + return func(yield func(*TeamDiscussion, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &DiscussionListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListDiscussionsBySlug(ctx, org, slug, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListPendingTeamInvitationsByIDIter returns an iterator that paginates through all results of ListPendingTeamInvitationsByID. +func (s *TeamsService) ListPendingTeamInvitationsByIDIter(ctx context.Context, orgID int64, teamID int64, opts *ListOptions) iter.Seq2[*Invitation, error] { + return func(yield func(*Invitation, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListPendingTeamInvitationsByID(ctx, orgID, teamID, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListPendingTeamInvitationsBySlugIter returns an iterator that paginates through all results of ListPendingTeamInvitationsBySlug. +func (s *TeamsService) ListPendingTeamInvitationsBySlugIter(ctx context.Context, org string, slug string, opts *ListOptions) iter.Seq2[*Invitation, error] { + return func(yield func(*Invitation, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListPendingTeamInvitationsBySlug(ctx, org, slug, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListTeamMembersByIDIter returns an iterator that paginates through all results of ListTeamMembersByID. +func (s *TeamsService) ListTeamMembersByIDIter(ctx context.Context, orgID int64, teamID int64, opts *TeamListTeamMembersOptions) iter.Seq2[*User, error] { + return func(yield func(*User, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &TeamListTeamMembersOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListTeamMembersByID(ctx, orgID, teamID, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListTeamMembersBySlugIter returns an iterator that paginates through all results of ListTeamMembersBySlug. +func (s *TeamsService) ListTeamMembersBySlugIter(ctx context.Context, org string, slug string, opts *TeamListTeamMembersOptions) iter.Seq2[*User, error] { + return func(yield func(*User, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &TeamListTeamMembersOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListTeamMembersBySlug(ctx, org, slug, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListTeamReposByIDIter returns an iterator that paginates through all results of ListTeamReposByID. +func (s *TeamsService) ListTeamReposByIDIter(ctx context.Context, orgID int64, teamID int64, opts *ListOptions) iter.Seq2[*Repository, error] { + return func(yield func(*Repository, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListTeamReposByID(ctx, orgID, teamID, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListTeamReposBySlugIter returns an iterator that paginates through all results of ListTeamReposBySlug. +func (s *TeamsService) ListTeamReposBySlugIter(ctx context.Context, org string, slug string, opts *ListOptions) iter.Seq2[*Repository, error] { + return func(yield func(*Repository, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListTeamReposBySlug(ctx, org, slug, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListTeamsIter returns an iterator that paginates through all results of ListTeams. +func (s *TeamsService) ListTeamsIter(ctx context.Context, org string, opts *ListOptions) iter.Seq2[*Team, error] { + return func(yield func(*Team, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListTeams(ctx, org, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListUserTeamsIter returns an iterator that paginates through all results of ListUserTeams. +func (s *TeamsService) ListUserTeamsIter(ctx context.Context, opts *ListOptions) iter.Seq2[*Team, error] { + return func(yield func(*Team, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListUserTeams(ctx, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListAllIter returns an iterator that paginates through all results of ListAll. +func (s *UsersService) ListAllIter(ctx context.Context, opts *UserListOptions) iter.Seq2[*User, error] { + return func(yield func(*User, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &UserListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListAll(ctx, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListBlockedUsersIter returns an iterator that paginates through all results of ListBlockedUsers. +func (s *UsersService) ListBlockedUsersIter(ctx context.Context, opts *ListOptions) iter.Seq2[*User, error] { + return func(yield func(*User, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListBlockedUsers(ctx, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListEmailsIter returns an iterator that paginates through all results of ListEmails. +func (s *UsersService) ListEmailsIter(ctx context.Context, opts *ListOptions) iter.Seq2[*UserEmail, error] { + return func(yield func(*UserEmail, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListEmails(ctx, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListFollowersIter returns an iterator that paginates through all results of ListFollowers. +func (s *UsersService) ListFollowersIter(ctx context.Context, user string, opts *ListOptions) iter.Seq2[*User, error] { + return func(yield func(*User, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListFollowers(ctx, user, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListFollowingIter returns an iterator that paginates through all results of ListFollowing. +func (s *UsersService) ListFollowingIter(ctx context.Context, user string, opts *ListOptions) iter.Seq2[*User, error] { + return func(yield func(*User, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListFollowing(ctx, user, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListGPGKeysIter returns an iterator that paginates through all results of ListGPGKeys. +func (s *UsersService) ListGPGKeysIter(ctx context.Context, user string, opts *ListOptions) iter.Seq2[*GPGKey, error] { + return func(yield func(*GPGKey, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListGPGKeys(ctx, user, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListInvitationsIter returns an iterator that paginates through all results of ListInvitations. +func (s *UsersService) ListInvitationsIter(ctx context.Context, opts *ListOptions) iter.Seq2[*RepositoryInvitation, error] { + return func(yield func(*RepositoryInvitation, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListInvitations(ctx, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListKeysIter returns an iterator that paginates through all results of ListKeys. +func (s *UsersService) ListKeysIter(ctx context.Context, user string, opts *ListOptions) iter.Seq2[*Key, error] { + return func(yield func(*Key, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListKeys(ctx, user, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListPackagesIter returns an iterator that paginates through all results of ListPackages. +func (s *UsersService) ListPackagesIter(ctx context.Context, user string, opts *PackageListOptions) iter.Seq2[*Package, error] { + return func(yield func(*Package, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &PackageListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListPackages(ctx, user, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.ListOptions.Page = resp.NextPage + + } + } +} + +// ListSSHSigningKeysIter returns an iterator that paginates through all results of ListSSHSigningKeys. +func (s *UsersService) ListSSHSigningKeysIter(ctx context.Context, user string, opts *ListOptions) iter.Seq2[*SSHSigningKey, error] { + return func(yield func(*SSHSigningKey, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListSSHSigningKeys(ctx, user, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListSocialAccountsIter returns an iterator that paginates through all results of ListSocialAccounts. +func (s *UsersService) ListSocialAccountsIter(ctx context.Context, opts *ListOptions) iter.Seq2[*SocialAccount, error] { + return func(yield func(*SocialAccount, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListSocialAccounts(ctx, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} + +// ListUserSocialAccountsIter returns an iterator that paginates through all results of ListUserSocialAccounts. +func (s *UsersService) ListUserSocialAccountsIter(ctx context.Context, username string, opts *ListOptions) iter.Seq2[*SocialAccount, error] { + return func(yield func(*SocialAccount, error) bool) { + + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOptions{} + } else { + optsCopy := *opts + opts = &optsCopy + } + + for { + items, resp, err := s.ListUserSocialAccounts(ctx, username, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.NextPage == 0 { + break + } + + opts.Page = resp.NextPage + + } + } +} diff --git a/github/iterators_gen_test.go b/github/iterators_gen_test.go new file mode 100644 index 00000000000..60015a7646e --- /dev/null +++ b/github/iterators_gen_test.go @@ -0,0 +1,2303 @@ +// Code generated by gen-iterators; DO NOT EDIT. + +// Copyright 2026 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 github + +import ( + "context" + "fmt" + "net/http" + "testing" +) + +func TestActivityService_ListEventsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Activity.ListEventsIter(context.Background(), nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestActivityService_ListEventsForOrganizationIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Activity.ListEventsForOrganizationIter(context.Background(), "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestActivityService_ListEventsForRepoNetworkIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Activity.ListEventsForRepoNetworkIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestActivityService_ListEventsPerformedByUserIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Activity.ListEventsPerformedByUserIter(context.Background(), "", false, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestActivityService_ListEventsReceivedByUserIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Activity.ListEventsReceivedByUserIter(context.Background(), "", false, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestActivityService_ListIssueEventsForRepositoryIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Activity.ListIssueEventsForRepositoryIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestActivityService_ListNotificationsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Activity.ListNotificationsIter(context.Background(), nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestActivityService_ListRepositoryEventsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Activity.ListRepositoryEventsIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestActivityService_ListRepositoryNotificationsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Activity.ListRepositoryNotificationsIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestActivityService_ListStargazersIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Activity.ListStargazersIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestActivityService_ListStarredIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Activity.ListStarredIter(context.Background(), "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestActivityService_ListUserEventsForOrganizationIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Activity.ListUserEventsForOrganizationIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestActivityService_ListWatchedIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Activity.ListWatchedIter(context.Background(), "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestActivityService_ListWatchersIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Activity.ListWatchersIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestAppsService_ListInstallationRequestsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Apps.ListInstallationRequestsIter(context.Background(), nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestAppsService_ListInstallationsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Apps.ListInstallationsIter(context.Background(), nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestAppsService_ListUserInstallationsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `{"installations": []}`) + }) + + // Call iterator with zero values + iter := client.Apps.ListUserInstallationsIter(context.Background(), nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestChecksService_ListCheckRunAnnotationsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Checks.ListCheckRunAnnotationsIter(context.Background(), "", "", 0, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestClassroomService_ListAcceptedAssignmentsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Classroom.ListAcceptedAssignmentsIter(context.Background(), 0, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestClassroomService_ListClassroomAssignmentsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Classroom.ListClassroomAssignmentsIter(context.Background(), 0, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestClassroomService_ListClassroomsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Classroom.ListClassroomsIter(context.Background(), nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestCodeScanningService_ListAlertInstancesIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.CodeScanning.ListAlertInstancesIter(context.Background(), "", "", 0, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestCodeScanningService_ListAlertsForOrgIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.CodeScanning.ListAlertsForOrgIter(context.Background(), "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestCodeScanningService_ListAlertsForRepoIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.CodeScanning.ListAlertsForRepoIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestCodeScanningService_ListAnalysesForRepoIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.CodeScanning.ListAnalysesForRepoIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestDependabotService_ListOrgAlertsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Dependabot.ListOrgAlertsIter(context.Background(), "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestDependabotService_ListRepoAlertsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Dependabot.ListRepoAlertsIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestEnterpriseService_ListAppAccessibleOrganizationRepositoriesIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Enterprise.ListAppAccessibleOrganizationRepositoriesIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestEnterpriseService_ListAppInstallableOrganizationsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Enterprise.ListAppInstallableOrganizationsIter(context.Background(), "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestEnterpriseService_ListAppInstallationsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Enterprise.ListAppInstallationsIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestEnterpriseService_ListAssignmentsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Enterprise.ListAssignmentsIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestEnterpriseService_ListOrganizationCustomPropertyValuesIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Enterprise.ListOrganizationCustomPropertyValuesIter(context.Background(), "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestEnterpriseService_ListRepositoriesForOrgAppInstallationIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Enterprise.ListRepositoriesForOrgAppInstallationIter(context.Background(), "", "", 0, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestEnterpriseService_ListTeamMembersIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Enterprise.ListTeamMembersIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestEnterpriseService_ListTeamsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Enterprise.ListTeamsIter(context.Background(), "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestGistsService_ListIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Gists.ListIter(context.Background(), "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestGistsService_ListAllIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Gists.ListAllIter(context.Background(), nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestGistsService_ListCommentsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Gists.ListCommentsIter(context.Background(), "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestGistsService_ListCommitsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Gists.ListCommitsIter(context.Background(), "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestGistsService_ListForksIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Gists.ListForksIter(context.Background(), "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestGistsService_ListStarredIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Gists.ListStarredIter(context.Background(), nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestIssuesService_ListIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Issues.ListIter(context.Background(), false, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestIssuesService_ListAssigneesIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Issues.ListAssigneesIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestIssuesService_ListByOrgIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Issues.ListByOrgIter(context.Background(), "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestIssuesService_ListByRepoIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Issues.ListByRepoIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestIssuesService_ListCommentsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Issues.ListCommentsIter(context.Background(), "", "", 0, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestIssuesService_ListIssueEventsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Issues.ListIssueEventsIter(context.Background(), "", "", 0, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestIssuesService_ListIssueTimelineIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Issues.ListIssueTimelineIter(context.Background(), "", "", 0, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestIssuesService_ListLabelsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Issues.ListLabelsIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestIssuesService_ListLabelsByIssueIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Issues.ListLabelsByIssueIter(context.Background(), "", "", 0, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestIssuesService_ListLabelsForMilestoneIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Issues.ListLabelsForMilestoneIter(context.Background(), "", "", 0, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestIssuesService_ListMilestonesIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Issues.ListMilestonesIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestIssuesService_ListRepositoryEventsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Issues.ListRepositoryEventsIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestMarketplaceService_ListMarketplacePurchasesForUserIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Marketplace.ListMarketplacePurchasesForUserIter(context.Background(), nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestMarketplaceService_ListPlanAccountsForPlanIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Marketplace.ListPlanAccountsForPlanIter(context.Background(), 0, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestMarketplaceService_ListPlansIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Marketplace.ListPlansIter(context.Background(), nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestMigrationService_ListMigrationsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Migrations.ListMigrationsIter(context.Background(), "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestMigrationService_ListUserMigrationsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Migrations.ListUserMigrationsIter(context.Background(), nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestOrganizationsService_ListIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Organizations.ListIter(context.Background(), "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestOrganizationsService_ListAllIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Organizations.ListAllIter(context.Background(), nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestOrganizationsService_ListBlockedUsersIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Organizations.ListBlockedUsersIter(context.Background(), "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestOrganizationsService_ListCredentialAuthorizationsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Organizations.ListCredentialAuthorizationsIter(context.Background(), "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestOrganizationsService_ListCustomPropertyValuesIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Organizations.ListCustomPropertyValuesIter(context.Background(), "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestOrganizationsService_ListFailedOrgInvitationsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Organizations.ListFailedOrgInvitationsIter(context.Background(), "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestOrganizationsService_ListFineGrainedPersonalAccessTokensIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Organizations.ListFineGrainedPersonalAccessTokensIter(context.Background(), "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestOrganizationsService_ListHooksIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Organizations.ListHooksIter(context.Background(), "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestOrganizationsService_ListMembersIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Organizations.ListMembersIter(context.Background(), "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestOrganizationsService_ListOrgInvitationTeamsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Organizations.ListOrgInvitationTeamsIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestOrganizationsService_ListOrgMembershipsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Organizations.ListOrgMembershipsIter(context.Background(), nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestOrganizationsService_ListOutsideCollaboratorsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Organizations.ListOutsideCollaboratorsIter(context.Background(), "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestOrganizationsService_ListPackagesIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Organizations.ListPackagesIter(context.Background(), "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestOrganizationsService_ListPendingOrgInvitationsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Organizations.ListPendingOrgInvitationsIter(context.Background(), "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestOrganizationsService_ListTeamsAssignedToOrgRoleIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Organizations.ListTeamsAssignedToOrgRoleIter(context.Background(), "", 0, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestOrganizationsService_ListUsersAssignedToOrgRoleIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Organizations.ListUsersAssignedToOrgRoleIter(context.Background(), "", 0, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestPullRequestsService_ListIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.PullRequests.ListIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestPullRequestsService_ListCommentsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.PullRequests.ListCommentsIter(context.Background(), "", "", 0, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestPullRequestsService_ListCommitsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.PullRequests.ListCommitsIter(context.Background(), "", "", 0, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestPullRequestsService_ListFilesIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.PullRequests.ListFilesIter(context.Background(), "", "", 0, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestPullRequestsService_ListPullRequestsWithCommitIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.PullRequests.ListPullRequestsWithCommitIter(context.Background(), "", "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestPullRequestsService_ListReviewCommentsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.PullRequests.ListReviewCommentsIter(context.Background(), "", "", 0, 0, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestPullRequestsService_ListReviewsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.PullRequests.ListReviewsIter(context.Background(), "", "", 0, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestReactionsService_ListCommentReactionsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Reactions.ListCommentReactionsIter(context.Background(), "", "", 0, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestReactionsService_ListIssueCommentReactionsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Reactions.ListIssueCommentReactionsIter(context.Background(), "", "", 0, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestReactionsService_ListIssueReactionsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Reactions.ListIssueReactionsIter(context.Background(), "", "", 0, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestReactionsService_ListPullRequestCommentReactionsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Reactions.ListPullRequestCommentReactionsIter(context.Background(), "", "", 0, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestReactionsService_ListReleaseReactionsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Reactions.ListReleaseReactionsIter(context.Background(), "", "", 0, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestReactionsService_ListTeamDiscussionCommentReactionsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Reactions.ListTeamDiscussionCommentReactionsIter(context.Background(), 0, 0, 0, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestReactionsService_ListTeamDiscussionReactionsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Reactions.ListTeamDiscussionReactionsIter(context.Background(), 0, 0, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestRepositoriesService_ListIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Repositories.ListIter(context.Background(), "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestRepositoriesService_ListAutolinksIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Repositories.ListAutolinksIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestRepositoriesService_ListBranchesIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Repositories.ListBranchesIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestRepositoriesService_ListByAuthenticatedUserIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Repositories.ListByAuthenticatedUserIter(context.Background(), nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestRepositoriesService_ListByOrgIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Repositories.ListByOrgIter(context.Background(), "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestRepositoriesService_ListByUserIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Repositories.ListByUserIter(context.Background(), "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestRepositoriesService_ListCollaboratorsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Repositories.ListCollaboratorsIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestRepositoriesService_ListCommentsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Repositories.ListCommentsIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestRepositoriesService_ListCommitCommentsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Repositories.ListCommitCommentsIter(context.Background(), "", "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestRepositoriesService_ListCommitsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Repositories.ListCommitsIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestRepositoriesService_ListContributorsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Repositories.ListContributorsIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestRepositoriesService_ListDeploymentStatusesIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Repositories.ListDeploymentStatusesIter(context.Background(), "", "", 0, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestRepositoriesService_ListDeploymentsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Repositories.ListDeploymentsIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestRepositoriesService_ListForksIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Repositories.ListForksIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestRepositoriesService_ListHooksIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Repositories.ListHooksIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestRepositoriesService_ListInvitationsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Repositories.ListInvitationsIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestRepositoriesService_ListKeysIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Repositories.ListKeysIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestRepositoriesService_ListPagesBuildsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Repositories.ListPagesBuildsIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestRepositoriesService_ListPreReceiveHooksIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Repositories.ListPreReceiveHooksIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestRepositoriesService_ListReleaseAssetsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Repositories.ListReleaseAssetsIter(context.Background(), "", "", 0, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestRepositoriesService_ListReleasesIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Repositories.ListReleasesIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestRepositoriesService_ListStatusesIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Repositories.ListStatusesIter(context.Background(), "", "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestRepositoriesService_ListTagsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Repositories.ListTagsIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestRepositoriesService_ListTeamsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Repositories.ListTeamsIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestSecretScanningService_ListAlertsForEnterpriseIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.SecretScanning.ListAlertsForEnterpriseIter(context.Background(), "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestSecretScanningService_ListAlertsForOrgIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.SecretScanning.ListAlertsForOrgIter(context.Background(), "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestSecretScanningService_ListAlertsForRepoIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.SecretScanning.ListAlertsForRepoIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestSecretScanningService_ListLocationsForAlertIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.SecretScanning.ListLocationsForAlertIter(context.Background(), "", "", 0, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestSubIssueService_ListByIssueIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.SubIssue.ListByIssueIter(context.Background(), "", "", 0, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestTeamsService_ListChildTeamsByParentIDIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Teams.ListChildTeamsByParentIDIter(context.Background(), 0, 0, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestTeamsService_ListChildTeamsByParentSlugIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Teams.ListChildTeamsByParentSlugIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestTeamsService_ListCommentsByIDIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Teams.ListCommentsByIDIter(context.Background(), 0, 0, 0, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestTeamsService_ListCommentsBySlugIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Teams.ListCommentsBySlugIter(context.Background(), "", "", 0, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestTeamsService_ListDiscussionsByIDIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Teams.ListDiscussionsByIDIter(context.Background(), 0, 0, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestTeamsService_ListDiscussionsBySlugIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Teams.ListDiscussionsBySlugIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestTeamsService_ListPendingTeamInvitationsByIDIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Teams.ListPendingTeamInvitationsByIDIter(context.Background(), 0, 0, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestTeamsService_ListPendingTeamInvitationsBySlugIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Teams.ListPendingTeamInvitationsBySlugIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestTeamsService_ListTeamMembersByIDIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Teams.ListTeamMembersByIDIter(context.Background(), 0, 0, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestTeamsService_ListTeamMembersBySlugIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Teams.ListTeamMembersBySlugIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestTeamsService_ListTeamReposByIDIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Teams.ListTeamReposByIDIter(context.Background(), 0, 0, nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestTeamsService_ListTeamReposBySlugIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Teams.ListTeamReposBySlugIter(context.Background(), "", "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestTeamsService_ListTeamsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Teams.ListTeamsIter(context.Background(), "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestTeamsService_ListUserTeamsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Teams.ListUserTeamsIter(context.Background(), nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestUsersService_ListAllIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Users.ListAllIter(context.Background(), nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestUsersService_ListBlockedUsersIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Users.ListBlockedUsersIter(context.Background(), nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestUsersService_ListEmailsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Users.ListEmailsIter(context.Background(), nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestUsersService_ListFollowersIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Users.ListFollowersIter(context.Background(), "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestUsersService_ListFollowingIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Users.ListFollowingIter(context.Background(), "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestUsersService_ListGPGKeysIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Users.ListGPGKeysIter(context.Background(), "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestUsersService_ListInvitationsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Users.ListInvitationsIter(context.Background(), nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestUsersService_ListKeysIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Users.ListKeysIter(context.Background(), "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestUsersService_ListPackagesIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Users.ListPackagesIter(context.Background(), "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestUsersService_ListSSHSigningKeysIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Users.ListSSHSigningKeysIter(context.Background(), "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestUsersService_ListSocialAccountsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Users.ListSocialAccountsIter(context.Background(), nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} + +func TestUsersService_ListUserSocialAccountsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, `[]`) + }) + + // Call iterator with zero values + iter := client.Users.ListUserSocialAccountsIter(context.Background(), "", nil) + for _, err := range iter { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } +} diff --git a/tools/metadata/metadata.go b/tools/metadata/metadata.go index 5b28085d54f..d0332f7ef8b 100644 --- a/tools/metadata/metadata.go +++ b/tools/metadata/metadata.go @@ -520,6 +520,11 @@ func nodeServiceMethod(fn *ast.FuncDecl) string { return "" } + // Skip generated Iterator methods. + if strings.HasSuffix(fn.Name.Name, "Iter") { + return "" + } + serviceMethod := id.Name + "." + fn.Name.Name if skipServiceMethod[serviceMethod] { return ""