Skip to content

Commit 54e4772

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
feat: update via SDK Studio (#108)
1 parent aa58312 commit 54e4772

File tree

82 files changed

+11930
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+11930
-1
lines changed

.stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
configured_endpoints: 1255
1+
configured_endpoints: 1288

README.md

+61
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,67 @@ Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typ
8181

8282
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`.
8383

84+
## Pagination
85+
86+
List methods in the Cloudflare API are paginated.
87+
88+
This library provides auto-paginating iterators with each list response, so you do not have to request successive pages manually:
89+
90+
```python
91+
import cloudflare
92+
93+
client = Cloudflare()
94+
95+
all_accounts = []
96+
# Automatically fetches more pages as needed.
97+
for account in client.accounts.list():
98+
# Do something with account here
99+
all_accounts.append(account)
100+
print(all_accounts)
101+
```
102+
103+
Or, asynchronously:
104+
105+
```python
106+
import asyncio
107+
import cloudflare
108+
109+
client = AsyncCloudflare()
110+
111+
112+
async def main() -> None:
113+
all_accounts = []
114+
# Iterate through items across all pages, issuing requests as needed.
115+
async for account in client.accounts.list():
116+
all_accounts.append(account)
117+
print(all_accounts)
118+
119+
120+
asyncio.run(main())
121+
```
122+
123+
Alternatively, you can use the `.has_next_page()`, `.next_page_info()`, or `.get_next_page()` methods for more granular control working with pages:
124+
125+
```python
126+
first_page = await client.accounts.list()
127+
if first_page.has_next_page():
128+
print(f"will fetch next page using these details: {first_page.next_page_info()}")
129+
next_page = await first_page.get_next_page()
130+
print(f"number of items we just fetched: {len(next_page.result)}")
131+
132+
# Remove `await` for non-async usage.
133+
```
134+
135+
Or just work directly with the returned data:
136+
137+
```python
138+
first_page = await client.accounts.list()
139+
for account in first_page.result:
140+
print(account)
141+
142+
# Remove `await` for non-async usage.
143+
```
144+
84145
## Handling errors
85146

86147
When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `cloudflare.APIConnectionError` is raised.

api.md

+156
Large diffs are not rendered by default.

src/cloudflare/_client.py

+8
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ class Cloudflare(SyncAPIClient):
9191
url_normalization: resources.URLNormalization
9292
spectrum: resources.Spectrum
9393
addressing: resources.Addressing
94+
audit_logs: resources.AuditLogs
9495
billing: resources.Billing
9596
brand_protection: resources.BrandProtection
9697
diagnostics: resources.Diagnostics
@@ -243,6 +244,7 @@ def __init__(
243244
self.url_normalization = resources.URLNormalization(self)
244245
self.spectrum = resources.Spectrum(self)
245246
self.addressing = resources.Addressing(self)
247+
self.audit_logs = resources.AuditLogs(self)
246248
self.billing = resources.Billing(self)
247249
self.brand_protection = resources.BrandProtection(self)
248250
self.diagnostics = resources.Diagnostics(self)
@@ -500,6 +502,7 @@ class AsyncCloudflare(AsyncAPIClient):
500502
url_normalization: resources.AsyncURLNormalization
501503
spectrum: resources.AsyncSpectrum
502504
addressing: resources.AsyncAddressing
505+
audit_logs: resources.AsyncAuditLogs
503506
billing: resources.AsyncBilling
504507
brand_protection: resources.AsyncBrandProtection
505508
diagnostics: resources.AsyncDiagnostics
@@ -652,6 +655,7 @@ def __init__(
652655
self.url_normalization = resources.AsyncURLNormalization(self)
653656
self.spectrum = resources.AsyncSpectrum(self)
654657
self.addressing = resources.AsyncAddressing(self)
658+
self.audit_logs = resources.AsyncAuditLogs(self)
655659
self.billing = resources.AsyncBilling(self)
656660
self.brand_protection = resources.AsyncBrandProtection(self)
657661
self.diagnostics = resources.AsyncDiagnostics(self)
@@ -910,6 +914,7 @@ def __init__(self, client: Cloudflare) -> None:
910914
self.url_normalization = resources.URLNormalizationWithRawResponse(client.url_normalization)
911915
self.spectrum = resources.SpectrumWithRawResponse(client.spectrum)
912916
self.addressing = resources.AddressingWithRawResponse(client.addressing)
917+
self.audit_logs = resources.AuditLogsWithRawResponse(client.audit_logs)
913918
self.billing = resources.BillingWithRawResponse(client.billing)
914919
self.brand_protection = resources.BrandProtectionWithRawResponse(client.brand_protection)
915920
self.diagnostics = resources.DiagnosticsWithRawResponse(client.diagnostics)
@@ -997,6 +1002,7 @@ def __init__(self, client: AsyncCloudflare) -> None:
9971002
self.url_normalization = resources.AsyncURLNormalizationWithRawResponse(client.url_normalization)
9981003
self.spectrum = resources.AsyncSpectrumWithRawResponse(client.spectrum)
9991004
self.addressing = resources.AsyncAddressingWithRawResponse(client.addressing)
1005+
self.audit_logs = resources.AsyncAuditLogsWithRawResponse(client.audit_logs)
10001006
self.billing = resources.AsyncBillingWithRawResponse(client.billing)
10011007
self.brand_protection = resources.AsyncBrandProtectionWithRawResponse(client.brand_protection)
10021008
self.diagnostics = resources.AsyncDiagnosticsWithRawResponse(client.diagnostics)
@@ -1086,6 +1092,7 @@ def __init__(self, client: Cloudflare) -> None:
10861092
self.url_normalization = resources.URLNormalizationWithStreamingResponse(client.url_normalization)
10871093
self.spectrum = resources.SpectrumWithStreamingResponse(client.spectrum)
10881094
self.addressing = resources.AddressingWithStreamingResponse(client.addressing)
1095+
self.audit_logs = resources.AuditLogsWithStreamingResponse(client.audit_logs)
10891096
self.billing = resources.BillingWithStreamingResponse(client.billing)
10901097
self.brand_protection = resources.BrandProtectionWithStreamingResponse(client.brand_protection)
10911098
self.diagnostics = resources.DiagnosticsWithStreamingResponse(client.diagnostics)
@@ -1177,6 +1184,7 @@ def __init__(self, client: AsyncCloudflare) -> None:
11771184
self.url_normalization = resources.AsyncURLNormalizationWithStreamingResponse(client.url_normalization)
11781185
self.spectrum = resources.AsyncSpectrumWithStreamingResponse(client.spectrum)
11791186
self.addressing = resources.AsyncAddressingWithStreamingResponse(client.addressing)
1187+
self.audit_logs = resources.AsyncAuditLogsWithStreamingResponse(client.audit_logs)
11801188
self.billing = resources.AsyncBillingWithStreamingResponse(client.billing)
11811189
self.brand_protection = resources.AsyncBrandProtectionWithStreamingResponse(client.brand_protection)
11821190
self.diagnostics = resources.AsyncDiagnosticsWithStreamingResponse(client.diagnostics)

src/cloudflare/resources/__init__.py

+14
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,14 @@
328328
AddressingWithStreamingResponse,
329329
AsyncAddressingWithStreamingResponse,
330330
)
331+
from .audit_logs import (
332+
AuditLogs,
333+
AsyncAuditLogs,
334+
AuditLogsWithRawResponse,
335+
AsyncAuditLogsWithRawResponse,
336+
AuditLogsWithStreamingResponse,
337+
AsyncAuditLogsWithStreamingResponse,
338+
)
331339
from .challenges import (
332340
Challenges,
333341
AsyncChallenges,
@@ -898,6 +906,12 @@
898906
"AsyncAddressingWithRawResponse",
899907
"AddressingWithStreamingResponse",
900908
"AsyncAddressingWithStreamingResponse",
909+
"AuditLogs",
910+
"AsyncAuditLogs",
911+
"AuditLogsWithRawResponse",
912+
"AsyncAuditLogsWithRawResponse",
913+
"AuditLogsWithStreamingResponse",
914+
"AsyncAuditLogsWithStreamingResponse",
901915
"Billing",
902916
"AsyncBilling",
903917
"BillingWithRawResponse",

0 commit comments

Comments
 (0)