+
Skip to content

Conversation

dghubble
Copy link
Contributor

@dghubble dghubble commented Oct 27, 2021

With this change, pagination can be performed

auditParams := &github.GetAuditLogOptions{}
for {
  entries, resp, err := client.Organizations.GetAuditLog(ctx, "myorg", auditParams)
  if err != nil {
    return err
  }

  if resp.After == "" {
    break
  }
  auditParams.After = resp.After
}

Rel: #1848

* Some Github APIs use `before`/`after` for pagination, rather
than `page` or `cursor` pagination. Parse these response values
* For example, the Organizations GetAuditLog (Enterprise Cloud)
https://docs.github.com/en/rest/reference/orgs#get-the-audit-log-for-an-organization

With this change, pagination can be performed

```go
for pageCount < PageMax {
  entries, resp, err := client.Organizations.GetAuditLog(ctx, "org", auditParams)
  if err != nil {
    return err
  }

  pageCount++
  if resp.After == "" {
    break
  }
  auditParams.After = resp.After
}
```
@google-cla google-cla bot added the cla: yes Indication that the PR author has signed a Google Contributor License Agreement. label Oct 27, 2021
@codecov
Copy link

codecov bot commented Oct 27, 2021

Codecov Report

Merging #2154 (cc18ba5) into master (d9d58a2) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2154      +/-   ##
==========================================
+ Coverage   97.78%   97.79%   +0.01%     
==========================================
  Files         112      112              
  Lines        9976    10036      +60     
==========================================
+ Hits         9755     9815      +60     
  Misses        154      154              
  Partials       67       67              
Impacted Files Coverage Δ
github/github.go 97.60% <100.00%> (+0.01%) ⬆️
github/code-scanning.go 100.00% <0.00%> (ø)
github/issues_timeline.go 100.00% <0.00%> (ø)
github/repos.go 98.68% <0.00%> (+0.02%) ⬆️
github/reactions.go 97.84% <0.00%> (+0.13%) ⬆️
github/issues.go 97.41% <0.00%> (+0.35%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d9d58a2...cc18ba5. Read the comment docs.

Copy link
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @dghubble !
LGTM.

Awaiting second LGTM before merging.

@gmlewis gmlewis requested a review from wesleimp October 27, 2021 21:03
@dghubble
Copy link
Contributor Author

Maybe another reviewer has time / interest?

@gmlewis
Copy link
Collaborator

gmlewis commented Nov 15, 2021

Perhaps @Parker77 has time?

Copy link

@Parker77 Parker77 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor change, otherwise LGTM!

Co-authored-by: Parker77 <20973702+Parker77@users.noreply.github.com>
@gmlewis
Copy link
Collaborator

gmlewis commented Nov 15, 2021

Thank you, @Parker77 !
Merging after tests pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes Indication that the PR author has signed a Google Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载