Skip to content

Commit a51aa98

Browse files
feat(api): api update
1 parent 2528e34 commit a51aa98

8 files changed

Lines changed: 221 additions & 156 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 1782
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-3d3fc261af1dcfd29dc261b9693276ed85a63fd68bb9fd32f3338dc56890f487.yml
3-
openapi_spec_hash: 5b0319bba3aa3b4ee74ceb0c9a3e565a
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-919d342c1261dd7a87ae8a67fc6c2117465be3579aefd581f12a35e6e1dd9d35.yml
3+
openapi_spec_hash: e76db51836ef60b3a31b1e1e340908be
44
config_hash: eda5b3d9487ce675d1fadf88153b457d

api.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9885,13 +9885,17 @@ Methods:
98859885
Types:
98869886

98879887
```python
9888-
from cloudflare.types.custom_pages import CustomPageUpdateResponse, CustomPageGetResponse
9888+
from cloudflare.types.custom_pages import (
9889+
CustomPageUpdateResponse,
9890+
CustomPageListResponse,
9891+
CustomPageGetResponse,
9892+
)
98899893
```
98909894

98919895
Methods:
98929896

98939897
- <code title="put /{accounts_or_zones}/{account_or_zone_id}/custom_pages/{identifier}">client.custom_pages.<a href="./src/cloudflare/resources/custom_pages.py">update</a>(identifier, \*, account_id, zone_id, \*\*<a href="src/cloudflare/types/custom_pages/custom_page_update_params.py">params</a>) -> <a href="./src/cloudflare/types/custom_pages/custom_page_update_response.py">Optional[CustomPageUpdateResponse]</a></code>
9894-
- <code title="get /{accounts_or_zones}/{account_or_zone_id}/custom_pages">client.custom_pages.<a href="./src/cloudflare/resources/custom_pages.py">list</a>(\*, account_id, zone_id) -> SyncSinglePage[object]</code>
9898+
- <code title="get /{accounts_or_zones}/{account_or_zone_id}/custom_pages">client.custom_pages.<a href="./src/cloudflare/resources/custom_pages.py">list</a>(\*, account_id, zone_id) -> <a href="./src/cloudflare/types/custom_pages/custom_page_list_response.py">SyncSinglePage[CustomPageListResponse]</a></code>
98959899
- <code title="get /{accounts_or_zones}/{account_or_zone_id}/custom_pages/{identifier}">client.custom_pages.<a href="./src/cloudflare/resources/custom_pages.py">get</a>(identifier, \*, account_id, zone_id) -> <a href="./src/cloudflare/types/custom_pages/custom_page_get_response.py">Optional[CustomPageGetResponse]</a></code>
98969900

98979901
# SecretsStore

src/cloudflare/resources/custom_pages.py

Lines changed: 98 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from typing import Any, Optional, cast
5+
from typing import Type, Optional, cast
66
from typing_extensions import Literal
77

88
import httpx
@@ -22,6 +22,7 @@
2222
from .._base_client import AsyncPaginator, make_request_options
2323
from ..types.custom_pages import custom_page_update_params
2424
from ..types.custom_pages.custom_page_get_response import CustomPageGetResponse
25+
from ..types.custom_pages.custom_page_list_response import CustomPageListResponse
2526
from ..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

src/cloudflare/types/custom_pages/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
from __future__ import annotations
44

55
from .custom_page_get_response import CustomPageGetResponse as CustomPageGetResponse
6+
from .custom_page_list_response import CustomPageListResponse as CustomPageListResponse
67
from .custom_page_update_params import CustomPageUpdateParams as CustomPageUpdateParams
78
from .custom_page_update_response import CustomPageUpdateResponse as CustomPageUpdateResponse
Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,29 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
from typing import Union
4-
from typing_extensions import TypeAlias
3+
from typing import List, Optional
4+
from datetime import datetime
5+
from typing_extensions import Literal
6+
7+
from ..._models import BaseModel
58

69
__all__ = ["CustomPageGetResponse"]
710

8-
CustomPageGetResponse: TypeAlias = Union[str, object, None]
11+
12+
class CustomPageGetResponse(BaseModel):
13+
id: Optional[str] = None
14+
15+
created_on: Optional[datetime] = None
16+
17+
description: Optional[str] = None
18+
19+
modified_on: Optional[datetime] = None
20+
21+
preview_target: Optional[str] = None
22+
23+
required_tokens: Optional[List[str]] = None
24+
25+
state: Optional[Literal["default", "customized"]] = None
26+
"""The custom page state."""
27+
28+
url: Optional[str] = None
29+
"""The URL associated with the custom page."""

0 commit comments

Comments
 (0)