Skip to content

Commit f4f5156

Browse files
feat: fix(total_tls): use upsert pattern for singleton zone setting
Changes total_tls from a create-based resource to an upsert-based resource, allowing in-place updates instead of destroy/recreate cycles. Fixes SECENG-13185
1 parent 1cee2cf commit f4f5156

9 files changed

Lines changed: 334 additions & 58 deletions

File tree

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 2015
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-83f49bc3fa9273ef989d3e8bcd27f6fdaa7d04ae2519a91f4878f46acc501bb9.yml
33
openapi_spec_hash: 3f4be3af6f51eea4787dc8345f9ca9c1
4-
config_hash: 53e953f2cbcf9a04714c4c2d0826f91c
4+
config_hash: 6648a23494f4fd69dedbd45bd743138a

api.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -855,12 +855,18 @@ Methods:
855855
Types:
856856

857857
```python
858-
from cloudflare.types.acm import CertificateAuthority, TotalTLSCreateResponse, TotalTLSGetResponse
858+
from cloudflare.types.acm import (
859+
CertificateAuthority,
860+
TotalTLSUpdateResponse,
861+
TotalTLSEditResponse,
862+
TotalTLSGetResponse,
863+
)
859864
```
860865

861866
Methods:
862867

863-
- <code title="post /zones/{zone_id}/acm/total_tls">client.acm.total_tls.<a href="./src/cloudflare/resources/acm/total_tls.py">create</a>(\*, zone_id, \*\*<a href="src/cloudflare/types/acm/total_tls_create_params.py">params</a>) -> <a href="./src/cloudflare/types/acm/total_tls_create_response.py">Optional[TotalTLSCreateResponse]</a></code>
868+
- <code title="post /zones/{zone_id}/acm/total_tls">client.acm.total_tls.<a href="./src/cloudflare/resources/acm/total_tls.py">update</a>(\*, zone_id, \*\*<a href="src/cloudflare/types/acm/total_tls_update_params.py">params</a>) -> <a href="./src/cloudflare/types/acm/total_tls_update_response.py">Optional[TotalTLSUpdateResponse]</a></code>
869+
- <code title="post /zones/{zone_id}/acm/total_tls">client.acm.total_tls.<a href="./src/cloudflare/resources/acm/total_tls.py">edit</a>(\*, zone_id, \*\*<a href="src/cloudflare/types/acm/total_tls_edit_params.py">params</a>) -> <a href="./src/cloudflare/types/acm/total_tls_edit_response.py">Optional[TotalTLSEditResponse]</a></code>
864870
- <code title="get /zones/{zone_id}/acm/total_tls">client.acm.total_tls.<a href="./src/cloudflare/resources/acm/total_tls.py">get</a>(\*, zone_id) -> <a href="./src/cloudflare/types/acm/total_tls_get_response.py">Optional[TotalTLSGetResponse]</a></code>
865871

866872
# Argo

src/cloudflare/resources/acm/total_tls.py

Lines changed: 139 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@
1717
async_to_streamed_response_wrapper,
1818
)
1919
from ..._wrappers import ResultWrapper
20-
from ...types.acm import CertificateAuthority, total_tls_create_params
20+
from ...types.acm import CertificateAuthority, total_tls_edit_params, total_tls_update_params
2121
from ..._base_client import make_request_options
2222
from ...types.acm.certificate_authority import CertificateAuthority
2323
from ...types.acm.total_tls_get_response import TotalTLSGetResponse
24-
from ...types.acm.total_tls_create_response import TotalTLSCreateResponse
24+
from ...types.acm.total_tls_edit_response import TotalTLSEditResponse
25+
from ...types.acm.total_tls_update_response import TotalTLSUpdateResponse
2526

2627
__all__ = ["TotalTLSResource", "AsyncTotalTLSResource"]
2728

@@ -46,7 +47,7 @@ def with_streaming_response(self) -> TotalTLSResourceWithStreamingResponse:
4647
"""
4748
return TotalTLSResourceWithStreamingResponse(self)
4849

49-
def create(
50+
def update(
5051
self,
5152
*,
5253
zone_id: str,
@@ -58,7 +59,7 @@ def create(
5859
extra_query: Query | None = None,
5960
extra_body: Body | None = None,
6061
timeout: float | httpx.Timeout | None | NotGiven = not_given,
61-
) -> Optional[TotalTLSCreateResponse]:
62+
) -> Optional[TotalTLSUpdateResponse]:
6263
"""
6364
Set Total TLS Settings or disable the feature for a Zone.
6465
@@ -87,16 +88,69 @@ def create(
8788
"enabled": enabled,
8889
"certificate_authority": certificate_authority,
8990
},
90-
total_tls_create_params.TotalTLSCreateParams,
91+
total_tls_update_params.TotalTLSUpdateParams,
9192
),
9293
options=make_request_options(
9394
extra_headers=extra_headers,
9495
extra_query=extra_query,
9596
extra_body=extra_body,
9697
timeout=timeout,
97-
post_parser=ResultWrapper[Optional[TotalTLSCreateResponse]]._unwrapper,
98+
post_parser=ResultWrapper[Optional[TotalTLSUpdateResponse]]._unwrapper,
9899
),
99-
cast_to=cast(Type[Optional[TotalTLSCreateResponse]], ResultWrapper[TotalTLSCreateResponse]),
100+
cast_to=cast(Type[Optional[TotalTLSUpdateResponse]], ResultWrapper[TotalTLSUpdateResponse]),
101+
)
102+
103+
def edit(
104+
self,
105+
*,
106+
zone_id: str,
107+
enabled: bool,
108+
certificate_authority: CertificateAuthority | Omit = omit,
109+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
110+
# The extra values given here take precedence over values defined on the client or passed to this method.
111+
extra_headers: Headers | None = None,
112+
extra_query: Query | None = None,
113+
extra_body: Body | None = None,
114+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
115+
) -> Optional[TotalTLSEditResponse]:
116+
"""
117+
Set Total TLS Settings or disable the feature for a Zone.
118+
119+
Args:
120+
zone_id: Identifier.
121+
122+
enabled: If enabled, Total TLS will order a hostname specific TLS certificate for any
123+
proxied A, AAAA, or CNAME record in your zone.
124+
125+
certificate_authority: The Certificate Authority that Total TLS certificates will be issued through.
126+
127+
extra_headers: Send extra headers
128+
129+
extra_query: Add additional query parameters to the request
130+
131+
extra_body: Add additional JSON properties to the request
132+
133+
timeout: Override the client-level default timeout for this request, in seconds
134+
"""
135+
if not zone_id:
136+
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
137+
return self._post(
138+
f"/zones/{zone_id}/acm/total_tls",
139+
body=maybe_transform(
140+
{
141+
"enabled": enabled,
142+
"certificate_authority": certificate_authority,
143+
},
144+
total_tls_edit_params.TotalTLSEditParams,
145+
),
146+
options=make_request_options(
147+
extra_headers=extra_headers,
148+
extra_query=extra_query,
149+
extra_body=extra_body,
150+
timeout=timeout,
151+
post_parser=ResultWrapper[Optional[TotalTLSEditResponse]]._unwrapper,
152+
),
153+
cast_to=cast(Type[Optional[TotalTLSEditResponse]], ResultWrapper[TotalTLSEditResponse]),
100154
)
101155

102156
def get(
@@ -159,7 +213,60 @@ def with_streaming_response(self) -> AsyncTotalTLSResourceWithStreamingResponse:
159213
"""
160214
return AsyncTotalTLSResourceWithStreamingResponse(self)
161215

162-
async def create(
216+
async def update(
217+
self,
218+
*,
219+
zone_id: str,
220+
enabled: bool,
221+
certificate_authority: CertificateAuthority | Omit = omit,
222+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
223+
# The extra values given here take precedence over values defined on the client or passed to this method.
224+
extra_headers: Headers | None = None,
225+
extra_query: Query | None = None,
226+
extra_body: Body | None = None,
227+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
228+
) -> Optional[TotalTLSUpdateResponse]:
229+
"""
230+
Set Total TLS Settings or disable the feature for a Zone.
231+
232+
Args:
233+
zone_id: Identifier.
234+
235+
enabled: If enabled, Total TLS will order a hostname specific TLS certificate for any
236+
proxied A, AAAA, or CNAME record in your zone.
237+
238+
certificate_authority: The Certificate Authority that Total TLS certificates will be issued through.
239+
240+
extra_headers: Send extra headers
241+
242+
extra_query: Add additional query parameters to the request
243+
244+
extra_body: Add additional JSON properties to the request
245+
246+
timeout: Override the client-level default timeout for this request, in seconds
247+
"""
248+
if not zone_id:
249+
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
250+
return await self._post(
251+
f"/zones/{zone_id}/acm/total_tls",
252+
body=await async_maybe_transform(
253+
{
254+
"enabled": enabled,
255+
"certificate_authority": certificate_authority,
256+
},
257+
total_tls_update_params.TotalTLSUpdateParams,
258+
),
259+
options=make_request_options(
260+
extra_headers=extra_headers,
261+
extra_query=extra_query,
262+
extra_body=extra_body,
263+
timeout=timeout,
264+
post_parser=ResultWrapper[Optional[TotalTLSUpdateResponse]]._unwrapper,
265+
),
266+
cast_to=cast(Type[Optional[TotalTLSUpdateResponse]], ResultWrapper[TotalTLSUpdateResponse]),
267+
)
268+
269+
async def edit(
163270
self,
164271
*,
165272
zone_id: str,
@@ -171,7 +278,7 @@ async def create(
171278
extra_query: Query | None = None,
172279
extra_body: Body | None = None,
173280
timeout: float | httpx.Timeout | None | NotGiven = not_given,
174-
) -> Optional[TotalTLSCreateResponse]:
281+
) -> Optional[TotalTLSEditResponse]:
175282
"""
176283
Set Total TLS Settings or disable the feature for a Zone.
177284
@@ -200,16 +307,16 @@ async def create(
200307
"enabled": enabled,
201308
"certificate_authority": certificate_authority,
202309
},
203-
total_tls_create_params.TotalTLSCreateParams,
310+
total_tls_edit_params.TotalTLSEditParams,
204311
),
205312
options=make_request_options(
206313
extra_headers=extra_headers,
207314
extra_query=extra_query,
208315
extra_body=extra_body,
209316
timeout=timeout,
210-
post_parser=ResultWrapper[Optional[TotalTLSCreateResponse]]._unwrapper,
317+
post_parser=ResultWrapper[Optional[TotalTLSEditResponse]]._unwrapper,
211318
),
212-
cast_to=cast(Type[Optional[TotalTLSCreateResponse]], ResultWrapper[TotalTLSCreateResponse]),
319+
cast_to=cast(Type[Optional[TotalTLSEditResponse]], ResultWrapper[TotalTLSEditResponse]),
213320
)
214321

215322
async def get(
@@ -256,8 +363,11 @@ class TotalTLSResourceWithRawResponse:
256363
def __init__(self, total_tls: TotalTLSResource) -> None:
257364
self._total_tls = total_tls
258365

259-
self.create = to_raw_response_wrapper(
260-
total_tls.create,
366+
self.update = to_raw_response_wrapper(
367+
total_tls.update,
368+
)
369+
self.edit = to_raw_response_wrapper(
370+
total_tls.edit,
261371
)
262372
self.get = to_raw_response_wrapper(
263373
total_tls.get,
@@ -268,8 +378,11 @@ class AsyncTotalTLSResourceWithRawResponse:
268378
def __init__(self, total_tls: AsyncTotalTLSResource) -> None:
269379
self._total_tls = total_tls
270380

271-
self.create = async_to_raw_response_wrapper(
272-
total_tls.create,
381+
self.update = async_to_raw_response_wrapper(
382+
total_tls.update,
383+
)
384+
self.edit = async_to_raw_response_wrapper(
385+
total_tls.edit,
273386
)
274387
self.get = async_to_raw_response_wrapper(
275388
total_tls.get,
@@ -280,8 +393,11 @@ class TotalTLSResourceWithStreamingResponse:
280393
def __init__(self, total_tls: TotalTLSResource) -> None:
281394
self._total_tls = total_tls
282395

283-
self.create = to_streamed_response_wrapper(
284-
total_tls.create,
396+
self.update = to_streamed_response_wrapper(
397+
total_tls.update,
398+
)
399+
self.edit = to_streamed_response_wrapper(
400+
total_tls.edit,
285401
)
286402
self.get = to_streamed_response_wrapper(
287403
total_tls.get,
@@ -292,8 +408,11 @@ class AsyncTotalTLSResourceWithStreamingResponse:
292408
def __init__(self, total_tls: AsyncTotalTLSResource) -> None:
293409
self._total_tls = total_tls
294410

295-
self.create = async_to_streamed_response_wrapper(
296-
total_tls.create,
411+
self.update = async_to_streamed_response_wrapper(
412+
total_tls.update,
413+
)
414+
self.edit = async_to_streamed_response_wrapper(
415+
total_tls.edit,
297416
)
298417
self.get = async_to_streamed_response_wrapper(
299418
total_tls.get,

src/cloudflare/types/acm/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from __future__ import annotations
44

55
from .certificate_authority import CertificateAuthority as CertificateAuthority
6+
from .total_tls_edit_params import TotalTLSEditParams as TotalTLSEditParams
67
from .total_tls_get_response import TotalTLSGetResponse as TotalTLSGetResponse
7-
from .total_tls_create_params import TotalTLSCreateParams as TotalTLSCreateParams
8-
from .total_tls_create_response import TotalTLSCreateResponse as TotalTLSCreateResponse
8+
from .total_tls_edit_response import TotalTLSEditResponse as TotalTLSEditResponse
9+
from .total_tls_update_params import TotalTLSUpdateParams as TotalTLSUpdateParams
10+
from .total_tls_update_response import TotalTLSUpdateResponse as TotalTLSUpdateResponse

src/cloudflare/types/acm/total_tls_create_params.py renamed to src/cloudflare/types/acm/total_tls_edit_params.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
from .certificate_authority import CertificateAuthority
88

9-
__all__ = ["TotalTLSCreateParams"]
9+
__all__ = ["TotalTLSEditParams"]
1010

1111

12-
class TotalTLSCreateParams(TypedDict, total=False):
12+
class TotalTLSEditParams(TypedDict, total=False):
1313
zone_id: Required[str]
1414
"""Identifier."""
1515

src/cloudflare/types/acm/total_tls_create_response.py renamed to src/cloudflare/types/acm/total_tls_edit_response.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
from ..._models import BaseModel
77
from .certificate_authority import CertificateAuthority
88

9-
__all__ = ["TotalTLSCreateResponse"]
9+
__all__ = ["TotalTLSEditResponse"]
1010

1111

12-
class TotalTLSCreateResponse(BaseModel):
12+
class TotalTLSEditResponse(BaseModel):
1313
certificate_authority: Optional[CertificateAuthority] = None
1414
"""The Certificate Authority that Total TLS certificates will be issued through."""
1515

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from typing_extensions import Required, TypedDict
6+
7+
from .certificate_authority import CertificateAuthority
8+
9+
__all__ = ["TotalTLSUpdateParams"]
10+
11+
12+
class TotalTLSUpdateParams(TypedDict, total=False):
13+
zone_id: Required[str]
14+
"""Identifier."""
15+
16+
enabled: Required[bool]
17+
"""
18+
If enabled, Total TLS will order a hostname specific TLS certificate for any
19+
proxied A, AAAA, or CNAME record in your zone.
20+
"""
21+
22+
certificate_authority: CertificateAuthority
23+
"""The Certificate Authority that Total TLS certificates will be issued through."""
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing import Optional
4+
from typing_extensions import Literal
5+
6+
from ..._models import BaseModel
7+
from .certificate_authority import CertificateAuthority
8+
9+
__all__ = ["TotalTLSUpdateResponse"]
10+
11+
12+
class TotalTLSUpdateResponse(BaseModel):
13+
certificate_authority: Optional[CertificateAuthority] = None
14+
"""The Certificate Authority that Total TLS certificates will be issued through."""
15+
16+
enabled: Optional[bool] = None
17+
"""
18+
If enabled, Total TLS will order a hostname specific TLS certificate for any
19+
proxied A, AAAA, or CNAME record in your zone.
20+
"""
21+
22+
validity_period: Optional[Literal[90]] = None
23+
"""The validity period in days for the certificates ordered via Total TLS."""

0 commit comments

Comments
 (0)