Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cloud_connector): define body param name #2314

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/cloudflare/resources/cloud_connector/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def update(
self,
*,
zone_id: str,
body: Iterable[rule_update_params.Body],
rules: Iterable[rule_update_params.Rule],
# 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 @@ -67,7 +67,7 @@ def update(
Args:
zone_id: Identifier

body: List of Cloud Connector rules
rules: List of Cloud Connector rules

extra_headers: Send extra headers

Expand All @@ -81,7 +81,7 @@ def update(
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
return self._put(
f"/zones/{zone_id}/cloud_connector/rules",
body=maybe_transform(body, Iterable[rule_update_params.Body]),
body=maybe_transform(rules, Iterable[rule_update_params.Rule]),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
Expand Down Expand Up @@ -153,7 +153,7 @@ async def update(
self,
*,
zone_id: str,
body: Iterable[rule_update_params.Body],
rules: Iterable[rule_update_params.Rule],
# 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 @@ -167,7 +167,7 @@ async def update(
Args:
zone_id: Identifier

body: List of Cloud Connector rules
rules: List of Cloud Connector rules

extra_headers: Send extra headers

Expand All @@ -181,7 +181,7 @@ async def update(
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
return await self._put(
f"/zones/{zone_id}/cloud_connector/rules",
body=await async_maybe_transform(body, Iterable[rule_update_params.Body]),
body=await async_maybe_transform(rules, Iterable[rule_update_params.Rule]),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
Expand Down
10 changes: 5 additions & 5 deletions src/cloudflare/types/cloud_connector/rule_update_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@
from typing import Iterable
from typing_extensions import Literal, Required, TypedDict

__all__ = ["RuleUpdateParams", "Body", "BodyParameters"]
__all__ = ["RuleUpdateParams", "Rule", "RuleParameters"]


class RuleUpdateParams(TypedDict, total=False):
zone_id: Required[str]
"""Identifier"""

body: Required[Iterable[Body]]
rules: Required[Iterable[Rule]]
"""List of Cloud Connector rules"""


class BodyParameters(TypedDict, total=False):
class RuleParameters(TypedDict, total=False):
host: str
"""Host to perform Cloud Connection to"""


class Body(TypedDict, total=False):
class Rule(TypedDict, total=False):
id: str

description: str
Expand All @@ -30,7 +30,7 @@ class Body(TypedDict, total=False):

expression: str

parameters: BodyParameters
parameters: RuleParameters
"""Parameters of Cloud Connector Rule"""

provider: Literal["aws_s3", "r2", "gcp_storage", "azure_storage"]
Expand Down
16 changes: 8 additions & 8 deletions tests/api_resources/cloud_connector/test_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ class TestRules:
def test_method_update(self, client: Cloudflare) -> None:
rule = client.cloud_connector.rules.update(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
body=[{}],
rules=[{}],
)
assert_matches_type(Optional[RuleUpdateResponse], rule, path=["response"])

@parametrize
def test_raw_response_update(self, client: Cloudflare) -> None:
response = client.cloud_connector.rules.with_raw_response.update(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
body=[{}],
rules=[{}],
)

assert response.is_closed is True
Expand All @@ -42,7 +42,7 @@ def test_raw_response_update(self, client: Cloudflare) -> None:
def test_streaming_response_update(self, client: Cloudflare) -> None:
with client.cloud_connector.rules.with_streaming_response.update(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
body=[{}],
rules=[{}],
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
Expand All @@ -57,7 +57,7 @@ def test_path_params_update(self, client: Cloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
client.cloud_connector.rules.with_raw_response.update(
zone_id="",
body=[{}],
rules=[{}],
)

@parametrize
Expand Down Expand Up @@ -106,15 +106,15 @@ class TestAsyncRules:
async def test_method_update(self, async_client: AsyncCloudflare) -> None:
rule = await async_client.cloud_connector.rules.update(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
body=[{}],
rules=[{}],
)
assert_matches_type(Optional[RuleUpdateResponse], rule, path=["response"])

@parametrize
async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None:
response = await async_client.cloud_connector.rules.with_raw_response.update(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
body=[{}],
rules=[{}],
)

assert response.is_closed is True
Expand All @@ -126,7 +126,7 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None:
async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None:
async with async_client.cloud_connector.rules.with_streaming_response.update(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
body=[{}],
rules=[{}],
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
Expand All @@ -141,7 +141,7 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
await async_client.cloud_connector.rules.with_raw_response.update(
zone_id="",
body=[{}],
rules=[{}],
)

@parametrize
Expand Down