Skip to content

Commit

Permalink
feat(api): Add PATCH zone hold update method (#2268)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Dec 13, 2024
1 parent 165bc8c commit f21869f
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 123 deletions.
2 changes: 1 addition & 1 deletion api.md
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,8 @@ from cloudflare.types.zones import ZoneHold
Methods:

- <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>
- <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>
- <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>
- <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>
- <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>

## Subscriptions
Expand Down
146 changes: 73 additions & 73 deletions src/cloudflare/resources/zones/holds.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
async_to_streamed_response_wrapper,
)
from ..._wrappers import ResultWrapper
from ...types.zones import hold_edit_params, hold_create_params, hold_delete_params
from ...types.zones import hold_create_params, hold_delete_params, hold_update_params
from ..._base_client import make_request_options
from ...types.zones.zone_hold import ZoneHold

Expand Down Expand Up @@ -94,11 +94,12 @@ def create(
cast_to=cast(Type[ZoneHold], ResultWrapper[ZoneHold]),
)

def delete(
def update(
self,
*,
zone_id: str,
hold_after: str | NotGiven = NOT_GIVEN,
include_subdomains: bool | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand All @@ -107,15 +108,22 @@ def delete(
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> ZoneHold:
"""
Stop enforcement of a zone hold on the zone, permanently or temporarily,
allowing the creation and activation of zones with this zone's hostname.
Update the `hold_after` and/or `include_subdomains` values on an existing zone
hold. The hold is enabled if the `hold_after` date-time value is in the past.
Args:
zone_id: Identifier
hold_after: If `hold_after` is provided, the hold will be temporarily disabled, then
automatically re-enabled by the system at the time specified in this
RFC3339-formatted timestamp. Otherwise, the hold will be disabled indefinitely.
hold_after: If `hold_after` is provided and future-dated, the hold will be temporarily
disabled, then automatically re-enabled by the system at the time specified in
this RFC3339-formatted timestamp. A past-dated `hold_after` value will have no
effect on an existing, enabled hold. Providing an empty string will set its
value to the current time.
include_subdomains: If `true`, the zone hold will extend to block any subdomain of the given zone,
as well as SSL4SaaS Custom Hostnames. For example, a zone hold on a zone with
the hostname 'example.com' and include_subdomains=true will block 'example.com',
'staging.example.com', 'api.staging.example.com', etc.
extra_headers: Send extra headers
Expand All @@ -127,25 +135,30 @@ def delete(
"""
if not zone_id:
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
return self._delete(
return self._patch(
f"/zones/{zone_id}/hold",
body=maybe_transform(
{
"hold_after": hold_after,
"include_subdomains": include_subdomains,
},
hold_update_params.HoldUpdateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform({"hold_after": hold_after}, hold_delete_params.HoldDeleteParams),
post_parser=ResultWrapper[ZoneHold]._unwrapper,
),
cast_to=cast(Type[ZoneHold], ResultWrapper[ZoneHold]),
)

def edit(
def delete(
self,
*,
zone_id: str,
hold_after: str | NotGiven = NOT_GIVEN,
include_subdomains: bool | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand All @@ -154,22 +167,15 @@ def edit(
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> ZoneHold:
"""
Update the `hold_after` and/or `include_subdomains` values on an existing zone
hold. The hold is enabled if the `hold_after` date-time value is in the past.
Stop enforcement of a zone hold on the zone, permanently or temporarily,
allowing the creation and activation of zones with this zone's hostname.
Args:
zone_id: Identifier
hold_after: If `hold_after` is provided and future-dated, the hold will be temporarily
disabled, then automatically re-enabled by the system at the time specified in
this RFC3339-formatted timestamp. A past-dated `hold_after` value will have no
effect on an existing, enabled hold. Providing an empty string will set its
value to the current time.
include_subdomains: If `true`, the zone hold will extend to block any subdomain of the given zone,
as well as SSL4SaaS Custom Hostnames. For example, a zone hold on a zone with
the hostname 'example.com' and include_subdomains=true will block 'example.com',
'staging.example.com', 'api.staging.example.com', etc.
hold_after: If `hold_after` is provided, the hold will be temporarily disabled, then
automatically re-enabled by the system at the time specified in this
RFC3339-formatted timestamp. Otherwise, the hold will be disabled indefinitely.
extra_headers: Send extra headers
Expand All @@ -181,20 +187,14 @@ def edit(
"""
if not zone_id:
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
return self._patch(
return self._delete(
f"/zones/{zone_id}/hold",
body=maybe_transform(
{
"hold_after": hold_after,
"include_subdomains": include_subdomains,
},
hold_edit_params.HoldEditParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform({"hold_after": hold_after}, hold_delete_params.HoldDeleteParams),
post_parser=ResultWrapper[ZoneHold]._unwrapper,
),
cast_to=cast(Type[ZoneHold], ResultWrapper[ZoneHold]),
Expand Down Expand Up @@ -310,11 +310,12 @@ async def create(
cast_to=cast(Type[ZoneHold], ResultWrapper[ZoneHold]),
)

async def delete(
async def update(
self,
*,
zone_id: str,
hold_after: str | NotGiven = NOT_GIVEN,
include_subdomains: bool | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand All @@ -323,15 +324,22 @@ async def delete(
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> ZoneHold:
"""
Stop enforcement of a zone hold on the zone, permanently or temporarily,
allowing the creation and activation of zones with this zone's hostname.
Update the `hold_after` and/or `include_subdomains` values on an existing zone
hold. The hold is enabled if the `hold_after` date-time value is in the past.
Args:
zone_id: Identifier
hold_after: If `hold_after` is provided, the hold will be temporarily disabled, then
automatically re-enabled by the system at the time specified in this
RFC3339-formatted timestamp. Otherwise, the hold will be disabled indefinitely.
hold_after: If `hold_after` is provided and future-dated, the hold will be temporarily
disabled, then automatically re-enabled by the system at the time specified in
this RFC3339-formatted timestamp. A past-dated `hold_after` value will have no
effect on an existing, enabled hold. Providing an empty string will set its
value to the current time.
include_subdomains: If `true`, the zone hold will extend to block any subdomain of the given zone,
as well as SSL4SaaS Custom Hostnames. For example, a zone hold on a zone with
the hostname 'example.com' and include_subdomains=true will block 'example.com',
'staging.example.com', 'api.staging.example.com', etc.
extra_headers: Send extra headers
Expand All @@ -343,25 +351,30 @@ async def delete(
"""
if not zone_id:
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
return await self._delete(
return await self._patch(
f"/zones/{zone_id}/hold",
body=await async_maybe_transform(
{
"hold_after": hold_after,
"include_subdomains": include_subdomains,
},
hold_update_params.HoldUpdateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=await async_maybe_transform({"hold_after": hold_after}, hold_delete_params.HoldDeleteParams),
post_parser=ResultWrapper[ZoneHold]._unwrapper,
),
cast_to=cast(Type[ZoneHold], ResultWrapper[ZoneHold]),
)

async def edit(
async def delete(
self,
*,
zone_id: str,
hold_after: str | NotGiven = NOT_GIVEN,
include_subdomains: bool | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand All @@ -370,22 +383,15 @@ async def edit(
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> ZoneHold:
"""
Update the `hold_after` and/or `include_subdomains` values on an existing zone
hold. The hold is enabled if the `hold_after` date-time value is in the past.
Stop enforcement of a zone hold on the zone, permanently or temporarily,
allowing the creation and activation of zones with this zone's hostname.
Args:
zone_id: Identifier
hold_after: If `hold_after` is provided and future-dated, the hold will be temporarily
disabled, then automatically re-enabled by the system at the time specified in
this RFC3339-formatted timestamp. A past-dated `hold_after` value will have no
effect on an existing, enabled hold. Providing an empty string will set its
value to the current time.
include_subdomains: If `true`, the zone hold will extend to block any subdomain of the given zone,
as well as SSL4SaaS Custom Hostnames. For example, a zone hold on a zone with
the hostname 'example.com' and include_subdomains=true will block 'example.com',
'staging.example.com', 'api.staging.example.com', etc.
hold_after: If `hold_after` is provided, the hold will be temporarily disabled, then
automatically re-enabled by the system at the time specified in this
RFC3339-formatted timestamp. Otherwise, the hold will be disabled indefinitely.
extra_headers: Send extra headers
Expand All @@ -397,20 +403,14 @@ async def edit(
"""
if not zone_id:
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
return await self._patch(
return await self._delete(
f"/zones/{zone_id}/hold",
body=await async_maybe_transform(
{
"hold_after": hold_after,
"include_subdomains": include_subdomains,
},
hold_edit_params.HoldEditParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=await async_maybe_transform({"hold_after": hold_after}, hold_delete_params.HoldDeleteParams),
post_parser=ResultWrapper[ZoneHold]._unwrapper,
),
cast_to=cast(Type[ZoneHold], ResultWrapper[ZoneHold]),
Expand Down Expand Up @@ -464,12 +464,12 @@ def __init__(self, holds: HoldsResource) -> None:
self.create = to_raw_response_wrapper(
holds.create,
)
self.update = to_raw_response_wrapper(
holds.update,
)
self.delete = to_raw_response_wrapper(
holds.delete,
)
self.edit = to_raw_response_wrapper(
holds.edit,
)
self.get = to_raw_response_wrapper(
holds.get,
)
Expand All @@ -482,12 +482,12 @@ def __init__(self, holds: AsyncHoldsResource) -> None:
self.create = async_to_raw_response_wrapper(
holds.create,
)
self.update = async_to_raw_response_wrapper(
holds.update,
)
self.delete = async_to_raw_response_wrapper(
holds.delete,
)
self.edit = async_to_raw_response_wrapper(
holds.edit,
)
self.get = async_to_raw_response_wrapper(
holds.get,
)
Expand All @@ -500,12 +500,12 @@ def __init__(self, holds: HoldsResource) -> None:
self.create = to_streamed_response_wrapper(
holds.create,
)
self.update = to_streamed_response_wrapper(
holds.update,
)
self.delete = to_streamed_response_wrapper(
holds.delete,
)
self.edit = to_streamed_response_wrapper(
holds.edit,
)
self.get = to_streamed_response_wrapper(
holds.get,
)
Expand All @@ -518,12 +518,12 @@ def __init__(self, holds: AsyncHoldsResource) -> None:
self.create = async_to_streamed_response_wrapper(
holds.create,
)
self.update = async_to_streamed_response_wrapper(
holds.update,
)
self.delete = async_to_streamed_response_wrapper(
holds.delete,
)
self.edit = async_to_streamed_response_wrapper(
holds.edit,
)
self.get = async_to_streamed_response_wrapper(
holds.get,
)
2 changes: 1 addition & 1 deletion src/cloudflare/types/zones/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
from .websocket_param import WebsocketParam as WebsocketParam
from .always_use_https import AlwaysUseHTTPS as AlwaysUseHTTPS
from .development_mode import DevelopmentMode as DevelopmentMode
from .hold_edit_params import HoldEditParams as HoldEditParams
from .orange_to_orange import OrangeToOrange as OrangeToOrange
from .prefetch_preload import PrefetchPreload as PrefetchPreload
from .security_headers import SecurityHeaders as SecurityHeaders
Expand All @@ -63,6 +62,7 @@
from .pseudo_ipv4_param import PseudoIPV4Param as PseudoIPV4Param
from .hold_create_params import HoldCreateParams as HoldCreateParams
from .hold_delete_params import HoldDeleteParams as HoldDeleteParams
from .hold_update_params import HoldUpdateParams as HoldUpdateParams
from .hotlink_protection import HotlinkProtection as HotlinkProtection
from .proxy_read_timeout import ProxyReadTimeout as ProxyReadTimeout
from .response_buffering import ResponseBuffering as ResponseBuffering
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

from typing_extensions import Required, TypedDict

__all__ = ["HoldEditParams"]
__all__ = ["HoldUpdateParams"]


class HoldEditParams(TypedDict, total=False):
class HoldUpdateParams(TypedDict, total=False):
zone_id: Required[str]
"""Identifier"""

Expand Down
Loading

0 comments on commit f21869f

Please sign in to comment.