You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+63Lines changed: 63 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -76,6 +76,69 @@ Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typ
76
76
77
77
Typed requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`.
78
78
79
+
## Pagination
80
+
81
+
List methods in the Gitpod API are paginated.
82
+
83
+
This library provides auto-paginating iterators with each list response, so you do not have to request successive pages manually:
84
+
85
+
```python
86
+
from gitpod import Gitpod
87
+
88
+
client = Gitpod()
89
+
90
+
all_services = []
91
+
# Automatically fetches more pages as needed.
92
+
for service in client.environments.automations.services.list():
93
+
# Do something with service here
94
+
all_services.append(service)
95
+
print(all_services)
96
+
```
97
+
98
+
Or, asynchronously:
99
+
100
+
```python
101
+
import asyncio
102
+
from gitpod import AsyncGitpod
103
+
104
+
client = AsyncGitpod()
105
+
106
+
107
+
asyncdefmain() -> None:
108
+
all_services = []
109
+
# Iterate through items across all pages, issuing requests as needed.
110
+
asyncfor service in client.environments.automations.services.list():
111
+
all_services.append(service)
112
+
print(all_services)
113
+
114
+
115
+
asyncio.run(main())
116
+
```
117
+
118
+
Alternatively, you can use the `.has_next_page()`, `.next_page_info()`, or `.get_next_page()` methods for more granular control working with pages:
for service in first_page.pagination.personal_access_tokens:
137
+
print(service.pagination)
138
+
139
+
# Remove `await` for non-async usage.
140
+
```
141
+
79
142
## Handling errors
80
143
81
144
When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `gitpod.APIConnectionError` is raised.
0 commit comments