From 94c88793f635b0db08c46a2eedd7952dddd17c92 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 2 Jul 2024 23:05:54 +0000 Subject: [PATCH] feat(api): OpenAPI spec update via Stainless API (#1163) --- .stats.yml | 2 +- src/cloudflare/_base_client.py | 20 +++++++++++++++++-- .../addressing/loa_documents/loa_documents.py | 8 ++++++++ .../api_gateway/user_schemas/user_schemas.py | 18 ++++++++--------- src/cloudflare/resources/dns/records.py | 8 ++++++++ src/cloudflare/resources/images/v1/v1.py | 8 ++++++++ .../resources/images/v2/direct_uploads.py | 8 ++++++++ .../intel/indicator_feeds/snapshots.py | 8 ++++++++ .../resources/kv/namespaces/values.py | 8 ++++++++ .../pages/projects/deployments/deployments.py | 8 ++++++++ src/cloudflare/resources/snippets/snippets.py | 8 ++++++++ .../stream/captions/language/language.py | 8 ++++++++ src/cloudflare/resources/stream/watermarks.py | 8 ++++++++ .../resources/workers/scripts/content.py | 18 ++++++++--------- .../resources/workers/scripts/versions.py | 18 ++++++++--------- .../dispatch/namespaces/scripts/content.py | 18 ++++++++--------- .../dispatch/namespaces/scripts/settings.py | 8 ++++++++ 17 files changed, 139 insertions(+), 43 deletions(-) diff --git a/.stats.yml b/.stats.yml index 227f9b449e3..9fbc3445370 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1254 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d4312bd23a02e20e5d46c142ec08fbe09bb97ce586a900e10d178982734f44ec.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-397336292b6904c10bbe601d75c2153455422a23f3c97a4d6b25087ceab822ad.yml diff --git a/src/cloudflare/_base_client.py b/src/cloudflare/_base_client.py index d6730dbb3e4..01020ef601c 100644 --- a/src/cloudflare/_base_client.py +++ b/src/cloudflare/_base_client.py @@ -58,6 +58,7 @@ HttpxSendArgs, AsyncTransport, RequestOptions, + HttpxRequestFiles, ModelBuilderProtocol, ) from ._utils import is_dict, is_list, asyncify, is_given, lru_cache, is_mapping @@ -459,6 +460,7 @@ def _build_request( headers = self._build_headers(options) params = _merge_mappings(self.default_query, options.params) content_type = headers.get("Content-Type") + files = options.files # If the given Content-Type header is multipart/form-data then it # has to be removed so that httpx can generate the header with @@ -472,7 +474,7 @@ def _build_request( headers.pop("Content-Type") # As we are now sending multipart/form-data instead of application/json - # we need to tell httpx to use it, https://www.python-httpx.org/advanced/#multipart-file-encoding + # we need to tell httpx to use it, https://www.python-httpx.org/advanced/clients/#multipart-file-encoding if json_data: if not is_dict(json_data): raise TypeError( @@ -480,6 +482,15 @@ def _build_request( ) kwargs["data"] = self._serialize_multipartform(json_data) + # httpx determines whether or not to send a "multipart/form-data" + # request based on the truthiness of the "files" argument. + # This gets around that issue by generating a dict value that + # evaluates to true. + # + # https://github.com/encode/httpx/discussions/2399#discussioncomment-3814186 + if not files: + files = cast(HttpxRequestFiles, ForceMultipartDict()) + # TODO: report this error to httpx return self._client.build_request( # pyright: ignore[reportUnknownMemberType] headers=headers, @@ -492,7 +503,7 @@ def _build_request( # https://github.com/microsoft/pyright/issues/3526#event-6715453066 params=self.qs.stringify(cast(Mapping[str, Any], params)) if params else None, json=json_data, - files=options.files, + files=files, **kwargs, ) @@ -1863,6 +1874,11 @@ def make_request_options( return options +class ForceMultipartDict(Dict[str, None]): + def __bool__(self) -> bool: + return True + + class OtherPlatform: def __init__(self, name: str) -> None: self.name = name diff --git a/src/cloudflare/resources/addressing/loa_documents/loa_documents.py b/src/cloudflare/resources/addressing/loa_documents/loa_documents.py index 7080381886a..28c6428ca39 100644 --- a/src/cloudflare/resources/addressing/loa_documents/loa_documents.py +++ b/src/cloudflare/resources/addressing/loa_documents/loa_documents.py @@ -80,6 +80,10 @@ def create( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + # 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}/addressing/loa_documents", body=maybe_transform({"loa_document": loa_document}, loa_document_create_params.LOADocumentCreateParams), @@ -137,6 +141,10 @@ async def create( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + # 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}/addressing/loa_documents", body=await async_maybe_transform( diff --git a/src/cloudflare/resources/api_gateway/user_schemas/user_schemas.py b/src/cloudflare/resources/api_gateway/user_schemas/user_schemas.py index 25fc670bd03..82510dc75c2 100644 --- a/src/cloudflare/resources/api_gateway/user_schemas/user_schemas.py +++ b/src/cloudflare/resources/api_gateway/user_schemas/user_schemas.py @@ -110,11 +110,10 @@ def create( } ) files = extract_files(cast(Mapping[str, object], body), paths=[["file"]]) - if files: - # 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 {})} + # 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"/zones/{zone_id}/api_gateway/user_schemas", body=maybe_transform(body, user_schema_create_params.UserSchemaCreateParams), @@ -392,11 +391,10 @@ async def create( } ) files = extract_files(cast(Mapping[str, object], body), paths=[["file"]]) - if files: - # 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 {})} + # 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"/zones/{zone_id}/api_gateway/user_schemas", body=await async_maybe_transform(body, user_schema_create_params.UserSchemaCreateParams), diff --git a/src/cloudflare/resources/dns/records.py b/src/cloudflare/resources/dns/records.py index 078bf19d50e..2f1defd119f 100644 --- a/src/cloudflare/resources/dns/records.py +++ b/src/cloudflare/resources/dns/records.py @@ -4326,6 +4326,10 @@ def import_( """ if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + # 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"/zones/{zone_id}/dns_records/import", body=maybe_transform( @@ -8668,6 +8672,10 @@ async def import_( """ if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + # 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"/zones/{zone_id}/dns_records/import", body=await async_maybe_transform( diff --git a/src/cloudflare/resources/images/v1/v1.py b/src/cloudflare/resources/images/v1/v1.py index b3ae56942d4..43cd026fcb5 100644 --- a/src/cloudflare/resources/images/v1/v1.py +++ b/src/cloudflare/resources/images/v1/v1.py @@ -133,6 +133,10 @@ def create( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + # 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}/images/v1", body=maybe_transform( @@ -434,6 +438,10 @@ async def create( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + # 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}/images/v1", body=await async_maybe_transform( diff --git a/src/cloudflare/resources/images/v2/direct_uploads.py b/src/cloudflare/resources/images/v2/direct_uploads.py index 3c66318e9f2..19b44f66b1e 100644 --- a/src/cloudflare/resources/images/v2/direct_uploads.py +++ b/src/cloudflare/resources/images/v2/direct_uploads.py @@ -89,6 +89,10 @@ def create( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + # 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}/images/v2/direct_upload", body=maybe_transform( @@ -170,6 +174,10 @@ async def create( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + # 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}/images/v2/direct_upload", body=await async_maybe_transform( diff --git a/src/cloudflare/resources/intel/indicator_feeds/snapshots.py b/src/cloudflare/resources/intel/indicator_feeds/snapshots.py index 3f05ef5b71a..3ee7cf376bc 100644 --- a/src/cloudflare/resources/intel/indicator_feeds/snapshots.py +++ b/src/cloudflare/resources/intel/indicator_feeds/snapshots.py @@ -71,6 +71,10 @@ def update( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + # 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}/intel/indicator-feeds/{feed_id}/snapshot", body=maybe_transform({"source": source}, snapshot_update_params.SnapshotUpdateParams), @@ -127,6 +131,10 @@ async def update( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + # 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}/intel/indicator-feeds/{feed_id}/snapshot", body=await async_maybe_transform({"source": source}, snapshot_update_params.SnapshotUpdateParams), diff --git a/src/cloudflare/resources/kv/namespaces/values.py b/src/cloudflare/resources/kv/namespaces/values.py index b80c2b635bb..d8b71b230d3 100644 --- a/src/cloudflare/resources/kv/namespaces/values.py +++ b/src/cloudflare/resources/kv/namespaces/values.py @@ -97,6 +97,10 @@ def update( raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") if not key_name: raise ValueError(f"Expected a non-empty value for `key_name` but received {key_name!r}") + # 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}/storage/kv/namespaces/{namespace_id}/values/{key_name}", body=maybe_transform( @@ -280,6 +284,10 @@ async def update( raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") if not key_name: raise ValueError(f"Expected a non-empty value for `key_name` but received {key_name!r}") + # 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}/storage/kv/namespaces/{namespace_id}/values/{key_name}", body=await async_maybe_transform( diff --git a/src/cloudflare/resources/pages/projects/deployments/deployments.py b/src/cloudflare/resources/pages/projects/deployments/deployments.py index 366eb26eacd..73ce05e0bfb 100644 --- a/src/cloudflare/resources/pages/projects/deployments/deployments.py +++ b/src/cloudflare/resources/pages/projects/deployments/deployments.py @@ -97,6 +97,10 @@ def create( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not project_name: raise ValueError(f"Expected a non-empty value for `project_name` but received {project_name!r}") + # 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}/pages/projects/{project_name}/deployments", body=maybe_transform({"branch": branch}, deployment_create_params.DeploymentCreateParams), @@ -408,6 +412,10 @@ async def create( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not project_name: raise ValueError(f"Expected a non-empty value for `project_name` but received {project_name!r}") + # 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}/pages/projects/{project_name}/deployments", body=await async_maybe_transform({"branch": branch}, deployment_create_params.DeploymentCreateParams), diff --git a/src/cloudflare/resources/snippets/snippets.py b/src/cloudflare/resources/snippets/snippets.py index 5c1a0bb75b0..c669513bdf9 100644 --- a/src/cloudflare/resources/snippets/snippets.py +++ b/src/cloudflare/resources/snippets/snippets.py @@ -101,6 +101,10 @@ def update( raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not snippet_name: raise ValueError(f"Expected a non-empty value for `snippet_name` but received {snippet_name!r}") + # 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"/zones/{zone_id}/snippets/{snippet_name}", body=maybe_transform( @@ -294,6 +298,10 @@ async def update( raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not snippet_name: raise ValueError(f"Expected a non-empty value for `snippet_name` but received {snippet_name!r}") + # 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"/zones/{zone_id}/snippets/{snippet_name}", body=await async_maybe_transform( diff --git a/src/cloudflare/resources/stream/captions/language/language.py b/src/cloudflare/resources/stream/captions/language/language.py index 3c1bfec470e..84bd7050dee 100644 --- a/src/cloudflare/resources/stream/captions/language/language.py +++ b/src/cloudflare/resources/stream/captions/language/language.py @@ -141,6 +141,10 @@ def update( raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") if not language: raise ValueError(f"Expected a non-empty value for `language` but received {language!r}") + # 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}/stream/{identifier}/captions/{language}", body=maybe_transform({"file": file}, language_update_params.LanguageUpdateParams), @@ -356,6 +360,10 @@ async def update( raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") if not language: raise ValueError(f"Expected a non-empty value for `language` but received {language!r}") + # 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}/stream/{identifier}/captions/{language}", body=await async_maybe_transform({"file": file}, language_update_params.LanguageUpdateParams), diff --git a/src/cloudflare/resources/stream/watermarks.py b/src/cloudflare/resources/stream/watermarks.py index bb80780d25d..b071f3a8237 100644 --- a/src/cloudflare/resources/stream/watermarks.py +++ b/src/cloudflare/resources/stream/watermarks.py @@ -96,6 +96,10 @@ def create( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + # 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}/stream/watermarks", body=maybe_transform( @@ -313,6 +317,10 @@ async def create( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + # 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}/stream/watermarks", body=await async_maybe_transform( diff --git a/src/cloudflare/resources/workers/scripts/content.py b/src/cloudflare/resources/workers/scripts/content.py index 381a25fff2d..7defff75eb2 100644 --- a/src/cloudflare/resources/workers/scripts/content.py +++ b/src/cloudflare/resources/workers/scripts/content.py @@ -111,11 +111,10 @@ def update( } ) files = extract_files(cast(Mapping[str, object], body), paths=[["", ""]]) - if files: - # 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 {})} + # 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), @@ -242,11 +241,10 @@ async def update( } ) files = extract_files(cast(Mapping[str, object], body), paths=[["", ""]]) - if files: - # 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 {})} + # 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), diff --git a/src/cloudflare/resources/workers/scripts/versions.py b/src/cloudflare/resources/workers/scripts/versions.py index a13d69c5e8d..baaeb73a4dc 100644 --- a/src/cloudflare/resources/workers/scripts/versions.py +++ b/src/cloudflare/resources/workers/scripts/versions.py @@ -91,11 +91,10 @@ def create( } ) files = extract_files(cast(Mapping[str, object], body), paths=[["", ""]]) - if files: - # 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 {})} + # 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), @@ -276,11 +275,10 @@ async def create( } ) files = extract_files(cast(Mapping[str, object], body), paths=[["", ""]]) - if files: - # 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 {})} + # 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), diff --git a/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/content.py b/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/content.py index c0e679c40d1..6a75cb6148c 100644 --- a/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/content.py +++ b/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/content.py @@ -116,11 +116,10 @@ def update( } ) files = extract_files(cast(Mapping[str, object], body), paths=[["", ""]]) - if files: - # 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 {})} + # 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/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/content", body=maybe_transform(body, content_update_params.ContentUpdateParams), @@ -258,11 +257,10 @@ async def update( } ) files = extract_files(cast(Mapping[str, object], body), paths=[["", ""]]) - if files: - # 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 {})} + # 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/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/content", body=await async_maybe_transform(body, content_update_params.ContentUpdateParams), diff --git a/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/settings.py b/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/settings.py index cd5dbad7f9d..c5454697e9e 100644 --- a/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/settings.py +++ b/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/settings.py @@ -77,6 +77,10 @@ def edit( raise ValueError(f"Expected a non-empty value for `dispatch_namespace` but received {dispatch_namespace!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") + # 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._patch( f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/settings", body=maybe_transform({"settings": settings}, setting_edit_params.SettingEditParams), @@ -187,6 +191,10 @@ async def edit( raise ValueError(f"Expected a non-empty value for `dispatch_namespace` but received {dispatch_namespace!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") + # 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._patch( f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/settings", body=await async_maybe_transform({"settings": settings}, setting_edit_params.SettingEditParams),