Skip to content

Commit 06da30c

Browse files
feat: Merge branch 'mingwei/BGP-418' into 'main'
feat: add Radar AS-SET lookup endpoint API docs Closes BGP-418 See merge request cloudflare/sdks/cloudflare-config!139
1 parent c4ed3df commit 06da30c

7 files changed

Lines changed: 230 additions & 3 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 1811
1+
configured_endpoints: 1812
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ccaf8367d55e99438b6a6f626a329882a58479d38acd63194e45d06a77451be1.yml
33
openapi_spec_hash: 53e2bb09eb6d7a3e927d0ee63a28815e
4-
config_hash: 13d4a964ecc36ea611888df92272c3da
4+
config_hash: 08d1e85e3d6166780e91482de72fa93c

api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8205,6 +8205,7 @@ Types:
82058205
```python
82068206
from cloudflare.types.radar.entities import (
82078207
ASNListResponse,
8208+
ASNAsSetResponse,
82088209
ASNGetResponse,
82098210
ASNIPResponse,
82108211
ASNRelResponse,
@@ -8214,6 +8215,7 @@ from cloudflare.types.radar.entities import (
82148215
Methods:
82158216

82168217
- <code title="get /radar/entities/asns">client.radar.entities.asns.<a href="./src/cloudflare/resources/radar/entities/asns.py">list</a>(\*\*<a href="src/cloudflare/types/radar/entities/asn_list_params.py">params</a>) -> <a href="./src/cloudflare/types/radar/entities/asn_list_response.py">ASNListResponse</a></code>
8218+
- <code title="get /radar/entities/asns/{asn}/as_set">client.radar.entities.asns.<a href="./src/cloudflare/resources/radar/entities/asns.py">as_set</a>(asn, \*\*<a href="src/cloudflare/types/radar/entities/asn_as_set_params.py">params</a>) -> <a href="./src/cloudflare/types/radar/entities/asn_as_set_response.py">ASNAsSetResponse</a></code>
82178219
- <code title="get /radar/entities/asns/{asn}">client.radar.entities.asns.<a href="./src/cloudflare/resources/radar/entities/asns.py">get</a>(asn, \*\*<a href="src/cloudflare/types/radar/entities/asn_get_params.py">params</a>) -> <a href="./src/cloudflare/types/radar/entities/asn_get_response.py">ASNGetResponse</a></code>
82188220
- <code title="get /radar/entities/asns/ip">client.radar.entities.asns.<a href="./src/cloudflare/resources/radar/entities/asns.py">ip</a>(\*\*<a href="src/cloudflare/types/radar/entities/asn_ip_params.py">params</a>) -> <a href="./src/cloudflare/types/radar/entities/asn_ip_response.py">ASNIPResponse</a></code>
82198221
- <code title="get /radar/entities/asns/{asn}/rel">client.radar.entities.asns.<a href="./src/cloudflare/resources/radar/entities/asns.py">rel</a>(asn, \*\*<a href="src/cloudflare/types/radar/entities/asn_rel_params.py">params</a>) -> <a href="./src/cloudflare/types/radar/entities/asn_rel_response.py">ASNRelResponse</a></code>

src/cloudflare/resources/radar/entities/asns.py

Lines changed: 96 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@
1919
)
2020
from ...._wrappers import ResultWrapper
2121
from ...._base_client import make_request_options
22-
from ....types.radar.entities import asn_ip_params, asn_get_params, asn_rel_params, asn_list_params
22+
from ....types.radar.entities import asn_ip_params, asn_get_params, asn_rel_params, asn_list_params, asn_as_set_params
2323
from ....types.radar.entities.asn_ip_response import ASNIPResponse
2424
from ....types.radar.entities.asn_get_response import ASNGetResponse
2525
from ....types.radar.entities.asn_rel_response import ASNRelResponse
2626
from ....types.radar.entities.asn_list_response import ASNListResponse
27+
from ....types.radar.entities.asn_as_set_response import ASNAsSetResponse
2728

2829
__all__ = ["ASNsResource", "AsyncASNsResource"]
2930

@@ -112,6 +113,47 @@ def list(
112113
cast_to=cast(Type[ASNListResponse], ResultWrapper[ASNListResponse]),
113114
)
114115

116+
def as_set(
117+
self,
118+
asn: int,
119+
*,
120+
format: Literal["JSON", "CSV"] | Omit = omit,
121+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
122+
# The extra values given here take precedence over values defined on the client or passed to this method.
123+
extra_headers: Headers | None = None,
124+
extra_query: Query | None = None,
125+
extra_body: Body | None = None,
126+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
127+
) -> ASNAsSetResponse:
128+
"""
129+
Retrieves Internet Routing Registry AS-SETs that an AS is a member of.
130+
131+
Args:
132+
asn: Retrieves all AS-SETs that the given AS is a member of.
133+
134+
format: Format in which results will be returned.
135+
136+
extra_headers: Send extra headers
137+
138+
extra_query: Add additional query parameters to the request
139+
140+
extra_body: Add additional JSON properties to the request
141+
142+
timeout: Override the client-level default timeout for this request, in seconds
143+
"""
144+
return self._get(
145+
f"/radar/entities/asns/{asn}/as_set",
146+
options=make_request_options(
147+
extra_headers=extra_headers,
148+
extra_query=extra_query,
149+
extra_body=extra_body,
150+
timeout=timeout,
151+
query=maybe_transform({"format": format}, asn_as_set_params.ASNAsSetParams),
152+
post_parser=ResultWrapper[ASNAsSetResponse]._unwrapper,
153+
),
154+
cast_to=cast(Type[ASNAsSetResponse], ResultWrapper[ASNAsSetResponse]),
155+
)
156+
115157
def get(
116158
self,
117159
asn: int,
@@ -341,6 +383,47 @@ async def list(
341383
cast_to=cast(Type[ASNListResponse], ResultWrapper[ASNListResponse]),
342384
)
343385

386+
async def as_set(
387+
self,
388+
asn: int,
389+
*,
390+
format: Literal["JSON", "CSV"] | Omit = omit,
391+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
392+
# The extra values given here take precedence over values defined on the client or passed to this method.
393+
extra_headers: Headers | None = None,
394+
extra_query: Query | None = None,
395+
extra_body: Body | None = None,
396+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
397+
) -> ASNAsSetResponse:
398+
"""
399+
Retrieves Internet Routing Registry AS-SETs that an AS is a member of.
400+
401+
Args:
402+
asn: Retrieves all AS-SETs that the given AS is a member of.
403+
404+
format: Format in which results will be returned.
405+
406+
extra_headers: Send extra headers
407+
408+
extra_query: Add additional query parameters to the request
409+
410+
extra_body: Add additional JSON properties to the request
411+
412+
timeout: Override the client-level default timeout for this request, in seconds
413+
"""
414+
return await self._get(
415+
f"/radar/entities/asns/{asn}/as_set",
416+
options=make_request_options(
417+
extra_headers=extra_headers,
418+
extra_query=extra_query,
419+
extra_body=extra_body,
420+
timeout=timeout,
421+
query=await async_maybe_transform({"format": format}, asn_as_set_params.ASNAsSetParams),
422+
post_parser=ResultWrapper[ASNAsSetResponse]._unwrapper,
423+
),
424+
cast_to=cast(Type[ASNAsSetResponse], ResultWrapper[ASNAsSetResponse]),
425+
)
426+
344427
async def get(
345428
self,
346429
asn: int,
@@ -493,6 +576,9 @@ def __init__(self, asns: ASNsResource) -> None:
493576
self.list = to_raw_response_wrapper(
494577
asns.list,
495578
)
579+
self.as_set = to_raw_response_wrapper(
580+
asns.as_set,
581+
)
496582
self.get = to_raw_response_wrapper(
497583
asns.get,
498584
)
@@ -511,6 +597,9 @@ def __init__(self, asns: AsyncASNsResource) -> None:
511597
self.list = async_to_raw_response_wrapper(
512598
asns.list,
513599
)
600+
self.as_set = async_to_raw_response_wrapper(
601+
asns.as_set,
602+
)
514603
self.get = async_to_raw_response_wrapper(
515604
asns.get,
516605
)
@@ -529,6 +618,9 @@ def __init__(self, asns: ASNsResource) -> None:
529618
self.list = to_streamed_response_wrapper(
530619
asns.list,
531620
)
621+
self.as_set = to_streamed_response_wrapper(
622+
asns.as_set,
623+
)
532624
self.get = to_streamed_response_wrapper(
533625
asns.get,
534626
)
@@ -547,6 +639,9 @@ def __init__(self, asns: AsyncASNsResource) -> None:
547639
self.list = async_to_streamed_response_wrapper(
548640
asns.list,
549641
)
642+
self.as_set = async_to_streamed_response_wrapper(
643+
asns.as_set,
644+
)
550645
self.get = async_to_streamed_response_wrapper(
551646
asns.get,
552647
)

src/cloudflare/types/radar/entities/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
from .asn_list_params import ASNListParams as ASNListParams
1010
from .asn_get_response import ASNGetResponse as ASNGetResponse
1111
from .asn_rel_response import ASNRelResponse as ASNRelResponse
12+
from .asn_as_set_params import ASNAsSetParams as ASNAsSetParams
1213
from .asn_list_response import ASNListResponse as ASNListResponse
14+
from .asn_as_set_response import ASNAsSetResponse as ASNAsSetResponse
1315
from .location_get_params import LocationGetParams as LocationGetParams
1416
from .location_list_params import LocationListParams as LocationListParams
1517
from .location_get_response import LocationGetResponse as LocationGetResponse
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from typing_extensions import Literal, TypedDict
6+
7+
__all__ = ["ASNAsSetParams"]
8+
9+
10+
class ASNAsSetParams(TypedDict, total=False):
11+
format: Literal["JSON", "CSV"]
12+
"""Format in which results will be returned."""
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing import List, Optional
4+
5+
from ...._models import BaseModel
6+
7+
__all__ = ["ASNAsSetResponse", "AsSet"]
8+
9+
10+
class AsSet(BaseModel):
11+
as_members_count: int
12+
"""The number of AS members in the AS-SET"""
13+
14+
as_set_members_count: int
15+
"""The number of AS-SET members in the AS-SET"""
16+
17+
as_set_upstreams_count: int
18+
"""The number of recursive upstream AS-SETs"""
19+
20+
asn_cone_size: int
21+
"""The number of unique ASNs in the AS-SETs recursive downstream"""
22+
23+
irr_sources: List[str]
24+
"""The IRR sources of the AS-SET"""
25+
26+
name: str
27+
"""The name of the AS-SET"""
28+
29+
asn: Optional[int] = None
30+
"""The inferred AS number of the AS-SET"""
31+
32+
33+
class ASNAsSetResponse(BaseModel):
34+
as_sets: List[AsSet]
35+
36+
paths: List[List[str]]
37+
"""Paths from the AS-SET that include the given AS to its upstreams recursively"""

tests/api_resources/radar/entities/test_asns.py

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
ASNGetResponse,
1515
ASNRelResponse,
1616
ASNListResponse,
17+
ASNAsSetResponse,
1718
)
1819

1920
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
@@ -59,6 +60,45 @@ def test_streaming_response_list(self, client: Cloudflare) -> None:
5960

6061
assert cast(Any, response.is_closed) is True
6162

63+
@parametrize
64+
def test_method_as_set(self, client: Cloudflare) -> None:
65+
asn = client.radar.entities.asns.as_set(
66+
asn=3,
67+
)
68+
assert_matches_type(ASNAsSetResponse, asn, path=["response"])
69+
70+
@parametrize
71+
def test_method_as_set_with_all_params(self, client: Cloudflare) -> None:
72+
asn = client.radar.entities.asns.as_set(
73+
asn=3,
74+
format="JSON",
75+
)
76+
assert_matches_type(ASNAsSetResponse, asn, path=["response"])
77+
78+
@parametrize
79+
def test_raw_response_as_set(self, client: Cloudflare) -> None:
80+
response = client.radar.entities.asns.with_raw_response.as_set(
81+
asn=3,
82+
)
83+
84+
assert response.is_closed is True
85+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
86+
asn = response.parse()
87+
assert_matches_type(ASNAsSetResponse, asn, path=["response"])
88+
89+
@parametrize
90+
def test_streaming_response_as_set(self, client: Cloudflare) -> None:
91+
with client.radar.entities.asns.with_streaming_response.as_set(
92+
asn=3,
93+
) as response:
94+
assert not response.is_closed
95+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
96+
97+
asn = response.parse()
98+
assert_matches_type(ASNAsSetResponse, asn, path=["response"])
99+
100+
assert cast(Any, response.is_closed) is True
101+
62102
@parametrize
63103
def test_method_get(self, client: Cloudflare) -> None:
64104
asn = client.radar.entities.asns.get(
@@ -220,6 +260,45 @@ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> N
220260

221261
assert cast(Any, response.is_closed) is True
222262

263+
@parametrize
264+
async def test_method_as_set(self, async_client: AsyncCloudflare) -> None:
265+
asn = await async_client.radar.entities.asns.as_set(
266+
asn=3,
267+
)
268+
assert_matches_type(ASNAsSetResponse, asn, path=["response"])
269+
270+
@parametrize
271+
async def test_method_as_set_with_all_params(self, async_client: AsyncCloudflare) -> None:
272+
asn = await async_client.radar.entities.asns.as_set(
273+
asn=3,
274+
format="JSON",
275+
)
276+
assert_matches_type(ASNAsSetResponse, asn, path=["response"])
277+
278+
@parametrize
279+
async def test_raw_response_as_set(self, async_client: AsyncCloudflare) -> None:
280+
response = await async_client.radar.entities.asns.with_raw_response.as_set(
281+
asn=3,
282+
)
283+
284+
assert response.is_closed is True
285+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
286+
asn = await response.parse()
287+
assert_matches_type(ASNAsSetResponse, asn, path=["response"])
288+
289+
@parametrize
290+
async def test_streaming_response_as_set(self, async_client: AsyncCloudflare) -> None:
291+
async with async_client.radar.entities.asns.with_streaming_response.as_set(
292+
asn=3,
293+
) as response:
294+
assert not response.is_closed
295+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
296+
297+
asn = await response.parse()
298+
assert_matches_type(ASNAsSetResponse, asn, path=["response"])
299+
300+
assert cast(Any, response.is_closed) is True
301+
223302
@parametrize
224303
async def test_method_get(self, async_client: AsyncCloudflare) -> None:
225304
asn = await async_client.radar.entities.asns.get(

0 commit comments

Comments
 (0)