Skip to content

Commit 7b8b1df

Browse files
feat(list_item): remove duplicated anyOf properties from component (#2342)
1 parent 12c54fe commit 7b8b1df

File tree

4 files changed

+30
-126
lines changed

4 files changed

+30
-126
lines changed

.stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 1490
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-6eed6659daa87db188a6095d59dbc3f6a84c1f63ca4e1b958283301d61cb16e5.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-403275b7baabda647cf36b6e08211b6ea4aa63c6b547124bbc0eb377330f623a.yml

src/cloudflare/resources/rules/lists/items.py

+21-31
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from typing import Any, Type, Iterable, cast
5+
from typing import Type, Iterable, cast
66

77
import httpx
88

@@ -219,7 +219,7 @@ def list(
219219
item_list_params.ItemListParams,
220220
),
221221
),
222-
model=cast(Any, ItemListResponse), # Union types cannot be passed in as arguments in the type system
222+
model=ItemListResponse,
223223
)
224224

225225
def delete(
@@ -308,21 +308,16 @@ def get(
308308
raise ValueError(f"Expected a non-empty value for `list_id` but received {list_id!r}")
309309
if not item_id:
310310
raise ValueError(f"Expected a non-empty value for `item_id` but received {item_id!r}")
311-
return cast(
312-
ItemGetResponse,
313-
self._get(
314-
f"/accounts/{account_identifier}/rules/lists/{list_id}/items/{item_id}",
315-
options=make_request_options(
316-
extra_headers=extra_headers,
317-
extra_query=extra_query,
318-
extra_body=extra_body,
319-
timeout=timeout,
320-
post_parser=ResultWrapper[ItemGetResponse]._unwrapper,
321-
),
322-
cast_to=cast(
323-
Any, ResultWrapper[ItemGetResponse]
324-
), # Union types cannot be passed in as arguments in the type system
311+
return self._get(
312+
f"/accounts/{account_identifier}/rules/lists/{list_id}/items/{item_id}",
313+
options=make_request_options(
314+
extra_headers=extra_headers,
315+
extra_query=extra_query,
316+
extra_body=extra_body,
317+
timeout=timeout,
318+
post_parser=ResultWrapper[ItemGetResponse]._unwrapper,
325319
),
320+
cast_to=cast(Type[ItemGetResponse], ResultWrapper[ItemGetResponse]),
326321
)
327322

328323

@@ -513,7 +508,7 @@ def list(
513508
item_list_params.ItemListParams,
514509
),
515510
),
516-
model=cast(Any, ItemListResponse), # Union types cannot be passed in as arguments in the type system
511+
model=ItemListResponse,
517512
)
518513

519514
async def delete(
@@ -602,21 +597,16 @@ async def get(
602597
raise ValueError(f"Expected a non-empty value for `list_id` but received {list_id!r}")
603598
if not item_id:
604599
raise ValueError(f"Expected a non-empty value for `item_id` but received {item_id!r}")
605-
return cast(
606-
ItemGetResponse,
607-
await self._get(
608-
f"/accounts/{account_identifier}/rules/lists/{list_id}/items/{item_id}",
609-
options=make_request_options(
610-
extra_headers=extra_headers,
611-
extra_query=extra_query,
612-
extra_body=extra_body,
613-
timeout=timeout,
614-
post_parser=ResultWrapper[ItemGetResponse]._unwrapper,
615-
),
616-
cast_to=cast(
617-
Any, ResultWrapper[ItemGetResponse]
618-
), # Union types cannot be passed in as arguments in the type system
600+
return await self._get(
601+
f"/accounts/{account_identifier}/rules/lists/{list_id}/items/{item_id}",
602+
options=make_request_options(
603+
extra_headers=extra_headers,
604+
extra_query=extra_query,
605+
extra_body=extra_body,
606+
timeout=timeout,
607+
post_parser=ResultWrapper[ItemGetResponse]._unwrapper,
619608
),
609+
cast_to=cast(Type[ItemGetResponse], ResultWrapper[ItemGetResponse]),
620610
)
621611

622612

Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
from typing import Union, Optional
4-
from typing_extensions import TypeAlias
3+
from typing import Optional
54

65
from ..hostname import Hostname
76
from ..redirect import Redirect
7+
from ...._models import BaseModel
88

9-
__all__ = ["ItemGetResponse", "UnionMember0", "RulesListsRedirect", "RulesListsHostname", "UnionMember3"]
9+
__all__ = ["ItemGetResponse"]
1010

1111

12-
class UnionMember0:
13-
pass
14-
15-
16-
class RulesListsRedirect(Redirect):
12+
class ItemGetResponse(BaseModel):
1713
id: Optional[str] = None
1814
"""The unique ID of the list."""
1915

@@ -43,42 +39,3 @@ class RulesListsRedirect(Redirect):
4339

4440
redirect: Optional[Redirect] = None
4541
"""The definition of the redirect."""
46-
47-
48-
class RulesListsHostname(Hostname):
49-
id: Optional[str] = None
50-
"""The unique ID of the list."""
51-
52-
asn: Optional[int] = None
53-
"""A non-negative 32 bit integer"""
54-
55-
comment: Optional[str] = None
56-
"""An informative summary of the list item."""
57-
58-
created_on: Optional[str] = None
59-
"""The RFC 3339 timestamp of when the item was created."""
60-
61-
hostname: Optional[Hostname] = None
62-
"""
63-
Valid characters for hostnames are ASCII(7) letters from a to z, the digits from
64-
0 to 9, wildcards (\\**), and the hyphen (-).
65-
"""
66-
67-
ip: Optional[str] = None
68-
"""An IPv4 address, an IPv4 CIDR, or an IPv6 CIDR.
69-
70-
IPv6 CIDRs are limited to a maximum of /64.
71-
"""
72-
73-
modified_on: Optional[str] = None
74-
"""The RFC 3339 timestamp of when the item was last modified."""
75-
76-
redirect: Optional[Redirect] = None
77-
"""The definition of the redirect."""
78-
79-
80-
class UnionMember3:
81-
pass
82-
83-
84-
ItemGetResponse: TypeAlias = Union[UnionMember0, RulesListsRedirect, RulesListsHostname, UnionMember3]
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
from typing import Union, Optional
4-
from typing_extensions import TypeAlias
3+
from typing import Optional
54

65
from ..hostname import Hostname
76
from ..redirect import Redirect
7+
from ...._models import BaseModel
88

9-
__all__ = ["ItemListResponse", "UnionMember0", "RulesListsRedirect", "RulesListsHostname", "UnionMember3"]
9+
__all__ = ["ItemListResponse"]
1010

1111

12-
class UnionMember0:
13-
pass
14-
15-
16-
class RulesListsRedirect(Redirect):
12+
class ItemListResponse(BaseModel):
1713
id: Optional[str] = None
1814
"""The unique ID of the list."""
1915

@@ -43,42 +39,3 @@ class RulesListsRedirect(Redirect):
4339

4440
redirect: Optional[Redirect] = None
4541
"""The definition of the redirect."""
46-
47-
48-
class RulesListsHostname(Hostname):
49-
id: Optional[str] = None
50-
"""The unique ID of the list."""
51-
52-
asn: Optional[int] = None
53-
"""A non-negative 32 bit integer"""
54-
55-
comment: Optional[str] = None
56-
"""An informative summary of the list item."""
57-
58-
created_on: Optional[str] = None
59-
"""The RFC 3339 timestamp of when the item was created."""
60-
61-
hostname: Optional[Hostname] = None
62-
"""
63-
Valid characters for hostnames are ASCII(7) letters from a to z, the digits from
64-
0 to 9, wildcards (\\**), and the hyphen (-).
65-
"""
66-
67-
ip: Optional[str] = None
68-
"""An IPv4 address, an IPv4 CIDR, or an IPv6 CIDR.
69-
70-
IPv6 CIDRs are limited to a maximum of /64.
71-
"""
72-
73-
modified_on: Optional[str] = None
74-
"""The RFC 3339 timestamp of when the item was last modified."""
75-
76-
redirect: Optional[Redirect] = None
77-
"""The definition of the redirect."""
78-
79-
80-
class UnionMember3:
81-
pass
82-
83-
84-
ItemListResponse: TypeAlias = Union[UnionMember0, RulesListsRedirect, RulesListsHostname, UnionMember3]

0 commit comments

Comments
 (0)