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

fix(waiting_room_rules): define body_param_name for bulk rules endpoint #2139

Merged
merged 1 commit into from
Nov 12, 2024
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
54 changes: 8 additions & 46 deletions src/cloudflare/resources/waiting_rooms/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,7 @@ def create(
waiting_room_id: str,
*,
zone_id: str,
action: Literal["bypass_waiting_room"],
expression: str,
description: str | NotGiven = NOT_GIVEN,
enabled: bool | NotGiven = NOT_GIVEN,
rules: rule_create_params.Rules,
# 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 @@ -76,14 +73,6 @@ def create(
Args:
zone_id: Identifier

action: The action to take when the expression matches.

expression: Criteria defining when there is a match for the current rule.

description: The description of the rule.

enabled: When set to true, the rule is enabled.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand All @@ -98,15 +87,7 @@ def create(
raise ValueError(f"Expected a non-empty value for `waiting_room_id` but received {waiting_room_id!r}")
return self._post(
f"/zones/{zone_id}/waiting_rooms/{waiting_room_id}/rules",
body=maybe_transform(
{
"action": action,
"expression": expression,
"description": description,
"enabled": enabled,
},
rule_create_params.RuleCreateParams,
),
body=maybe_transform(rules, rule_create_params.RuleCreateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
Expand All @@ -122,7 +103,7 @@ def update(
waiting_room_id: str,
*,
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 Down Expand Up @@ -152,7 +133,7 @@ def update(
raise ValueError(f"Expected a non-empty value for `waiting_room_id` but received {waiting_room_id!r}")
return self._put(
f"/zones/{zone_id}/waiting_rooms/{waiting_room_id}/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 @@ -350,10 +331,7 @@ async def create(
waiting_room_id: str,
*,
zone_id: str,
action: Literal["bypass_waiting_room"],
expression: str,
description: str | NotGiven = NOT_GIVEN,
enabled: bool | NotGiven = NOT_GIVEN,
rules: rule_create_params.Rules,
# 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 @@ -369,14 +347,6 @@ async def create(
Args:
zone_id: Identifier

action: The action to take when the expression matches.

expression: Criteria defining when there is a match for the current rule.

description: The description of the rule.

enabled: When set to true, the rule is enabled.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand All @@ -391,15 +361,7 @@ async def create(
raise ValueError(f"Expected a non-empty value for `waiting_room_id` but received {waiting_room_id!r}")
return await self._post(
f"/zones/{zone_id}/waiting_rooms/{waiting_room_id}/rules",
body=await async_maybe_transform(
{
"action": action,
"expression": expression,
"description": description,
"enabled": enabled,
},
rule_create_params.RuleCreateParams,
),
body=await async_maybe_transform(rules, rule_create_params.RuleCreateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
Expand All @@ -415,7 +377,7 @@ async def update(
waiting_room_id: str,
*,
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 Down Expand Up @@ -445,7 +407,7 @@ async def update(
raise ValueError(f"Expected a non-empty value for `waiting_room_id` but received {waiting_room_id!r}")
return await self._put(
f"/zones/{zone_id}/waiting_rooms/{waiting_room_id}/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
6 changes: 5 additions & 1 deletion src/cloudflare/types/waiting_rooms/rule_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@

from typing_extensions import Literal, Required, TypedDict

__all__ = ["RuleCreateParams"]
__all__ = ["RuleCreateParams", "Rules"]


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

rules: Required[Rules]


class Rules(TypedDict, total=False):
action: Required[Literal["bypass_waiting_room"]]
"""The action to take when the expression matches."""

Expand Down
6 changes: 3 additions & 3 deletions src/cloudflare/types/waiting_rooms/rule_update_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
from typing import Iterable
from typing_extensions import Literal, Required, TypedDict

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


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

body: Required[Iterable[Body]]
rules: Required[Iterable[Rule]]


class Body(TypedDict, total=False):
class Rule(TypedDict, total=False):
action: Required[Literal["bypass_waiting_room"]]
"""The action to take when the expression matches."""

Expand Down
Loading