Skip to content

feat: OpenAPI spec update via Stainless API #76

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

Merged
merged 1 commit into from
Feb 29, 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
4 changes: 2 additions & 2 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2370,7 +2370,7 @@ Methods:
- <code title="post /{account_or_zone}/{account_or_zone_id}/firewall/access_rules/rules">client.firewall.access_rules.<a href="./src/cloudflare/resources/firewall/access_rules.py">create</a>(\*, account_id, zone_id, \*\*<a href="src/cloudflare/types/firewall/access_rule_create_params.py">params</a>) -> <a href="./src/cloudflare/types/firewall/access_rule_create_response.py">Optional</a></code>
- <code title="get /{account_or_zone}/{account_or_zone_id}/firewall/access_rules/rules">client.firewall.access_rules.<a href="./src/cloudflare/resources/firewall/access_rules.py">list</a>(\*, account_id, zone_id, \*\*<a href="src/cloudflare/types/firewall/access_rule_list_params.py">params</a>) -> <a href="./src/cloudflare/types/firewall/access_rule_list_response.py">SyncV4PagePaginationArray[object]</a></code>
- <code title="delete /{account_or_zone}/{account_or_zone_id}/firewall/access_rules/rules/{identifier}">client.firewall.access_rules.<a href="./src/cloudflare/resources/firewall/access_rules.py">delete</a>(identifier, \*, account_id, zone_id) -> <a href="./src/cloudflare/types/firewall/access_rule_delete_response.py">Optional</a></code>
- <code title="patch /{account_or_zone}/{account_or_zone_id}/firewall/access_rules/rules/{identifier}">client.firewall.access_rules.<a href="./src/cloudflare/resources/firewall/access_rules.py">edit</a>(identifier, \*, account_identifier, \*\*<a href="src/cloudflare/types/firewall/access_rule_edit_params.py">params</a>) -> <a href="./src/cloudflare/types/firewall/access_rule_edit_response.py">Optional</a></code>
- <code title="patch /{account_or_zone}/{account_or_zone_id}/firewall/access_rules/rules/{identifier}">client.firewall.access_rules.<a href="./src/cloudflare/resources/firewall/access_rules.py">edit</a>(identifier, \*, account_id, zone_id, \*\*<a href="src/cloudflare/types/firewall/access_rule_edit_params.py">params</a>) -> <a href="./src/cloudflare/types/firewall/access_rule_edit_response.py">Optional</a></code>
- <code title="get /{account_or_zone}/{account_or_zone_id}/firewall/access_rules/rules/{identifier}">client.firewall.access_rules.<a href="./src/cloudflare/resources/firewall/access_rules.py">get</a>(identifier, \*, account_id, zone_id) -> <a href="./src/cloudflare/types/firewall/access_rule_get_response.py">Optional</a></code>

## UARules
Expand Down Expand Up @@ -3660,7 +3660,7 @@ Methods:

- <code title="post /{account_or_zone}/{account_or_zone_id}/rulesets/{ruleset_id}/rules">client.rulesets.rules.<a href="./src/cloudflare/resources/rulesets/rules.py">create</a>(ruleset_id, \*, account_id, zone_id, \*\*<a href="src/cloudflare/types/rulesets/rule_create_params.py">params</a>) -> <a href="./src/cloudflare/types/rulesets/rule_create_response.py">RuleCreateResponse</a></code>
- <code title="delete /{account_or_zone}/{account_or_zone_id}/rulesets/{ruleset_id}/rules/{rule_id}">client.rulesets.rules.<a href="./src/cloudflare/resources/rulesets/rules.py">delete</a>(rule_id, \*, account_id, zone_id, ruleset_id) -> <a href="./src/cloudflare/types/rulesets/rule_delete_response.py">RuleDeleteResponse</a></code>
- <code title="patch /{account_or_zone}/{account_or_zone_id}/rulesets/{ruleset_id}/rules/{rule_id}">client.rulesets.rules.<a href="./src/cloudflare/resources/rulesets/rules.py">edit</a>(rule_id, \*, account_id, ruleset_id, \*\*<a href="src/cloudflare/types/rulesets/rule_edit_params.py">params</a>) -> <a href="./src/cloudflare/types/rulesets/rule_edit_response.py">RuleEditResponse</a></code>
- <code title="patch /{account_or_zone}/{account_or_zone_id}/rulesets/{ruleset_id}/rules/{rule_id}">client.rulesets.rules.<a href="./src/cloudflare/resources/rulesets/rules.py">edit</a>(rule_id, \*, account_id, zone_id, ruleset_id, \*\*<a href="src/cloudflare/types/rulesets/rule_edit_params.py">params</a>) -> <a href="./src/cloudflare/types/rulesets/rule_edit_response.py">RuleEditResponse</a></code>

## Versions

Expand Down
26 changes: 22 additions & 4 deletions src/cloudflare/resources/firewall/access_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ def edit(
self,
identifier: object,
*,
account_identifier: object,
account_id: str,
zone_id: str,
configuration: access_rule_edit_params.Configuration,
mode: Literal["block", "challenge", "whitelist", "js_challenge", "managed_challenge"],
notes: str | NotGiven = NOT_GIVEN,
Expand All @@ -256,6 +257,10 @@ def edit(
Note: This operation will affect all zones in the account.

Args:
account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.

zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.

configuration: The rule configuration.

mode: The action to apply to a matched request.
Expand All @@ -270,10 +275,14 @@ def edit(

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 zone_id:
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
return cast(
Optional[AccessRuleEditResponse],
self._patch(
f"/{account_identifier}/{identifier}/firewall/access_rules/rules/:identifier",
f"/{account_id}/{zone_id}/firewall/access_rules/rules/{identifier}",
body=maybe_transform(
{
"configuration": configuration,
Expand Down Expand Up @@ -549,7 +558,8 @@ async def edit(
self,
identifier: object,
*,
account_identifier: object,
account_id: str,
zone_id: str,
configuration: access_rule_edit_params.Configuration,
mode: Literal["block", "challenge", "whitelist", "js_challenge", "managed_challenge"],
notes: str | NotGiven = NOT_GIVEN,
Expand All @@ -566,6 +576,10 @@ async def edit(
Note: This operation will affect all zones in the account.

Args:
account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.

zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.

configuration: The rule configuration.

mode: The action to apply to a matched request.
Expand All @@ -580,10 +594,14 @@ async def edit(

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 zone_id:
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
return cast(
Optional[AccessRuleEditResponse],
await self._patch(
f"/{account_identifier}/{identifier}/firewall/access_rules/rules/:identifier",
f"/{account_id}/{zone_id}/firewall/access_rules/rules/{identifier}",
body=maybe_transform(
{
"configuration": configuration,
Expand Down
18 changes: 14 additions & 4 deletions src/cloudflare/resources/rulesets/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ def edit(
rule_id: str,
*,
account_id: str,
zone_id: str,
ruleset_id: str,
position: rule_edit_params.Position | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
Expand All @@ -167,7 +168,9 @@ def edit(
Updates an existing rule in an account ruleset.

Args:
account_id: The unique ID of the account.
account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.

zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.

ruleset_id: The unique ID of the ruleset.

Expand All @@ -185,12 +188,14 @@ def edit(
"""
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
if not zone_id:
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
if not ruleset_id:
raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}")
if not rule_id:
raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}")
return self._patch(
f"/{account_id}/{ruleset_id}/rulesets/{rule_id}/rules/:rule_id",
f"/{account_id}/{zone_id}/rulesets/{ruleset_id}/rules/{rule_id}",
body=maybe_transform({"position": position}, rule_edit_params.RuleEditParams),
options=make_request_options(
extra_headers=extra_headers,
Expand Down Expand Up @@ -326,6 +331,7 @@ async def edit(
rule_id: str,
*,
account_id: str,
zone_id: str,
ruleset_id: str,
position: rule_edit_params.Position | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
Expand All @@ -339,7 +345,9 @@ async def edit(
Updates an existing rule in an account ruleset.

Args:
account_id: The unique ID of the account.
account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.

zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.

ruleset_id: The unique ID of the ruleset.

Expand All @@ -357,12 +365,14 @@ async def edit(
"""
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
if not zone_id:
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
if not ruleset_id:
raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}")
if not rule_id:
raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}")
return await self._patch(
f"/{account_id}/{ruleset_id}/rulesets/{rule_id}/rules/:rule_id",
f"/{account_id}/{zone_id}/rulesets/{ruleset_id}/rules/{rule_id}",
body=maybe_transform({"position": position}, rule_edit_params.RuleEditParams),
options=make_request_options(
extra_headers=extra_headers,
Expand Down
6 changes: 5 additions & 1 deletion src/cloudflare/types/firewall/access_rule_edit_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@


class AccessRuleEditParams(TypedDict, total=False):
account_identifier: Required[object]
account_id: Required[str]
"""The Account ID to use for this endpoint. Mutually exclusive with the Zone ID."""

zone_id: Required[str]
"""The Zone ID to use for this endpoint. Mutually exclusive with the Account ID."""

configuration: Required[Configuration]
"""The rule configuration."""
Expand Down
5 changes: 4 additions & 1 deletion src/cloudflare/types/rulesets/rule_edit_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@

class RuleEditParams(TypedDict, total=False):
account_id: Required[str]
"""The unique ID of the account."""
"""The Account ID to use for this endpoint. Mutually exclusive with the Zone ID."""

zone_id: Required[str]
"""The Zone ID to use for this endpoint. Mutually exclusive with the Account ID."""

ruleset_id: Required[str]
"""The unique ID of the ruleset."""
Expand Down
66 changes: 58 additions & 8 deletions tests/api_resources/firewall/test_access_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,8 @@ def test_path_params_delete(self, client: Cloudflare) -> None:
def test_method_edit(self, client: Cloudflare) -> None:
access_rule = client.firewall.access_rules.edit(
{},
account_identifier={},
account_id="string",
zone_id="string",
configuration={},
mode="challenge",
)
Expand All @@ -251,7 +252,8 @@ def test_method_edit(self, client: Cloudflare) -> None:
def test_method_edit_with_all_params(self, client: Cloudflare) -> None:
access_rule = client.firewall.access_rules.edit(
{},
account_identifier={},
account_id="string",
zone_id="string",
configuration={
"target": "ip",
"value": "198.51.100.4",
Expand All @@ -266,7 +268,8 @@ def test_method_edit_with_all_params(self, client: Cloudflare) -> None:
def test_raw_response_edit(self, client: Cloudflare) -> None:
response = client.firewall.access_rules.with_raw_response.edit(
{},
account_identifier={},
account_id="string",
zone_id="string",
configuration={},
mode="challenge",
)
Expand All @@ -281,7 +284,8 @@ def test_raw_response_edit(self, client: Cloudflare) -> None:
def test_streaming_response_edit(self, client: Cloudflare) -> None:
with client.firewall.access_rules.with_streaming_response.edit(
{},
account_identifier={},
account_id="string",
zone_id="string",
configuration={},
mode="challenge",
) as response:
Expand All @@ -293,6 +297,27 @@ def test_streaming_response_edit(self, client: Cloudflare) -> None:

assert cast(Any, response.is_closed) is True

@pytest.mark.skip()
@parametrize
def test_path_params_edit(self, client: Cloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
client.firewall.access_rules.with_raw_response.edit(
{},
account_id="",
zone_id="string",
configuration={},
mode="challenge",
)

with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
client.firewall.access_rules.with_raw_response.edit(
{},
account_id="string",
zone_id="",
configuration={},
mode="challenge",
)

@pytest.mark.skip()
@parametrize
def test_method_get(self, client: Cloudflare) -> None:
Expand Down Expand Up @@ -571,7 +596,8 @@ async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None:
async def test_method_edit(self, async_client: AsyncCloudflare) -> None:
access_rule = await async_client.firewall.access_rules.edit(
{},
account_identifier={},
account_id="string",
zone_id="string",
configuration={},
mode="challenge",
)
Expand All @@ -582,7 +608,8 @@ async def test_method_edit(self, async_client: AsyncCloudflare) -> None:
async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None:
access_rule = await async_client.firewall.access_rules.edit(
{},
account_identifier={},
account_id="string",
zone_id="string",
configuration={
"target": "ip",
"value": "198.51.100.4",
Expand All @@ -597,7 +624,8 @@ async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare)
async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None:
response = await async_client.firewall.access_rules.with_raw_response.edit(
{},
account_identifier={},
account_id="string",
zone_id="string",
configuration={},
mode="challenge",
)
Expand All @@ -612,7 +640,8 @@ async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None:
async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None:
async with async_client.firewall.access_rules.with_streaming_response.edit(
{},
account_identifier={},
account_id="string",
zone_id="string",
configuration={},
mode="challenge",
) as response:
Expand All @@ -624,6 +653,27 @@ async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> N

assert cast(Any, response.is_closed) is True

@pytest.mark.skip()
@parametrize
async def test_path_params_edit(self, async_client: AsyncCloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
await async_client.firewall.access_rules.with_raw_response.edit(
{},
account_id="",
zone_id="string",
configuration={},
mode="challenge",
)

with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
await async_client.firewall.access_rules.with_raw_response.edit(
{},
account_id="string",
zone_id="",
configuration={},
mode="challenge",
)

@pytest.mark.skip()
@parametrize
async def test_method_get(self, async_client: AsyncCloudflare) -> None:
Expand Down
Loading