Skip to content

Commit a07c855

Browse files
author
Chris Thorwarth
committed
Merge branch 'ct/script-upload-issue' of github.com:christhorwarth/cloudflare-python into ct/script-upload-issue
# Conflicts: # examples/workers/script_upload.py
2 parents b2cfe5e + 0bef8fa commit a07c855

3,553 files changed

Lines changed: 227172 additions & 68783 deletions

File tree

Some content is hidden

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

.github/workflows/ci.yml

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ on:
88
- 'integrated/**'
99
- 'stl-preview-head/**'
1010
- 'stl-preview-base/**'
11+
pull_request:
12+
branches-ignore:
13+
- 'stl-preview-head/**'
14+
- 'stl-preview-base/**'
1115

1216
concurrency:
1317
group: ${{ github.workflow }}-${{ github.ref }}
@@ -18,8 +22,9 @@ jobs:
1822
timeout-minutes: 10
1923
name: lint
2024
runs-on: ${{ github.repository == 'stainless-sdks/cloudflare-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
25+
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
2126
steps:
22-
- uses: actions/checkout@v4
27+
- uses: actions/checkout@v6
2328

2429
- name: Install Rye
2530
run: |
@@ -35,24 +40,40 @@ jobs:
3540
- name: Run lints
3641
run: ./scripts/lint
3742

38-
upload:
39-
if: github.repository == 'stainless-sdks/cloudflare-python'
43+
build:
44+
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
4045
timeout-minutes: 10
41-
name: upload
46+
name: build
4247
permissions:
4348
contents: read
4449
id-token: write
45-
runs-on: depot-ubuntu-24.04
50+
runs-on: ${{ github.repository == 'stainless-sdks/cloudflare-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
4651
steps:
47-
- uses: actions/checkout@v4
52+
- uses: actions/checkout@v6
53+
54+
- name: Install Rye
55+
run: |
56+
curl -sSf https://rye.astral.sh/get | bash
57+
echo "$HOME/.rye/shims" >> $GITHUB_PATH
58+
env:
59+
RYE_VERSION: '0.44.0'
60+
RYE_INSTALL_OPTION: '--yes'
61+
62+
- name: Install dependencies
63+
run: rye sync --all-features
64+
65+
- name: Run build
66+
run: rye build
4867

4968
- name: Get GitHub OIDC Token
69+
if: github.repository == 'stainless-sdks/cloudflare-python'
5070
id: github-oidc
5171
uses: actions/github-script@v6
5272
with:
5373
script: core.setOutput('github_token', await core.getIDToken());
5474

5575
- name: Upload tarball
76+
if: github.repository == 'stainless-sdks/cloudflare-python'
5677
env:
5778
URL: https://pkg.stainless.com/s
5879
AUTH: ${{ steps.github-oidc.outputs.github_token }}
@@ -63,8 +84,9 @@ jobs:
6384
timeout-minutes: 30
6485
name: test
6586
runs-on: ${{ github.repository == 'stainless-sdks/cloudflare-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
87+
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
6688
steps:
67-
- uses: actions/checkout@v4
89+
- uses: actions/checkout@v6
6890

6991
- name: Install Rye
7092
run: |
@@ -84,10 +106,10 @@ jobs:
84106
timeout-minutes: 10
85107
name: examples
86108
runs-on: ${{ github.repository == 'stainless-sdks/cloudflare-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
87-
if: github.repository == 'cloudflare/cloudflare-python'
109+
if: github.repository == 'cloudflare/cloudflare-python' && (github.event_name == 'push' || github.event.pull_request.head.repo.fork)
88110

89111
steps:
90-
- uses: actions/checkout@v4
112+
- uses: actions/checkout@v6
91113

92114
- name: Install Rye
93115
run: |
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: CI
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
- next
7+
8+
jobs:
9+
detect_breaking_changes:
10+
runs-on: 'ubuntu-latest'
11+
name: detect-breaking-changes
12+
if: github.repository == 'cloudflare/cloudflare-python'
13+
steps:
14+
- name: Calculate fetch-depth
15+
run: |
16+
echo "FETCH_DEPTH=$(expr ${{ github.event.pull_request.commits }} + 1)" >> $GITHUB_ENV
17+
18+
- uses: actions/checkout@v6
19+
with:
20+
# Ensure we can check out the pull request base in the script below.
21+
fetch-depth: ${{ env.FETCH_DEPTH }}
22+
23+
- name: Install Rye
24+
run: |
25+
curl -sSf https://rye.astral.sh/get | bash
26+
echo "$HOME/.rye/shims" >> $GITHUB_PATH
27+
env:
28+
RYE_VERSION: '0.44.0'
29+
RYE_INSTALL_OPTION: '--yes'
30+
- name: Install dependencies
31+
run: |
32+
rye sync --all-features
33+
- name: Detect removed symbols
34+
run: |
35+
rye run python scripts/detect-breaking-changes.py "${{ github.event.pull_request.base.sha }}"
36+
37+
- name: Detect breaking changes
38+
run: |
39+
# Try to check out previous versions of the breaking change detection script. This ensures that
40+
# we still detect breaking changes when entire files and their tests are removed.
41+
git checkout "${{ github.event.pull_request.base.sha }}" -- ./scripts/detect-breaking-changes 2>/dev/null || true
42+
./scripts/detect-breaking-changes ${{ github.event.pull_request.base.sha }}

.github/workflows/publish-pypi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515

1616
steps:
17-
- uses: actions/checkout@v4
17+
- uses: actions/checkout@v6
1818

1919
- name: Install Rye
2020
run: |

.github/workflows/release-doctor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
if: github.repository == 'cloudflare/cloudflare-python' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next')
1919

2020
steps:
21-
- uses: actions/checkout@v4
21+
- uses: actions/checkout@v6
2222

2323
- name: Check release environment
2424
run: |

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
.prism.log
2-
.vscode
32
_dev
43

54
__pycache__

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 1752
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b15b44e0efd207de48e7e74e742b0b4b190c74f12a941a1a0ef59a51656a5224.yml
3-
openapi_spec_hash: 83243c9ee06f88d0fa91e9b185d8a42e
4-
config_hash: 8601d43fd5ccaf9e3d08f26748a5a63a
1+
configured_endpoints: 1995
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-28b84a5db03b38290dfe7ef1de2c68feb68762d7a8f207bdbea4d39a7aeef1ea.yml
3+
openapi_spec_hash: ba6bd61621e4be20b581f4f3bf0978d3
4+
config_hash: b73d16cbbb07431f2e4dff6dc0290ba5

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"python.analysis.importFormat": "relative",
3+
}

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2025 Cloudflare
189+
Copyright 2026 Cloudflare
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

README.md

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Cloudflare Python API library
22

3-
[![PyPI version](https://img.shields.io/pypi/v/cloudflare.svg)](https://pypi.org/project/cloudflare/)
3+
<!-- prettier-ignore -->
4+
[![PyPI version](https://img.shields.io/pypi/v/cloudflare.svg?label=pypi%20(stable))](https://pypi.org/project/cloudflare/)
45

5-
The Cloudflare Python library provides convenient access to the Cloudflare REST API from any Python 3.8+
6+
The Cloudflare Python library provides convenient access to the Cloudflare REST API from any Python 3.9+
67
application. The library includes type definitions for all request params and response fields,
78
and offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).
89

@@ -70,6 +71,42 @@ asyncio.run(main())
7071

7172
Functionality between the synchronous and asynchronous clients is otherwise identical.
7273

74+
### With aiohttp
75+
76+
By default, the async client uses `httpx` for HTTP requests. However, for improved concurrency performance you may also use `aiohttp` as the HTTP backend.
77+
78+
You can enable this by installing `aiohttp`:
79+
80+
```sh
81+
# install from PyPI
82+
pip install cloudflare[aiohttp]
83+
```
84+
85+
Then you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:
86+
87+
```python
88+
import os
89+
import asyncio
90+
from cloudflare import DefaultAioHttpClient
91+
from cloudflare import AsyncCloudflare
92+
93+
94+
async def main() -> None:
95+
async with AsyncCloudflare(
96+
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
97+
http_client=DefaultAioHttpClient(),
98+
) as client:
99+
zone = await client.zones.create(
100+
account={"id": "023e105f4ecef8ad9ca31a8372d0c353"},
101+
name="example.com",
102+
type="full",
103+
)
104+
print(zone.id)
105+
106+
107+
asyncio.run(main())
108+
```
109+
73110
## Using types
74111

75112
Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). Responses are [Pydantic models](https://docs.pydantic.dev) which also provide helper methods for things like:
@@ -244,7 +281,7 @@ client.with_options(max_retries=5).zones.get(
244281
### Timeouts
245282

246283
By default requests time out after 1 minute. You can configure this with a `timeout` option,
247-
which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/#fine-tuning-the-configuration) object:
284+
which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/timeouts/#fine-tuning-the-configuration) object:
248285

249286
```python
250287
from cloudflare import Cloudflare
@@ -438,7 +475,7 @@ print(cloudflare.__version__)
438475

439476
## Requirements
440477

441-
Python 3.8 or higher.
478+
Python 3.9 or higher.
442479

443480
## Contributing
444481

0 commit comments

Comments
 (0)