Skip to content

Commit e48c03c

Browse files
Merge pull request #72 from PowerShell/SteveL-MSFT-patch-1
RFC for Link-header-based-pagination-for-WebCmdlets.md
2 parents 1532579 + cfa4395 commit e48c03c

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
RFC: RFC0021
3+
Author: Steve Lee
4+
Status: Draft
5+
SupercededBy: N/A
6+
Version: 0.1
7+
Area: Cmdlets
8+
Comments Due: 3/10/2017
9+
---
10+
11+
# Support for Link header based pagination for WebCmdlets
12+
13+
Invoke-RestMethod makes it easy to automate against REST APIs.
14+
The standard for pagination based on https://tools.ietf.org/html/rfc5988#page-6 relies on a response header that you can only get via Invoke-WebRequest and requires each script to parse and utilize.
15+
16+
## Motivation
17+
18+
REST APIs have a standard for pagination that Invoke-WebRequest and Invoke-RestMethod should adopt to simplify scripts so script authors don't have to write similar code for pagination.
19+
20+
## Specification
21+
22+
Invoke-WebRequest would expose a RelationLink property in the output object.
23+
The RelationLink property would be a hash table of the relation links from the Link header.
24+
The `rel` value would be the key and the URL would be the value in the hash table.
25+
26+
Example:
27+
```
28+
Link: </TheBook/chapter2>;
29+
rel="previous"; title*=UTF-8'de'letztes%20Kapitel,
30+
</TheBook/chapter4>;
31+
rel="next"; title*=UTF-8'de'n%c3%a4chstes%20Kapitel
32+
```
33+
34+
This would result in RelationLink property hash table consisting of:
35+
36+
|Key|Value|
37+
|---|---|
38+
|previous|/TheBook/chapter2|
39+
|next|/TheBook/chapter4|
40+
41+
Since `title` is not a relation link, it is not exposed by this RFC.
42+
Malformed Link headers that do not conform to RFC5988 will be quietly ignored making this loose validating.
43+
44+
Invoke-RestMethod would expose a `-FollowRelLink` switch to automatically follow the relation `next` links to the end if it exists.
45+
46+
For use cases that have to throttle REST API calls (such as querying GitHub API), recommendation would be to use Invoke-WebRequest for finer control.
47+
48+
## Alternate Proposals and Considerations
49+
50+
None

0 commit comments

Comments
 (0)