Skip to content

Commit 5408013

Browse files
feat(api): api update (#2292)
1 parent 17a3ce1 commit 5408013

27 files changed

+268
-349
lines changed

.stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 1480
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-18ccd4bfa5225ea54ecb087df6d6542117dc16f65b932d7e33a3e05d6c8e3c7e.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-44c89a561938bdc3a04bf86b60afa04650b1b9c246c07987e9ae26ca3cdf18fe.yml

api.md

-1
Original file line numberDiff line numberDiff line change
@@ -2293,7 +2293,6 @@ from cloudflare.types.workers import (
22932293
R2Binding,
22942294
ServiceBinding,
22952295
SingleStepMigration,
2296-
SteppedMigration,
22972296
WorkerMetadata,
22982297
)
22992298
```

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

+6-40
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22

33
from __future__ import annotations
44

5-
from typing import List, Type, Mapping, Optional, cast
5+
from typing import Type, Optional, cast
66

77
import httpx
88

9-
from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes
9+
from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
1010
from ...._utils import (
11-
extract_files,
1211
maybe_transform,
1312
strip_not_given,
14-
deepcopy_minimal,
1513
async_maybe_transform,
1614
)
1715
from ...._compat import cached_property
@@ -64,8 +62,7 @@ def update(
6462
script_name: str,
6563
*,
6664
account_id: str,
67-
any_part_name: List[FileTypes] | NotGiven = NOT_GIVEN,
68-
metadata: WorkerMetadataParam | NotGiven = NOT_GIVEN,
65+
metadata: WorkerMetadataParam,
6966
cf_worker_body_part: str | NotGiven = NOT_GIVEN,
7067
cf_worker_main_module_part: str | NotGiven = NOT_GIVEN,
7168
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -83,13 +80,6 @@ def update(
8380
8481
script_name: Name of the script, used in URLs and route configuration.
8582
86-
any_part_name: A module comprising a Worker script, often a javascript file. Multiple modules
87-
may be provided as separate named parts, but at least one module must be
88-
present. This should be referenced either in the metadata as `main_module`
89-
(esm)/`body_part` (service worker) or as a header `CF-WORKER-MAIN-MODULE-PART`
90-
(esm) /`CF-WORKER-BODY-PART` (service worker) by part name. Source maps may also
91-
be included using the `application/source-map` content type.
92-
9383
metadata: JSON encoded metadata about the uploaded parts and Worker configuration.
9484
9585
extra_headers: Send extra headers
@@ -113,21 +103,13 @@ def update(
113103
),
114104
**(extra_headers or {}),
115105
}
116-
body = deepcopy_minimal(
117-
{
118-
"any_part_name": any_part_name,
119-
"metadata": metadata,
120-
}
121-
)
122-
files = extract_files(cast(Mapping[str, object], body), paths=[["<any part name>", "<array>"]])
123106
# It should be noted that the actual Content-Type header that will be
124107
# sent to the server will contain a `boundary` parameter, e.g.
125108
# multipart/form-data; boundary=---abc--
126109
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
127110
return self._put(
128111
f"/accounts/{account_id}/workers/scripts/{script_name}/content",
129-
body=maybe_transform(body, content_update_params.ContentUpdateParams),
130-
files=files,
112+
body=maybe_transform({"metadata": metadata}, content_update_params.ContentUpdateParams),
131113
options=make_request_options(
132114
extra_headers=extra_headers,
133115
extra_query=extra_query,
@@ -205,8 +187,7 @@ async def update(
205187
script_name: str,
206188
*,
207189
account_id: str,
208-
any_part_name: List[FileTypes] | NotGiven = NOT_GIVEN,
209-
metadata: WorkerMetadataParam | NotGiven = NOT_GIVEN,
190+
metadata: WorkerMetadataParam,
210191
cf_worker_body_part: str | NotGiven = NOT_GIVEN,
211192
cf_worker_main_module_part: str | NotGiven = NOT_GIVEN,
212193
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -224,13 +205,6 @@ async def update(
224205
225206
script_name: Name of the script, used in URLs and route configuration.
226207
227-
any_part_name: A module comprising a Worker script, often a javascript file. Multiple modules
228-
may be provided as separate named parts, but at least one module must be
229-
present. This should be referenced either in the metadata as `main_module`
230-
(esm)/`body_part` (service worker) or as a header `CF-WORKER-MAIN-MODULE-PART`
231-
(esm) /`CF-WORKER-BODY-PART` (service worker) by part name. Source maps may also
232-
be included using the `application/source-map` content type.
233-
234208
metadata: JSON encoded metadata about the uploaded parts and Worker configuration.
235209
236210
extra_headers: Send extra headers
@@ -254,21 +228,13 @@ async def update(
254228
),
255229
**(extra_headers or {}),
256230
}
257-
body = deepcopy_minimal(
258-
{
259-
"any_part_name": any_part_name,
260-
"metadata": metadata,
261-
}
262-
)
263-
files = extract_files(cast(Mapping[str, object], body), paths=[["<any part name>", "<array>"]])
264231
# It should be noted that the actual Content-Type header that will be
265232
# sent to the server will contain a `boundary` parameter, e.g.
266233
# multipart/form-data; boundary=---abc--
267234
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
268235
return await self._put(
269236
f"/accounts/{account_id}/workers/scripts/{script_name}/content",
270-
body=await async_maybe_transform(body, content_update_params.ContentUpdateParams),
271-
files=files,
237+
body=await async_maybe_transform({"metadata": metadata}, content_update_params.ContentUpdateParams),
272238
options=make_request_options(
273239
extra_headers=extra_headers,
274240
extra_query=extra_query,

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

+12-30
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from typing import List, Type, Optional, cast
5+
from typing import Type, Optional, cast
66
from typing_extensions import overload
77

88
import httpx
@@ -39,7 +39,7 @@
3939
VersionsResourceWithStreamingResponse,
4040
AsyncVersionsResourceWithStreamingResponse,
4141
)
42-
from ...._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven, FileTypes
42+
from ...._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven
4343
from ...._utils import (
4444
required_args,
4545
maybe_transform,
@@ -161,9 +161,8 @@ def update(
161161
script_name: str,
162162
*,
163163
account_id: str,
164+
metadata: script_update_params.Variant0Metadata,
164165
rollback_to: str | NotGiven = NOT_GIVEN,
165-
any_part_name: List[FileTypes] | NotGiven = NOT_GIVEN,
166-
metadata: script_update_params.Variant0Metadata | NotGiven = NOT_GIVEN,
167166
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
168167
# The extra values given here take precedence over values defined on the client or passed to this method.
169168
extra_headers: Headers | None = None,
@@ -182,18 +181,12 @@ def update(
182181
183182
script_name: Name of the script, used in URLs and route configuration.
184183
184+
metadata: JSON encoded metadata about the uploaded parts and Worker configuration.
185+
185186
rollback_to: Rollback to provided deployment based on deployment ID. Request body will only
186187
parse a "message" part. You can learn more about deployments
187188
[here](https://developers.cloudflare.com/workers/platform/deployments/).
188189
189-
any_part_name: A module comprising a Worker script, often a javascript file. Multiple modules
190-
may be provided as separate named parts, but at least one module must be present
191-
and referenced in the metadata as `main_module` or `body_part` by part name.
192-
Source maps may also be included using the `application/source-map` content
193-
type.
194-
195-
metadata: JSON encoded metadata about the uploaded parts and Worker configuration.
196-
197190
extra_headers: Send extra headers
198191
199192
extra_query: Add additional query parameters to the request
@@ -247,15 +240,14 @@ def update(
247240
"""
248241
...
249242

250-
@required_args(["account_id"])
243+
@required_args(["account_id", "metadata"], ["account_id"])
251244
def update(
252245
self,
253246
script_name: str,
254247
*,
255248
account_id: str,
256-
rollback_to: str | NotGiven = NOT_GIVEN,
257-
any_part_name: List[FileTypes] | NotGiven = NOT_GIVEN,
258249
metadata: script_update_params.Variant0Metadata | NotGiven = NOT_GIVEN,
250+
rollback_to: str | NotGiven = NOT_GIVEN,
259251
message: str | NotGiven = NOT_GIVEN,
260252
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
261253
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -272,7 +264,6 @@ def update(
272264
f"/accounts/{account_id}/workers/scripts/{script_name}",
273265
body=maybe_transform(
274266
{
275-
"any_part_name": any_part_name,
276267
"metadata": metadata,
277268
"message": message,
278269
},
@@ -478,9 +469,8 @@ async def update(
478469
script_name: str,
479470
*,
480471
account_id: str,
472+
metadata: script_update_params.Variant0Metadata,
481473
rollback_to: str | NotGiven = NOT_GIVEN,
482-
any_part_name: List[FileTypes] | NotGiven = NOT_GIVEN,
483-
metadata: script_update_params.Variant0Metadata | NotGiven = NOT_GIVEN,
484474
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
485475
# The extra values given here take precedence over values defined on the client or passed to this method.
486476
extra_headers: Headers | None = None,
@@ -499,18 +489,12 @@ async def update(
499489
500490
script_name: Name of the script, used in URLs and route configuration.
501491
492+
metadata: JSON encoded metadata about the uploaded parts and Worker configuration.
493+
502494
rollback_to: Rollback to provided deployment based on deployment ID. Request body will only
503495
parse a "message" part. You can learn more about deployments
504496
[here](https://developers.cloudflare.com/workers/platform/deployments/).
505497
506-
any_part_name: A module comprising a Worker script, often a javascript file. Multiple modules
507-
may be provided as separate named parts, but at least one module must be present
508-
and referenced in the metadata as `main_module` or `body_part` by part name.
509-
Source maps may also be included using the `application/source-map` content
510-
type.
511-
512-
metadata: JSON encoded metadata about the uploaded parts and Worker configuration.
513-
514498
extra_headers: Send extra headers
515499
516500
extra_query: Add additional query parameters to the request
@@ -564,15 +548,14 @@ async def update(
564548
"""
565549
...
566550

567-
@required_args(["account_id"])
551+
@required_args(["account_id", "metadata"], ["account_id"])
568552
async def update(
569553
self,
570554
script_name: str,
571555
*,
572556
account_id: str,
573-
rollback_to: str | NotGiven = NOT_GIVEN,
574-
any_part_name: List[FileTypes] | NotGiven = NOT_GIVEN,
575557
metadata: script_update_params.Variant0Metadata | NotGiven = NOT_GIVEN,
558+
rollback_to: str | NotGiven = NOT_GIVEN,
576559
message: str | NotGiven = NOT_GIVEN,
577560
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
578561
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -589,7 +572,6 @@ async def update(
589572
f"/accounts/{account_id}/workers/scripts/{script_name}",
590573
body=await async_maybe_transform(
591574
{
592-
"any_part_name": any_part_name,
593575
"metadata": metadata,
594576
"message": message,
595577
},

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

+6-34
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22

33
from __future__ import annotations
44

5-
from typing import List, Type, Mapping, Optional, cast
5+
from typing import Type, Optional, cast
66

77
import httpx
88

9-
from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes
9+
from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
1010
from ...._utils import (
11-
extract_files,
1211
maybe_transform,
13-
deepcopy_minimal,
1412
async_maybe_transform,
1513
)
1614
from ...._compat import cached_property
@@ -57,8 +55,7 @@ def create(
5755
script_name: str,
5856
*,
5957
account_id: str,
60-
any_part_name: List[FileTypes] | NotGiven = NOT_GIVEN,
61-
metadata: version_create_params.Metadata | NotGiven = NOT_GIVEN,
58+
metadata: version_create_params.Metadata,
6259
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
6360
# The extra values given here take precedence over values defined on the client or passed to this method.
6461
extra_headers: Headers | None = None,
@@ -77,10 +74,6 @@ def create(
7774
7875
script_name: Name of the script.
7976
80-
any_part_name: A module comprising a Worker script, often a javascript file. Multiple modules
81-
may be provided as separate named parts, but at least one module must be present
82-
and referenced in the metadata as `main_module`.
83-
8477
metadata: JSON encoded metadata about the uploaded parts and Worker configuration.
8578
8679
extra_headers: Send extra headers
@@ -95,21 +88,13 @@ def create(
9588
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
9689
if not script_name:
9790
raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}")
98-
body = deepcopy_minimal(
99-
{
100-
"any_part_name": any_part_name,
101-
"metadata": metadata,
102-
}
103-
)
104-
files = extract_files(cast(Mapping[str, object], body), paths=[["<any part name>", "<array>"]])
10591
# It should be noted that the actual Content-Type header that will be
10692
# sent to the server will contain a `boundary` parameter, e.g.
10793
# multipart/form-data; boundary=---abc--
10894
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
10995
return self._post(
11096
f"/accounts/{account_id}/workers/scripts/{script_name}/versions",
111-
body=maybe_transform(body, version_create_params.VersionCreateParams),
112-
files=files,
97+
body=maybe_transform({"metadata": metadata}, version_create_params.VersionCreateParams),
11398
options=make_request_options(
11499
extra_headers=extra_headers,
115100
extra_query=extra_query,
@@ -255,8 +240,7 @@ async def create(
255240
script_name: str,
256241
*,
257242
account_id: str,
258-
any_part_name: List[FileTypes] | NotGiven = NOT_GIVEN,
259-
metadata: version_create_params.Metadata | NotGiven = NOT_GIVEN,
243+
metadata: version_create_params.Metadata,
260244
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
261245
# The extra values given here take precedence over values defined on the client or passed to this method.
262246
extra_headers: Headers | None = None,
@@ -275,10 +259,6 @@ async def create(
275259
276260
script_name: Name of the script.
277261
278-
any_part_name: A module comprising a Worker script, often a javascript file. Multiple modules
279-
may be provided as separate named parts, but at least one module must be present
280-
and referenced in the metadata as `main_module`.
281-
282262
metadata: JSON encoded metadata about the uploaded parts and Worker configuration.
283263
284264
extra_headers: Send extra headers
@@ -293,21 +273,13 @@ async def create(
293273
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
294274
if not script_name:
295275
raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}")
296-
body = deepcopy_minimal(
297-
{
298-
"any_part_name": any_part_name,
299-
"metadata": metadata,
300-
}
301-
)
302-
files = extract_files(cast(Mapping[str, object], body), paths=[["<any part name>", "<array>"]])
303276
# It should be noted that the actual Content-Type header that will be
304277
# sent to the server will contain a `boundary` parameter, e.g.
305278
# multipart/form-data; boundary=---abc--
306279
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
307280
return await self._post(
308281
f"/accounts/{account_id}/workers/scripts/{script_name}/versions",
309-
body=await async_maybe_transform(body, version_create_params.VersionCreateParams),
310-
files=files,
282+
body=await async_maybe_transform({"metadata": metadata}, version_create_params.VersionCreateParams),
311283
options=make_request_options(
312284
extra_headers=extra_headers,
313285
extra_query=extra_query,

0 commit comments

Comments
 (0)