Skip to content

Commit c1e8143

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
feat(api): api update (#2146)
1 parent 6473ee6 commit c1e8143

File tree

12 files changed

+593
-2
lines changed

12 files changed

+593
-2
lines changed

.stats.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
configured_endpoints: 1416
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-3f87896b62cce36e33c03f416ad98add2717ccd78f1743925c160a6c6a67ff15.yml
1+
configured_endpoints: 1417
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4396f2b615f2349cc28c23e9df6cf66c1c0fd8257d18df0ce54d7e74c839bf9f.yml

api.md

+14
Original file line numberDiff line numberDiff line change
@@ -2298,6 +2298,20 @@ Methods:
22982298
- <code title="delete /accounts/{account_id}/workers/scripts/{script_name}">client.workers.scripts.<a href="./src/cloudflare/resources/workers/scripts/scripts.py">delete</a>(script_name, \*, account_id, \*\*<a href="src/cloudflare/types/workers/script_delete_params.py">params</a>) -> None</code>
22992299
- <code title="get /accounts/{account_id}/workers/scripts/{script_name}">client.workers.scripts.<a href="./src/cloudflare/resources/workers/scripts/scripts.py">get</a>(script_name, \*, account_id) -> BinaryAPIResponse</code>
23002300

2301+
### Assets
2302+
2303+
#### Upload
2304+
2305+
Types:
2306+
2307+
```python
2308+
from cloudflare.types.workers.scripts.assets import UploadCreateResponse
2309+
```
2310+
2311+
Methods:
2312+
2313+
- <code title="post /accounts/{account_id}/workers/scripts/{script_name}/assets-upload-session">client.workers.scripts.assets.upload.<a href="./src/cloudflare/resources/workers/scripts/assets/upload.py">create</a>(script_name, \*, account_id, \*\*<a href="src/cloudflare/types/workers/scripts/assets/upload_create_params.py">params</a>) -> <a href="./src/cloudflare/types/workers/scripts/assets/upload_create_response.py">Optional</a></code>
2314+
23012315
### Subdomain
23022316

23032317
Types:

src/cloudflare/resources/workers/scripts/__init__.py

+14
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@
88
TailResourceWithStreamingResponse,
99
AsyncTailResourceWithStreamingResponse,
1010
)
11+
from .assets import (
12+
AssetsResource,
13+
AsyncAssetsResource,
14+
AssetsResourceWithRawResponse,
15+
AsyncAssetsResourceWithRawResponse,
16+
AssetsResourceWithStreamingResponse,
17+
AsyncAssetsResourceWithStreamingResponse,
18+
)
1119
from .content import (
1220
ContentResource,
1321
AsyncContentResource,
@@ -66,6 +74,12 @@
6674
)
6775

6876
__all__ = [
77+
"AssetsResource",
78+
"AsyncAssetsResource",
79+
"AssetsResourceWithRawResponse",
80+
"AsyncAssetsResourceWithRawResponse",
81+
"AssetsResourceWithStreamingResponse",
82+
"AsyncAssetsResourceWithStreamingResponse",
6983
"SubdomainResource",
7084
"AsyncSubdomainResource",
7185
"SubdomainResourceWithRawResponse",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from .assets import (
4+
AssetsResource,
5+
AsyncAssetsResource,
6+
AssetsResourceWithRawResponse,
7+
AsyncAssetsResourceWithRawResponse,
8+
AssetsResourceWithStreamingResponse,
9+
AsyncAssetsResourceWithStreamingResponse,
10+
)
11+
from .upload import (
12+
UploadResource,
13+
AsyncUploadResource,
14+
UploadResourceWithRawResponse,
15+
AsyncUploadResourceWithRawResponse,
16+
UploadResourceWithStreamingResponse,
17+
AsyncUploadResourceWithStreamingResponse,
18+
)
19+
20+
__all__ = [
21+
"UploadResource",
22+
"AsyncUploadResource",
23+
"UploadResourceWithRawResponse",
24+
"AsyncUploadResourceWithRawResponse",
25+
"UploadResourceWithStreamingResponse",
26+
"AsyncUploadResourceWithStreamingResponse",
27+
"AssetsResource",
28+
"AsyncAssetsResource",
29+
"AssetsResourceWithRawResponse",
30+
"AsyncAssetsResourceWithRawResponse",
31+
"AssetsResourceWithStreamingResponse",
32+
"AsyncAssetsResourceWithStreamingResponse",
33+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from .upload import (
6+
UploadResource,
7+
AsyncUploadResource,
8+
UploadResourceWithRawResponse,
9+
AsyncUploadResourceWithRawResponse,
10+
UploadResourceWithStreamingResponse,
11+
AsyncUploadResourceWithStreamingResponse,
12+
)
13+
from ....._compat import cached_property
14+
from ....._resource import SyncAPIResource, AsyncAPIResource
15+
16+
__all__ = ["AssetsResource", "AsyncAssetsResource"]
17+
18+
19+
class AssetsResource(SyncAPIResource):
20+
@cached_property
21+
def upload(self) -> UploadResource:
22+
return UploadResource(self._client)
23+
24+
@cached_property
25+
def with_raw_response(self) -> AssetsResourceWithRawResponse:
26+
"""
27+
This property can be used as a prefix for any HTTP method call to return the
28+
the raw response object instead of the parsed content.
29+
30+
For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers
31+
"""
32+
return AssetsResourceWithRawResponse(self)
33+
34+
@cached_property
35+
def with_streaming_response(self) -> AssetsResourceWithStreamingResponse:
36+
"""
37+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
38+
39+
For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response
40+
"""
41+
return AssetsResourceWithStreamingResponse(self)
42+
43+
44+
class AsyncAssetsResource(AsyncAPIResource):
45+
@cached_property
46+
def upload(self) -> AsyncUploadResource:
47+
return AsyncUploadResource(self._client)
48+
49+
@cached_property
50+
def with_raw_response(self) -> AsyncAssetsResourceWithRawResponse:
51+
"""
52+
This property can be used as a prefix for any HTTP method call to return the
53+
the raw response object instead of the parsed content.
54+
55+
For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers
56+
"""
57+
return AsyncAssetsResourceWithRawResponse(self)
58+
59+
@cached_property
60+
def with_streaming_response(self) -> AsyncAssetsResourceWithStreamingResponse:
61+
"""
62+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
63+
64+
For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response
65+
"""
66+
return AsyncAssetsResourceWithStreamingResponse(self)
67+
68+
69+
class AssetsResourceWithRawResponse:
70+
def __init__(self, assets: AssetsResource) -> None:
71+
self._assets = assets
72+
73+
@cached_property
74+
def upload(self) -> UploadResourceWithRawResponse:
75+
return UploadResourceWithRawResponse(self._assets.upload)
76+
77+
78+
class AsyncAssetsResourceWithRawResponse:
79+
def __init__(self, assets: AsyncAssetsResource) -> None:
80+
self._assets = assets
81+
82+
@cached_property
83+
def upload(self) -> AsyncUploadResourceWithRawResponse:
84+
return AsyncUploadResourceWithRawResponse(self._assets.upload)
85+
86+
87+
class AssetsResourceWithStreamingResponse:
88+
def __init__(self, assets: AssetsResource) -> None:
89+
self._assets = assets
90+
91+
@cached_property
92+
def upload(self) -> UploadResourceWithStreamingResponse:
93+
return UploadResourceWithStreamingResponse(self._assets.upload)
94+
95+
96+
class AsyncAssetsResourceWithStreamingResponse:
97+
def __init__(self, assets: AsyncAssetsResource) -> None:
98+
self._assets = assets
99+
100+
@cached_property
101+
def upload(self) -> AsyncUploadResourceWithStreamingResponse:
102+
return AsyncUploadResourceWithStreamingResponse(self._assets.upload)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from typing import Dict, Type, Optional, cast
6+
7+
import httpx
8+
9+
from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven
10+
from ....._utils import (
11+
maybe_transform,
12+
async_maybe_transform,
13+
)
14+
from ....._compat import cached_property
15+
from ....._resource import SyncAPIResource, AsyncAPIResource
16+
from ....._response import (
17+
to_raw_response_wrapper,
18+
to_streamed_response_wrapper,
19+
async_to_raw_response_wrapper,
20+
async_to_streamed_response_wrapper,
21+
)
22+
from ....._wrappers import ResultWrapper
23+
from ....._base_client import make_request_options
24+
from .....types.workers.scripts.assets import upload_create_params
25+
from .....types.workers.scripts.assets.upload_create_response import UploadCreateResponse
26+
27+
__all__ = ["UploadResource", "AsyncUploadResource"]
28+
29+
30+
class UploadResource(SyncAPIResource):
31+
@cached_property
32+
def with_raw_response(self) -> UploadResourceWithRawResponse:
33+
"""
34+
This property can be used as a prefix for any HTTP method call to return the
35+
the raw response object instead of the parsed content.
36+
37+
For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers
38+
"""
39+
return UploadResourceWithRawResponse(self)
40+
41+
@cached_property
42+
def with_streaming_response(self) -> UploadResourceWithStreamingResponse:
43+
"""
44+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
45+
46+
For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response
47+
"""
48+
return UploadResourceWithStreamingResponse(self)
49+
50+
def create(
51+
self,
52+
script_name: str,
53+
*,
54+
account_id: str,
55+
manifest: Dict[str, upload_create_params.Manifest] | NotGiven = NOT_GIVEN,
56+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
57+
# The extra values given here take precedence over values defined on the client or passed to this method.
58+
extra_headers: Headers | None = None,
59+
extra_query: Query | None = None,
60+
extra_body: Body | None = None,
61+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
62+
) -> Optional[UploadCreateResponse]:
63+
"""
64+
Start uploading a collection of assets for use in a Worker version.
65+
66+
Args:
67+
account_id: Identifier
68+
69+
script_name: Name of the script, used in URLs and route configuration.
70+
71+
manifest: A manifest ([path]: {hash, size}) map of files to upload. As an example,
72+
`/blog/hello-world.html` would be a valid path key.
73+
74+
extra_headers: Send extra headers
75+
76+
extra_query: Add additional query parameters to the request
77+
78+
extra_body: Add additional JSON properties to the request
79+
80+
timeout: Override the client-level default timeout for this request, in seconds
81+
"""
82+
if not account_id:
83+
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
84+
if not script_name:
85+
raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}")
86+
return self._post(
87+
f"/accounts/{account_id}/workers/scripts/{script_name}/assets-upload-session",
88+
body=maybe_transform({"manifest": manifest}, upload_create_params.UploadCreateParams),
89+
options=make_request_options(
90+
extra_headers=extra_headers,
91+
extra_query=extra_query,
92+
extra_body=extra_body,
93+
timeout=timeout,
94+
post_parser=ResultWrapper[Optional[UploadCreateResponse]]._unwrapper,
95+
),
96+
cast_to=cast(Type[Optional[UploadCreateResponse]], ResultWrapper[UploadCreateResponse]),
97+
)
98+
99+
100+
class AsyncUploadResource(AsyncAPIResource):
101+
@cached_property
102+
def with_raw_response(self) -> AsyncUploadResourceWithRawResponse:
103+
"""
104+
This property can be used as a prefix for any HTTP method call to return the
105+
the raw response object instead of the parsed content.
106+
107+
For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers
108+
"""
109+
return AsyncUploadResourceWithRawResponse(self)
110+
111+
@cached_property
112+
def with_streaming_response(self) -> AsyncUploadResourceWithStreamingResponse:
113+
"""
114+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
115+
116+
For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response
117+
"""
118+
return AsyncUploadResourceWithStreamingResponse(self)
119+
120+
async def create(
121+
self,
122+
script_name: str,
123+
*,
124+
account_id: str,
125+
manifest: Dict[str, upload_create_params.Manifest] | NotGiven = NOT_GIVEN,
126+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
127+
# The extra values given here take precedence over values defined on the client or passed to this method.
128+
extra_headers: Headers | None = None,
129+
extra_query: Query | None = None,
130+
extra_body: Body | None = None,
131+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
132+
) -> Optional[UploadCreateResponse]:
133+
"""
134+
Start uploading a collection of assets for use in a Worker version.
135+
136+
Args:
137+
account_id: Identifier
138+
139+
script_name: Name of the script, used in URLs and route configuration.
140+
141+
manifest: A manifest ([path]: {hash, size}) map of files to upload. As an example,
142+
`/blog/hello-world.html` would be a valid path key.
143+
144+
extra_headers: Send extra headers
145+
146+
extra_query: Add additional query parameters to the request
147+
148+
extra_body: Add additional JSON properties to the request
149+
150+
timeout: Override the client-level default timeout for this request, in seconds
151+
"""
152+
if not account_id:
153+
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
154+
if not script_name:
155+
raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}")
156+
return await self._post(
157+
f"/accounts/{account_id}/workers/scripts/{script_name}/assets-upload-session",
158+
body=await async_maybe_transform({"manifest": manifest}, upload_create_params.UploadCreateParams),
159+
options=make_request_options(
160+
extra_headers=extra_headers,
161+
extra_query=extra_query,
162+
extra_body=extra_body,
163+
timeout=timeout,
164+
post_parser=ResultWrapper[Optional[UploadCreateResponse]]._unwrapper,
165+
),
166+
cast_to=cast(Type[Optional[UploadCreateResponse]], ResultWrapper[UploadCreateResponse]),
167+
)
168+
169+
170+
class UploadResourceWithRawResponse:
171+
def __init__(self, upload: UploadResource) -> None:
172+
self._upload = upload
173+
174+
self.create = to_raw_response_wrapper(
175+
upload.create,
176+
)
177+
178+
179+
class AsyncUploadResourceWithRawResponse:
180+
def __init__(self, upload: AsyncUploadResource) -> None:
181+
self._upload = upload
182+
183+
self.create = async_to_raw_response_wrapper(
184+
upload.create,
185+
)
186+
187+
188+
class UploadResourceWithStreamingResponse:
189+
def __init__(self, upload: UploadResource) -> None:
190+
self._upload = upload
191+
192+
self.create = to_streamed_response_wrapper(
193+
upload.create,
194+
)
195+
196+
197+
class AsyncUploadResourceWithStreamingResponse:
198+
def __init__(self, upload: AsyncUploadResource) -> None:
199+
self._upload = upload
200+
201+
self.create = async_to_streamed_response_wrapper(
202+
upload.create,
203+
)

0 commit comments

Comments
 (0)