From fab2b7ecff04856e8ca2028c6b2c8185669c8a92 Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Mon, 17 Mar 2025 00:30:41 +0000
Subject: [PATCH] feat(workers): add in secrets endpoints
---
.stats.yml | 2 +-
api.md | 22 +
.../resources/workers/scripts/__init__.py | 14 +
.../resources/workers/scripts/scripts.py | 32 +
.../resources/workers/scripts/secrets.py | 547 ++++++++++++++++++
.../dispatch/namespaces/scripts/secrets.py | 120 ++++
.../types/workers/scripts/__init__.py | 4 +
.../workers/scripts/secret_get_response.py | 19 +
.../workers/scripts/secret_list_response.py | 19 +
.../workers/scripts/secret_update_params.py | 24 +
.../workers/scripts/secret_update_response.py | 19 +
.../workers/scripts/test_secrets.py | 481 +++++++++++++++
.../namespaces/scripts/test_secrets.py | 152 +++++
13 files changed, 1454 insertions(+), 1 deletion(-)
create mode 100644 src/cloudflare/resources/workers/scripts/secrets.py
create mode 100644 src/cloudflare/types/workers/scripts/secret_get_response.py
create mode 100644 src/cloudflare/types/workers/scripts/secret_list_response.py
create mode 100644 src/cloudflare/types/workers/scripts/secret_update_params.py
create mode 100644 src/cloudflare/types/workers/scripts/secret_update_response.py
create mode 100644 tests/api_resources/workers/scripts/test_secrets.py
diff --git a/.stats.yml b/.stats.yml
index a99045ea641..e4c3b0bef0b 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,2 +1,2 @@
-configured_endpoints: 1612
+configured_endpoints: 1617
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-8103ad52977aa9c1ce4655e2afd3ade7f6e891aafaa9bd1fbf4630348bc3fd02.yml
diff --git a/api.md b/api.md
index 0b61f88bc8b..85586631933 100644
--- a/api.md
+++ b/api.md
@@ -2459,6 +2459,26 @@ Methods:
- client.workers.scripts.versions.list(script_name, \*, account_id, \*\*params) -> SyncV4PagePagination[VersionListResponse]
- client.workers.scripts.versions.get(version_id, \*, account_id, script_name) -> Optional[VersionGetResponse]
+### Secrets
+
+Types:
+
+```python
+from cloudflare.types.workers.scripts import (
+ SecretUpdateResponse,
+ SecretListResponse,
+ SecretDeleteResponse,
+ SecretGetResponse,
+)
+```
+
+Methods:
+
+- client.workers.scripts.secrets.update(script_name, \*, account_id, \*\*params) -> Optional[SecretUpdateResponse]
+- client.workers.scripts.secrets.list(script_name, \*, account_id) -> SyncSinglePage[SecretListResponse]
+- client.workers.scripts.secrets.delete(secret_name, \*, account_id, script_name) -> object
+- client.workers.scripts.secrets.get(secret_name, \*, account_id, script_name) -> Optional[SecretGetResponse]
+
## AccountSettings
Types:
@@ -4909,6 +4929,7 @@ from cloudflare.types.workers_for_platforms.dispatch.namespaces.scripts import (
WorkersSecretModel,
SecretUpdateResponse,
SecretListResponse,
+ SecretDeleteResponse,
SecretGetResponse,
)
```
@@ -4917,6 +4938,7 @@ Methods:
- client.workers_for_platforms.dispatch.namespaces.scripts.secrets.update(script_name, \*, account_id, dispatch_namespace, \*\*params) -> Optional[SecretUpdateResponse]
- client.workers_for_platforms.dispatch.namespaces.scripts.secrets.list(script_name, \*, account_id, dispatch_namespace) -> SyncSinglePage[SecretListResponse]
+- client.workers_for_platforms.dispatch.namespaces.scripts.secrets.delete(secret_name, \*, account_id, dispatch_namespace, script_name) -> object
- client.workers_for_platforms.dispatch.namespaces.scripts.secrets.get(secret_name, \*, account_id, dispatch_namespace, script_name) -> Optional[SecretGetResponse]
##### Tags
diff --git a/src/cloudflare/resources/workers/scripts/__init__.py b/src/cloudflare/resources/workers/scripts/__init__.py
index 8923954063a..c77e0723379 100644
--- a/src/cloudflare/resources/workers/scripts/__init__.py
+++ b/src/cloudflare/resources/workers/scripts/__init__.py
@@ -32,6 +32,14 @@
ScriptsResourceWithStreamingResponse,
AsyncScriptsResourceWithStreamingResponse,
)
+from .secrets import (
+ SecretsResource,
+ AsyncSecretsResource,
+ SecretsResourceWithRawResponse,
+ AsyncSecretsResourceWithRawResponse,
+ SecretsResourceWithStreamingResponse,
+ AsyncSecretsResourceWithStreamingResponse,
+)
from .settings import (
SettingsResource,
AsyncSettingsResource,
@@ -122,6 +130,12 @@
"AsyncVersionsResourceWithRawResponse",
"VersionsResourceWithStreamingResponse",
"AsyncVersionsResourceWithStreamingResponse",
+ "SecretsResource",
+ "AsyncSecretsResource",
+ "SecretsResourceWithRawResponse",
+ "AsyncSecretsResourceWithRawResponse",
+ "SecretsResourceWithStreamingResponse",
+ "AsyncSecretsResourceWithStreamingResponse",
"ScriptsResource",
"AsyncScriptsResource",
"ScriptsResourceWithRawResponse",
diff --git a/src/cloudflare/resources/workers/scripts/scripts.py b/src/cloudflare/resources/workers/scripts/scripts.py
index 7738ba71148..2e436150745 100644
--- a/src/cloudflare/resources/workers/scripts/scripts.py
+++ b/src/cloudflare/resources/workers/scripts/scripts.py
@@ -22,6 +22,14 @@
ContentResourceWithStreamingResponse,
AsyncContentResourceWithStreamingResponse,
)
+from .secrets import (
+ SecretsResource,
+ AsyncSecretsResource,
+ SecretsResourceWithRawResponse,
+ AsyncSecretsResourceWithRawResponse,
+ SecretsResourceWithStreamingResponse,
+ AsyncSecretsResourceWithStreamingResponse,
+)
from .settings import (
SettingsResource,
AsyncSettingsResource,
@@ -126,6 +134,10 @@ def deployments(self) -> DeploymentsResource:
def versions(self) -> VersionsResource:
return VersionsResource(self._client)
+ @cached_property
+ def secrets(self) -> SecretsResource:
+ return SecretsResource(self._client)
+
@cached_property
def with_raw_response(self) -> ScriptsResourceWithRawResponse:
"""
@@ -360,6 +372,10 @@ def deployments(self) -> AsyncDeploymentsResource:
def versions(self) -> AsyncVersionsResource:
return AsyncVersionsResource(self._client)
+ @cached_property
+ def secrets(self) -> AsyncSecretsResource:
+ return AsyncSecretsResource(self._client)
+
@cached_property
def with_raw_response(self) -> AsyncScriptsResourceWithRawResponse:
"""
@@ -610,6 +626,10 @@ def deployments(self) -> DeploymentsResourceWithRawResponse:
def versions(self) -> VersionsResourceWithRawResponse:
return VersionsResourceWithRawResponse(self._scripts.versions)
+ @cached_property
+ def secrets(self) -> SecretsResourceWithRawResponse:
+ return SecretsResourceWithRawResponse(self._scripts.secrets)
+
class AsyncScriptsResourceWithRawResponse:
def __init__(self, scripts: AsyncScriptsResource) -> None:
@@ -660,6 +680,10 @@ def deployments(self) -> AsyncDeploymentsResourceWithRawResponse:
def versions(self) -> AsyncVersionsResourceWithRawResponse:
return AsyncVersionsResourceWithRawResponse(self._scripts.versions)
+ @cached_property
+ def secrets(self) -> AsyncSecretsResourceWithRawResponse:
+ return AsyncSecretsResourceWithRawResponse(self._scripts.secrets)
+
class ScriptsResourceWithStreamingResponse:
def __init__(self, scripts: ScriptsResource) -> None:
@@ -710,6 +734,10 @@ def deployments(self) -> DeploymentsResourceWithStreamingResponse:
def versions(self) -> VersionsResourceWithStreamingResponse:
return VersionsResourceWithStreamingResponse(self._scripts.versions)
+ @cached_property
+ def secrets(self) -> SecretsResourceWithStreamingResponse:
+ return SecretsResourceWithStreamingResponse(self._scripts.secrets)
+
class AsyncScriptsResourceWithStreamingResponse:
def __init__(self, scripts: AsyncScriptsResource) -> None:
@@ -759,3 +787,7 @@ def deployments(self) -> AsyncDeploymentsResourceWithStreamingResponse:
@cached_property
def versions(self) -> AsyncVersionsResourceWithStreamingResponse:
return AsyncVersionsResourceWithStreamingResponse(self._scripts.versions)
+
+ @cached_property
+ def secrets(self) -> AsyncSecretsResourceWithStreamingResponse:
+ return AsyncSecretsResourceWithStreamingResponse(self._scripts.secrets)
diff --git a/src/cloudflare/resources/workers/scripts/secrets.py b/src/cloudflare/resources/workers/scripts/secrets.py
new file mode 100644
index 00000000000..279878bd2b1
--- /dev/null
+++ b/src/cloudflare/resources/workers/scripts/secrets.py
@@ -0,0 +1,547 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing import Type, Optional, cast
+from typing_extensions import Literal
+
+import httpx
+
+from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
+from ...._utils import (
+ maybe_transform,
+ async_maybe_transform,
+)
+from ...._compat import cached_property
+from ...._resource import SyncAPIResource, AsyncAPIResource
+from ...._response import (
+ to_raw_response_wrapper,
+ to_streamed_response_wrapper,
+ async_to_raw_response_wrapper,
+ async_to_streamed_response_wrapper,
+)
+from ...._wrappers import ResultWrapper
+from ....pagination import SyncSinglePage, AsyncSinglePage
+from ...._base_client import AsyncPaginator, make_request_options
+from ....types.workers.scripts import secret_update_params
+from ....types.workers.scripts.secret_get_response import SecretGetResponse
+from ....types.workers.scripts.secret_list_response import SecretListResponse
+from ....types.workers.scripts.secret_update_response import SecretUpdateResponse
+
+__all__ = ["SecretsResource", "AsyncSecretsResource"]
+
+
+class SecretsResource(SyncAPIResource):
+ @cached_property
+ def with_raw_response(self) -> SecretsResourceWithRawResponse:
+ """
+ This property can be used as a prefix for any HTTP method call to return
+ the raw response object instead of the parsed content.
+
+ For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers
+ """
+ return SecretsResourceWithRawResponse(self)
+
+ @cached_property
+ def with_streaming_response(self) -> SecretsResourceWithStreamingResponse:
+ """
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
+
+ For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response
+ """
+ return SecretsResourceWithStreamingResponse(self)
+
+ def update(
+ self,
+ script_name: str,
+ *,
+ account_id: str,
+ name: str | NotGiven = NOT_GIVEN,
+ text: str | NotGiven = NOT_GIVEN,
+ type: Literal["secret_text"] | 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,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> Optional[SecretUpdateResponse]:
+ """
+ Add a secret to a script.
+
+ Args:
+ account_id: Identifier
+
+ script_name: Name of the script, used in URLs and route configuration.
+
+ name: The name of this secret, this is what will be used to access it inside the
+ Worker.
+
+ text: The value of the secret.
+
+ type: The type of secret to put.
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ if not account_id:
+ 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}")
+ return self._put(
+ f"/accounts/{account_id}/workers/scripts/{script_name}/secrets",
+ body=maybe_transform(
+ {
+ "name": name,
+ "text": text,
+ "type": type,
+ },
+ secret_update_params.SecretUpdateParams,
+ ),
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper[Optional[SecretUpdateResponse]]._unwrapper,
+ ),
+ cast_to=cast(Type[Optional[SecretUpdateResponse]], ResultWrapper[SecretUpdateResponse]),
+ )
+
+ def list(
+ self,
+ script_name: str,
+ *,
+ account_id: str,
+ # 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,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> SyncSinglePage[SecretListResponse]:
+ """
+ List secrets bound to a script.
+
+ Args:
+ account_id: Identifier
+
+ script_name: Name of the script, used in URLs and route configuration.
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ if not account_id:
+ 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}")
+ return self._get_api_list(
+ f"/accounts/{account_id}/workers/scripts/{script_name}/secrets",
+ page=SyncSinglePage[SecretListResponse],
+ options=make_request_options(
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ ),
+ model=SecretListResponse,
+ )
+
+ def delete(
+ self,
+ secret_name: str,
+ *,
+ account_id: str,
+ script_name: str,
+ # 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,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> object:
+ """
+ Remove a secret from a script.
+
+ Args:
+ account_id: Identifier
+
+ script_name: Name of the script, used in URLs and route configuration.
+
+ secret_name: A JavaScript variable name for the secret binding.
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ if not account_id:
+ 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}")
+ if not secret_name:
+ raise ValueError(f"Expected a non-empty value for `secret_name` but received {secret_name!r}")
+ return self._delete(
+ f"/accounts/{account_id}/workers/scripts/{script_name}/secrets/{secret_name}",
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper[Optional[object]]._unwrapper,
+ ),
+ cast_to=cast(Type[object], ResultWrapper[object]),
+ )
+
+ def get(
+ self,
+ secret_name: str,
+ *,
+ account_id: str,
+ script_name: str,
+ # 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,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> Optional[SecretGetResponse]:
+ """
+ Get a given secret binding (value omitted) on a script.
+
+ Args:
+ account_id: Identifier
+
+ script_name: Name of the script, used in URLs and route configuration.
+
+ secret_name: A JavaScript variable name for the secret binding.
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ if not account_id:
+ 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}")
+ if not secret_name:
+ raise ValueError(f"Expected a non-empty value for `secret_name` but received {secret_name!r}")
+ return self._get(
+ f"/accounts/{account_id}/workers/scripts/{script_name}/secrets/{secret_name}",
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper[Optional[SecretGetResponse]]._unwrapper,
+ ),
+ cast_to=cast(Type[Optional[SecretGetResponse]], ResultWrapper[SecretGetResponse]),
+ )
+
+
+class AsyncSecretsResource(AsyncAPIResource):
+ @cached_property
+ def with_raw_response(self) -> AsyncSecretsResourceWithRawResponse:
+ """
+ This property can be used as a prefix for any HTTP method call to return
+ the raw response object instead of the parsed content.
+
+ For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers
+ """
+ return AsyncSecretsResourceWithRawResponse(self)
+
+ @cached_property
+ def with_streaming_response(self) -> AsyncSecretsResourceWithStreamingResponse:
+ """
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
+
+ For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response
+ """
+ return AsyncSecretsResourceWithStreamingResponse(self)
+
+ async def update(
+ self,
+ script_name: str,
+ *,
+ account_id: str,
+ name: str | NotGiven = NOT_GIVEN,
+ text: str | NotGiven = NOT_GIVEN,
+ type: Literal["secret_text"] | 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,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> Optional[SecretUpdateResponse]:
+ """
+ Add a secret to a script.
+
+ Args:
+ account_id: Identifier
+
+ script_name: Name of the script, used in URLs and route configuration.
+
+ name: The name of this secret, this is what will be used to access it inside the
+ Worker.
+
+ text: The value of the secret.
+
+ type: The type of secret to put.
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ if not account_id:
+ 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}")
+ return await self._put(
+ f"/accounts/{account_id}/workers/scripts/{script_name}/secrets",
+ body=await async_maybe_transform(
+ {
+ "name": name,
+ "text": text,
+ "type": type,
+ },
+ secret_update_params.SecretUpdateParams,
+ ),
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper[Optional[SecretUpdateResponse]]._unwrapper,
+ ),
+ cast_to=cast(Type[Optional[SecretUpdateResponse]], ResultWrapper[SecretUpdateResponse]),
+ )
+
+ def list(
+ self,
+ script_name: str,
+ *,
+ account_id: str,
+ # 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,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> AsyncPaginator[SecretListResponse, AsyncSinglePage[SecretListResponse]]:
+ """
+ List secrets bound to a script.
+
+ Args:
+ account_id: Identifier
+
+ script_name: Name of the script, used in URLs and route configuration.
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ if not account_id:
+ 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}")
+ return self._get_api_list(
+ f"/accounts/{account_id}/workers/scripts/{script_name}/secrets",
+ page=AsyncSinglePage[SecretListResponse],
+ options=make_request_options(
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ ),
+ model=SecretListResponse,
+ )
+
+ async def delete(
+ self,
+ secret_name: str,
+ *,
+ account_id: str,
+ script_name: str,
+ # 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,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> object:
+ """
+ Remove a secret from a script.
+
+ Args:
+ account_id: Identifier
+
+ script_name: Name of the script, used in URLs and route configuration.
+
+ secret_name: A JavaScript variable name for the secret binding.
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ if not account_id:
+ 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}")
+ if not secret_name:
+ raise ValueError(f"Expected a non-empty value for `secret_name` but received {secret_name!r}")
+ return await self._delete(
+ f"/accounts/{account_id}/workers/scripts/{script_name}/secrets/{secret_name}",
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper[Optional[object]]._unwrapper,
+ ),
+ cast_to=cast(Type[object], ResultWrapper[object]),
+ )
+
+ async def get(
+ self,
+ secret_name: str,
+ *,
+ account_id: str,
+ script_name: str,
+ # 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,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> Optional[SecretGetResponse]:
+ """
+ Get a given secret binding (value omitted) on a script.
+
+ Args:
+ account_id: Identifier
+
+ script_name: Name of the script, used in URLs and route configuration.
+
+ secret_name: A JavaScript variable name for the secret binding.
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ if not account_id:
+ 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}")
+ if not secret_name:
+ raise ValueError(f"Expected a non-empty value for `secret_name` but received {secret_name!r}")
+ return await self._get(
+ f"/accounts/{account_id}/workers/scripts/{script_name}/secrets/{secret_name}",
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper[Optional[SecretGetResponse]]._unwrapper,
+ ),
+ cast_to=cast(Type[Optional[SecretGetResponse]], ResultWrapper[SecretGetResponse]),
+ )
+
+
+class SecretsResourceWithRawResponse:
+ def __init__(self, secrets: SecretsResource) -> None:
+ self._secrets = secrets
+
+ self.update = to_raw_response_wrapper(
+ secrets.update,
+ )
+ self.list = to_raw_response_wrapper(
+ secrets.list,
+ )
+ self.delete = to_raw_response_wrapper(
+ secrets.delete,
+ )
+ self.get = to_raw_response_wrapper(
+ secrets.get,
+ )
+
+
+class AsyncSecretsResourceWithRawResponse:
+ def __init__(self, secrets: AsyncSecretsResource) -> None:
+ self._secrets = secrets
+
+ self.update = async_to_raw_response_wrapper(
+ secrets.update,
+ )
+ self.list = async_to_raw_response_wrapper(
+ secrets.list,
+ )
+ self.delete = async_to_raw_response_wrapper(
+ secrets.delete,
+ )
+ self.get = async_to_raw_response_wrapper(
+ secrets.get,
+ )
+
+
+class SecretsResourceWithStreamingResponse:
+ def __init__(self, secrets: SecretsResource) -> None:
+ self._secrets = secrets
+
+ self.update = to_streamed_response_wrapper(
+ secrets.update,
+ )
+ self.list = to_streamed_response_wrapper(
+ secrets.list,
+ )
+ self.delete = to_streamed_response_wrapper(
+ secrets.delete,
+ )
+ self.get = to_streamed_response_wrapper(
+ secrets.get,
+ )
+
+
+class AsyncSecretsResourceWithStreamingResponse:
+ def __init__(self, secrets: AsyncSecretsResource) -> None:
+ self._secrets = secrets
+
+ self.update = async_to_streamed_response_wrapper(
+ secrets.update,
+ )
+ self.list = async_to_streamed_response_wrapper(
+ secrets.list,
+ )
+ self.delete = async_to_streamed_response_wrapper(
+ secrets.delete,
+ )
+ self.get = async_to_streamed_response_wrapper(
+ secrets.get,
+ )
diff --git a/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/secrets.py b/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/secrets.py
index 4b5309b1bb7..0a20ba52861 100644
--- a/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/secrets.py
+++ b/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/secrets.py
@@ -164,6 +164,60 @@ def list(
model=SecretListResponse,
)
+ def delete(
+ self,
+ secret_name: str,
+ *,
+ account_id: str,
+ dispatch_namespace: str,
+ script_name: str,
+ # 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,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> object:
+ """
+ Remove a secret from a script uploaded to a Workers for Platforms namespace.
+
+ Args:
+ account_id: Identifier
+
+ dispatch_namespace: Name of the Workers for Platforms dispatch namespace.
+
+ script_name: Name of the script, used in URLs and route configuration.
+
+ secret_name: A JavaScript variable name for the secret binding.
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ if not account_id:
+ raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
+ if not dispatch_namespace:
+ 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}")
+ if not secret_name:
+ raise ValueError(f"Expected a non-empty value for `secret_name` but received {secret_name!r}")
+ return self._delete(
+ f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/secrets/{secret_name}",
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper[Optional[object]]._unwrapper,
+ ),
+ cast_to=cast(Type[object], ResultWrapper[object]),
+ )
+
def get(
self,
secret_name: str,
@@ -353,6 +407,60 @@ def list(
model=SecretListResponse,
)
+ async def delete(
+ self,
+ secret_name: str,
+ *,
+ account_id: str,
+ dispatch_namespace: str,
+ script_name: str,
+ # 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,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> object:
+ """
+ Remove a secret from a script uploaded to a Workers for Platforms namespace.
+
+ Args:
+ account_id: Identifier
+
+ dispatch_namespace: Name of the Workers for Platforms dispatch namespace.
+
+ script_name: Name of the script, used in URLs and route configuration.
+
+ secret_name: A JavaScript variable name for the secret binding.
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ if not account_id:
+ raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
+ if not dispatch_namespace:
+ 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}")
+ if not secret_name:
+ raise ValueError(f"Expected a non-empty value for `secret_name` but received {secret_name!r}")
+ return await self._delete(
+ f"/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/secrets/{secret_name}",
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper[Optional[object]]._unwrapper,
+ ),
+ cast_to=cast(Type[object], ResultWrapper[object]),
+ )
+
async def get(
self,
secret_name: str,
@@ -419,6 +527,9 @@ def __init__(self, secrets: SecretsResource) -> None:
self.list = to_raw_response_wrapper(
secrets.list,
)
+ self.delete = to_raw_response_wrapper(
+ secrets.delete,
+ )
self.get = to_raw_response_wrapper(
secrets.get,
)
@@ -434,6 +545,9 @@ def __init__(self, secrets: AsyncSecretsResource) -> None:
self.list = async_to_raw_response_wrapper(
secrets.list,
)
+ self.delete = async_to_raw_response_wrapper(
+ secrets.delete,
+ )
self.get = async_to_raw_response_wrapper(
secrets.get,
)
@@ -449,6 +563,9 @@ def __init__(self, secrets: SecretsResource) -> None:
self.list = to_streamed_response_wrapper(
secrets.list,
)
+ self.delete = to_streamed_response_wrapper(
+ secrets.delete,
+ )
self.get = to_streamed_response_wrapper(
secrets.get,
)
@@ -464,6 +581,9 @@ def __init__(self, secrets: AsyncSecretsResource) -> None:
self.list = async_to_streamed_response_wrapper(
secrets.list,
)
+ self.delete = async_to_streamed_response_wrapper(
+ secrets.delete,
+ )
self.get = async_to_streamed_response_wrapper(
secrets.get,
)
diff --git a/src/cloudflare/types/workers/scripts/__init__.py b/src/cloudflare/types/workers/scripts/__init__.py
index c8b592499c2..581c056d222 100644
--- a/src/cloudflare/types/workers/scripts/__init__.py
+++ b/src/cloudflare/types/workers/scripts/__init__.py
@@ -9,8 +9,11 @@
from .deployment_param import DeploymentParam as DeploymentParam
from .tail_get_response import TailGetResponse as TailGetResponse
from .tail_create_params import TailCreateParams as TailCreateParams
+from .secret_get_response import SecretGetResponse as SecretGetResponse
from .setting_edit_params import SettingEditParams as SettingEditParams
from .version_list_params import VersionListParams as VersionListParams
+from .secret_list_response import SecretListResponse as SecretListResponse
+from .secret_update_params import SecretUpdateParams as SecretUpdateParams
from .tail_create_response import TailCreateResponse as TailCreateResponse
from .tail_delete_response import TailDeleteResponse as TailDeleteResponse
from .version_get_response import VersionGetResponse as VersionGetResponse
@@ -20,6 +23,7 @@
from .version_create_params import VersionCreateParams as VersionCreateParams
from .version_list_response import VersionListResponse as VersionListResponse
from .schedule_update_params import ScheduleUpdateParams as ScheduleUpdateParams
+from .secret_update_response import SecretUpdateResponse as SecretUpdateResponse
from .subdomain_get_response import SubdomainGetResponse as SubdomainGetResponse
from .deployment_get_response import DeploymentGetResponse as DeploymentGetResponse
from .subdomain_create_params import SubdomainCreateParams as SubdomainCreateParams
diff --git a/src/cloudflare/types/workers/scripts/secret_get_response.py b/src/cloudflare/types/workers/scripts/secret_get_response.py
new file mode 100644
index 00000000000..a4c8d9379f7
--- /dev/null
+++ b/src/cloudflare/types/workers/scripts/secret_get_response.py
@@ -0,0 +1,19 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from typing import Optional
+from typing_extensions import Literal
+
+from ...._models import BaseModel
+
+__all__ = ["SecretGetResponse"]
+
+
+class SecretGetResponse(BaseModel):
+ name: Optional[str] = None
+ """
+ The name of this secret, this is what will be used to access it inside the
+ Worker.
+ """
+
+ type: Optional[Literal["secret_text"]] = None
+ """The type of secret."""
diff --git a/src/cloudflare/types/workers/scripts/secret_list_response.py b/src/cloudflare/types/workers/scripts/secret_list_response.py
new file mode 100644
index 00000000000..a2992bd1761
--- /dev/null
+++ b/src/cloudflare/types/workers/scripts/secret_list_response.py
@@ -0,0 +1,19 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from typing import Optional
+from typing_extensions import Literal
+
+from ...._models import BaseModel
+
+__all__ = ["SecretListResponse"]
+
+
+class SecretListResponse(BaseModel):
+ name: Optional[str] = None
+ """
+ The name of this secret, this is what will be used to access it inside the
+ Worker.
+ """
+
+ type: Optional[Literal["secret_text"]] = None
+ """The type of secret."""
diff --git a/src/cloudflare/types/workers/scripts/secret_update_params.py b/src/cloudflare/types/workers/scripts/secret_update_params.py
new file mode 100644
index 00000000000..943a4789102
--- /dev/null
+++ b/src/cloudflare/types/workers/scripts/secret_update_params.py
@@ -0,0 +1,24 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing_extensions import Literal, Required, TypedDict
+
+__all__ = ["SecretUpdateParams"]
+
+
+class SecretUpdateParams(TypedDict, total=False):
+ account_id: Required[str]
+ """Identifier"""
+
+ name: str
+ """
+ The name of this secret, this is what will be used to access it inside the
+ Worker.
+ """
+
+ text: str
+ """The value of the secret."""
+
+ type: Literal["secret_text"]
+ """The type of secret to put."""
diff --git a/src/cloudflare/types/workers/scripts/secret_update_response.py b/src/cloudflare/types/workers/scripts/secret_update_response.py
new file mode 100644
index 00000000000..548df41c408
--- /dev/null
+++ b/src/cloudflare/types/workers/scripts/secret_update_response.py
@@ -0,0 +1,19 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from typing import Optional
+from typing_extensions import Literal
+
+from ...._models import BaseModel
+
+__all__ = ["SecretUpdateResponse"]
+
+
+class SecretUpdateResponse(BaseModel):
+ name: Optional[str] = None
+ """
+ The name of this secret, this is what will be used to access it inside the
+ Worker.
+ """
+
+ type: Optional[Literal["secret_text"]] = None
+ """The type of secret."""
diff --git a/tests/api_resources/workers/scripts/test_secrets.py b/tests/api_resources/workers/scripts/test_secrets.py
new file mode 100644
index 00000000000..c6576082da5
--- /dev/null
+++ b/tests/api_resources/workers/scripts/test_secrets.py
@@ -0,0 +1,481 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+import os
+from typing import Any, Optional, cast
+
+import pytest
+
+from cloudflare import Cloudflare, AsyncCloudflare
+from tests.utils import assert_matches_type
+from cloudflare.pagination import SyncSinglePage, AsyncSinglePage
+from cloudflare.types.workers.scripts import (
+ SecretGetResponse,
+ SecretListResponse,
+ SecretUpdateResponse,
+)
+
+base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
+
+
+class TestSecrets:
+ parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
+
+ @parametrize
+ def test_method_update(self, client: Cloudflare) -> None:
+ secret = client.workers.scripts.secrets.update(
+ script_name="this-is_my_script-01",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+ assert_matches_type(Optional[SecretUpdateResponse], secret, path=["response"])
+
+ @parametrize
+ def test_method_update_with_all_params(self, client: Cloudflare) -> None:
+ secret = client.workers.scripts.secrets.update(
+ script_name="this-is_my_script-01",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ name="MY_SECRET",
+ text="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9",
+ type="secret_text",
+ )
+ assert_matches_type(Optional[SecretUpdateResponse], secret, path=["response"])
+
+ @parametrize
+ def test_raw_response_update(self, client: Cloudflare) -> None:
+ response = client.workers.scripts.secrets.with_raw_response.update(
+ script_name="this-is_my_script-01",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ secret = response.parse()
+ assert_matches_type(Optional[SecretUpdateResponse], secret, path=["response"])
+
+ @parametrize
+ def test_streaming_response_update(self, client: Cloudflare) -> None:
+ with client.workers.scripts.secrets.with_streaming_response.update(
+ script_name="this-is_my_script-01",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ secret = response.parse()
+ assert_matches_type(Optional[SecretUpdateResponse], secret, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ def test_path_params_update(self, client: Cloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ client.workers.scripts.secrets.with_raw_response.update(
+ script_name="this-is_my_script-01",
+ account_id="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `script_name` but received ''"):
+ client.workers.scripts.secrets.with_raw_response.update(
+ script_name="",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ @parametrize
+ def test_method_list(self, client: Cloudflare) -> None:
+ secret = client.workers.scripts.secrets.list(
+ script_name="this-is_my_script-01",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+ assert_matches_type(SyncSinglePage[SecretListResponse], secret, path=["response"])
+
+ @parametrize
+ def test_raw_response_list(self, client: Cloudflare) -> None:
+ response = client.workers.scripts.secrets.with_raw_response.list(
+ script_name="this-is_my_script-01",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ secret = response.parse()
+ assert_matches_type(SyncSinglePage[SecretListResponse], secret, path=["response"])
+
+ @parametrize
+ def test_streaming_response_list(self, client: Cloudflare) -> None:
+ with client.workers.scripts.secrets.with_streaming_response.list(
+ script_name="this-is_my_script-01",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ secret = response.parse()
+ assert_matches_type(SyncSinglePage[SecretListResponse], secret, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ def test_path_params_list(self, client: Cloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ client.workers.scripts.secrets.with_raw_response.list(
+ script_name="this-is_my_script-01",
+ account_id="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `script_name` but received ''"):
+ client.workers.scripts.secrets.with_raw_response.list(
+ script_name="",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ @parametrize
+ def test_method_delete(self, client: Cloudflare) -> None:
+ secret = client.workers.scripts.secrets.delete(
+ secret_name="mySecret",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ script_name="this-is_my_script-01",
+ )
+ assert_matches_type(object, secret, path=["response"])
+
+ @parametrize
+ def test_raw_response_delete(self, client: Cloudflare) -> None:
+ response = client.workers.scripts.secrets.with_raw_response.delete(
+ secret_name="mySecret",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ script_name="this-is_my_script-01",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ secret = response.parse()
+ assert_matches_type(object, secret, path=["response"])
+
+ @parametrize
+ def test_streaming_response_delete(self, client: Cloudflare) -> None:
+ with client.workers.scripts.secrets.with_streaming_response.delete(
+ secret_name="mySecret",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ script_name="this-is_my_script-01",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ secret = response.parse()
+ assert_matches_type(object, secret, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ def test_path_params_delete(self, client: Cloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ client.workers.scripts.secrets.with_raw_response.delete(
+ secret_name="mySecret",
+ account_id="",
+ script_name="this-is_my_script-01",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `script_name` but received ''"):
+ client.workers.scripts.secrets.with_raw_response.delete(
+ secret_name="mySecret",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ script_name="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `secret_name` but received ''"):
+ client.workers.scripts.secrets.with_raw_response.delete(
+ secret_name="",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ script_name="this-is_my_script-01",
+ )
+
+ @parametrize
+ def test_method_get(self, client: Cloudflare) -> None:
+ secret = client.workers.scripts.secrets.get(
+ secret_name="mySecret",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ script_name="this-is_my_script-01",
+ )
+ assert_matches_type(Optional[SecretGetResponse], secret, path=["response"])
+
+ @parametrize
+ def test_raw_response_get(self, client: Cloudflare) -> None:
+ response = client.workers.scripts.secrets.with_raw_response.get(
+ secret_name="mySecret",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ script_name="this-is_my_script-01",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ secret = response.parse()
+ assert_matches_type(Optional[SecretGetResponse], secret, path=["response"])
+
+ @parametrize
+ def test_streaming_response_get(self, client: Cloudflare) -> None:
+ with client.workers.scripts.secrets.with_streaming_response.get(
+ secret_name="mySecret",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ script_name="this-is_my_script-01",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ secret = response.parse()
+ assert_matches_type(Optional[SecretGetResponse], secret, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ def test_path_params_get(self, client: Cloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ client.workers.scripts.secrets.with_raw_response.get(
+ secret_name="mySecret",
+ account_id="",
+ script_name="this-is_my_script-01",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `script_name` but received ''"):
+ client.workers.scripts.secrets.with_raw_response.get(
+ secret_name="mySecret",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ script_name="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `secret_name` but received ''"):
+ client.workers.scripts.secrets.with_raw_response.get(
+ secret_name="",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ script_name="this-is_my_script-01",
+ )
+
+
+class TestAsyncSecrets:
+ parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
+
+ @parametrize
+ async def test_method_update(self, async_client: AsyncCloudflare) -> None:
+ secret = await async_client.workers.scripts.secrets.update(
+ script_name="this-is_my_script-01",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+ assert_matches_type(Optional[SecretUpdateResponse], secret, path=["response"])
+
+ @parametrize
+ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None:
+ secret = await async_client.workers.scripts.secrets.update(
+ script_name="this-is_my_script-01",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ name="MY_SECRET",
+ text="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9",
+ type="secret_text",
+ )
+ assert_matches_type(Optional[SecretUpdateResponse], secret, path=["response"])
+
+ @parametrize
+ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None:
+ response = await async_client.workers.scripts.secrets.with_raw_response.update(
+ script_name="this-is_my_script-01",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ secret = await response.parse()
+ assert_matches_type(Optional[SecretUpdateResponse], secret, path=["response"])
+
+ @parametrize
+ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None:
+ async with async_client.workers.scripts.secrets.with_streaming_response.update(
+ script_name="this-is_my_script-01",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ secret = await response.parse()
+ assert_matches_type(Optional[SecretUpdateResponse], secret, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ await async_client.workers.scripts.secrets.with_raw_response.update(
+ script_name="this-is_my_script-01",
+ account_id="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `script_name` but received ''"):
+ await async_client.workers.scripts.secrets.with_raw_response.update(
+ script_name="",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ @parametrize
+ async def test_method_list(self, async_client: AsyncCloudflare) -> None:
+ secret = await async_client.workers.scripts.secrets.list(
+ script_name="this-is_my_script-01",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+ assert_matches_type(AsyncSinglePage[SecretListResponse], secret, path=["response"])
+
+ @parametrize
+ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None:
+ response = await async_client.workers.scripts.secrets.with_raw_response.list(
+ script_name="this-is_my_script-01",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ secret = await response.parse()
+ assert_matches_type(AsyncSinglePage[SecretListResponse], secret, path=["response"])
+
+ @parametrize
+ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None:
+ async with async_client.workers.scripts.secrets.with_streaming_response.list(
+ script_name="this-is_my_script-01",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ secret = await response.parse()
+ assert_matches_type(AsyncSinglePage[SecretListResponse], secret, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ await async_client.workers.scripts.secrets.with_raw_response.list(
+ script_name="this-is_my_script-01",
+ account_id="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `script_name` but received ''"):
+ await async_client.workers.scripts.secrets.with_raw_response.list(
+ script_name="",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ @parametrize
+ async def test_method_delete(self, async_client: AsyncCloudflare) -> None:
+ secret = await async_client.workers.scripts.secrets.delete(
+ secret_name="mySecret",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ script_name="this-is_my_script-01",
+ )
+ assert_matches_type(object, secret, path=["response"])
+
+ @parametrize
+ async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None:
+ response = await async_client.workers.scripts.secrets.with_raw_response.delete(
+ secret_name="mySecret",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ script_name="this-is_my_script-01",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ secret = await response.parse()
+ assert_matches_type(object, secret, path=["response"])
+
+ @parametrize
+ async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None:
+ async with async_client.workers.scripts.secrets.with_streaming_response.delete(
+ secret_name="mySecret",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ script_name="this-is_my_script-01",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ secret = await response.parse()
+ assert_matches_type(object, secret, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ await async_client.workers.scripts.secrets.with_raw_response.delete(
+ secret_name="mySecret",
+ account_id="",
+ script_name="this-is_my_script-01",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `script_name` but received ''"):
+ await async_client.workers.scripts.secrets.with_raw_response.delete(
+ secret_name="mySecret",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ script_name="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `secret_name` but received ''"):
+ await async_client.workers.scripts.secrets.with_raw_response.delete(
+ secret_name="",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ script_name="this-is_my_script-01",
+ )
+
+ @parametrize
+ async def test_method_get(self, async_client: AsyncCloudflare) -> None:
+ secret = await async_client.workers.scripts.secrets.get(
+ secret_name="mySecret",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ script_name="this-is_my_script-01",
+ )
+ assert_matches_type(Optional[SecretGetResponse], secret, path=["response"])
+
+ @parametrize
+ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None:
+ response = await async_client.workers.scripts.secrets.with_raw_response.get(
+ secret_name="mySecret",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ script_name="this-is_my_script-01",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ secret = await response.parse()
+ assert_matches_type(Optional[SecretGetResponse], secret, path=["response"])
+
+ @parametrize
+ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None:
+ async with async_client.workers.scripts.secrets.with_streaming_response.get(
+ secret_name="mySecret",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ script_name="this-is_my_script-01",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ secret = await response.parse()
+ assert_matches_type(Optional[SecretGetResponse], secret, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ async def test_path_params_get(self, async_client: AsyncCloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ await async_client.workers.scripts.secrets.with_raw_response.get(
+ secret_name="mySecret",
+ account_id="",
+ script_name="this-is_my_script-01",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `script_name` but received ''"):
+ await async_client.workers.scripts.secrets.with_raw_response.get(
+ secret_name="mySecret",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ script_name="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `secret_name` but received ''"):
+ await async_client.workers.scripts.secrets.with_raw_response.get(
+ secret_name="",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ script_name="this-is_my_script-01",
+ )
diff --git a/tests/api_resources/workers_for_platforms/dispatch/namespaces/scripts/test_secrets.py b/tests/api_resources/workers_for_platforms/dispatch/namespaces/scripts/test_secrets.py
index 0a63545598c..19e470c0d73 100644
--- a/tests/api_resources/workers_for_platforms/dispatch/namespaces/scripts/test_secrets.py
+++ b/tests/api_resources/workers_for_platforms/dispatch/namespaces/scripts/test_secrets.py
@@ -154,6 +154,80 @@ def test_path_params_list(self, client: Cloudflare) -> None:
dispatch_namespace="my-dispatch-namespace",
)
+ @parametrize
+ def test_method_delete(self, client: Cloudflare) -> None:
+ secret = client.workers_for_platforms.dispatch.namespaces.scripts.secrets.delete(
+ secret_name="mySecret",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ dispatch_namespace="my-dispatch-namespace",
+ script_name="this-is_my_script-01",
+ )
+ assert_matches_type(object, secret, path=["response"])
+
+ @parametrize
+ def test_raw_response_delete(self, client: Cloudflare) -> None:
+ response = client.workers_for_platforms.dispatch.namespaces.scripts.secrets.with_raw_response.delete(
+ secret_name="mySecret",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ dispatch_namespace="my-dispatch-namespace",
+ script_name="this-is_my_script-01",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ secret = response.parse()
+ assert_matches_type(object, secret, path=["response"])
+
+ @parametrize
+ def test_streaming_response_delete(self, client: Cloudflare) -> None:
+ with client.workers_for_platforms.dispatch.namespaces.scripts.secrets.with_streaming_response.delete(
+ secret_name="mySecret",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ dispatch_namespace="my-dispatch-namespace",
+ script_name="this-is_my_script-01",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ secret = response.parse()
+ assert_matches_type(object, secret, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ def test_path_params_delete(self, client: Cloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ client.workers_for_platforms.dispatch.namespaces.scripts.secrets.with_raw_response.delete(
+ secret_name="mySecret",
+ account_id="",
+ dispatch_namespace="my-dispatch-namespace",
+ script_name="this-is_my_script-01",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `dispatch_namespace` but received ''"):
+ client.workers_for_platforms.dispatch.namespaces.scripts.secrets.with_raw_response.delete(
+ secret_name="mySecret",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ dispatch_namespace="",
+ script_name="this-is_my_script-01",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `script_name` but received ''"):
+ client.workers_for_platforms.dispatch.namespaces.scripts.secrets.with_raw_response.delete(
+ secret_name="mySecret",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ dispatch_namespace="my-dispatch-namespace",
+ script_name="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `secret_name` but received ''"):
+ client.workers_for_platforms.dispatch.namespaces.scripts.secrets.with_raw_response.delete(
+ secret_name="",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ dispatch_namespace="my-dispatch-namespace",
+ script_name="this-is_my_script-01",
+ )
+
@parametrize
def test_method_get(self, client: Cloudflare) -> None:
secret = client.workers_for_platforms.dispatch.namespaces.scripts.secrets.get(
@@ -368,6 +442,84 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None:
dispatch_namespace="my-dispatch-namespace",
)
+ @parametrize
+ async def test_method_delete(self, async_client: AsyncCloudflare) -> None:
+ secret = await async_client.workers_for_platforms.dispatch.namespaces.scripts.secrets.delete(
+ secret_name="mySecret",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ dispatch_namespace="my-dispatch-namespace",
+ script_name="this-is_my_script-01",
+ )
+ assert_matches_type(object, secret, path=["response"])
+
+ @parametrize
+ async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None:
+ response = (
+ await async_client.workers_for_platforms.dispatch.namespaces.scripts.secrets.with_raw_response.delete(
+ secret_name="mySecret",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ dispatch_namespace="my-dispatch-namespace",
+ script_name="this-is_my_script-01",
+ )
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ secret = await response.parse()
+ assert_matches_type(object, secret, path=["response"])
+
+ @parametrize
+ async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None:
+ async with (
+ async_client.workers_for_platforms.dispatch.namespaces.scripts.secrets.with_streaming_response.delete(
+ secret_name="mySecret",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ dispatch_namespace="my-dispatch-namespace",
+ script_name="this-is_my_script-01",
+ )
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ secret = await response.parse()
+ assert_matches_type(object, secret, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ await async_client.workers_for_platforms.dispatch.namespaces.scripts.secrets.with_raw_response.delete(
+ secret_name="mySecret",
+ account_id="",
+ dispatch_namespace="my-dispatch-namespace",
+ script_name="this-is_my_script-01",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `dispatch_namespace` but received ''"):
+ await async_client.workers_for_platforms.dispatch.namespaces.scripts.secrets.with_raw_response.delete(
+ secret_name="mySecret",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ dispatch_namespace="",
+ script_name="this-is_my_script-01",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `script_name` but received ''"):
+ await async_client.workers_for_platforms.dispatch.namespaces.scripts.secrets.with_raw_response.delete(
+ secret_name="mySecret",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ dispatch_namespace="my-dispatch-namespace",
+ script_name="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `secret_name` but received ''"):
+ await async_client.workers_for_platforms.dispatch.namespaces.scripts.secrets.with_raw_response.delete(
+ secret_name="",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ dispatch_namespace="my-dispatch-namespace",
+ script_name="this-is_my_script-01",
+ )
+
@parametrize
async def test_method_get(self, async_client: AsyncCloudflare) -> None:
secret = await async_client.workers_for_platforms.dispatch.namespaces.scripts.secrets.get(