Skip to content

Commit 435c73d

Browse files
feat: feat(registrar): add registrar registrations list method on main
* feat(registrar): add registrations list method on main Add registrar.registrations.list to the main registrar resource so the new GET /accounts/{account_id}/registrar/registrations endpoint is exposed through the converged Registrar surface on main as well as staging.
1 parent 5ec0a7b commit 435c73d

File tree

6 files changed

+285
-4
lines changed

6 files changed

+285
-4
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 2129
1+
configured_endpoints: 2130
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-83a81462699153d3f2d3c484d97cdc6877b7c73a664cae829661e89bc6130afc.yml
33
openapi_spec_hash: 6b9d05215024e69850fed051e136ba7c
4-
config_hash: 61ff4afd70fa432affae760c7dedebad
4+
config_hash: fce4390351fe38ffbbe66f8b173ece0a

api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4852,6 +4852,7 @@ Methods:
48524852
Methods:
48534853

48544854
- <code title="post /accounts/{account_id}/registrar/registrations">client.registrar.registrations.<a href="./src/cloudflare/resources/registrar/registrations.py">create</a>(\*, account_id, \*\*<a href="src/cloudflare/types/registrar/registration_create_params.py">params</a>) -> <a href="./src/cloudflare/types/registrar/workflow_status.py">WorkflowStatus</a></code>
4855+
- <code title="get /accounts/{account_id}/registrar/registrations">client.registrar.registrations.<a href="./src/cloudflare/resources/registrar/registrations.py">list</a>(\*, account_id, \*\*<a href="src/cloudflare/types/registrar/registration_list_params.py">params</a>) -> <a href="./src/cloudflare/types/registrar/registration.py">SyncCursorPagination[Registration]</a></code>
48554856
- <code title="patch /accounts/{account_id}/registrar/registrations/{domain_name}">client.registrar.registrations.<a href="./src/cloudflare/resources/registrar/registrations.py">edit</a>(domain_name, \*, account_id, \*\*<a href="src/cloudflare/types/registrar/registration_edit_params.py">params</a>) -> <a href="./src/cloudflare/types/registrar/workflow_status.py">WorkflowStatus</a></code>
48564857
- <code title="get /accounts/{account_id}/registrar/registrations/{domain_name}">client.registrar.registrations.<a href="./src/cloudflare/resources/registrar/registrations.py">get</a>(domain_name, \*, account_id) -> <a href="./src/cloudflare/types/registrar/registration.py">Registration</a></code>
48574858

src/cloudflare/resources/registrar/registrations.py

Lines changed: 151 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
async_to_streamed_response_wrapper,
1919
)
2020
from ..._wrappers import ResultWrapper
21-
from ..._base_client import make_request_options
22-
from ...types.registrar import registration_edit_params, registration_create_params
21+
from ...pagination import SyncCursorPagination, AsyncCursorPagination
22+
from ..._base_client import AsyncPaginator, make_request_options
23+
from ...types.registrar import registration_edit_params, registration_list_params, registration_create_params
2324
from ...types.registrar.registration import Registration
2425
from ...types.registrar.workflow_status import WorkflowStatus
2526

@@ -193,6 +194,74 @@ def create(
193194
cast_to=cast(Type[WorkflowStatus], ResultWrapper[WorkflowStatus]),
194195
)
195196

197+
def list(
198+
self,
199+
*,
200+
account_id: str,
201+
cursor: str | Omit = omit,
202+
direction: Literal["asc", "desc"] | Omit = omit,
203+
per_page: int | Omit = omit,
204+
sort_by: Literal["registry_created_at", "registry_expires_at", "name"] | Omit = omit,
205+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
206+
# The extra values given here take precedence over values defined on the client or passed to this method.
207+
extra_headers: Headers | None = None,
208+
extra_query: Query | None = None,
209+
extra_body: Body | None = None,
210+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
211+
) -> SyncCursorPagination[Registration]:
212+
"""
213+
Returns a paginated list of domain registrations owned by the account.
214+
215+
This endpoint uses cursor-based pagination. Results are ordered by registration
216+
date by default. To fetch the next page, pass the `cursor` value from the
217+
`result_info` object in the response as the `cursor` query parameter in your
218+
next request. An empty `cursor` string indicates there are no more pages.
219+
220+
Args:
221+
account_id: Identifier
222+
223+
cursor: Opaque token from a previous response's `result_info.cursor`. Pass this value to
224+
fetch the next page of results. Omit (or pass an empty string) for the first
225+
page.
226+
227+
direction: Sort direction for results. Defaults to ascending order.
228+
229+
per_page: Number of items to return per page.
230+
231+
sort_by: Column to sort results by. Defaults to registration date (`registry_created_at`)
232+
when omitted.
233+
234+
extra_headers: Send extra headers
235+
236+
extra_query: Add additional query parameters to the request
237+
238+
extra_body: Add additional JSON properties to the request
239+
240+
timeout: Override the client-level default timeout for this request, in seconds
241+
"""
242+
if not account_id:
243+
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
244+
return self._get_api_list(
245+
f"/accounts/{account_id}/registrar/registrations",
246+
page=SyncCursorPagination[Registration],
247+
options=make_request_options(
248+
extra_headers=extra_headers,
249+
extra_query=extra_query,
250+
extra_body=extra_body,
251+
timeout=timeout,
252+
query=maybe_transform(
253+
{
254+
"cursor": cursor,
255+
"direction": direction,
256+
"per_page": per_page,
257+
"sort_by": sort_by,
258+
},
259+
registration_list_params.RegistrationListParams,
260+
),
261+
),
262+
model=Registration,
263+
)
264+
196265
def edit(
197266
self,
198267
domain_name: str,
@@ -483,6 +552,74 @@ async def create(
483552
cast_to=cast(Type[WorkflowStatus], ResultWrapper[WorkflowStatus]),
484553
)
485554

555+
def list(
556+
self,
557+
*,
558+
account_id: str,
559+
cursor: str | Omit = omit,
560+
direction: Literal["asc", "desc"] | Omit = omit,
561+
per_page: int | Omit = omit,
562+
sort_by: Literal["registry_created_at", "registry_expires_at", "name"] | Omit = omit,
563+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
564+
# The extra values given here take precedence over values defined on the client or passed to this method.
565+
extra_headers: Headers | None = None,
566+
extra_query: Query | None = None,
567+
extra_body: Body | None = None,
568+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
569+
) -> AsyncPaginator[Registration, AsyncCursorPagination[Registration]]:
570+
"""
571+
Returns a paginated list of domain registrations owned by the account.
572+
573+
This endpoint uses cursor-based pagination. Results are ordered by registration
574+
date by default. To fetch the next page, pass the `cursor` value from the
575+
`result_info` object in the response as the `cursor` query parameter in your
576+
next request. An empty `cursor` string indicates there are no more pages.
577+
578+
Args:
579+
account_id: Identifier
580+
581+
cursor: Opaque token from a previous response's `result_info.cursor`. Pass this value to
582+
fetch the next page of results. Omit (or pass an empty string) for the first
583+
page.
584+
585+
direction: Sort direction for results. Defaults to ascending order.
586+
587+
per_page: Number of items to return per page.
588+
589+
sort_by: Column to sort results by. Defaults to registration date (`registry_created_at`)
590+
when omitted.
591+
592+
extra_headers: Send extra headers
593+
594+
extra_query: Add additional query parameters to the request
595+
596+
extra_body: Add additional JSON properties to the request
597+
598+
timeout: Override the client-level default timeout for this request, in seconds
599+
"""
600+
if not account_id:
601+
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
602+
return self._get_api_list(
603+
f"/accounts/{account_id}/registrar/registrations",
604+
page=AsyncCursorPagination[Registration],
605+
options=make_request_options(
606+
extra_headers=extra_headers,
607+
extra_query=extra_query,
608+
extra_body=extra_body,
609+
timeout=timeout,
610+
query=maybe_transform(
611+
{
612+
"cursor": cursor,
613+
"direction": direction,
614+
"per_page": per_page,
615+
"sort_by": sort_by,
616+
},
617+
registration_list_params.RegistrationListParams,
618+
),
619+
),
620+
model=Registration,
621+
)
622+
486623
async def edit(
487624
self,
488625
domain_name: str,
@@ -615,6 +752,9 @@ def __init__(self, registrations: RegistrationsResource) -> None:
615752
self.create = to_raw_response_wrapper(
616753
registrations.create,
617754
)
755+
self.list = to_raw_response_wrapper(
756+
registrations.list,
757+
)
618758
self.edit = to_raw_response_wrapper(
619759
registrations.edit,
620760
)
@@ -630,6 +770,9 @@ def __init__(self, registrations: AsyncRegistrationsResource) -> None:
630770
self.create = async_to_raw_response_wrapper(
631771
registrations.create,
632772
)
773+
self.list = async_to_raw_response_wrapper(
774+
registrations.list,
775+
)
633776
self.edit = async_to_raw_response_wrapper(
634777
registrations.edit,
635778
)
@@ -645,6 +788,9 @@ def __init__(self, registrations: RegistrationsResource) -> None:
645788
self.create = to_streamed_response_wrapper(
646789
registrations.create,
647790
)
791+
self.list = to_streamed_response_wrapper(
792+
registrations.list,
793+
)
648794
self.edit = to_streamed_response_wrapper(
649795
registrations.edit,
650796
)
@@ -660,6 +806,9 @@ def __init__(self, registrations: AsyncRegistrationsResource) -> None:
660806
self.create = async_to_streamed_response_wrapper(
661807
registrations.create,
662808
)
809+
self.list = async_to_streamed_response_wrapper(
810+
registrations.list,
811+
)
663812
self.edit = async_to_streamed_response_wrapper(
664813
registrations.edit,
665814
)

src/cloudflare/types/registrar/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
from .registrar_search_params import RegistrarSearchParams as RegistrarSearchParams
1111
from .registrar_check_response import RegistrarCheckResponse as RegistrarCheckResponse
1212
from .registration_edit_params import RegistrationEditParams as RegistrationEditParams
13+
from .registration_list_params import RegistrationListParams as RegistrationListParams
1314
from .registrar_search_response import RegistrarSearchResponse as RegistrarSearchResponse
1415
from .registration_create_params import RegistrationCreateParams as RegistrationCreateParams
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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, Required, TypedDict
6+
7+
__all__ = ["RegistrationListParams"]
8+
9+
10+
class RegistrationListParams(TypedDict, total=False):
11+
account_id: Required[str]
12+
"""Identifier"""
13+
14+
cursor: str
15+
"""
16+
Opaque token from a previous response's `result_info.cursor`. Pass this value to
17+
fetch the next page of results. Omit (or pass an empty string) for the first
18+
page.
19+
"""
20+
21+
direction: Literal["asc", "desc"]
22+
"""Sort direction for results. Defaults to ascending order."""
23+
24+
per_page: int
25+
"""Number of items to return per page."""
26+
27+
sort_by: Literal["registry_created_at", "registry_expires_at", "name"]
28+
"""Column to sort results by.
29+
30+
Defaults to registration date (`registry_created_at`) when omitted.
31+
"""

tests/api_resources/registrar/test_registrations.py

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
from cloudflare import Cloudflare, AsyncCloudflare
1111
from tests.utils import assert_matches_type
12+
from cloudflare.pagination import SyncCursorPagination, AsyncCursorPagination
1213
from cloudflare.types.registrar import (
1314
Registration,
1415
WorkflowStatus,
@@ -92,6 +93,55 @@ def test_path_params_create(self, client: Cloudflare) -> None:
9293
domain_name="my-new-startup.com",
9394
)
9495

96+
@parametrize
97+
def test_method_list(self, client: Cloudflare) -> None:
98+
registration = client.registrar.registrations.list(
99+
account_id="023e105f4ecef8ad9ca31a8372d0c353",
100+
)
101+
assert_matches_type(SyncCursorPagination[Registration], registration, path=["response"])
102+
103+
@parametrize
104+
def test_method_list_with_all_params(self, client: Cloudflare) -> None:
105+
registration = client.registrar.registrations.list(
106+
account_id="023e105f4ecef8ad9ca31a8372d0c353",
107+
cursor="cursor",
108+
direction="asc",
109+
per_page=1,
110+
sort_by="registry_created_at",
111+
)
112+
assert_matches_type(SyncCursorPagination[Registration], registration, path=["response"])
113+
114+
@parametrize
115+
def test_raw_response_list(self, client: Cloudflare) -> None:
116+
response = client.registrar.registrations.with_raw_response.list(
117+
account_id="023e105f4ecef8ad9ca31a8372d0c353",
118+
)
119+
120+
assert response.is_closed is True
121+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
122+
registration = response.parse()
123+
assert_matches_type(SyncCursorPagination[Registration], registration, path=["response"])
124+
125+
@parametrize
126+
def test_streaming_response_list(self, client: Cloudflare) -> None:
127+
with client.registrar.registrations.with_streaming_response.list(
128+
account_id="023e105f4ecef8ad9ca31a8372d0c353",
129+
) as response:
130+
assert not response.is_closed
131+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
132+
133+
registration = response.parse()
134+
assert_matches_type(SyncCursorPagination[Registration], registration, path=["response"])
135+
136+
assert cast(Any, response.is_closed) is True
137+
138+
@parametrize
139+
def test_path_params_list(self, client: Cloudflare) -> None:
140+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
141+
client.registrar.registrations.with_raw_response.list(
142+
account_id="",
143+
)
144+
95145
@parametrize
96146
def test_method_edit(self, client: Cloudflare) -> None:
97147
registration = client.registrar.registrations.edit(
@@ -276,6 +326,55 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None:
276326
domain_name="my-new-startup.com",
277327
)
278328

329+
@parametrize
330+
async def test_method_list(self, async_client: AsyncCloudflare) -> None:
331+
registration = await async_client.registrar.registrations.list(
332+
account_id="023e105f4ecef8ad9ca31a8372d0c353",
333+
)
334+
assert_matches_type(AsyncCursorPagination[Registration], registration, path=["response"])
335+
336+
@parametrize
337+
async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None:
338+
registration = await async_client.registrar.registrations.list(
339+
account_id="023e105f4ecef8ad9ca31a8372d0c353",
340+
cursor="cursor",
341+
direction="asc",
342+
per_page=1,
343+
sort_by="registry_created_at",
344+
)
345+
assert_matches_type(AsyncCursorPagination[Registration], registration, path=["response"])
346+
347+
@parametrize
348+
async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None:
349+
response = await async_client.registrar.registrations.with_raw_response.list(
350+
account_id="023e105f4ecef8ad9ca31a8372d0c353",
351+
)
352+
353+
assert response.is_closed is True
354+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
355+
registration = await response.parse()
356+
assert_matches_type(AsyncCursorPagination[Registration], registration, path=["response"])
357+
358+
@parametrize
359+
async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None:
360+
async with async_client.registrar.registrations.with_streaming_response.list(
361+
account_id="023e105f4ecef8ad9ca31a8372d0c353",
362+
) as response:
363+
assert not response.is_closed
364+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
365+
366+
registration = await response.parse()
367+
assert_matches_type(AsyncCursorPagination[Registration], registration, path=["response"])
368+
369+
assert cast(Any, response.is_closed) is True
370+
371+
@parametrize
372+
async def test_path_params_list(self, async_client: AsyncCloudflare) -> None:
373+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
374+
await async_client.registrar.registrations.with_raw_response.list(
375+
account_id="",
376+
)
377+
279378
@parametrize
280379
async def test_method_edit(self, async_client: AsyncCloudflare) -> None:
281380
registration = await async_client.registrar.registrations.edit(

0 commit comments

Comments
 (0)