22
33from __future__ import annotations
44
5- from typing import Optional
5+ from typing import Type , Optional , cast
66
77import httpx
88
99from ..._types import Body , Query , Headers , NotGiven , not_given
10+ from ..._utils import maybe_transform , async_maybe_transform
1011from ..._compat import cached_property
1112from ..._resource import SyncAPIResource , AsyncAPIResource
1213from ..._response import (
1314 BinaryAPIResponse ,
1415 AsyncBinaryAPIResponse ,
1516 StreamedBinaryAPIResponse ,
1617 AsyncStreamedBinaryAPIResponse ,
18+ to_raw_response_wrapper ,
19+ to_streamed_response_wrapper ,
20+ async_to_raw_response_wrapper ,
1721 to_custom_raw_response_wrapper ,
22+ async_to_streamed_response_wrapper ,
1823 to_custom_streamed_response_wrapper ,
1924 async_to_custom_raw_response_wrapper ,
2025 async_to_custom_streamed_response_wrapper ,
2126)
27+ from ..._wrappers import ResultWrapper
2228from ..._base_client import make_request_options
29+ from ...types .addressing import loa_document_create_params
30+ from ...types .addressing .loa_document_create_response import LOADocumentCreateResponse
2331
2432__all__ = ["LOADocumentsResource" , "AsyncLOADocumentsResource" ]
2533
@@ -44,6 +52,53 @@ def with_streaming_response(self) -> LOADocumentsResourceWithStreamingResponse:
4452 """
4553 return LOADocumentsResourceWithStreamingResponse (self )
4654
55+ def create (
56+ self ,
57+ * ,
58+ account_id : str ,
59+ loa_document : str ,
60+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
61+ # The extra values given here take precedence over values defined on the client or passed to this method.
62+ extra_headers : Headers | None = None ,
63+ extra_query : Query | None = None ,
64+ extra_body : Body | None = None ,
65+ timeout : float | httpx .Timeout | None | NotGiven = not_given ,
66+ ) -> Optional [LOADocumentCreateResponse ]:
67+ """
68+ Submit LOA document (pdf format) under the account.
69+
70+ Args:
71+ account_id: Identifier of a Cloudflare account.
72+
73+ loa_document: LOA document to upload.
74+
75+ extra_headers: Send extra headers
76+
77+ extra_query: Add additional query parameters to the request
78+
79+ extra_body: Add additional JSON properties to the request
80+
81+ timeout: Override the client-level default timeout for this request, in seconds
82+ """
83+ if not account_id :
84+ raise ValueError (f"Expected a non-empty value for `account_id` but received { account_id !r} " )
85+ # It should be noted that the actual Content-Type header that will be
86+ # sent to the server will contain a `boundary` parameter, e.g.
87+ # multipart/form-data; boundary=---abc--
88+ extra_headers = {"Content-Type" : "multipart/form-data" , ** (extra_headers or {})}
89+ return self ._post (
90+ f"/accounts/{ account_id } /addressing/loa_documents" ,
91+ body = maybe_transform ({"loa_document" : loa_document }, loa_document_create_params .LOADocumentCreateParams ),
92+ options = make_request_options (
93+ extra_headers = extra_headers ,
94+ extra_query = extra_query ,
95+ extra_body = extra_body ,
96+ timeout = timeout ,
97+ post_parser = ResultWrapper [Optional [LOADocumentCreateResponse ]]._unwrapper ,
98+ ),
99+ cast_to = cast (Type [Optional [LOADocumentCreateResponse ]], ResultWrapper [LOADocumentCreateResponse ]),
100+ )
101+
47102 def get (
48103 self ,
49104 loa_document_id : Optional [str ],
@@ -106,6 +161,55 @@ def with_streaming_response(self) -> AsyncLOADocumentsResourceWithStreamingRespo
106161 """
107162 return AsyncLOADocumentsResourceWithStreamingResponse (self )
108163
164+ async def create (
165+ self ,
166+ * ,
167+ account_id : str ,
168+ loa_document : str ,
169+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
170+ # The extra values given here take precedence over values defined on the client or passed to this method.
171+ extra_headers : Headers | None = None ,
172+ extra_query : Query | None = None ,
173+ extra_body : Body | None = None ,
174+ timeout : float | httpx .Timeout | None | NotGiven = not_given ,
175+ ) -> Optional [LOADocumentCreateResponse ]:
176+ """
177+ Submit LOA document (pdf format) under the account.
178+
179+ Args:
180+ account_id: Identifier of a Cloudflare account.
181+
182+ loa_document: LOA document to upload.
183+
184+ extra_headers: Send extra headers
185+
186+ extra_query: Add additional query parameters to the request
187+
188+ extra_body: Add additional JSON properties to the request
189+
190+ timeout: Override the client-level default timeout for this request, in seconds
191+ """
192+ if not account_id :
193+ raise ValueError (f"Expected a non-empty value for `account_id` but received { account_id !r} " )
194+ # It should be noted that the actual Content-Type header that will be
195+ # sent to the server will contain a `boundary` parameter, e.g.
196+ # multipart/form-data; boundary=---abc--
197+ extra_headers = {"Content-Type" : "multipart/form-data" , ** (extra_headers or {})}
198+ return await self ._post (
199+ f"/accounts/{ account_id } /addressing/loa_documents" ,
200+ body = await async_maybe_transform (
201+ {"loa_document" : loa_document }, loa_document_create_params .LOADocumentCreateParams
202+ ),
203+ options = make_request_options (
204+ extra_headers = extra_headers ,
205+ extra_query = extra_query ,
206+ extra_body = extra_body ,
207+ timeout = timeout ,
208+ post_parser = ResultWrapper [Optional [LOADocumentCreateResponse ]]._unwrapper ,
209+ ),
210+ cast_to = cast (Type [Optional [LOADocumentCreateResponse ]], ResultWrapper [LOADocumentCreateResponse ]),
211+ )
212+
109213 async def get (
110214 self ,
111215 loa_document_id : Optional [str ],
@@ -152,6 +256,9 @@ class LOADocumentsResourceWithRawResponse:
152256 def __init__ (self , loa_documents : LOADocumentsResource ) -> None :
153257 self ._loa_documents = loa_documents
154258
259+ self .create = to_raw_response_wrapper (
260+ loa_documents .create ,
261+ )
155262 self .get = to_custom_raw_response_wrapper (
156263 loa_documents .get ,
157264 BinaryAPIResponse ,
@@ -162,6 +269,9 @@ class AsyncLOADocumentsResourceWithRawResponse:
162269 def __init__ (self , loa_documents : AsyncLOADocumentsResource ) -> None :
163270 self ._loa_documents = loa_documents
164271
272+ self .create = async_to_raw_response_wrapper (
273+ loa_documents .create ,
274+ )
165275 self .get = async_to_custom_raw_response_wrapper (
166276 loa_documents .get ,
167277 AsyncBinaryAPIResponse ,
@@ -172,6 +282,9 @@ class LOADocumentsResourceWithStreamingResponse:
172282 def __init__ (self , loa_documents : LOADocumentsResource ) -> None :
173283 self ._loa_documents = loa_documents
174284
285+ self .create = to_streamed_response_wrapper (
286+ loa_documents .create ,
287+ )
175288 self .get = to_custom_streamed_response_wrapper (
176289 loa_documents .get ,
177290 StreamedBinaryAPIResponse ,
@@ -182,6 +295,9 @@ class AsyncLOADocumentsResourceWithStreamingResponse:
182295 def __init__ (self , loa_documents : AsyncLOADocumentsResource ) -> None :
183296 self ._loa_documents = loa_documents
184297
298+ self .create = async_to_streamed_response_wrapper (
299+ loa_documents .create ,
300+ )
185301 self .get = async_to_custom_streamed_response_wrapper (
186302 loa_documents .get ,
187303 AsyncStreamedBinaryAPIResponse ,
0 commit comments