Skip to content

Commit c10d3b7

Browse files
feat(loa_documents)!: move download subresource into parent as get (#2304)
1 parent b9a842b commit c10d3b7

File tree

9 files changed

+289
-465
lines changed

9 files changed

+289
-465
lines changed

api.md

+2-7
Original file line numberDiff line numberDiff line change
@@ -3218,13 +3218,8 @@ from cloudflare.types.addressing import LOADocumentCreateResponse
32183218

32193219
Methods:
32203220

3221-
- <code title="post /accounts/{account_id}/addressing/loa_documents">client.addressing.loa_documents.<a href="./src/cloudflare/resources/addressing/loa_documents/loa_documents.py">create</a>(\*, account_id, \*\*<a href="src/cloudflare/types/addressing/loa_document_create_params.py">params</a>) -> <a href="./src/cloudflare/types/addressing/loa_document_create_response.py">Optional[LOADocumentCreateResponse]</a></code>
3222-
3223-
### Downloads
3224-
3225-
Methods:
3226-
3227-
- <code title="get /accounts/{account_id}/addressing/loa_documents/{loa_document_id}/download">client.addressing.loa_documents.downloads.<a href="./src/cloudflare/resources/addressing/loa_documents/downloads.py">get</a>(loa_document_id, \*, account_id) -> BinaryAPIResponse</code>
3221+
- <code title="post /accounts/{account_id}/addressing/loa_documents">client.addressing.loa_documents.<a href="./src/cloudflare/resources/addressing/loa_documents.py">create</a>(\*, account_id, \*\*<a href="src/cloudflare/types/addressing/loa_document_create_params.py">params</a>) -> <a href="./src/cloudflare/types/addressing/loa_document_create_response.py">Optional[LOADocumentCreateResponse]</a></code>
3222+
- <code title="get /accounts/{account_id}/addressing/loa_documents/{loa_document_id}/download">client.addressing.loa_documents.<a href="./src/cloudflare/resources/addressing/loa_documents.py">get</a>(loa_document_id, \*, account_id) -> BinaryAPIResponse</code>
32283223

32293224
## Prefixes
32303225

src/cloudflare/resources/addressing/addressing.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@
1212
)
1313
from ..._compat import cached_property
1414
from ..._resource import SyncAPIResource, AsyncAPIResource
15+
from .loa_documents import (
16+
LOADocumentsResource,
17+
AsyncLOADocumentsResource,
18+
LOADocumentsResourceWithRawResponse,
19+
AsyncLOADocumentsResourceWithRawResponse,
20+
LOADocumentsResourceWithStreamingResponse,
21+
AsyncLOADocumentsResourceWithStreamingResponse,
22+
)
1523
from .prefixes.prefixes import (
1624
PrefixesResource,
1725
AsyncPrefixesResource,
@@ -28,14 +36,6 @@
2836
AddressMapsResourceWithStreamingResponse,
2937
AsyncAddressMapsResourceWithStreamingResponse,
3038
)
31-
from .loa_documents.loa_documents import (
32-
LOADocumentsResource,
33-
AsyncLOADocumentsResource,
34-
LOADocumentsResourceWithRawResponse,
35-
AsyncLOADocumentsResourceWithRawResponse,
36-
LOADocumentsResourceWithStreamingResponse,
37-
AsyncLOADocumentsResourceWithStreamingResponse,
38-
)
3939
from .regional_hostnames.regional_hostnames import (
4040
RegionalHostnamesResource,
4141
AsyncRegionalHostnamesResource,

src/cloudflare/resources/addressing/loa_documents/loa_documents.py src/cloudflare/resources/addressing/loa_documents.py

+115-41
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,36 @@
66

77
import httpx
88

9-
from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
10-
from ...._utils import (
9+
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
10+
from ..._utils import (
1111
maybe_transform,
1212
async_maybe_transform,
1313
)
14-
from .downloads import (
15-
DownloadsResource,
16-
AsyncDownloadsResource,
17-
DownloadsResourceWithRawResponse,
18-
AsyncDownloadsResourceWithRawResponse,
19-
DownloadsResourceWithStreamingResponse,
20-
AsyncDownloadsResourceWithStreamingResponse,
21-
)
22-
from ...._compat import cached_property
23-
from ...._resource import SyncAPIResource, AsyncAPIResource
24-
from ...._response import (
14+
from ..._compat import cached_property
15+
from ..._resource import SyncAPIResource, AsyncAPIResource
16+
from ..._response import (
17+
BinaryAPIResponse,
18+
AsyncBinaryAPIResponse,
19+
StreamedBinaryAPIResponse,
20+
AsyncStreamedBinaryAPIResponse,
2521
to_raw_response_wrapper,
2622
to_streamed_response_wrapper,
2723
async_to_raw_response_wrapper,
24+
to_custom_raw_response_wrapper,
2825
async_to_streamed_response_wrapper,
26+
to_custom_streamed_response_wrapper,
27+
async_to_custom_raw_response_wrapper,
28+
async_to_custom_streamed_response_wrapper,
2929
)
30-
from ...._wrappers import ResultWrapper
31-
from ...._base_client import make_request_options
32-
from ....types.addressing import loa_document_create_params
33-
from ....types.addressing.loa_document_create_response import LOADocumentCreateResponse
30+
from ..._wrappers import ResultWrapper
31+
from ..._base_client import make_request_options
32+
from ...types.addressing import loa_document_create_params
33+
from ...types.addressing.loa_document_create_response import LOADocumentCreateResponse
3434

3535
__all__ = ["LOADocumentsResource", "AsyncLOADocumentsResource"]
3636

3737

3838
class LOADocumentsResource(SyncAPIResource):
39-
@cached_property
40-
def downloads(self) -> DownloadsResource:
41-
return DownloadsResource(self._client)
42-
4339
@cached_property
4440
def with_raw_response(self) -> LOADocumentsResourceWithRawResponse:
4541
"""
@@ -106,12 +102,49 @@ def create(
106102
cast_to=cast(Type[Optional[LOADocumentCreateResponse]], ResultWrapper[LOADocumentCreateResponse]),
107103
)
108104

105+
def get(
106+
self,
107+
loa_document_id: Optional[str],
108+
*,
109+
account_id: str,
110+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
111+
# The extra values given here take precedence over values defined on the client or passed to this method.
112+
extra_headers: Headers | None = None,
113+
extra_query: Query | None = None,
114+
extra_body: Body | None = None,
115+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
116+
) -> BinaryAPIResponse:
117+
"""
118+
Download specified LOA document under the account.
109119
110-
class AsyncLOADocumentsResource(AsyncAPIResource):
111-
@cached_property
112-
def downloads(self) -> AsyncDownloadsResource:
113-
return AsyncDownloadsResource(self._client)
120+
Args:
121+
account_id: Identifier
122+
123+
loa_document_id: Identifier for the uploaded LOA document.
124+
125+
extra_headers: Send extra headers
126+
127+
extra_query: Add additional query parameters to the request
128+
129+
extra_body: Add additional JSON properties to the request
114130
131+
timeout: Override the client-level default timeout for this request, in seconds
132+
"""
133+
if not account_id:
134+
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
135+
if not loa_document_id:
136+
raise ValueError(f"Expected a non-empty value for `loa_document_id` but received {loa_document_id!r}")
137+
extra_headers = {"Accept": "application/pdf", **(extra_headers or {})}
138+
return self._get(
139+
f"/accounts/{account_id}/addressing/loa_documents/{loa_document_id}/download",
140+
options=make_request_options(
141+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
142+
),
143+
cast_to=BinaryAPIResponse,
144+
)
145+
146+
147+
class AsyncLOADocumentsResource(AsyncAPIResource):
115148
@cached_property
116149
def with_raw_response(self) -> AsyncLOADocumentsResourceWithRawResponse:
117150
"""
@@ -180,6 +213,47 @@ async def create(
180213
cast_to=cast(Type[Optional[LOADocumentCreateResponse]], ResultWrapper[LOADocumentCreateResponse]),
181214
)
182215

216+
async def get(
217+
self,
218+
loa_document_id: Optional[str],
219+
*,
220+
account_id: str,
221+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
222+
# The extra values given here take precedence over values defined on the client or passed to this method.
223+
extra_headers: Headers | None = None,
224+
extra_query: Query | None = None,
225+
extra_body: Body | None = None,
226+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
227+
) -> AsyncBinaryAPIResponse:
228+
"""
229+
Download specified LOA document under the account.
230+
231+
Args:
232+
account_id: Identifier
233+
234+
loa_document_id: Identifier for the uploaded LOA document.
235+
236+
extra_headers: Send extra headers
237+
238+
extra_query: Add additional query parameters to the request
239+
240+
extra_body: Add additional JSON properties to the request
241+
242+
timeout: Override the client-level default timeout for this request, in seconds
243+
"""
244+
if not account_id:
245+
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
246+
if not loa_document_id:
247+
raise ValueError(f"Expected a non-empty value for `loa_document_id` but received {loa_document_id!r}")
248+
extra_headers = {"Accept": "application/pdf", **(extra_headers or {})}
249+
return await self._get(
250+
f"/accounts/{account_id}/addressing/loa_documents/{loa_document_id}/download",
251+
options=make_request_options(
252+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
253+
),
254+
cast_to=AsyncBinaryAPIResponse,
255+
)
256+
183257

184258
class LOADocumentsResourceWithRawResponse:
185259
def __init__(self, loa_documents: LOADocumentsResource) -> None:
@@ -188,10 +262,10 @@ def __init__(self, loa_documents: LOADocumentsResource) -> None:
188262
self.create = to_raw_response_wrapper(
189263
loa_documents.create,
190264
)
191-
192-
@cached_property
193-
def downloads(self) -> DownloadsResourceWithRawResponse:
194-
return DownloadsResourceWithRawResponse(self._loa_documents.downloads)
265+
self.get = to_custom_raw_response_wrapper(
266+
loa_documents.get,
267+
BinaryAPIResponse,
268+
)
195269

196270

197271
class AsyncLOADocumentsResourceWithRawResponse:
@@ -201,10 +275,10 @@ def __init__(self, loa_documents: AsyncLOADocumentsResource) -> None:
201275
self.create = async_to_raw_response_wrapper(
202276
loa_documents.create,
203277
)
204-
205-
@cached_property
206-
def downloads(self) -> AsyncDownloadsResourceWithRawResponse:
207-
return AsyncDownloadsResourceWithRawResponse(self._loa_documents.downloads)
278+
self.get = async_to_custom_raw_response_wrapper(
279+
loa_documents.get,
280+
AsyncBinaryAPIResponse,
281+
)
208282

209283

210284
class LOADocumentsResourceWithStreamingResponse:
@@ -214,10 +288,10 @@ def __init__(self, loa_documents: LOADocumentsResource) -> None:
214288
self.create = to_streamed_response_wrapper(
215289
loa_documents.create,
216290
)
217-
218-
@cached_property
219-
def downloads(self) -> DownloadsResourceWithStreamingResponse:
220-
return DownloadsResourceWithStreamingResponse(self._loa_documents.downloads)
291+
self.get = to_custom_streamed_response_wrapper(
292+
loa_documents.get,
293+
StreamedBinaryAPIResponse,
294+
)
221295

222296

223297
class AsyncLOADocumentsResourceWithStreamingResponse:
@@ -227,7 +301,7 @@ def __init__(self, loa_documents: AsyncLOADocumentsResource) -> None:
227301
self.create = async_to_streamed_response_wrapper(
228302
loa_documents.create,
229303
)
230-
231-
@cached_property
232-
def downloads(self) -> AsyncDownloadsResourceWithStreamingResponse:
233-
return AsyncDownloadsResourceWithStreamingResponse(self._loa_documents.downloads)
304+
self.get = async_to_custom_streamed_response_wrapper(
305+
loa_documents.get,
306+
AsyncStreamedBinaryAPIResponse,
307+
)

src/cloudflare/resources/addressing/loa_documents/__init__.py

-33
This file was deleted.

0 commit comments

Comments
 (0)