Skip to content

Commit

Permalink
feat(api): api update (#2131)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Nov 7, 2024
1 parent f57867d commit e077e34
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 79 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: 1397
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a139ab241e810768035bd12ba862cd60f33591339da49b4fb8bccb36e012802c.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-cedc346a76dfdf50768c01a48e573dfaeddfe35be8910188d42fe3c5afaaa5bb.yml
8 changes: 5 additions & 3 deletions src/cloudflare/types/firewall/configuration.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import Union
from typing import List, Union
from typing_extensions import TypeAlias

from .lockdown_ip_configuration import LockdownIPConfiguration
from .lockdown_cidr_configuration import LockdownCIDRConfiguration

__all__ = ["Configuration"]
__all__ = ["Configuration", "ConfigurationItem"]

Configuration: TypeAlias = Union[LockdownIPConfiguration, LockdownCIDRConfiguration]
ConfigurationItem: TypeAlias = Union[LockdownIPConfiguration, LockdownCIDRConfiguration]

Configuration: TypeAlias = List[ConfigurationItem]
8 changes: 5 additions & 3 deletions src/cloudflare/types/firewall/configuration_param.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

from __future__ import annotations

from typing import Union
from typing import List, Union
from typing_extensions import TypeAlias

from .lockdown_ip_configuration_param import LockdownIPConfigurationParam
from .lockdown_cidr_configuration_param import LockdownCIDRConfigurationParam

__all__ = ["ConfigurationParam"]
__all__ = ["ConfigurationParam", "ConfigurationParamItem"]

ConfigurationParam: TypeAlias = Union[LockdownIPConfigurationParam, LockdownCIDRConfigurationParam]
ConfigurationParamItem: TypeAlias = Union[LockdownIPConfigurationParam, LockdownCIDRConfigurationParam]

ConfigurationParam: TypeAlias = List[ConfigurationParamItem]
90 changes: 18 additions & 72 deletions tests/api_resources/firewall/test_lockdowns.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,7 @@ class TestLockdowns:
def test_method_create(self, client: Cloudflare) -> None:
lockdown = client.firewall.lockdowns.create(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
configurations={},
urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"],
)
assert_matches_type(Lockdown, lockdown, path=["response"])

@pytest.mark.skip(reason="TODO: investigate broken test")
@parametrize
def test_method_create_with_all_params(self, client: Cloudflare) -> None:
lockdown = client.firewall.lockdowns.create(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
configurations={
"target": "ip",
"value": "198.51.100.4",
},
configurations=[{}, {}, {}],
urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"],
)
assert_matches_type(Lockdown, lockdown, path=["response"])
Expand All @@ -50,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None:
def test_raw_response_create(self, client: Cloudflare) -> None:
response = client.firewall.lockdowns.with_raw_response.create(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
configurations={},
configurations=[{}, {}, {}],
urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"],
)

Expand All @@ -64,7 +51,7 @@ def test_raw_response_create(self, client: Cloudflare) -> None:
def test_streaming_response_create(self, client: Cloudflare) -> None:
with client.firewall.lockdowns.with_streaming_response.create(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
configurations={},
configurations=[{}, {}, {}],
urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"],
) as response:
assert not response.is_closed
Expand All @@ -81,7 +68,7 @@ def test_path_params_create(self, client: Cloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
client.firewall.lockdowns.with_raw_response.create(
zone_id="",
configurations={},
configurations=[{}, {}, {}],
urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"],
)

Expand All @@ -91,21 +78,7 @@ def test_method_update(self, client: Cloudflare) -> None:
lockdown = client.firewall.lockdowns.update(
lock_downs_id="372e67954025e0ba6aaa6d586b9e0b59",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
configurations={},
urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"],
)
assert_matches_type(Lockdown, lockdown, path=["response"])

@pytest.mark.skip(reason="TODO: investigate broken test")
@parametrize
def test_method_update_with_all_params(self, client: Cloudflare) -> None:
lockdown = client.firewall.lockdowns.update(
lock_downs_id="372e67954025e0ba6aaa6d586b9e0b59",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
configurations={
"target": "ip",
"value": "198.51.100.4",
},
configurations=[{}, {}, {}],
urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"],
)
assert_matches_type(Lockdown, lockdown, path=["response"])
Expand All @@ -116,7 +89,7 @@ def test_raw_response_update(self, client: Cloudflare) -> None:
response = client.firewall.lockdowns.with_raw_response.update(
lock_downs_id="372e67954025e0ba6aaa6d586b9e0b59",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
configurations={},
configurations=[{}, {}, {}],
urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"],
)

Expand All @@ -131,7 +104,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None:
with client.firewall.lockdowns.with_streaming_response.update(
lock_downs_id="372e67954025e0ba6aaa6d586b9e0b59",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
configurations={},
configurations=[{}, {}, {}],
urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"],
) as response:
assert not response.is_closed
Expand All @@ -149,15 +122,15 @@ def test_path_params_update(self, client: Cloudflare) -> None:
client.firewall.lockdowns.with_raw_response.update(
lock_downs_id="372e67954025e0ba6aaa6d586b9e0b59",
zone_id="",
configurations={},
configurations=[{}, {}, {}],
urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"],
)

with pytest.raises(ValueError, match=r"Expected a non-empty value for `lock_downs_id` but received ''"):
client.firewall.lockdowns.with_raw_response.update(
lock_downs_id="",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
configurations={},
configurations=[{}, {}, {}],
urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"],
)

Expand Down Expand Up @@ -322,20 +295,7 @@ class TestAsyncLockdowns:
async def test_method_create(self, async_client: AsyncCloudflare) -> None:
lockdown = await async_client.firewall.lockdowns.create(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
configurations={},
urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"],
)
assert_matches_type(Lockdown, lockdown, path=["response"])

@pytest.mark.skip(reason="TODO: investigate broken test")
@parametrize
async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None:
lockdown = await async_client.firewall.lockdowns.create(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
configurations={
"target": "ip",
"value": "198.51.100.4",
},
configurations=[{}, {}, {}],
urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"],
)
assert_matches_type(Lockdown, lockdown, path=["response"])
Expand All @@ -345,7 +305,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare
async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None:
response = await async_client.firewall.lockdowns.with_raw_response.create(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
configurations={},
configurations=[{}, {}, {}],
urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"],
)

Expand All @@ -359,7 +319,7 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None:
async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None:
async with async_client.firewall.lockdowns.with_streaming_response.create(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
configurations={},
configurations=[{}, {}, {}],
urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"],
) as response:
assert not response.is_closed
Expand All @@ -376,7 +336,7 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
await async_client.firewall.lockdowns.with_raw_response.create(
zone_id="",
configurations={},
configurations=[{}, {}, {}],
urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"],
)

Expand All @@ -386,21 +346,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None:
lockdown = await async_client.firewall.lockdowns.update(
lock_downs_id="372e67954025e0ba6aaa6d586b9e0b59",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
configurations={},
urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"],
)
assert_matches_type(Lockdown, lockdown, path=["response"])

@pytest.mark.skip(reason="TODO: investigate broken test")
@parametrize
async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None:
lockdown = await async_client.firewall.lockdowns.update(
lock_downs_id="372e67954025e0ba6aaa6d586b9e0b59",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
configurations={
"target": "ip",
"value": "198.51.100.4",
},
configurations=[{}, {}, {}],
urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"],
)
assert_matches_type(Lockdown, lockdown, path=["response"])
Expand All @@ -411,7 +357,7 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None:
response = await async_client.firewall.lockdowns.with_raw_response.update(
lock_downs_id="372e67954025e0ba6aaa6d586b9e0b59",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
configurations={},
configurations=[{}, {}, {}],
urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"],
)

Expand All @@ -426,7 +372,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) ->
async with async_client.firewall.lockdowns.with_streaming_response.update(
lock_downs_id="372e67954025e0ba6aaa6d586b9e0b59",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
configurations={},
configurations=[{}, {}, {}],
urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"],
) as response:
assert not response.is_closed
Expand All @@ -444,15 +390,15 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None:
await async_client.firewall.lockdowns.with_raw_response.update(
lock_downs_id="372e67954025e0ba6aaa6d586b9e0b59",
zone_id="",
configurations={},
configurations=[{}, {}, {}],
urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"],
)

with pytest.raises(ValueError, match=r"Expected a non-empty value for `lock_downs_id` but received ''"):
await async_client.firewall.lockdowns.with_raw_response.update(
lock_downs_id="",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
configurations={},
configurations=[{}, {}, {}],
urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"],
)

Expand Down

0 comments on commit e077e34

Please sign in to comment.