Skip to content

Commit defd55e

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
feat(api): update via SDK Studio (#233)
1 parent f90dc3a commit defd55e

File tree

848 files changed

+9401
-9615
lines changed

Some content is hidden

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

848 files changed

+9401
-9615
lines changed

README.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -352,13 +352,12 @@ You can directly override the [httpx client](https://www.python-httpx.org/api/#c
352352
- Additional [advanced](https://www.python-httpx.org/advanced/#client-instances) functionality
353353

354354
```python
355-
import httpx
356-
from cloudflare import Cloudflare
355+
from cloudflare import Cloudflare, DefaultHttpxClient
357356

358357
client = Cloudflare(
359358
# Or use the `CLOUDFLARE_BASE_URL` env var
360359
base_url="http://my.test.server.example.com:8083",
361-
http_client=httpx.Client(
360+
http_client=DefaultHttpxClient(
362361
proxies="http://my.test.proxy.example.com",
363362
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
364363
),

api.md

+514-603
Large diffs are not rendered by default.

src/cloudflare/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
UnprocessableEntityError,
3535
APIResponseValidationError,
3636
)
37+
from ._base_client import DefaultHttpxClient, DefaultAsyncHttpxClient
3738
from ._utils._logs import setup_logging as _setup_logging
3839

3940
__all__ = [
@@ -72,6 +73,8 @@
7273
"DEFAULT_TIMEOUT",
7374
"DEFAULT_MAX_RETRIES",
7475
"DEFAULT_CONNECTION_LIMITS",
76+
"DefaultHttpxClient",
77+
"DefaultAsyncHttpxClient",
7578
]
7679

7780
_setup_logging()

src/cloudflare/_base_client.py

+42-2
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,27 @@ def _idempotency_key(self) -> str:
715715
return f"stainless-python-retry-{uuid.uuid4()}"
716716

717717

718-
class SyncHttpxClientWrapper(httpx.Client):
718+
class _DefaultHttpxClient(httpx.Client):
719+
def __init__(self, **kwargs: Any) -> None:
720+
kwargs.setdefault("timeout", DEFAULT_TIMEOUT)
721+
kwargs.setdefault("limits", DEFAULT_CONNECTION_LIMITS)
722+
kwargs.setdefault("follow_redirects", True)
723+
super().__init__(**kwargs)
724+
725+
726+
if TYPE_CHECKING:
727+
DefaultHttpxClient = httpx.Client
728+
"""An alias to `httpx.Client` that provides the same defaults that this SDK
729+
uses internally.
730+
731+
This is useful because overriding the `http_client` with your own instance of
732+
`httpx.Client` will result in httpx's defaults being used, not ours.
733+
"""
734+
else:
735+
DefaultHttpxClient = _DefaultHttpxClient
736+
737+
738+
class SyncHttpxClientWrapper(DefaultHttpxClient):
719739
def __del__(self) -> None:
720740
try:
721741
self.close()
@@ -1248,7 +1268,27 @@ def get_api_list(
12481268
return self._request_api_list(model, page, opts)
12491269

12501270

1251-
class AsyncHttpxClientWrapper(httpx.AsyncClient):
1271+
class _DefaultAsyncHttpxClient(httpx.AsyncClient):
1272+
def __init__(self, **kwargs: Any) -> None:
1273+
kwargs.setdefault("timeout", DEFAULT_TIMEOUT)
1274+
kwargs.setdefault("limits", DEFAULT_CONNECTION_LIMITS)
1275+
kwargs.setdefault("follow_redirects", True)
1276+
super().__init__(**kwargs)
1277+
1278+
1279+
if TYPE_CHECKING:
1280+
DefaultAsyncHttpxClient = httpx.AsyncClient
1281+
"""An alias to `httpx.AsyncClient` that provides the same defaults that this SDK
1282+
uses internally.
1283+
1284+
This is useful because overriding the `http_client` with your own instance of
1285+
`httpx.AsyncClient` will result in httpx's defaults being used, not ours.
1286+
"""
1287+
else:
1288+
DefaultAsyncHttpxClient = _DefaultAsyncHttpxClient
1289+
1290+
1291+
class AsyncHttpxClientWrapper(DefaultAsyncHttpxClient):
12521292
def __del__(self) -> None:
12531293
try:
12541294
# TODO(someday): support non asyncio runtimes here

src/cloudflare/_client.py

+22-18
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class Cloudflare(SyncAPIClient):
5151
origin_ca_certificates: resources.OriginCACertificates
5252
ips: resources.IPs
5353
memberships: resources.Memberships
54-
user: resources.UserResource
54+
user: resources.User
5555
zones: resources.Zones
5656
load_balancers: resources.LoadBalancers
5757
cache: resources.Cache
@@ -108,7 +108,7 @@ class Cloudflare(SyncAPIClient):
108108
storage: resources.Storage
109109
stream: resources.Stream
110110
alerting: resources.Alerting
111-
d1: resources.D1
111+
d1: resources.D1Resource
112112
r2: resources.R2
113113
warp_connector: resources.WARPConnector
114114
workers_for_platforms: resources.WorkersForPlatforms
@@ -148,7 +148,9 @@ def __init__(
148148
max_retries: int = DEFAULT_MAX_RETRIES,
149149
default_headers: Mapping[str, str] | None = None,
150150
default_query: Mapping[str, object] | None = None,
151-
# Configure a custom httpx client. See the [httpx documentation](https://www.python-httpx.org/api/#client) for more details.
151+
# Configure a custom httpx client.
152+
# We provide a `DefaultHttpxClient` class that you can pass to retain the default values we use for `limits`, `timeout` & `follow_redirects`.
153+
# See the [httpx documentation](https://www.python-httpx.org/api/#client) for more details.
152154
http_client: httpx.Client | None = None,
153155
# Enable or disable schema validation for data returned by the API.
154156
# When enabled an error APIResponseValidationError is raised
@@ -204,7 +206,7 @@ def __init__(
204206
self.origin_ca_certificates = resources.OriginCACertificates(self)
205207
self.ips = resources.IPs(self)
206208
self.memberships = resources.Memberships(self)
207-
self.user = resources.UserResource(self)
209+
self.user = resources.User(self)
208210
self.zones = resources.Zones(self)
209211
self.load_balancers = resources.LoadBalancers(self)
210212
self.cache = resources.Cache(self)
@@ -261,7 +263,7 @@ def __init__(
261263
self.storage = resources.Storage(self)
262264
self.stream = resources.Stream(self)
263265
self.alerting = resources.Alerting(self)
264-
self.d1 = resources.D1(self)
266+
self.d1 = resources.D1Resource(self)
265267
self.r2 = resources.R2(self)
266268
self.warp_connector = resources.WARPConnector(self)
267269
self.workers_for_platforms = resources.WorkersForPlatforms(self)
@@ -462,7 +464,7 @@ class AsyncCloudflare(AsyncAPIClient):
462464
origin_ca_certificates: resources.AsyncOriginCACertificates
463465
ips: resources.AsyncIPs
464466
memberships: resources.AsyncMemberships
465-
user: resources.AsyncUserResource
467+
user: resources.AsyncUser
466468
zones: resources.AsyncZones
467469
load_balancers: resources.AsyncLoadBalancers
468470
cache: resources.AsyncCache
@@ -519,7 +521,7 @@ class AsyncCloudflare(AsyncAPIClient):
519521
storage: resources.AsyncStorage
520522
stream: resources.AsyncStream
521523
alerting: resources.AsyncAlerting
522-
d1: resources.AsyncD1
524+
d1: resources.AsyncD1Resource
523525
r2: resources.AsyncR2
524526
warp_connector: resources.AsyncWARPConnector
525527
workers_for_platforms: resources.AsyncWorkersForPlatforms
@@ -559,7 +561,9 @@ def __init__(
559561
max_retries: int = DEFAULT_MAX_RETRIES,
560562
default_headers: Mapping[str, str] | None = None,
561563
default_query: Mapping[str, object] | None = None,
562-
# Configure a custom httpx client. See the [httpx documentation](https://www.python-httpx.org/api/#asyncclient) for more details.
564+
# Configure a custom httpx client.
565+
# We provide a `DefaultAsyncHttpxClient` class that you can pass to retain the default values we use for `limits`, `timeout` & `follow_redirects`.
566+
# See the [httpx documentation](https://www.python-httpx.org/api/#asyncclient) for more details.
563567
http_client: httpx.AsyncClient | None = None,
564568
# Enable or disable schema validation for data returned by the API.
565569
# When enabled an error APIResponseValidationError is raised
@@ -615,7 +619,7 @@ def __init__(
615619
self.origin_ca_certificates = resources.AsyncOriginCACertificates(self)
616620
self.ips = resources.AsyncIPs(self)
617621
self.memberships = resources.AsyncMemberships(self)
618-
self.user = resources.AsyncUserResource(self)
622+
self.user = resources.AsyncUser(self)
619623
self.zones = resources.AsyncZones(self)
620624
self.load_balancers = resources.AsyncLoadBalancers(self)
621625
self.cache = resources.AsyncCache(self)
@@ -672,7 +676,7 @@ def __init__(
672676
self.storage = resources.AsyncStorage(self)
673677
self.stream = resources.AsyncStream(self)
674678
self.alerting = resources.AsyncAlerting(self)
675-
self.d1 = resources.AsyncD1(self)
679+
self.d1 = resources.AsyncD1Resource(self)
676680
self.r2 = resources.AsyncR2(self)
677681
self.warp_connector = resources.AsyncWARPConnector(self)
678682
self.workers_for_platforms = resources.AsyncWorkersForPlatforms(self)
@@ -874,7 +878,7 @@ def __init__(self, client: Cloudflare) -> None:
874878
self.origin_ca_certificates = resources.OriginCACertificatesWithRawResponse(client.origin_ca_certificates)
875879
self.ips = resources.IPsWithRawResponse(client.ips)
876880
self.memberships = resources.MembershipsWithRawResponse(client.memberships)
877-
self.user = resources.UserResourceWithRawResponse(client.user)
881+
self.user = resources.UserWithRawResponse(client.user)
878882
self.zones = resources.ZonesWithRawResponse(client.zones)
879883
self.load_balancers = resources.LoadBalancersWithRawResponse(client.load_balancers)
880884
self.cache = resources.CacheWithRawResponse(client.cache)
@@ -931,7 +935,7 @@ def __init__(self, client: Cloudflare) -> None:
931935
self.storage = resources.StorageWithRawResponse(client.storage)
932936
self.stream = resources.StreamWithRawResponse(client.stream)
933937
self.alerting = resources.AlertingWithRawResponse(client.alerting)
934-
self.d1 = resources.D1WithRawResponse(client.d1)
938+
self.d1 = resources.D1ResourceWithRawResponse(client.d1)
935939
self.r2 = resources.R2WithRawResponse(client.r2)
936940
self.warp_connector = resources.WARPConnectorWithRawResponse(client.warp_connector)
937941
self.workers_for_platforms = resources.WorkersForPlatformsWithRawResponse(client.workers_for_platforms)
@@ -960,7 +964,7 @@ def __init__(self, client: AsyncCloudflare) -> None:
960964
self.origin_ca_certificates = resources.AsyncOriginCACertificatesWithRawResponse(client.origin_ca_certificates)
961965
self.ips = resources.AsyncIPsWithRawResponse(client.ips)
962966
self.memberships = resources.AsyncMembershipsWithRawResponse(client.memberships)
963-
self.user = resources.AsyncUserResourceWithRawResponse(client.user)
967+
self.user = resources.AsyncUserWithRawResponse(client.user)
964968
self.zones = resources.AsyncZonesWithRawResponse(client.zones)
965969
self.load_balancers = resources.AsyncLoadBalancersWithRawResponse(client.load_balancers)
966970
self.cache = resources.AsyncCacheWithRawResponse(client.cache)
@@ -1021,7 +1025,7 @@ def __init__(self, client: AsyncCloudflare) -> None:
10211025
self.storage = resources.AsyncStorageWithRawResponse(client.storage)
10221026
self.stream = resources.AsyncStreamWithRawResponse(client.stream)
10231027
self.alerting = resources.AsyncAlertingWithRawResponse(client.alerting)
1024-
self.d1 = resources.AsyncD1WithRawResponse(client.d1)
1028+
self.d1 = resources.AsyncD1ResourceWithRawResponse(client.d1)
10251029
self.r2 = resources.AsyncR2WithRawResponse(client.r2)
10261030
self.warp_connector = resources.AsyncWARPConnectorWithRawResponse(client.warp_connector)
10271031
self.workers_for_platforms = resources.AsyncWorkersForPlatformsWithRawResponse(client.workers_for_platforms)
@@ -1050,7 +1054,7 @@ def __init__(self, client: Cloudflare) -> None:
10501054
self.origin_ca_certificates = resources.OriginCACertificatesWithStreamingResponse(client.origin_ca_certificates)
10511055
self.ips = resources.IPsWithStreamingResponse(client.ips)
10521056
self.memberships = resources.MembershipsWithStreamingResponse(client.memberships)
1053-
self.user = resources.UserResourceWithStreamingResponse(client.user)
1057+
self.user = resources.UserWithStreamingResponse(client.user)
10541058
self.zones = resources.ZonesWithStreamingResponse(client.zones)
10551059
self.load_balancers = resources.LoadBalancersWithStreamingResponse(client.load_balancers)
10561060
self.cache = resources.CacheWithStreamingResponse(client.cache)
@@ -1111,7 +1115,7 @@ def __init__(self, client: Cloudflare) -> None:
11111115
self.storage = resources.StorageWithStreamingResponse(client.storage)
11121116
self.stream = resources.StreamWithStreamingResponse(client.stream)
11131117
self.alerting = resources.AlertingWithStreamingResponse(client.alerting)
1114-
self.d1 = resources.D1WithStreamingResponse(client.d1)
1118+
self.d1 = resources.D1ResourceWithStreamingResponse(client.d1)
11151119
self.r2 = resources.R2WithStreamingResponse(client.r2)
11161120
self.warp_connector = resources.WARPConnectorWithStreamingResponse(client.warp_connector)
11171121
self.workers_for_platforms = resources.WorkersForPlatformsWithStreamingResponse(client.workers_for_platforms)
@@ -1142,7 +1146,7 @@ def __init__(self, client: AsyncCloudflare) -> None:
11421146
)
11431147
self.ips = resources.AsyncIPsWithStreamingResponse(client.ips)
11441148
self.memberships = resources.AsyncMembershipsWithStreamingResponse(client.memberships)
1145-
self.user = resources.AsyncUserResourceWithStreamingResponse(client.user)
1149+
self.user = resources.AsyncUserWithStreamingResponse(client.user)
11461150
self.zones = resources.AsyncZonesWithStreamingResponse(client.zones)
11471151
self.load_balancers = resources.AsyncLoadBalancersWithStreamingResponse(client.load_balancers)
11481152
self.cache = resources.AsyncCacheWithStreamingResponse(client.cache)
@@ -1205,7 +1209,7 @@ def __init__(self, client: AsyncCloudflare) -> None:
12051209
self.storage = resources.AsyncStorageWithStreamingResponse(client.storage)
12061210
self.stream = resources.AsyncStreamWithStreamingResponse(client.stream)
12071211
self.alerting = resources.AsyncAlertingWithStreamingResponse(client.alerting)
1208-
self.d1 = resources.AsyncD1WithStreamingResponse(client.d1)
1212+
self.d1 = resources.AsyncD1ResourceWithStreamingResponse(client.d1)
12091213
self.r2 = resources.AsyncR2WithStreamingResponse(client.r2)
12101214
self.warp_connector = resources.AsyncWARPConnectorWithStreamingResponse(client.warp_connector)
12111215
self.workers_for_platforms = resources.AsyncWorkersForPlatformsWithStreamingResponse(

src/cloudflare/resources/__init__.py

+24-24
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

33
from .d1 import (
4-
D1,
5-
AsyncD1,
6-
D1WithRawResponse,
7-
AsyncD1WithRawResponse,
8-
D1WithStreamingResponse,
9-
AsyncD1WithStreamingResponse,
4+
D1Resource,
5+
AsyncD1Resource,
6+
D1ResourceWithRawResponse,
7+
AsyncD1ResourceWithRawResponse,
8+
D1ResourceWithStreamingResponse,
9+
AsyncD1ResourceWithStreamingResponse,
1010
)
1111
from .kv import (
1212
KV,
@@ -81,12 +81,12 @@
8181
AsyncLogsWithStreamingResponse,
8282
)
8383
from .user import (
84-
UserResource,
85-
AsyncUserResource,
86-
UserResourceWithRawResponse,
87-
AsyncUserResourceWithRawResponse,
88-
UserResourceWithStreamingResponse,
89-
AsyncUserResourceWithStreamingResponse,
84+
User,
85+
AsyncUser,
86+
UserWithRawResponse,
87+
AsyncUserWithRawResponse,
88+
UserWithStreamingResponse,
89+
AsyncUserWithStreamingResponse,
9090
)
9191
from .web3 import (
9292
Web3,
@@ -666,12 +666,12 @@
666666
"AsyncMembershipsWithRawResponse",
667667
"MembershipsWithStreamingResponse",
668668
"AsyncMembershipsWithStreamingResponse",
669-
"UserResource",
670-
"AsyncUserResource",
671-
"UserResourceWithRawResponse",
672-
"AsyncUserResourceWithRawResponse",
673-
"UserResourceWithStreamingResponse",
674-
"AsyncUserResourceWithStreamingResponse",
669+
"User",
670+
"AsyncUser",
671+
"UserWithRawResponse",
672+
"AsyncUserWithRawResponse",
673+
"UserWithStreamingResponse",
674+
"AsyncUserWithStreamingResponse",
675675
"Zones",
676676
"AsyncZones",
677677
"ZonesWithRawResponse",
@@ -1008,12 +1008,12 @@
10081008
"AsyncAlertingWithRawResponse",
10091009
"AlertingWithStreamingResponse",
10101010
"AsyncAlertingWithStreamingResponse",
1011-
"D1",
1012-
"AsyncD1",
1013-
"D1WithRawResponse",
1014-
"AsyncD1WithRawResponse",
1015-
"D1WithStreamingResponse",
1016-
"AsyncD1WithStreamingResponse",
1011+
"D1Resource",
1012+
"AsyncD1Resource",
1013+
"D1ResourceWithRawResponse",
1014+
"AsyncD1ResourceWithRawResponse",
1015+
"D1ResourceWithStreamingResponse",
1016+
"AsyncD1ResourceWithStreamingResponse",
10171017
"R2",
10181018
"AsyncR2",
10191019
"R2WithRawResponse",

src/cloudflare/resources/accounts/members.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@
2828
)
2929
from ...types.accounts import (
3030
Member,
31-
MemberWithCode,
31+
MemberRoleParam,
3232
MemberListResponse,
3333
MemberDeleteResponse,
34+
MemberWithInviteCode,
3435
member_list_params,
3536
member_create_params,
3637
member_delete_params,
@@ -62,7 +63,7 @@ def create(
6263
extra_query: Query | None = None,
6364
extra_body: Body | None = None,
6465
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
65-
) -> MemberWithCode:
66+
) -> MemberWithInviteCode:
6667
"""
6768
Add a user to the list of members for this account.
6869
@@ -96,15 +97,15 @@ def create(
9697
timeout=timeout,
9798
post_parser=ResultWrapper._unwrapper,
9899
),
99-
cast_to=cast(Type[MemberWithCode], ResultWrapper[MemberWithCode]),
100+
cast_to=cast(Type[MemberWithInviteCode], ResultWrapper[MemberWithInviteCode]),
100101
)
101102

102103
def update(
103104
self,
104105
member_id: str,
105106
*,
106107
account_id: object,
107-
roles: Iterable[member_update_params.Role],
108+
roles: Iterable[MemberRoleParam],
108109
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
109110
# The extra values given here take precedence over values defined on the client or passed to this method.
110111
extra_headers: Headers | None = None,
@@ -308,7 +309,7 @@ async def create(
308309
extra_query: Query | None = None,
309310
extra_body: Body | None = None,
310311
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
311-
) -> MemberWithCode:
312+
) -> MemberWithInviteCode:
312313
"""
313314
Add a user to the list of members for this account.
314315
@@ -342,15 +343,15 @@ async def create(
342343
timeout=timeout,
343344
post_parser=ResultWrapper._unwrapper,
344345
),
345-
cast_to=cast(Type[MemberWithCode], ResultWrapper[MemberWithCode]),
346+
cast_to=cast(Type[MemberWithInviteCode], ResultWrapper[MemberWithInviteCode]),
346347
)
347348

348349
async def update(
349350
self,
350351
member_id: str,
351352
*,
352353
account_id: object,
353-
roles: Iterable[member_update_params.Role],
354+
roles: Iterable[MemberRoleParam],
354355
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
355356
# The extra values given here take precedence over values defined on the client or passed to this method.
356357
extra_headers: Headers | None = None,

0 commit comments

Comments
 (0)