зеркало из https://github.com/github/docs.git
Added cursor based pagination examples as well as links and references (#22235)
Co-authored-by: Sarah Edwards <skedwards88@github.com>
This commit is contained in:
Родитель
d155e71cd0
Коммит
15c854ec3b
|
@ -117,6 +117,10 @@ For more information about the audit log REST API, see "[Enterprise administrati
|
|||
|
||||
### Example 1: All events in an enterprise, for a specific date, with pagination
|
||||
|
||||
You can use page-based pagination or cursor based pagination. For more information, see "[Traversing with Pagination](/rest/guides/traversing-with-pagination)."
|
||||
|
||||
#### Example with page-based pagination
|
||||
|
||||
The query below searches for audit log events created on Jan 1st, 2022 in the `avocado-corp` enterprise, and return the first page with a maximum of 100 items per page using [REST API pagination](/rest/overview/resources-in-the-rest-api#pagination):
|
||||
|
||||
```shell
|
||||
|
@ -125,6 +129,32 @@ curl -H "Authorization: Bearer TOKEN" \
|
|||
"https://api.github.com/enterprises/avocado-corp/audit-log?phrase=created:2022-01-01&page=1&per_page=100"
|
||||
```
|
||||
|
||||
#### Example with cursor-based pagination
|
||||
|
||||
The query below searches for audit log events created on Jan 1st, 2022 in the `avocado-corp` enterprise, and returns the first page with a maximum of 100 items per page using [REST API pagination](/rest/overview/resources-in-the-rest-api#pagination). The `--include` flag causes the headers to be returned along with the response.
|
||||
|
||||
```
|
||||
curl --include -H "Authorization: Bearer TOKEN" \
|
||||
--request GET \
|
||||
"https://api.github.com/enterprises/avocado-corp/audit-log?phrase=created:2022-01-01&per_page=100"
|
||||
```
|
||||
|
||||
If there are more than 100 results, the `link` header will include URLs to fetch the next, first, and previous pages of results.
|
||||
|
||||
```
|
||||
link: <https://api.github.com/enterprises/13827/audit-log?%3A2022-11-01=&per_page=100&after=MS42NjQzODMzNTk5MjdlKzEyfDloQzBxdURzaFdVbVlLWjkxRU9mNXc%3D&before=>; rel="next",
|
||||
<https://api.github.com/enterprises/13827/audit-log?%3A2022-11-01=&per_page=100&after=&before=>; rel="first",
|
||||
<https://api.github.com/enterprises/13827/audit-log?%3A2022-11-01=&per_page=100&after=&before=MS42Njc4NDA2MjM4MzNlKzEyfExqeG5sUElvNEZMbG1XZHA5akdKTVE%3D>; rel="prev"
|
||||
```
|
||||
|
||||
Copy the corresponding pagination link into your next request. For example:
|
||||
|
||||
```shell
|
||||
curl -I -H "Authorization: Bearer TOKEN" \
|
||||
--request GET \
|
||||
"https://api.github.com/enterprises/13827/audit-log?%3A2022-11-01=&per_page=100&after=MS42Njc4NDA2MjM5NDFlKzEyfHRYa3AwSkxUd2xyRjA5bWxfOS1RbFE%3D&before="
|
||||
```
|
||||
|
||||
### Example 2: Events for pull requests in an enterprise, for a specific date and actor
|
||||
|
||||
You can specify multiple search phrases, such as `created` and `actor`, by separating them in your formed URL with the `+` symbol or ASCII character code `%20`.
|
||||
|
@ -136,3 +166,9 @@ curl -H "Authorization: Bearer TOKEN" \
|
|||
--request GET \
|
||||
"https://api.github.com/enterprises/avocado-corp/audit-log?phrase=action:pull_request+created:>=2022-01-01+actor:octocat"
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче