22
33from __future__ import annotations
44
5- from typing import Any , Optional , cast
5+ from typing import Type , Optional , cast
66from typing_extensions import Literal
77
88import httpx
2222from .._base_client import AsyncPaginator , make_request_options
2323from ..types .custom_pages import custom_page_update_params
2424from ..types .custom_pages .custom_page_get_response import CustomPageGetResponse
25+ from ..types .custom_pages .custom_page_list_response import CustomPageListResponse
2526from ..types .custom_pages .custom_page_update_response import CustomPageUpdateResponse
2627
2728__all__ = ["CustomPagesResource" , "AsyncCustomPagesResource" ]
@@ -49,7 +50,15 @@ def with_streaming_response(self) -> CustomPagesResourceWithStreamingResponse:
4950
5051 def update (
5152 self ,
52- identifier : str ,
53+ identifier : Literal [
54+ "waf_block" ,
55+ "ip_block" ,
56+ "country_challenge" ,
57+ "500_errors" ,
58+ "1000_errors" ,
59+ "managed_challenge" ,
60+ "ratelimit_block" ,
61+ ],
5362 * ,
5463 state : Literal ["default" , "customized" ],
5564 url : str ,
@@ -66,7 +75,7 @@ def update(
6675 Updates the configuration of an existing custom page.
6776
6877 Args:
69- identifier: Identifier
78+ identifier: Error Page Types
7079
7180 state: The custom page state.
7281
@@ -98,28 +107,23 @@ def update(
98107
99108 account_or_zone = "zones"
100109 account_or_zone_id = zone_id
101- return cast (
102- Optional [CustomPageUpdateResponse ],
103- self ._put (
104- f"/{ account_or_zone } /{ account_or_zone_id } /custom_pages/{ identifier } " ,
105- body = maybe_transform (
106- {
107- "state" : state ,
108- "url" : url ,
109- },
110- custom_page_update_params .CustomPageUpdateParams ,
111- ),
112- options = make_request_options (
113- extra_headers = extra_headers ,
114- extra_query = extra_query ,
115- extra_body = extra_body ,
116- timeout = timeout ,
117- post_parser = ResultWrapper [Optional [CustomPageUpdateResponse ]]._unwrapper ,
118- ),
119- cast_to = cast (
120- Any , ResultWrapper [CustomPageUpdateResponse ]
121- ), # Union types cannot be passed in as arguments in the type system
110+ return self ._put (
111+ f"/{ account_or_zone } /{ account_or_zone_id } /custom_pages/{ identifier } " ,
112+ body = maybe_transform (
113+ {
114+ "state" : state ,
115+ "url" : url ,
116+ },
117+ custom_page_update_params .CustomPageUpdateParams ,
122118 ),
119+ options = make_request_options (
120+ extra_headers = extra_headers ,
121+ extra_query = extra_query ,
122+ extra_body = extra_body ,
123+ timeout = timeout ,
124+ post_parser = ResultWrapper [Optional [CustomPageUpdateResponse ]]._unwrapper ,
125+ ),
126+ cast_to = cast (Type [Optional [CustomPageUpdateResponse ]], ResultWrapper [CustomPageUpdateResponse ]),
123127 )
124128
125129 def list (
@@ -133,7 +137,7 @@ def list(
133137 extra_query : Query | None = None ,
134138 extra_body : Body | None = None ,
135139 timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
136- ) -> SyncSinglePage [object ]:
140+ ) -> SyncSinglePage [CustomPageListResponse ]:
137141 """
138142 Fetches all the custom pages.
139143
@@ -164,16 +168,24 @@ def list(
164168 account_or_zone_id = zone_id
165169 return self ._get_api_list (
166170 f"/{ account_or_zone } /{ account_or_zone_id } /custom_pages" ,
167- page = SyncSinglePage [object ],
171+ page = SyncSinglePage [CustomPageListResponse ],
168172 options = make_request_options (
169173 extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
170174 ),
171- model = object ,
175+ model = CustomPageListResponse ,
172176 )
173177
174178 def get (
175179 self ,
176- identifier : str ,
180+ identifier : Literal [
181+ "waf_block" ,
182+ "ip_block" ,
183+ "country_challenge" ,
184+ "500_errors" ,
185+ "1000_errors" ,
186+ "managed_challenge" ,
187+ "ratelimit_block" ,
188+ ],
177189 * ,
178190 account_id : str | NotGiven = NOT_GIVEN ,
179191 zone_id : str | NotGiven = NOT_GIVEN ,
@@ -188,7 +200,7 @@ def get(
188200 Fetches the details of a custom page.
189201
190202 Args:
191- identifier: Identifier
203+ identifier: Error Page Types
192204
193205 account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.
194206
@@ -216,21 +228,16 @@ def get(
216228
217229 account_or_zone = "zones"
218230 account_or_zone_id = zone_id
219- return cast (
220- Optional [CustomPageGetResponse ],
221- self ._get (
222- f"/{ account_or_zone } /{ account_or_zone_id } /custom_pages/{ identifier } " ,
223- options = make_request_options (
224- extra_headers = extra_headers ,
225- extra_query = extra_query ,
226- extra_body = extra_body ,
227- timeout = timeout ,
228- post_parser = ResultWrapper [Optional [CustomPageGetResponse ]]._unwrapper ,
229- ),
230- cast_to = cast (
231- Any , ResultWrapper [CustomPageGetResponse ]
232- ), # Union types cannot be passed in as arguments in the type system
231+ return self ._get (
232+ f"/{ account_or_zone } /{ account_or_zone_id } /custom_pages/{ identifier } " ,
233+ options = make_request_options (
234+ extra_headers = extra_headers ,
235+ extra_query = extra_query ,
236+ extra_body = extra_body ,
237+ timeout = timeout ,
238+ post_parser = ResultWrapper [Optional [CustomPageGetResponse ]]._unwrapper ,
233239 ),
240+ cast_to = cast (Type [Optional [CustomPageGetResponse ]], ResultWrapper [CustomPageGetResponse ]),
234241 )
235242
236243
@@ -256,7 +263,15 @@ def with_streaming_response(self) -> AsyncCustomPagesResourceWithStreamingRespon
256263
257264 async def update (
258265 self ,
259- identifier : str ,
266+ identifier : Literal [
267+ "waf_block" ,
268+ "ip_block" ,
269+ "country_challenge" ,
270+ "500_errors" ,
271+ "1000_errors" ,
272+ "managed_challenge" ,
273+ "ratelimit_block" ,
274+ ],
260275 * ,
261276 state : Literal ["default" , "customized" ],
262277 url : str ,
@@ -273,7 +288,7 @@ async def update(
273288 Updates the configuration of an existing custom page.
274289
275290 Args:
276- identifier: Identifier
291+ identifier: Error Page Types
277292
278293 state: The custom page state.
279294
@@ -305,28 +320,23 @@ async def update(
305320
306321 account_or_zone = "zones"
307322 account_or_zone_id = zone_id
308- return cast (
309- Optional [CustomPageUpdateResponse ],
310- await self ._put (
311- f"/{ account_or_zone } /{ account_or_zone_id } /custom_pages/{ identifier } " ,
312- body = await async_maybe_transform (
313- {
314- "state" : state ,
315- "url" : url ,
316- },
317- custom_page_update_params .CustomPageUpdateParams ,
318- ),
319- options = make_request_options (
320- extra_headers = extra_headers ,
321- extra_query = extra_query ,
322- extra_body = extra_body ,
323- timeout = timeout ,
324- post_parser = ResultWrapper [Optional [CustomPageUpdateResponse ]]._unwrapper ,
325- ),
326- cast_to = cast (
327- Any , ResultWrapper [CustomPageUpdateResponse ]
328- ), # Union types cannot be passed in as arguments in the type system
323+ return await self ._put (
324+ f"/{ account_or_zone } /{ account_or_zone_id } /custom_pages/{ identifier } " ,
325+ body = await async_maybe_transform (
326+ {
327+ "state" : state ,
328+ "url" : url ,
329+ },
330+ custom_page_update_params .CustomPageUpdateParams ,
329331 ),
332+ options = make_request_options (
333+ extra_headers = extra_headers ,
334+ extra_query = extra_query ,
335+ extra_body = extra_body ,
336+ timeout = timeout ,
337+ post_parser = ResultWrapper [Optional [CustomPageUpdateResponse ]]._unwrapper ,
338+ ),
339+ cast_to = cast (Type [Optional [CustomPageUpdateResponse ]], ResultWrapper [CustomPageUpdateResponse ]),
330340 )
331341
332342 def list (
@@ -340,7 +350,7 @@ def list(
340350 extra_query : Query | None = None ,
341351 extra_body : Body | None = None ,
342352 timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
343- ) -> AsyncPaginator [object , AsyncSinglePage [object ]]:
353+ ) -> AsyncPaginator [CustomPageListResponse , AsyncSinglePage [CustomPageListResponse ]]:
344354 """
345355 Fetches all the custom pages.
346356
@@ -371,16 +381,24 @@ def list(
371381 account_or_zone_id = zone_id
372382 return self ._get_api_list (
373383 f"/{ account_or_zone } /{ account_or_zone_id } /custom_pages" ,
374- page = AsyncSinglePage [object ],
384+ page = AsyncSinglePage [CustomPageListResponse ],
375385 options = make_request_options (
376386 extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
377387 ),
378- model = object ,
388+ model = CustomPageListResponse ,
379389 )
380390
381391 async def get (
382392 self ,
383- identifier : str ,
393+ identifier : Literal [
394+ "waf_block" ,
395+ "ip_block" ,
396+ "country_challenge" ,
397+ "500_errors" ,
398+ "1000_errors" ,
399+ "managed_challenge" ,
400+ "ratelimit_block" ,
401+ ],
384402 * ,
385403 account_id : str | NotGiven = NOT_GIVEN ,
386404 zone_id : str | NotGiven = NOT_GIVEN ,
@@ -395,7 +413,7 @@ async def get(
395413 Fetches the details of a custom page.
396414
397415 Args:
398- identifier: Identifier
416+ identifier: Error Page Types
399417
400418 account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.
401419
@@ -423,21 +441,16 @@ async def get(
423441
424442 account_or_zone = "zones"
425443 account_or_zone_id = zone_id
426- return cast (
427- Optional [CustomPageGetResponse ],
428- await self ._get (
429- f"/{ account_or_zone } /{ account_or_zone_id } /custom_pages/{ identifier } " ,
430- options = make_request_options (
431- extra_headers = extra_headers ,
432- extra_query = extra_query ,
433- extra_body = extra_body ,
434- timeout = timeout ,
435- post_parser = ResultWrapper [Optional [CustomPageGetResponse ]]._unwrapper ,
436- ),
437- cast_to = cast (
438- Any , ResultWrapper [CustomPageGetResponse ]
439- ), # Union types cannot be passed in as arguments in the type system
444+ return await self ._get (
445+ f"/{ account_or_zone } /{ account_or_zone_id } /custom_pages/{ identifier } " ,
446+ options = make_request_options (
447+ extra_headers = extra_headers ,
448+ extra_query = extra_query ,
449+ extra_body = extra_body ,
450+ timeout = timeout ,
451+ post_parser = ResultWrapper [Optional [CustomPageGetResponse ]]._unwrapper ,
440452 ),
453+ cast_to = cast (Type [Optional [CustomPageGetResponse ]], ResultWrapper [CustomPageGetResponse ]),
441454 )
442455
443456
0 commit comments