Skip to content

release: 4.4.0 #2664

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 114 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
a2476e7
codegen metadata
stainless-app[bot] Jun 16, 2025
ad0f8c2
chore(ci): enable for pull requests
stainless-app[bot] Jun 17, 2025
2f9af7b
chore(api): TTL is required on DNS records
stainless-app[bot] Jun 17, 2025
b84a94e
chore(readme): update badges
stainless-app[bot] Jun 17, 2025
721188d
fix(tests): fix: tests which call HTTP endpoints directly with the ex…
stainless-app[bot] Jun 17, 2025
61aabac
codegen metadata
stainless-app[bot] Jun 17, 2025
0114564
docs(client): fix httpx.Timeout documentation reference
stainless-app[bot] Jun 18, 2025
4c6cda0
feat(api): api update
stainless-app[bot] Jun 20, 2025
5a71a18
codegen metadata
stainless-app[bot] Jun 20, 2025
6956f9c
codegen metadata
stainless-app[bot] Jun 20, 2025
b922a42
codegen metadata
stainless-app[bot] Jun 20, 2025
764b4ea
feat(api): api update
stainless-app[bot] Jun 20, 2025
ed26a10
codegen metadata
stainless-app[bot] Jun 20, 2025
80d9fef
feat(client): add support for aiohttp
stainless-app[bot] Jun 20, 2025
98e3174
codegen metadata
stainless-app[bot] Jun 20, 2025
966fa64
codegen metadata
stainless-app[bot] Jun 20, 2025
d7e2d59
codegen metadata
stainless-app[bot] Jun 20, 2025
cfc9b04
codegen metadata
stainless-app[bot] Jun 20, 2025
c1802dd
codegen metadata
stainless-app[bot] Jun 20, 2025
5c7e9a9
codegen metadata
stainless-app[bot] Jun 20, 2025
d7e224c
codegen metadata
stainless-app[bot] Jun 20, 2025
8daec22
codegen metadata
stainless-app[bot] Jun 20, 2025
fb41e73
codegen metadata
stainless-app[bot] Jun 20, 2025
b82033c
codegen metadata
stainless-app[bot] Jun 20, 2025
666cff3
codegen metadata
stainless-app[bot] Jun 23, 2025
8059b07
codegen metadata
stainless-app[bot] Jun 23, 2025
e0988cf
codegen metadata
stainless-app[bot] Jun 23, 2025
97f1a13
codegen metadata
stainless-app[bot] Jun 23, 2025
c843ee1
codegen metadata
stainless-app[bot] Jun 23, 2025
b0d7add
codegen metadata
stainless-app[bot] Jun 23, 2025
261240b
codegen metadata
stainless-app[bot] Jun 23, 2025
5e1c247
codegen metadata
stainless-app[bot] Jun 23, 2025
5044c05
codegen metadata
stainless-app[bot] Jun 23, 2025
7a46f71
codegen metadata
stainless-app[bot] Jun 23, 2025
a6cb63b
codegen metadata
stainless-app[bot] Jun 23, 2025
03c2840
codegen metadata
stainless-app[bot] Jun 23, 2025
34b39b4
codegen metadata
stainless-app[bot] Jun 23, 2025
e4337fe
codegen metadata
stainless-app[bot] Jun 23, 2025
fbe47f4
codegen metadata
stainless-app[bot] Jun 23, 2025
9af4c62
codegen metadata
stainless-app[bot] Jun 23, 2025
7ea3038
codegen metadata
stainless-app[bot] Jun 23, 2025
5dd2397
codegen metadata
stainless-app[bot] Jun 23, 2025
986f70f
codegen metadata
stainless-app[bot] Jun 23, 2025
17b75a7
codegen metadata
stainless-app[bot] Jun 23, 2025
848c446
codegen metadata
stainless-app[bot] Jun 23, 2025
da1f9e3
codegen metadata
stainless-app[bot] Jun 23, 2025
70b65e5
codegen metadata
stainless-app[bot] Jun 23, 2025
55ac51e
codegen metadata
stainless-app[bot] Jun 23, 2025
dbbb02d
chore(tests): skip some failing tests on the latest python versions
stainless-app[bot] Jun 23, 2025
bd5ff92
codegen metadata
stainless-app[bot] Jun 23, 2025
ea2f75f
codegen metadata
stainless-app[bot] Jun 23, 2025
42024d8
codegen metadata
stainless-app[bot] Jun 23, 2025
91b2a22
codegen metadata
stainless-app[bot] Jun 23, 2025
4fa1f0c
codegen metadata
stainless-app[bot] Jun 23, 2025
32f2cbe
codegen metadata
stainless-app[bot] Jun 23, 2025
e6f4984
codegen metadata
stainless-app[bot] Jun 23, 2025
b77ac30
codegen metadata
stainless-app[bot] Jun 23, 2025
3743d11
codegen metadata
stainless-app[bot] Jun 23, 2025
a8296be
codegen metadata
stainless-app[bot] Jun 23, 2025
752214a
codegen metadata
stainless-app[bot] Jun 24, 2025
79324cb
codegen metadata
stainless-app[bot] Jun 24, 2025
138db78
codegen metadata
stainless-app[bot] Jun 24, 2025
bc47aad
codegen metadata
stainless-app[bot] Jun 24, 2025
a3a9ea6
codegen metadata
stainless-app[bot] Jun 24, 2025
8274221
codegen metadata
stainless-app[bot] Jun 24, 2025
9b1a0da
codegen metadata
stainless-app[bot] Jun 24, 2025
5e53e66
codegen metadata
stainless-app[bot] Jun 24, 2025
8619b77
codegen metadata
stainless-app[bot] Jun 24, 2025
2bf9737
feat(api): api update
stainless-app[bot] Jun 24, 2025
b69ea15
codegen metadata
stainless-app[bot] Jun 24, 2025
35bd023
codegen metadata
stainless-app[bot] Jun 24, 2025
d78e2ac
codegen metadata
stainless-app[bot] Jun 24, 2025
ba49769
codegen metadata
stainless-app[bot] Jun 24, 2025
29baf9d
codegen metadata
stainless-app[bot] Jun 24, 2025
835ee91
codegen metadata
stainless-app[bot] Jun 24, 2025
fd9a98d
codegen metadata
stainless-app[bot] Jun 24, 2025
b299ce2
codegen metadata
stainless-app[bot] Jun 24, 2025
601cb97
codegen metadata
stainless-app[bot] Jun 24, 2025
639265a
codegen metadata
stainless-app[bot] Jun 24, 2025
2db1372
codegen metadata
stainless-app[bot] Jun 24, 2025
3a5e37a
codegen metadata
stainless-app[bot] Jun 24, 2025
a8d5fa1
codegen metadata
stainless-app[bot] Jun 24, 2025
a916b7e
codegen metadata
stainless-app[bot] Jun 25, 2025
94cdb65
codegen metadata
stainless-app[bot] Jun 25, 2025
695cb14
codegen metadata
stainless-app[bot] Jun 25, 2025
4d31720
codegen metadata
stainless-app[bot] Jun 25, 2025
4a6b563
codegen metadata
stainless-app[bot] Jun 25, 2025
002726f
codegen metadata
stainless-app[bot] Jun 25, 2025
204472a
codegen metadata
stainless-app[bot] Jun 25, 2025
8894476
codegen metadata
stainless-app[bot] Jun 25, 2025
4a5401e
codegen metadata
stainless-app[bot] Jun 25, 2025
d4a0f2b
codegen metadata
stainless-app[bot] Jun 25, 2025
211ddfc
feat(api): api update
stainless-app[bot] Jun 25, 2025
23fcd79
codegen metadata
stainless-app[bot] Jun 25, 2025
cca2c32
codegen metadata
stainless-app[bot] Jun 25, 2025
a437f58
codegen metadata
stainless-app[bot] Jun 25, 2025
40f82c0
codegen metadata
stainless-app[bot] Jun 25, 2025
e5e4e72
codegen metadata
stainless-app[bot] Jun 25, 2025
93b79eb
codegen metadata
stainless-app[bot] Jun 25, 2025
540dac3
codegen metadata
stainless-app[bot] Jun 25, 2025
7a5bc7f
codegen metadata
stainless-app[bot] Jun 25, 2025
685df2c
codegen metadata
stainless-app[bot] Jun 25, 2025
4a75ab8
codegen metadata
stainless-app[bot] Jun 25, 2025
50a5c7e
codegen metadata
stainless-app[bot] Jun 25, 2025
8d5c342
codegen metadata
stainless-app[bot] Jun 25, 2025
dab268e
codegen metadata
stainless-app[bot] Jun 25, 2025
0eb468d
codegen metadata
stainless-app[bot] Jun 25, 2025
c880ed2
codegen metadata
stainless-app[bot] Jun 25, 2025
63c4b80
codegen metadata
stainless-app[bot] Jun 25, 2025
f5209e5
codegen metadata
stainless-app[bot] Jun 25, 2025
9dfc3d6
codegen metadata
stainless-app[bot] Jun 25, 2025
cb30380
codegen metadata
stainless-app[bot] Jun 25, 2025
9853cfc
codegen metadata
stainless-app[bot] Jun 25, 2025
5b84585
release: 4.4.0
stainless-app[bot] Jun 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ on:
- 'integrated/**'
- 'stl-preview-head/**'
- 'stl-preview-base/**'
pull_request:
branches-ignore:
- 'stl-preview-head/**'
- 'stl-preview-base/**'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "4.3.1"
".": "4.4.0"
}
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 1752
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b15b44e0efd207de48e7e74e742b0b4b190c74f12a941a1a0ef59a51656a5224.yml
openapi_spec_hash: 83243c9ee06f88d0fa91e9b185d8a42e
config_hash: 8601d43fd5ccaf9e3d08f26748a5a63a
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-6588112f47f25ab1b947342bfc30854370192f46f61d728fe5f408f44ac733b3.yml
openapi_spec_hash: 2bc739c52d568d16d5f0768898336d54
config_hash: 3638b66b63ea825ab6a770e729104836
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
# Changelog

## 4.4.0 (2025-06-25)

Full Changelog: [v4.3.1...v4.4.0](https://github.com/cloudflare/cloudflare-python/compare/v4.3.1...v4.4.0)

### Features

* **api:** api update ([211ddfc](https://github.com/cloudflare/cloudflare-python/commit/211ddfcf9176cf778d6de310817ee01194f6844e))
* **api:** api update ([2bf9737](https://github.com/cloudflare/cloudflare-python/commit/2bf9737af8db398d3e00c9ddb3f67d0c9527491f))
* **api:** api update ([764b4ea](https://github.com/cloudflare/cloudflare-python/commit/764b4ea4333e86e8c1c76c7625887c077c435f8a))
* **api:** api update ([4c6cda0](https://github.com/cloudflare/cloudflare-python/commit/4c6cda072e94640d2ea181dd1de2e4ef3f943e76))
* **client:** add support for aiohttp ([80d9fef](https://github.com/cloudflare/cloudflare-python/commit/80d9fefc3aabba6ee9d6addea001a7108b9684cd))


### Bug Fixes

* **tests:** fix: tests which call HTTP endpoints directly with the example parameters ([721188d](https://github.com/cloudflare/cloudflare-python/commit/721188dddf88b71ba2c0754461c8d7f8d4359304))


### Chores

* **api:** TTL is required on DNS records ([2f9af7b](https://github.com/cloudflare/cloudflare-python/commit/2f9af7be7ec065f07ed714c627777874b5e86f16))
* **ci:** enable for pull requests ([ad0f8c2](https://github.com/cloudflare/cloudflare-python/commit/ad0f8c218463493e3a7798ed724debe91471ff35))
* **readme:** update badges ([b84a94e](https://github.com/cloudflare/cloudflare-python/commit/b84a94e1ba4d55e05cd07acc04fdbbdd7a0fd0ae))
* **tests:** skip some failing tests on the latest python versions ([dbbb02d](https://github.com/cloudflare/cloudflare-python/commit/dbbb02d2077911a1eac2069ac1e82b54e2ae5b1b))


### Documentation

* **client:** fix httpx.Timeout documentation reference ([0114564](https://github.com/cloudflare/cloudflare-python/commit/0114564d5cfb8459f19fe3dd80ce6e55617096ec))

## 4.3.1 (2025-06-16)

Full Changelog: [v4.3.0...v4.3.1](https://github.com/cloudflare/cloudflare-python/compare/v4.3.0...v4.3.1)
Expand Down
40 changes: 38 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Cloudflare Python API library

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

The Cloudflare Python library provides convenient access to the Cloudflare REST API from any Python 3.8+
application. The library includes type definitions for all request params and response fields,
Expand Down Expand Up @@ -70,6 +70,42 @@ asyncio.run(main())

Functionality between the synchronous and asynchronous clients is otherwise identical.

### With aiohttp

By default, the async client uses `httpx` for HTTP requests. However, for improved concurrency performance you may also use `aiohttp` as the HTTP backend.

You can enable this by installing `aiohttp`:

```sh
# install from PyPI
pip install cloudflare[aiohttp]
```

Then you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:

```python
import os
import asyncio
from cloudflare import DefaultAioHttpClient
from cloudflare import AsyncCloudflare


async def main() -> None:
async with AsyncCloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
http_client=DefaultAioHttpClient(),
) as client:
zone = await client.zones.create(
account={"id": "023e105f4ecef8ad9ca31a8372d0c353"},
name="example.com",
type="full",
)
print(zone.id)


asyncio.run(main())
```

## Using types

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:
Expand Down Expand Up @@ -244,7 +280,7 @@ client.with_options(max_retries=5).zones.get(
### Timeouts

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

```python
from cloudflare import Cloudflare
Expand Down
8 changes: 1 addition & 7 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2570,15 +2570,9 @@ Methods:

### Metadata

Types:

```python
from cloudflare.types.kv.namespaces import MetadataGetResponse
```

Methods:

- <code title="get /accounts/{account_id}/storage/kv/namespaces/{namespace_id}/metadata/{key_name}">client.kv.namespaces.metadata.<a href="./src/cloudflare/resources/kv/namespaces/metadata.py">get</a>(key_name, \*, account_id, namespace_id) -> <a href="./src/cloudflare/types/kv/namespaces/metadata_get_response.py">Optional[MetadataGetResponse]</a></code>
- <code title="get /accounts/{account_id}/storage/kv/namespaces/{namespace_id}/metadata/{key_name}">client.kv.namespaces.metadata.<a href="./src/cloudflare/resources/kv/namespaces/metadata.py">get</a>(key_name, \*, account_id, namespace_id) -> object</code>

### Values

Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "cloudflare"
version = "4.3.1"
version = "4.4.0"
description = "The official Python library for the cloudflare API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down Expand Up @@ -37,6 +37,8 @@ classifiers = [
Homepage = "https://github.com/cloudflare/cloudflare-python"
Repository = "https://github.com/cloudflare/cloudflare-python"

[project.optional-dependencies]
aiohttp = ["aiohttp", "httpx_aiohttp>=0.1.6"]

[tool.rye]
managed = true
Expand Down
27 changes: 27 additions & 0 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,24 @@
# universal: false

-e file:.
aiohappyeyeballs==2.6.1
# via aiohttp
aiohttp==3.12.8
# via cloudflare
# via httpx-aiohttp
aiosignal==1.3.2
# via aiohttp
annotated-types==0.6.0
# via pydantic
anyio==4.4.0
# via cloudflare
# via httpx
argcomplete==3.1.2
# via nox
async-timeout==5.0.1
# via aiohttp
attrs==25.3.0
# via aiohttp
certifi==2023.7.22
# via httpcore
# via httpx
Expand All @@ -34,23 +45,33 @@ execnet==2.1.1
# via pytest-xdist
filelock==3.12.4
# via virtualenv
frozenlist==1.6.2
# via aiohttp
# via aiosignal
h11==0.14.0
# via httpcore
httpcore==1.0.2
# via httpx
httpx==0.28.1
# via cloudflare
# via httpx-aiohttp
# via respx
httpx-aiohttp==0.1.6
# via cloudflare
idna==3.4
# via anyio
# via httpx
# via yarl
importlib-metadata==7.0.0
iniconfig==2.0.0
# via pytest
markdown-it-py==3.0.0
# via rich
mdurl==0.1.2
# via markdown-it-py
multidict==6.4.4
# via aiohttp
# via yarl
mypy==1.14.1
mypy-extensions==1.0.0
# via mypy
Expand All @@ -65,6 +86,9 @@ platformdirs==3.11.0
# via virtualenv
pluggy==1.5.0
# via pytest
propcache==0.3.1
# via aiohttp
# via yarl
pydantic==2.10.3
# via cloudflare
pydantic-core==2.27.1
Expand Down Expand Up @@ -98,11 +122,14 @@ tomli==2.0.2
typing-extensions==4.12.2
# via anyio
# via cloudflare
# via multidict
# via mypy
# via pydantic
# via pydantic-core
# via pyright
virtualenv==20.24.5
# via nox
yarl==1.20.0
# via aiohttp
zipp==3.17.0
# via importlib-metadata
27 changes: 27 additions & 0 deletions requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,51 @@
# universal: false

-e file:.
aiohappyeyeballs==2.6.1
# via aiohttp
aiohttp==3.12.8
# via cloudflare
# via httpx-aiohttp
aiosignal==1.3.2
# via aiohttp
annotated-types==0.6.0
# via pydantic
anyio==4.4.0
# via cloudflare
# via httpx
async-timeout==5.0.1
# via aiohttp
attrs==25.3.0
# via aiohttp
certifi==2023.7.22
# via httpcore
# via httpx
distro==1.8.0
# via cloudflare
exceptiongroup==1.2.2
# via anyio
frozenlist==1.6.2
# via aiohttp
# via aiosignal
h11==0.14.0
# via httpcore
httpcore==1.0.2
# via httpx
httpx==0.28.1
# via cloudflare
# via httpx-aiohttp
httpx-aiohttp==0.1.6
# via cloudflare
idna==3.4
# via anyio
# via httpx
# via yarl
multidict==6.4.4
# via aiohttp
# via yarl
propcache==0.3.1
# via aiohttp
# via yarl
pydantic==2.10.3
# via cloudflare
pydantic-core==2.27.1
Expand All @@ -41,5 +65,8 @@ sniffio==1.3.0
typing-extensions==4.12.2
# via anyio
# via cloudflare
# via multidict
# via pydantic
# via pydantic-core
yarl==1.20.0
# via aiohttp
3 changes: 2 additions & 1 deletion src/cloudflare/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
UnprocessableEntityError,
APIResponseValidationError,
)
from ._base_client import DefaultHttpxClient, DefaultAsyncHttpxClient
from ._base_client import DefaultHttpxClient, DefaultAioHttpClient, DefaultAsyncHttpxClient
from ._utils._logs import setup_logging as _setup_logging

__all__ = [
Expand Down Expand Up @@ -78,6 +78,7 @@
"DEFAULT_CONNECTION_LIMITS",
"DefaultHttpxClient",
"DefaultAsyncHttpxClient",
"DefaultAioHttpClient",
]

if not _t.TYPE_CHECKING:
Expand Down
22 changes: 22 additions & 0 deletions src/cloudflare/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1331,6 +1331,24 @@ def __init__(self, **kwargs: Any) -> None:
super().__init__(**kwargs)


try:
import httpx_aiohttp
except ImportError:

class _DefaultAioHttpClient(httpx.AsyncClient):
def __init__(self, **_kwargs: Any) -> None:
raise RuntimeError("To use the aiohttp client you must have installed the package with the `aiohttp` extra")
else:

class _DefaultAioHttpClient(httpx_aiohttp.HttpxAiohttpClient): # type: ignore
def __init__(self, **kwargs: Any) -> None:
kwargs.setdefault("timeout", DEFAULT_TIMEOUT)
kwargs.setdefault("limits", DEFAULT_CONNECTION_LIMITS)
kwargs.setdefault("follow_redirects", True)

super().__init__(**kwargs)


if TYPE_CHECKING:
DefaultAsyncHttpxClient = httpx.AsyncClient
"""An alias to `httpx.AsyncClient` that provides the same defaults that this SDK
Expand All @@ -1339,8 +1357,12 @@ def __init__(self, **kwargs: Any) -> None:
This is useful because overriding the `http_client` with your own instance of
`httpx.AsyncClient` will result in httpx's defaults being used, not ours.
"""

DefaultAioHttpClient = httpx.AsyncClient
"""An alias to `httpx.AsyncClient` that changes the default HTTP transport to `aiohttp`."""
else:
DefaultAsyncHttpxClient = _DefaultAsyncHttpxClient
DefaultAioHttpClient = _DefaultAioHttpClient


class AsyncHttpxClientWrapper(DefaultAsyncHttpxClient):
Expand Down
2 changes: 1 addition & 1 deletion src/cloudflare/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

__title__ = "cloudflare"
__version__ = "4.3.1" # x-release-please-version
__version__ = "4.4.0" # x-release-please-version
Loading
Loading