Skip to content
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

release: 3.0.0-beta.8 #197

Merged
merged 159 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
159 commits
Select commit Hold shift + click to select a range
ac53439
feat(api): OpenAPI spec update via Stainless API (#196)
stainless-app[bot] Apr 2, 2024
436ce30
feat(api): OpenAPI spec update via Stainless API (#198)
stainless-app[bot] Apr 2, 2024
6c908fc
feat(api): OpenAPI spec update via Stainless API (#199)
stainless-app[bot] Apr 2, 2024
683552a
feat(api): OpenAPI spec update via Stainless API (#200)
stainless-app[bot] Apr 2, 2024
c2b9b35
feat(api): OpenAPI spec update via Stainless API (#201)
stainless-app[bot] Apr 2, 2024
3a3a661
feat(api): OpenAPI spec update via Stainless API (#202)
stainless-app[bot] Apr 2, 2024
7ecac59
feat(api): update via SDK Studio (#203)
stainless-app[bot] Apr 2, 2024
9e8b61a
feat(api): update via SDK Studio (#207)
stainless-app[bot] Apr 3, 2024
9a2ec53
feat(api): update via SDK Studio (#208)
stainless-app[bot] Apr 3, 2024
70bd1e4
feat(api): update via SDK Studio (#209)
stainless-app[bot] Apr 3, 2024
033c962
feat(api): update via SDK Studio (#210)
stainless-app[bot] Apr 3, 2024
87add37
feat(api): update via SDK Studio (#211)
stainless-app[bot] Apr 3, 2024
c3f0e24
feat(api): OpenAPI spec update via Stainless API (#212)
stainless-app[bot] Apr 3, 2024
e612347
feat(api): OpenAPI spec update via Stainless API (#213)
stainless-app[bot] Apr 3, 2024
51159f5
feat(api): OpenAPI spec update via Stainless API (#214)
stainless-app[bot] Apr 3, 2024
6bf76e3
feat(api): OpenAPI spec update via Stainless API (#215)
stainless-app[bot] Apr 3, 2024
f1c1451
feat(api): update via SDK Studio (#216)
stainless-app[bot] Apr 3, 2024
9b10753
feat(api): update via SDK Studio (#217)
stainless-app[bot] Apr 4, 2024
c1e3025
feat(api): update via SDK Studio (#218)
stainless-app[bot] Apr 4, 2024
23e38ea
feat(api): update via SDK Studio (#219)
stainless-app[bot] Apr 4, 2024
df86b06
feat(api): update via SDK Studio (#220)
stainless-app[bot] Apr 4, 2024
737e6e4
feat(api): update via SDK Studio (#221)
stainless-app[bot] Apr 4, 2024
522d336
feat(api): update via SDK Studio (#222)
stainless-app[bot] Apr 4, 2024
dfa9884
feat(api): update via SDK Studio (#223)
stainless-app[bot] Apr 4, 2024
e06ef4e
feat(api): OpenAPI spec update via Stainless API (#224)
stainless-app[bot] Apr 4, 2024
5dadedb
feat(api): update via SDK Studio (#225)
stainless-app[bot] Apr 4, 2024
dc229bd
feat(api): update via SDK Studio (#226)
stainless-app[bot] Apr 4, 2024
fba97f2
feat(api): update via SDK Studio (#227)
stainless-app[bot] Apr 4, 2024
c774af3
feat(api): update via SDK Studio (#228)
stainless-app[bot] Apr 5, 2024
dd6a5b7
feat(api): update via SDK Studio (#229)
stainless-app[bot] Apr 5, 2024
f90dc3a
feat(api): update via SDK Studio (#230)
stainless-app[bot] Apr 5, 2024
defd55e
feat(api): update via SDK Studio (#233)
stainless-app[bot] Apr 9, 2024
27c7d71
feat(api): update via SDK Studio (#234)
stainless-app[bot] Apr 9, 2024
47f9f56
feat(api): update via SDK Studio (#235)
stainless-app[bot] Apr 9, 2024
8ba08ef
feat(api): update via SDK Studio (#236)
stainless-app[bot] Apr 9, 2024
a333132
feat(api): update via SDK Studio (#237)
stainless-app[bot] Apr 9, 2024
b4310a5
feat(api): update via SDK Studio (#238)
stainless-app[bot] Apr 9, 2024
f44f877
feat(api): update via SDK Studio (#239)
stainless-app[bot] Apr 9, 2024
dd33a93
feat(api): update via SDK Studio (#240)
stainless-app[bot] Apr 9, 2024
9e1e430
feat(api): update via SDK Studio (#241)
stainless-app[bot] Apr 9, 2024
7eba978
feat(api): update via SDK Studio (#242)
stainless-app[bot] Apr 9, 2024
cc646b9
feat(api): update via SDK Studio (#243)
stainless-app[bot] Apr 9, 2024
268e06c
feat(api): update via SDK Studio (#244)
stainless-app[bot] Apr 9, 2024
2ed1953
feat(api): update via SDK Studio (#245)
stainless-app[bot] Apr 9, 2024
3ea7393
feat(api): OpenAPI spec update via Stainless API (#246)
stainless-app[bot] Apr 9, 2024
eee2f14
feat(api): update via SDK Studio (#247)
stainless-app[bot] Apr 9, 2024
d17c894
feat(api): update via SDK Studio (#248)
stainless-app[bot] Apr 9, 2024
7ad459c
feat(api): update via SDK Studio (#249)
stainless-app[bot] Apr 9, 2024
b4fbc33
feat(api): update via SDK Studio (#250)
stainless-app[bot] Apr 9, 2024
4964d0e
feat(api): update via SDK Studio (#251)
stainless-app[bot] Apr 9, 2024
d4bfe4e
feat(api): update via SDK Studio (#252)
stainless-app[bot] Apr 9, 2024
124a709
feat(api): update via SDK Studio (#253)
stainless-app[bot] Apr 9, 2024
04f7e9d
feat(api): update via SDK Studio (#254)
stainless-app[bot] Apr 9, 2024
a9f75be
feat(api): update via SDK Studio (#255)
stainless-app[bot] Apr 9, 2024
c31e274
feat(api): update via SDK Studio (#256)
stainless-app[bot] Apr 10, 2024
a138540
feat(api): update via SDK Studio (#257)
stainless-app[bot] Apr 10, 2024
33da158
feat(api): update via SDK Studio (#258)
stainless-app[bot] Apr 10, 2024
1e66658
feat(api): update via SDK Studio (#259)
stainless-app[bot] Apr 10, 2024
ec56e67
feat(api): update via SDK Studio (#260)
stainless-app[bot] Apr 10, 2024
952514e
feat(api): update via SDK Studio (#261)
stainless-app[bot] Apr 10, 2024
df8af97
feat(api): update via SDK Studio (#262)
stainless-app[bot] Apr 10, 2024
dfc5fef
feat(api): update via SDK Studio (#263)
stainless-app[bot] Apr 10, 2024
adeb5fa
feat(api): update via SDK Studio (#264)
stainless-app[bot] Apr 10, 2024
4cdc7ea
feat(api): update via SDK Studio (#265)
stainless-app[bot] Apr 10, 2024
45906d2
feat(api): update via SDK Studio (#266)
stainless-app[bot] Apr 10, 2024
89f4f0c
feat(api): OpenAPI spec update via Stainless API (#267)
stainless-app[bot] Apr 10, 2024
7006adb
feat(api): update via SDK Studio (#268)
stainless-app[bot] Apr 10, 2024
947dd45
feat(api): update via SDK Studio (#269)
stainless-app[bot] Apr 10, 2024
794ddc0
feat(api): update via SDK Studio (#270)
stainless-app[bot] Apr 10, 2024
11d4f1d
feat(api): update via SDK Studio (#271)
stainless-app[bot] Apr 10, 2024
cbbb0be
feat(api): OpenAPI spec update via Stainless API (#272)
stainless-app[bot] Apr 10, 2024
72a3b86
feat(api): OpenAPI spec update via Stainless API (#273)
stainless-app[bot] Apr 10, 2024
2a11bb1
feat(api): OpenAPI spec update via Stainless API (#274)
stainless-app[bot] Apr 10, 2024
9683250
feat(api): OpenAPI spec update via Stainless API (#275)
stainless-app[bot] Apr 10, 2024
02dc91c
feat(api): OpenAPI spec update via Stainless API (#276)
stainless-app[bot] Apr 10, 2024
f3e3ce8
feat(api): OpenAPI spec update via Stainless API (#277)
stainless-app[bot] Apr 10, 2024
192ef64
feat(api): update via SDK Studio (#278)
stainless-app[bot] Apr 10, 2024
e2478c5
feat(api): update via SDK Studio (#279)
stainless-app[bot] Apr 10, 2024
2fc1388
feat(api): update via SDK Studio (#280)
stainless-app[bot] Apr 10, 2024
2c2219f
feat(api): update via SDK Studio (#281)
stainless-app[bot] Apr 10, 2024
17adfbc
feat(api): update via SDK Studio (#282)
stainless-app[bot] Apr 10, 2024
9b2178a
feat(api): update via SDK Studio (#283)
stainless-app[bot] Apr 11, 2024
f46eebe
feat(api): update via SDK Studio (#284)
stainless-app[bot] Apr 11, 2024
ad4380d
feat(api): update via SDK Studio (#285)
stainless-app[bot] Apr 11, 2024
e4f36e1
feat(api): update via SDK Studio (#286)
stainless-app[bot] Apr 11, 2024
14b8cac
feat(api): update via SDK Studio (#287)
stainless-app[bot] Apr 11, 2024
f4891c0
feat(api): update via SDK Studio (#288)
stainless-app[bot] Apr 11, 2024
b6008f2
feat(api): update via SDK Studio (#289)
stainless-app[bot] Apr 11, 2024
c6c81d4
feat(api): update via SDK Studio (#290)
stainless-app[bot] Apr 11, 2024
39eabf7
feat(api): update via SDK Studio (#291)
stainless-app[bot] Apr 11, 2024
39eb096
feat(api): update via SDK Studio (#292)
stainless-app[bot] Apr 11, 2024
f7797bc
feat(api): update via SDK Studio (#293)
stainless-app[bot] Apr 11, 2024
f01d46e
feat(api): update via SDK Studio (#294)
stainless-app[bot] Apr 11, 2024
db173b7
feat(api): OpenAPI spec update via Stainless API (#295)
stainless-app[bot] Apr 11, 2024
bef513f
feat(api): OpenAPI spec update via Stainless API (#296)
stainless-app[bot] Apr 11, 2024
f408b80
feat(api): OpenAPI spec update via Stainless API (#297)
stainless-app[bot] Apr 11, 2024
413836b
feat(api): update via SDK Studio (#298)
stainless-app[bot] Apr 11, 2024
fb43f24
feat(api): update via SDK Studio (#299)
stainless-app[bot] Apr 12, 2024
0e084cf
feat(api): update via SDK Studio (#300)
stainless-app[bot] Apr 12, 2024
c5ea97f
feat(api): update via SDK Studio (#301)
stainless-app[bot] Apr 12, 2024
6be0122
feat(api): update via SDK Studio (#302)
stainless-app[bot] Apr 12, 2024
8e31a5a
feat(api): update via SDK Studio (#303)
stainless-app[bot] Apr 12, 2024
6ca31f1
feat(api): update via SDK Studio (#304)
stainless-app[bot] Apr 12, 2024
8e45d94
feat(api): update via SDK Studio (#305)
stainless-app[bot] Apr 12, 2024
f74e151
feat(api): update via SDK Studio (#306)
stainless-app[bot] Apr 12, 2024
289d760
feat(api): update via SDK Studio (#307)
stainless-app[bot] Apr 12, 2024
5a49713
feat(api): update via SDK Studio (#308)
stainless-app[bot] Apr 15, 2024
ddd0ea3
feat(api): OpenAPI spec update via Stainless API (#309)
stainless-app[bot] Apr 15, 2024
6fedcdb
feat(api): OpenAPI spec update via Stainless API (#310)
stainless-app[bot] Apr 15, 2024
6bc0063
feat(api): OpenAPI spec update via Stainless API (#311)
stainless-app[bot] Apr 15, 2024
b0fa819
feat(api): OpenAPI spec update via Stainless API (#312)
stainless-app[bot] Apr 15, 2024
df9cab4
feat(api): OpenAPI spec update via Stainless API (#313)
stainless-app[bot] Apr 15, 2024
51169d3
feat(api): OpenAPI spec update via Stainless API (#314)
stainless-app[bot] Apr 15, 2024
d42b574
feat(api): OpenAPI spec update via Stainless API (#315)
stainless-app[bot] Apr 15, 2024
032d4ea
feat(api): OpenAPI spec update via Stainless API (#316)
stainless-app[bot] Apr 15, 2024
e553303
feat(api): OpenAPI spec update via Stainless API (#317)
stainless-app[bot] Apr 15, 2024
8766ffb
feat(api): OpenAPI spec update via Stainless API (#318)
stainless-app[bot] Apr 15, 2024
f8b8339
feat(api): OpenAPI spec update via Stainless API (#319)
stainless-app[bot] Apr 15, 2024
9a5ecf5
feat(api): OpenAPI spec update via Stainless API (#320)
stainless-app[bot] Apr 15, 2024
49fca30
feat(api): OpenAPI spec update via Stainless API (#321)
stainless-app[bot] Apr 16, 2024
9e78a68
feat(api): OpenAPI spec update via Stainless API (#322)
stainless-app[bot] Apr 16, 2024
c9914bc
feat(api): OpenAPI spec update via Stainless API (#323)
stainless-app[bot] Apr 16, 2024
e3a9d7f
feat(api): OpenAPI spec update via Stainless API (#324)
stainless-app[bot] Apr 16, 2024
892540a
feat(api): OpenAPI spec update via Stainless API (#325)
stainless-app[bot] Apr 16, 2024
a8d801a
feat(api): OpenAPI spec update via Stainless API (#326)
stainless-app[bot] Apr 16, 2024
1740e2f
feat(api): OpenAPI spec update via Stainless API (#327)
stainless-app[bot] Apr 16, 2024
dff460b
feat(api): OpenAPI spec update via Stainless API (#328)
stainless-app[bot] Apr 16, 2024
0c0db5b
feat(api): OpenAPI spec update via Stainless API (#329)
stainless-app[bot] Apr 16, 2024
4c6b0ce
feat(api): OpenAPI spec update via Stainless API (#330)
stainless-app[bot] Apr 16, 2024
dc9f277
feat(api): OpenAPI spec update via Stainless API (#331)
stainless-app[bot] Apr 16, 2024
8b4c1a0
feat(api): update via SDK Studio (#332)
stainless-app[bot] Apr 16, 2024
81d95a5
feat(api): OpenAPI spec update via Stainless API (#333)
stainless-app[bot] Apr 16, 2024
9bf6572
feat(api): update via SDK Studio (#334)
stainless-app[bot] Apr 16, 2024
266c0dc
feat(api): update via SDK Studio (#335)
stainless-app[bot] Apr 17, 2024
0b9bdab
feat(api): update via SDK Studio (#336)
stainless-app[bot] Apr 17, 2024
0b41651
feat(api): OpenAPI spec update via Stainless API (#337)
stainless-app[bot] Apr 17, 2024
8aa19d4
feat(api): OpenAPI spec update via Stainless API (#338)
stainless-app[bot] Apr 17, 2024
13403a2
feat(api): update via SDK Studio (#339)
stainless-app[bot] Apr 18, 2024
9f6893c
feat(api): OpenAPI spec update via Stainless API (#340)
stainless-app[bot] Apr 18, 2024
3d2205f
feat(api): OpenAPI spec update via Stainless API (#341)
stainless-app[bot] Apr 18, 2024
91dbab3
feat(api): update via SDK Studio (#342)
stainless-app[bot] Apr 18, 2024
ac1e643
feat(api): update via SDK Studio (#343)
stainless-app[bot] Apr 19, 2024
3ba27b3
feat(api): update via SDK Studio (#344)
stainless-app[bot] Apr 19, 2024
50a9207
feat(api): update via SDK Studio (#345)
stainless-app[bot] Apr 19, 2024
b6f0062
feat(api): update via SDK Studio (#346)
stainless-app[bot] Apr 19, 2024
5b9a07e
feat(api): update via SDK Studio (#348)
stainless-app[bot] Apr 22, 2024
5a4d204
feat(api): update via SDK Studio (#349)
stainless-app[bot] Apr 22, 2024
55a52b3
feat(api): OpenAPI spec update via Stainless API (#350)
stainless-app[bot] Apr 22, 2024
5683c75
feat(api): OpenAPI spec update via Stainless API (#351)
stainless-app[bot] Apr 22, 2024
42e0458
feat(api): OpenAPI spec update via Stainless API (#352)
stainless-app[bot] Apr 22, 2024
477c21a
feat(api): update via SDK Studio (#353)
stainless-app[bot] Apr 23, 2024
c0f7159
feat(api): update via SDK Studio (#354)
stainless-app[bot] Apr 23, 2024
f168068
feat(api): OpenAPI spec update via Stainless API (#355)
stainless-app[bot] Apr 23, 2024
e6e5f2d
feat(api): update via SDK Studio (#356)
stainless-app[bot] Apr 23, 2024
d7aa7ad
feat(api): update via SDK Studio (#357)
stainless-app[bot] Apr 23, 2024
0c9946d
feat(api): OpenAPI spec update via Stainless API (#358)
stainless-app[bot] Apr 23, 2024
5467248
feat(api): OpenAPI spec update via Stainless API (#359)
stainless-app[bot] Apr 23, 2024
327dd08
feat(api): update via SDK Studio (#360)
stainless-app[bot] Apr 24, 2024
4d28968
release: 3.0.0-beta.8
stainless-app[bot] Apr 24, 2024
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
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
28 changes: 27 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
echo "$HOME/.rye/shims" >> $GITHUB_PATH
env:
RYE_VERSION: 0.24.0
RYE_INSTALL_OPTION: "--yes"
RYE_INSTALL_OPTION: '--yes'

- name: Install dependencies
run: |
Expand All @@ -39,3 +39,29 @@ jobs:
- name: Ensure importable
run: |
rye run python -c 'import cloudflare'

examples:
name: examples
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install Rye
run: |
curl -sSf https://rye-up.com/get | bash
echo "$HOME/.rye/shims" >> $GITHUB_PATH
env:
RYE_VERSION: 0.24.0
RYE_INSTALL_OPTION: "--yes"
- name: Install dependencies
run: |
rye sync --all-features

- env:
CLOUDFLARE_ACCOUNT_ID: f037e56e89293a057740de681ac9abbe
CLOUDFLARE_EMAIL: [email protected]
CLOUDFLARE_ZONE_ID: 0da42c8d2132a9ddaf714f9e7c92011
CLOUDFLARE_API_KEY: ${{ secrets.CLOUDFLARE_API_KEY }}
run: |
rye run python ./examples/workers/ai/demo.py
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "3.0.0-beta.7"
".": "3.0.0-beta.8"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
configured_endpoints: 1292
configured_endpoints: 1266
165 changes: 165 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ from cloudflare import Cloudflare
client = Cloudflare(
# This is the default and can be omitted
api_email=os.environ.get("CLOUDFLARE_EMAIL"),
# This is the default and can be omitted
api_key=os.environ.get("CLOUDFLARE_API_KEY"),
)

zone = client.zones.create(
Expand Down Expand Up @@ -57,6 +59,8 @@ from cloudflare import AsyncCloudflare
client = AsyncCloudflare(
# This is the default and can be omitted
api_email=os.environ.get("CLOUDFLARE_EMAIL"),
# This is the default and can be omitted
api_key=os.environ.get("CLOUDFLARE_API_KEY"),
)


Expand All @@ -76,10 +80,10 @@ Functionality between the synchronous and asynchronous clients is otherwise iden

## 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 provide helper methods for things like:
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:

- Serializing back into JSON, `model.model_dump_json(indent=2, exclude_unset=True)`
- Converting to a dictionary, `model.model_dump(exclude_unset=True)`
- Serializing back into JSON, `model.to_json()`
- Converting to a dictionary, `model.to_dict()`

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

Expand Down Expand Up @@ -352,13 +356,12 @@ You can directly override the [httpx client](https://www.python-httpx.org/api/#c
- Additional [advanced](https://www.python-httpx.org/advanced/#client-instances) functionality

```python
import httpx
from cloudflare import Cloudflare
from cloudflare import Cloudflare, DefaultHttpxClient

client = Cloudflare(
# Or use the `CLOUDFLARE_BASE_URL` env var
base_url="http://my.test.server.example.com:8083",
http_client=httpx.Client(
http_client=DefaultHttpxClient(
proxies="http://my.test.proxy.example.com",
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
),
Expand Down
3,166 changes: 1,704 additions & 1,462 deletions api.md

Large diffs are not rendered by default.

11 changes: 8 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "cloudflare"
version = "3.0.0-beta.7"
version = "3.0.0-beta.8"
description = "The official Python library for the cloudflare API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down Expand Up @@ -48,7 +48,7 @@ Repository = "https://github.com/cloudflare/cloudflare-python"
managed = true
# version pins are in requirements-dev.lock
dev-dependencies = [
"pyright",
"pyright>=1.1.359",
"mypy",
"respx",
"pytest",
Expand Down Expand Up @@ -162,7 +162,9 @@ select = [
"T201",
"T203",
# misuse of typing.TYPE_CHECKING
"TCH004"
"TCH004",
# import rules
"TID251",
]
ignore = [
# mutable defaults
Expand All @@ -178,6 +180,9 @@ ignore-init-module-imports = true
[tool.ruff.format]
docstring-code-format = true

[tool.ruff.lint.flake8-tidy-imports.banned-api]
"functools.lru_cache".msg = "This function does not retain type information for the wrapped function's arguments; The `lru_cache` function from `_utils` should be used instead"

[tool.ruff.lint.isort]
length-sort = true
length-sort-straight = true
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pydantic==2.4.2
# via cloudflare
pydantic-core==2.10.1
# via pydantic
pyright==1.1.353
pyright==1.1.359
pytest==7.1.1
# via pytest-asyncio
pytest-asyncio==0.21.1
Expand Down
3 changes: 3 additions & 0 deletions src/cloudflare/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
UnprocessableEntityError,
APIResponseValidationError,
)
from ._base_client import DefaultHttpxClient, DefaultAsyncHttpxClient
from ._utils._logs import setup_logging as _setup_logging

__all__ = [
Expand Down Expand Up @@ -72,6 +73,8 @@
"DEFAULT_TIMEOUT",
"DEFAULT_MAX_RETRIES",
"DEFAULT_CONNECTION_LIMITS",
"DefaultHttpxClient",
"DefaultAsyncHttpxClient",
]

_setup_logging()
Expand Down
47 changes: 43 additions & 4 deletions src/cloudflare/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
cast,
overload,
)
from functools import lru_cache
from typing_extensions import Literal, override, get_origin

import anyio
Expand Down Expand Up @@ -61,7 +60,7 @@
RequestOptions,
ModelBuilderProtocol,
)
from ._utils import is_dict, is_list, is_given, is_mapping
from ._utils import is_dict, is_list, is_given, lru_cache, is_mapping
from ._compat import model_copy, model_dump
from ._models import GenericModel, FinalRequestOptions, validate_type, construct_type
from ._response import (
Expand Down Expand Up @@ -715,7 +714,27 @@ def _idempotency_key(self) -> str:
return f"stainless-python-retry-{uuid.uuid4()}"


class SyncHttpxClientWrapper(httpx.Client):
class _DefaultHttpxClient(httpx.Client):
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:
DefaultHttpxClient = httpx.Client
"""An alias to `httpx.Client` that provides the same defaults that this SDK
uses internally.

This is useful because overriding the `http_client` with your own instance of
`httpx.Client` will result in httpx's defaults being used, not ours.
"""
else:
DefaultHttpxClient = _DefaultHttpxClient


class SyncHttpxClientWrapper(DefaultHttpxClient):
def __del__(self) -> None:
try:
self.close()
Expand Down Expand Up @@ -1248,7 +1267,27 @@ def get_api_list(
return self._request_api_list(model, page, opts)


class AsyncHttpxClientWrapper(httpx.AsyncClient):
class _DefaultAsyncHttpxClient(httpx.AsyncClient):
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
uses internally.

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.
"""
else:
DefaultAsyncHttpxClient = _DefaultAsyncHttpxClient


class AsyncHttpxClientWrapper(DefaultAsyncHttpxClient):
def __del__(self) -> None:
try:
# TODO(someday): support non asyncio runtimes here
Expand Down
Loading
Loading