Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 1480
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-18ccd4bfa5225ea54ecb087df6d6542117dc16f65b932d7e33a3e05d6c8e3c7e.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-44c89a561938bdc3a04bf86b60afa04650b1b9c246c07987e9ae26ca3cdf18fe.yml
1 change: 0 additions & 1 deletion api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2293,7 +2293,6 @@ from cloudflare.types.workers import (
R2Binding,
ServiceBinding,
SingleStepMigration,
SteppedMigration,
WorkerMetadata,
)
```
Expand Down
46 changes: 6 additions & 40 deletions src/cloudflare/resources/workers/scripts/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@

from __future__ import annotations

from typing import List, Type, Mapping, Optional, cast
from typing import Type, Optional, cast

import httpx

from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes
from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from ...._utils import (
extract_files,
maybe_transform,
strip_not_given,
deepcopy_minimal,
async_maybe_transform,
)
from ...._compat import cached_property
Expand Down Expand Up @@ -64,8 +62,7 @@ def update(
script_name: str,
*,
account_id: str,
any_part_name: List[FileTypes] | NotGiven = NOT_GIVEN,
metadata: WorkerMetadataParam | NotGiven = NOT_GIVEN,
metadata: WorkerMetadataParam,
cf_worker_body_part: str | NotGiven = NOT_GIVEN,
cf_worker_main_module_part: str | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
Expand All @@ -83,13 +80,6 @@ def update(

script_name: Name of the script, used in URLs and route configuration.

any_part_name: A module comprising a Worker script, often a javascript file. Multiple modules
may be provided as separate named parts, but at least one module must be
present. This should be referenced either in the metadata as `main_module`
(esm)/`body_part` (service worker) or as a header `CF-WORKER-MAIN-MODULE-PART`
(esm) /`CF-WORKER-BODY-PART` (service worker) by part name. Source maps may also
be included using the `application/source-map` content type.

metadata: JSON encoded metadata about the uploaded parts and Worker configuration.

extra_headers: Send extra headers
Expand All @@ -113,21 +103,13 @@ def update(
),
**(extra_headers or {}),
}
body = deepcopy_minimal(
{
"any_part_name": any_part_name,
"metadata": metadata,
}
)
files = extract_files(cast(Mapping[str, object], body), paths=[["<any part name>", "<array>"]])
# It should be noted that the actual Content-Type header that will be
# sent to the server will contain a `boundary` parameter, e.g.
# multipart/form-data; boundary=---abc--
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
return self._put(
f"/accounts/{account_id}/workers/scripts/{script_name}/content",
body=maybe_transform(body, content_update_params.ContentUpdateParams),
files=files,
body=maybe_transform({"metadata": metadata}, content_update_params.ContentUpdateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
Expand Down Expand Up @@ -205,8 +187,7 @@ async def update(
script_name: str,
*,
account_id: str,
any_part_name: List[FileTypes] | NotGiven = NOT_GIVEN,
metadata: WorkerMetadataParam | NotGiven = NOT_GIVEN,
metadata: WorkerMetadataParam,
cf_worker_body_part: str | NotGiven = NOT_GIVEN,
cf_worker_main_module_part: str | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
Expand All @@ -224,13 +205,6 @@ async def update(

script_name: Name of the script, used in URLs and route configuration.

any_part_name: A module comprising a Worker script, often a javascript file. Multiple modules
may be provided as separate named parts, but at least one module must be
present. This should be referenced either in the metadata as `main_module`
(esm)/`body_part` (service worker) or as a header `CF-WORKER-MAIN-MODULE-PART`
(esm) /`CF-WORKER-BODY-PART` (service worker) by part name. Source maps may also
be included using the `application/source-map` content type.

metadata: JSON encoded metadata about the uploaded parts and Worker configuration.

extra_headers: Send extra headers
Expand All @@ -254,21 +228,13 @@ async def update(
),
**(extra_headers or {}),
}
body = deepcopy_minimal(
{
"any_part_name": any_part_name,
"metadata": metadata,
}
)
files = extract_files(cast(Mapping[str, object], body), paths=[["<any part name>", "<array>"]])
# It should be noted that the actual Content-Type header that will be
# sent to the server will contain a `boundary` parameter, e.g.
# multipart/form-data; boundary=---abc--
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
return await self._put(
f"/accounts/{account_id}/workers/scripts/{script_name}/content",
body=await async_maybe_transform(body, content_update_params.ContentUpdateParams),
files=files,
body=await async_maybe_transform({"metadata": metadata}, content_update_params.ContentUpdateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
Expand Down
42 changes: 12 additions & 30 deletions src/cloudflare/resources/workers/scripts/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from typing import List, Type, Optional, cast
from typing import Type, Optional, cast
from typing_extensions import overload

import httpx
Expand Down Expand Up @@ -39,7 +39,7 @@
VersionsResourceWithStreamingResponse,
AsyncVersionsResourceWithStreamingResponse,
)
from ...._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven, FileTypes
from ...._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven
from ...._utils import (
required_args,
maybe_transform,
Expand Down Expand Up @@ -161,9 +161,8 @@ def update(
script_name: str,
*,
account_id: str,
metadata: script_update_params.Variant0Metadata,
rollback_to: str | NotGiven = NOT_GIVEN,
any_part_name: List[FileTypes] | NotGiven = NOT_GIVEN,
metadata: script_update_params.Variant0Metadata | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand All @@ -182,18 +181,12 @@ def update(

script_name: Name of the script, used in URLs and route configuration.

metadata: JSON encoded metadata about the uploaded parts and Worker configuration.

rollback_to: Rollback to provided deployment based on deployment ID. Request body will only
parse a "message" part. You can learn more about deployments
[here](https://developers.cloudflare.com/workers/platform/deployments/).

any_part_name: A module comprising a Worker script, often a javascript file. Multiple modules
may be provided as separate named parts, but at least one module must be present
and referenced in the metadata as `main_module` or `body_part` by part name.
Source maps may also be included using the `application/source-map` content
type.

metadata: JSON encoded metadata about the uploaded parts and Worker configuration.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand Down Expand Up @@ -247,15 +240,14 @@ def update(
"""
...

@required_args(["account_id"])
@required_args(["account_id", "metadata"], ["account_id"])
def update(
self,
script_name: str,
*,
account_id: str,
rollback_to: str | NotGiven = NOT_GIVEN,
any_part_name: List[FileTypes] | NotGiven = NOT_GIVEN,
metadata: script_update_params.Variant0Metadata | NotGiven = NOT_GIVEN,
rollback_to: str | NotGiven = NOT_GIVEN,
message: str | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
Expand All @@ -272,7 +264,6 @@ def update(
f"/accounts/{account_id}/workers/scripts/{script_name}",
body=maybe_transform(
{
"any_part_name": any_part_name,
"metadata": metadata,
"message": message,
},
Expand Down Expand Up @@ -478,9 +469,8 @@ async def update(
script_name: str,
*,
account_id: str,
metadata: script_update_params.Variant0Metadata,
rollback_to: str | NotGiven = NOT_GIVEN,
any_part_name: List[FileTypes] | NotGiven = NOT_GIVEN,
metadata: script_update_params.Variant0Metadata | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand All @@ -499,18 +489,12 @@ async def update(

script_name: Name of the script, used in URLs and route configuration.

metadata: JSON encoded metadata about the uploaded parts and Worker configuration.

rollback_to: Rollback to provided deployment based on deployment ID. Request body will only
parse a "message" part. You can learn more about deployments
[here](https://developers.cloudflare.com/workers/platform/deployments/).

any_part_name: A module comprising a Worker script, often a javascript file. Multiple modules
may be provided as separate named parts, but at least one module must be present
and referenced in the metadata as `main_module` or `body_part` by part name.
Source maps may also be included using the `application/source-map` content
type.

metadata: JSON encoded metadata about the uploaded parts and Worker configuration.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand Down Expand Up @@ -564,15 +548,14 @@ async def update(
"""
...

@required_args(["account_id"])
@required_args(["account_id", "metadata"], ["account_id"])
async def update(
self,
script_name: str,
*,
account_id: str,
rollback_to: str | NotGiven = NOT_GIVEN,
any_part_name: List[FileTypes] | NotGiven = NOT_GIVEN,
metadata: script_update_params.Variant0Metadata | NotGiven = NOT_GIVEN,
rollback_to: str | NotGiven = NOT_GIVEN,
message: str | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
Expand All @@ -589,7 +572,6 @@ async def update(
f"/accounts/{account_id}/workers/scripts/{script_name}",
body=await async_maybe_transform(
{
"any_part_name": any_part_name,
"metadata": metadata,
"message": message,
},
Expand Down
40 changes: 6 additions & 34 deletions src/cloudflare/resources/workers/scripts/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@

from __future__ import annotations

from typing import List, Type, Mapping, Optional, cast
from typing import Type, Optional, cast

import httpx

from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes
from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from ...._utils import (
extract_files,
maybe_transform,
deepcopy_minimal,
async_maybe_transform,
)
from ...._compat import cached_property
Expand Down Expand Up @@ -57,8 +55,7 @@ def create(
script_name: str,
*,
account_id: str,
any_part_name: List[FileTypes] | NotGiven = NOT_GIVEN,
metadata: version_create_params.Metadata | NotGiven = NOT_GIVEN,
metadata: version_create_params.Metadata,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand All @@ -77,10 +74,6 @@ def create(

script_name: Name of the script.

any_part_name: A module comprising a Worker script, often a javascript file. Multiple modules
may be provided as separate named parts, but at least one module must be present
and referenced in the metadata as `main_module`.

metadata: JSON encoded metadata about the uploaded parts and Worker configuration.

extra_headers: Send extra headers
Expand All @@ -95,21 +88,13 @@ def create(
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
if not script_name:
raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}")
body = deepcopy_minimal(
{
"any_part_name": any_part_name,
"metadata": metadata,
}
)
files = extract_files(cast(Mapping[str, object], body), paths=[["<any part name>", "<array>"]])
# It should be noted that the actual Content-Type header that will be
# sent to the server will contain a `boundary` parameter, e.g.
# multipart/form-data; boundary=---abc--
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
return self._post(
f"/accounts/{account_id}/workers/scripts/{script_name}/versions",
body=maybe_transform(body, version_create_params.VersionCreateParams),
files=files,
body=maybe_transform({"metadata": metadata}, version_create_params.VersionCreateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
Expand Down Expand Up @@ -255,8 +240,7 @@ async def create(
script_name: str,
*,
account_id: str,
any_part_name: List[FileTypes] | NotGiven = NOT_GIVEN,
metadata: version_create_params.Metadata | NotGiven = NOT_GIVEN,
metadata: version_create_params.Metadata,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand All @@ -275,10 +259,6 @@ async def create(

script_name: Name of the script.

any_part_name: A module comprising a Worker script, often a javascript file. Multiple modules
may be provided as separate named parts, but at least one module must be present
and referenced in the metadata as `main_module`.

metadata: JSON encoded metadata about the uploaded parts and Worker configuration.

extra_headers: Send extra headers
Expand All @@ -293,21 +273,13 @@ async def create(
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
if not script_name:
raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}")
body = deepcopy_minimal(
{
"any_part_name": any_part_name,
"metadata": metadata,
}
)
files = extract_files(cast(Mapping[str, object], body), paths=[["<any part name>", "<array>"]])
# It should be noted that the actual Content-Type header that will be
# sent to the server will contain a `boundary` parameter, e.g.
# multipart/form-data; boundary=---abc--
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
return await self._post(
f"/accounts/{account_id}/workers/scripts/{script_name}/versions",
body=await async_maybe_transform(body, version_create_params.VersionCreateParams),
files=files,
body=await async_maybe_transform({"metadata": metadata}, version_create_params.VersionCreateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
Expand Down
Loading