Skip to content

Commit

Permalink
feat(api): api update (#2175)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Nov 19, 2024
1 parent dbebda3 commit d22a2de
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 1411
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d6dd7ea434d79d52578f28ebdc5ddd1fbf9e68526bf0e32285f1c3725ccacb4d.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-829ade7062fed63a30accc2a5e1a14c6c26fd4dc003d300d1b25a5416b8b8727.yml
28 changes: 4 additions & 24 deletions src/cloudflare/resources/workers/scripts/subdomain.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ def create(
script_name: str,
*,
account_id: str,
enabled: bool,
previews_enabled: bool | NotGiven = NOT_GIVEN,
enabled: bool | 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 @@ -69,9 +68,6 @@ def create(
enabled: Whether the Worker should be available on the workers.dev subdomain.
previews_enabled: Whether the Worker's Preview URLs should be available on the workers.dev
subdomain.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
Expand All @@ -86,13 +82,7 @@ def create(
raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}")
return self._post(
f"/accounts/{account_id}/workers/scripts/{script_name}/subdomain",
body=maybe_transform(
{
"enabled": enabled,
"previews_enabled": previews_enabled,
},
subdomain_create_params.SubdomainCreateParams,
),
body=maybe_transform({"enabled": enabled}, subdomain_create_params.SubdomainCreateParams),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
Expand Down Expand Up @@ -165,8 +155,7 @@ async def create(
script_name: str,
*,
account_id: str,
enabled: bool,
previews_enabled: bool | NotGiven = NOT_GIVEN,
enabled: bool | 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 @@ -184,9 +173,6 @@ async def create(
enabled: Whether the Worker should be available on the workers.dev subdomain.
previews_enabled: Whether the Worker's Preview URLs should be available on the workers.dev
subdomain.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
Expand All @@ -201,13 +187,7 @@ async def create(
raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}")
return await self._post(
f"/accounts/{account_id}/workers/scripts/{script_name}/subdomain",
body=await async_maybe_transform(
{
"enabled": enabled,
"previews_enabled": previews_enabled,
},
subdomain_create_params.SubdomainCreateParams,
),
body=await async_maybe_transform({"enabled": enabled}, subdomain_create_params.SubdomainCreateParams),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,5 @@ class SubdomainCreateParams(TypedDict, total=False):
account_id: Required[str]
"""Identifier"""

enabled: Required[bool]
enabled: bool
"""Whether the Worker should be available on the workers.dev subdomain."""

previews_enabled: bool
"""
Whether the Worker's Preview URLs should be available on the workers.dev
subdomain.
"""
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,3 @@
class SubdomainCreateResponse(BaseModel):
enabled: Optional[bool] = None
"""Whether the Worker is available on the workers.dev subdomain."""

previews_enabled: Optional[bool] = None
"""
Whether the Worker's Preview URLs should be available on the workers.dev
subdomain.
"""
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,3 @@
class SubdomainGetResponse(BaseModel):
enabled: Optional[bool] = None
"""Whether the Worker is available on the workers.dev subdomain."""

previews_enabled: Optional[bool] = None
"""
Whether the Worker's Preview URLs should be available on the workers.dev
subdomain.
"""
12 changes: 0 additions & 12 deletions tests/api_resources/workers/scripts/test_subdomain.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def test_method_create(self, client: Cloudflare) -> None:
subdomain = client.workers.scripts.subdomain.create(
script_name="this-is_my_script-01",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
enabled=True,
)
assert_matches_type(SubdomainCreateResponse, subdomain, path=["response"])

Expand All @@ -32,7 +31,6 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None:
script_name="this-is_my_script-01",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
enabled=True,
previews_enabled=True,
)
assert_matches_type(SubdomainCreateResponse, subdomain, path=["response"])

Expand All @@ -41,7 +39,6 @@ def test_raw_response_create(self, client: Cloudflare) -> None:
response = client.workers.scripts.subdomain.with_raw_response.create(
script_name="this-is_my_script-01",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
enabled=True,
)

assert response.is_closed is True
Expand All @@ -54,7 +51,6 @@ def test_streaming_response_create(self, client: Cloudflare) -> None:
with client.workers.scripts.subdomain.with_streaming_response.create(
script_name="this-is_my_script-01",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
enabled=True,
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
Expand All @@ -70,14 +66,12 @@ def test_path_params_create(self, client: Cloudflare) -> None:
client.workers.scripts.subdomain.with_raw_response.create(
script_name="this-is_my_script-01",
account_id="",
enabled=True,
)

with pytest.raises(ValueError, match=r"Expected a non-empty value for `script_name` but received ''"):
client.workers.scripts.subdomain.with_raw_response.create(
script_name="",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
enabled=True,
)

@parametrize
Expand Down Expand Up @@ -137,7 +131,6 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None:
subdomain = await async_client.workers.scripts.subdomain.create(
script_name="this-is_my_script-01",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
enabled=True,
)
assert_matches_type(SubdomainCreateResponse, subdomain, path=["response"])

Expand All @@ -147,7 +140,6 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare
script_name="this-is_my_script-01",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
enabled=True,
previews_enabled=True,
)
assert_matches_type(SubdomainCreateResponse, subdomain, path=["response"])

Expand All @@ -156,7 +148,6 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None:
response = await async_client.workers.scripts.subdomain.with_raw_response.create(
script_name="this-is_my_script-01",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
enabled=True,
)

assert response.is_closed is True
Expand All @@ -169,7 +160,6 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) ->
async with async_client.workers.scripts.subdomain.with_streaming_response.create(
script_name="this-is_my_script-01",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
enabled=True,
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
Expand All @@ -185,14 +175,12 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None:
await async_client.workers.scripts.subdomain.with_raw_response.create(
script_name="this-is_my_script-01",
account_id="",
enabled=True,
)

with pytest.raises(ValueError, match=r"Expected a non-empty value for `script_name` but received ''"):
await async_client.workers.scripts.subdomain.with_raw_response.create(
script_name="",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
enabled=True,
)

@parametrize
Expand Down

0 comments on commit d22a2de

Please sign in to comment.