Skip to content

Commit f21869f

Browse files
feat(api): Add PATCH zone hold update method (#2268)
1 parent 165bc8c commit f21869f

File tree

5 files changed

+123
-123
lines changed

5 files changed

+123
-123
lines changed

api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,8 @@ from cloudflare.types.zones import ZoneHold
416416
Methods:
417417

418418
- <code title="post /zones/{zone_id}/hold">client.zones.holds.<a href="./src/cloudflare/resources/zones/holds.py">create</a>(\*, zone_id, \*\*<a href="src/cloudflare/types/zones/hold_create_params.py">params</a>) -> <a href="./src/cloudflare/types/zones/zone_hold.py">ZoneHold</a></code>
419+
- <code title="patch /zones/{zone_id}/hold">client.zones.holds.<a href="./src/cloudflare/resources/zones/holds.py">update</a>(\*, zone_id, \*\*<a href="src/cloudflare/types/zones/hold_update_params.py">params</a>) -> <a href="./src/cloudflare/types/zones/zone_hold.py">ZoneHold</a></code>
419420
- <code title="delete /zones/{zone_id}/hold">client.zones.holds.<a href="./src/cloudflare/resources/zones/holds.py">delete</a>(\*, zone_id, \*\*<a href="src/cloudflare/types/zones/hold_delete_params.py">params</a>) -> <a href="./src/cloudflare/types/zones/zone_hold.py">ZoneHold</a></code>
420-
- <code title="patch /zones/{zone_id}/hold">client.zones.holds.<a href="./src/cloudflare/resources/zones/holds.py">edit</a>(\*, zone_id, \*\*<a href="src/cloudflare/types/zones/hold_edit_params.py">params</a>) -> <a href="./src/cloudflare/types/zones/zone_hold.py">ZoneHold</a></code>
421421
- <code title="get /zones/{zone_id}/hold">client.zones.holds.<a href="./src/cloudflare/resources/zones/holds.py">get</a>(\*, zone_id) -> <a href="./src/cloudflare/types/zones/zone_hold.py">ZoneHold</a></code>
422422

423423
## Subscriptions

src/cloudflare/resources/zones/holds.py

+73-73
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
async_to_streamed_response_wrapper,
2121
)
2222
from ..._wrappers import ResultWrapper
23-
from ...types.zones import hold_edit_params, hold_create_params, hold_delete_params
23+
from ...types.zones import hold_create_params, hold_delete_params, hold_update_params
2424
from ..._base_client import make_request_options
2525
from ...types.zones.zone_hold import ZoneHold
2626

@@ -94,11 +94,12 @@ def create(
9494
cast_to=cast(Type[ZoneHold], ResultWrapper[ZoneHold]),
9595
)
9696

97-
def delete(
97+
def update(
9898
self,
9999
*,
100100
zone_id: str,
101101
hold_after: str | NotGiven = NOT_GIVEN,
102+
include_subdomains: bool | NotGiven = NOT_GIVEN,
102103
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
103104
# The extra values given here take precedence over values defined on the client or passed to this method.
104105
extra_headers: Headers | None = None,
@@ -107,15 +108,22 @@ def delete(
107108
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
108109
) -> ZoneHold:
109110
"""
110-
Stop enforcement of a zone hold on the zone, permanently or temporarily,
111-
allowing the creation and activation of zones with this zone's hostname.
111+
Update the `hold_after` and/or `include_subdomains` values on an existing zone
112+
hold. The hold is enabled if the `hold_after` date-time value is in the past.
112113
113114
Args:
114115
zone_id: Identifier
115116
116-
hold_after: If `hold_after` is provided, the hold will be temporarily disabled, then
117-
automatically re-enabled by the system at the time specified in this
118-
RFC3339-formatted timestamp. Otherwise, the hold will be disabled indefinitely.
117+
hold_after: If `hold_after` is provided and future-dated, the hold will be temporarily
118+
disabled, then automatically re-enabled by the system at the time specified in
119+
this RFC3339-formatted timestamp. A past-dated `hold_after` value will have no
120+
effect on an existing, enabled hold. Providing an empty string will set its
121+
value to the current time.
122+
123+
include_subdomains: If `true`, the zone hold will extend to block any subdomain of the given zone,
124+
as well as SSL4SaaS Custom Hostnames. For example, a zone hold on a zone with
125+
the hostname 'example.com' and include_subdomains=true will block 'example.com',
126+
'staging.example.com', 'api.staging.example.com', etc.
119127
120128
extra_headers: Send extra headers
121129
@@ -127,25 +135,30 @@ def delete(
127135
"""
128136
if not zone_id:
129137
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
130-
return self._delete(
138+
return self._patch(
131139
f"/zones/{zone_id}/hold",
140+
body=maybe_transform(
141+
{
142+
"hold_after": hold_after,
143+
"include_subdomains": include_subdomains,
144+
},
145+
hold_update_params.HoldUpdateParams,
146+
),
132147
options=make_request_options(
133148
extra_headers=extra_headers,
134149
extra_query=extra_query,
135150
extra_body=extra_body,
136151
timeout=timeout,
137-
query=maybe_transform({"hold_after": hold_after}, hold_delete_params.HoldDeleteParams),
138152
post_parser=ResultWrapper[ZoneHold]._unwrapper,
139153
),
140154
cast_to=cast(Type[ZoneHold], ResultWrapper[ZoneHold]),
141155
)
142156

143-
def edit(
157+
def delete(
144158
self,
145159
*,
146160
zone_id: str,
147161
hold_after: str | NotGiven = NOT_GIVEN,
148-
include_subdomains: bool | NotGiven = NOT_GIVEN,
149162
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
150163
# The extra values given here take precedence over values defined on the client or passed to this method.
151164
extra_headers: Headers | None = None,
@@ -154,22 +167,15 @@ def edit(
154167
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
155168
) -> ZoneHold:
156169
"""
157-
Update the `hold_after` and/or `include_subdomains` values on an existing zone
158-
hold. The hold is enabled if the `hold_after` date-time value is in the past.
170+
Stop enforcement of a zone hold on the zone, permanently or temporarily,
171+
allowing the creation and activation of zones with this zone's hostname.
159172
160173
Args:
161174
zone_id: Identifier
162175
163-
hold_after: If `hold_after` is provided and future-dated, the hold will be temporarily
164-
disabled, then automatically re-enabled by the system at the time specified in
165-
this RFC3339-formatted timestamp. A past-dated `hold_after` value will have no
166-
effect on an existing, enabled hold. Providing an empty string will set its
167-
value to the current time.
168-
169-
include_subdomains: If `true`, the zone hold will extend to block any subdomain of the given zone,
170-
as well as SSL4SaaS Custom Hostnames. For example, a zone hold on a zone with
171-
the hostname 'example.com' and include_subdomains=true will block 'example.com',
172-
'staging.example.com', 'api.staging.example.com', etc.
176+
hold_after: If `hold_after` is provided, the hold will be temporarily disabled, then
177+
automatically re-enabled by the system at the time specified in this
178+
RFC3339-formatted timestamp. Otherwise, the hold will be disabled indefinitely.
173179
174180
extra_headers: Send extra headers
175181
@@ -181,20 +187,14 @@ def edit(
181187
"""
182188
if not zone_id:
183189
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
184-
return self._patch(
190+
return self._delete(
185191
f"/zones/{zone_id}/hold",
186-
body=maybe_transform(
187-
{
188-
"hold_after": hold_after,
189-
"include_subdomains": include_subdomains,
190-
},
191-
hold_edit_params.HoldEditParams,
192-
),
193192
options=make_request_options(
194193
extra_headers=extra_headers,
195194
extra_query=extra_query,
196195
extra_body=extra_body,
197196
timeout=timeout,
197+
query=maybe_transform({"hold_after": hold_after}, hold_delete_params.HoldDeleteParams),
198198
post_parser=ResultWrapper[ZoneHold]._unwrapper,
199199
),
200200
cast_to=cast(Type[ZoneHold], ResultWrapper[ZoneHold]),
@@ -310,11 +310,12 @@ async def create(
310310
cast_to=cast(Type[ZoneHold], ResultWrapper[ZoneHold]),
311311
)
312312

313-
async def delete(
313+
async def update(
314314
self,
315315
*,
316316
zone_id: str,
317317
hold_after: str | NotGiven = NOT_GIVEN,
318+
include_subdomains: bool | NotGiven = NOT_GIVEN,
318319
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
319320
# The extra values given here take precedence over values defined on the client or passed to this method.
320321
extra_headers: Headers | None = None,
@@ -323,15 +324,22 @@ async def delete(
323324
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
324325
) -> ZoneHold:
325326
"""
326-
Stop enforcement of a zone hold on the zone, permanently or temporarily,
327-
allowing the creation and activation of zones with this zone's hostname.
327+
Update the `hold_after` and/or `include_subdomains` values on an existing zone
328+
hold. The hold is enabled if the `hold_after` date-time value is in the past.
328329
329330
Args:
330331
zone_id: Identifier
331332
332-
hold_after: If `hold_after` is provided, the hold will be temporarily disabled, then
333-
automatically re-enabled by the system at the time specified in this
334-
RFC3339-formatted timestamp. Otherwise, the hold will be disabled indefinitely.
333+
hold_after: If `hold_after` is provided and future-dated, the hold will be temporarily
334+
disabled, then automatically re-enabled by the system at the time specified in
335+
this RFC3339-formatted timestamp. A past-dated `hold_after` value will have no
336+
effect on an existing, enabled hold. Providing an empty string will set its
337+
value to the current time.
338+
339+
include_subdomains: If `true`, the zone hold will extend to block any subdomain of the given zone,
340+
as well as SSL4SaaS Custom Hostnames. For example, a zone hold on a zone with
341+
the hostname 'example.com' and include_subdomains=true will block 'example.com',
342+
'staging.example.com', 'api.staging.example.com', etc.
335343
336344
extra_headers: Send extra headers
337345
@@ -343,25 +351,30 @@ async def delete(
343351
"""
344352
if not zone_id:
345353
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
346-
return await self._delete(
354+
return await self._patch(
347355
f"/zones/{zone_id}/hold",
356+
body=await async_maybe_transform(
357+
{
358+
"hold_after": hold_after,
359+
"include_subdomains": include_subdomains,
360+
},
361+
hold_update_params.HoldUpdateParams,
362+
),
348363
options=make_request_options(
349364
extra_headers=extra_headers,
350365
extra_query=extra_query,
351366
extra_body=extra_body,
352367
timeout=timeout,
353-
query=await async_maybe_transform({"hold_after": hold_after}, hold_delete_params.HoldDeleteParams),
354368
post_parser=ResultWrapper[ZoneHold]._unwrapper,
355369
),
356370
cast_to=cast(Type[ZoneHold], ResultWrapper[ZoneHold]),
357371
)
358372

359-
async def edit(
373+
async def delete(
360374
self,
361375
*,
362376
zone_id: str,
363377
hold_after: str | NotGiven = NOT_GIVEN,
364-
include_subdomains: bool | NotGiven = NOT_GIVEN,
365378
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
366379
# The extra values given here take precedence over values defined on the client or passed to this method.
367380
extra_headers: Headers | None = None,
@@ -370,22 +383,15 @@ async def edit(
370383
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
371384
) -> ZoneHold:
372385
"""
373-
Update the `hold_after` and/or `include_subdomains` values on an existing zone
374-
hold. The hold is enabled if the `hold_after` date-time value is in the past.
386+
Stop enforcement of a zone hold on the zone, permanently or temporarily,
387+
allowing the creation and activation of zones with this zone's hostname.
375388
376389
Args:
377390
zone_id: Identifier
378391
379-
hold_after: If `hold_after` is provided and future-dated, the hold will be temporarily
380-
disabled, then automatically re-enabled by the system at the time specified in
381-
this RFC3339-formatted timestamp. A past-dated `hold_after` value will have no
382-
effect on an existing, enabled hold. Providing an empty string will set its
383-
value to the current time.
384-
385-
include_subdomains: If `true`, the zone hold will extend to block any subdomain of the given zone,
386-
as well as SSL4SaaS Custom Hostnames. For example, a zone hold on a zone with
387-
the hostname 'example.com' and include_subdomains=true will block 'example.com',
388-
'staging.example.com', 'api.staging.example.com', etc.
392+
hold_after: If `hold_after` is provided, the hold will be temporarily disabled, then
393+
automatically re-enabled by the system at the time specified in this
394+
RFC3339-formatted timestamp. Otherwise, the hold will be disabled indefinitely.
389395
390396
extra_headers: Send extra headers
391397
@@ -397,20 +403,14 @@ async def edit(
397403
"""
398404
if not zone_id:
399405
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
400-
return await self._patch(
406+
return await self._delete(
401407
f"/zones/{zone_id}/hold",
402-
body=await async_maybe_transform(
403-
{
404-
"hold_after": hold_after,
405-
"include_subdomains": include_subdomains,
406-
},
407-
hold_edit_params.HoldEditParams,
408-
),
409408
options=make_request_options(
410409
extra_headers=extra_headers,
411410
extra_query=extra_query,
412411
extra_body=extra_body,
413412
timeout=timeout,
413+
query=await async_maybe_transform({"hold_after": hold_after}, hold_delete_params.HoldDeleteParams),
414414
post_parser=ResultWrapper[ZoneHold]._unwrapper,
415415
),
416416
cast_to=cast(Type[ZoneHold], ResultWrapper[ZoneHold]),
@@ -464,12 +464,12 @@ def __init__(self, holds: HoldsResource) -> None:
464464
self.create = to_raw_response_wrapper(
465465
holds.create,
466466
)
467+
self.update = to_raw_response_wrapper(
468+
holds.update,
469+
)
467470
self.delete = to_raw_response_wrapper(
468471
holds.delete,
469472
)
470-
self.edit = to_raw_response_wrapper(
471-
holds.edit,
472-
)
473473
self.get = to_raw_response_wrapper(
474474
holds.get,
475475
)
@@ -482,12 +482,12 @@ def __init__(self, holds: AsyncHoldsResource) -> None:
482482
self.create = async_to_raw_response_wrapper(
483483
holds.create,
484484
)
485+
self.update = async_to_raw_response_wrapper(
486+
holds.update,
487+
)
485488
self.delete = async_to_raw_response_wrapper(
486489
holds.delete,
487490
)
488-
self.edit = async_to_raw_response_wrapper(
489-
holds.edit,
490-
)
491491
self.get = async_to_raw_response_wrapper(
492492
holds.get,
493493
)
@@ -500,12 +500,12 @@ def __init__(self, holds: HoldsResource) -> None:
500500
self.create = to_streamed_response_wrapper(
501501
holds.create,
502502
)
503+
self.update = to_streamed_response_wrapper(
504+
holds.update,
505+
)
503506
self.delete = to_streamed_response_wrapper(
504507
holds.delete,
505508
)
506-
self.edit = to_streamed_response_wrapper(
507-
holds.edit,
508-
)
509509
self.get = to_streamed_response_wrapper(
510510
holds.get,
511511
)
@@ -518,12 +518,12 @@ def __init__(self, holds: AsyncHoldsResource) -> None:
518518
self.create = async_to_streamed_response_wrapper(
519519
holds.create,
520520
)
521+
self.update = async_to_streamed_response_wrapper(
522+
holds.update,
523+
)
521524
self.delete = async_to_streamed_response_wrapper(
522525
holds.delete,
523526
)
524-
self.edit = async_to_streamed_response_wrapper(
525-
holds.edit,
526-
)
527527
self.get = async_to_streamed_response_wrapper(
528528
holds.get,
529529
)

src/cloudflare/types/zones/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
from .websocket_param import WebsocketParam as WebsocketParam
5050
from .always_use_https import AlwaysUseHTTPS as AlwaysUseHTTPS
5151
from .development_mode import DevelopmentMode as DevelopmentMode
52-
from .hold_edit_params import HoldEditParams as HoldEditParams
5352
from .orange_to_orange import OrangeToOrange as OrangeToOrange
5453
from .prefetch_preload import PrefetchPreload as PrefetchPreload
5554
from .security_headers import SecurityHeaders as SecurityHeaders
@@ -63,6 +62,7 @@
6362
from .pseudo_ipv4_param import PseudoIPV4Param as PseudoIPV4Param
6463
from .hold_create_params import HoldCreateParams as HoldCreateParams
6564
from .hold_delete_params import HoldDeleteParams as HoldDeleteParams
65+
from .hold_update_params import HoldUpdateParams as HoldUpdateParams
6666
from .hotlink_protection import HotlinkProtection as HotlinkProtection
6767
from .proxy_read_timeout import ProxyReadTimeout as ProxyReadTimeout
6868
from .response_buffering import ResponseBuffering as ResponseBuffering

src/cloudflare/types/zones/hold_edit_params.py src/cloudflare/types/zones/hold_update_params.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
from typing_extensions import Required, TypedDict
66

7-
__all__ = ["HoldEditParams"]
7+
__all__ = ["HoldUpdateParams"]
88

99

10-
class HoldEditParams(TypedDict, total=False):
10+
class HoldUpdateParams(TypedDict, total=False):
1111
zone_id: Required[str]
1212
"""Identifier"""
1313

0 commit comments

Comments
 (0)