8000 feat(origin_post_quantum_encryption): swap PUT for PATCH operation (#… · cloudflare/cloudflare-python@26aa6ce · GitHub
[go: up one dir, main page]

Skip to content

Commit 26aa6ce

Browse files
feat(origin_post_quantum_encryption): swap PUT for PATCH operation (#2321)
1 parent 3aa2efc commit 26aa6ce

File tree

7 files changed

+285
-3
lines changed

7 files changed

+285
-3
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
configured_endpoints: 1489
1+
configured_endpoints: 1490
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d52d1344e2e65f3eda2fe8fff8c7d95cebf7cad134af21eaf9d6d5b6a04d783a.yml

api.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7792,11 +7792,15 @@ Methods:
77927792
Types:
77937793

77947794
```python
7795-
from cloudflare.types.origin_post_quantum_encryption import OriginPostQuantumEncryptionGetResponse
7795+
from cloudflare.types.origin_post_quantum_encryption import (
7796+
OriginPostQuantumEncryptionEditResponse,
7797+
OriginPostQuantumEncryptionGetResponse,
7798+
)
77967799
```
77977800

77987801
Methods:
77997802

7803+
- <code title="patch /zones/{zone_id}/cache/origin_post_quantum_encryption">client.origin_post_quantum_encryption.<a href="./src/cloudflare/resources/origin_post_quantum_encryption.py">edit</a>(\*, zone_id, \*\*<a href="src/cloudflare/types/origin_post_quantum_encryption/origin_post_quantum_encryption_edit_params.py">params</a>) -> <a href="./src/cloudflare/types/origin_post_quantum_encryption/origin_post_quantum_encryption_edit_response.py">Optional[OriginPostQuantumEncryptionEditResponse]</a></code>
78007804
- <code title="get /zones/{zone_id}/cache/origin_post_quantum_encryption">client.origin_post_quantum_encryption.<a href="./src/cloudflare/resources/origin_post_quantum_encryption.py">get</a>(\*, zone_id) -> <a href="./src/cloudflare/types/origin_post_quantum_encryption/origin_post_quantum_encryption_get_response.py">Optional[OriginPostQuantumEncryptionGetResponse]</a></code>
78017805

78027806
# Speed

src/cloudflare/resources/origin_post_quantum_encryption.py

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@
33
from __future__ import annotations
44

55
from typing import Type, Optional, cast
6+
from typing_extensions import Literal
67

78
import httpx
89

910
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
11+
from .._utils import (
12+
maybe_transform,
13+
async_maybe_transform,
14+
)
1015
from .._compat import cached_property
1116
from .._resource import SyncAPIResource, AsyncAPIResource
1217
from .._response import (
@@ -17,9 +22,13 @@
1722
)
1823
from .._wrappers import ResultWrapper
1924
from .._base_client import make_request_options
25+
from ..types.origin_post_quantum_encryption import origin_post_quantum_encryption_edit_params
2026
from ..types.origin_post_quantum_encryption.origin_post_quantum_encryption_get_response import (
2127
OriginPostQuantumEncryptionGetResponse,
2228
)
29+
from ..types.origin_post_quantum_encryption.origin_post_quantum_encryption_edit_response import (
30+
OriginPostQuantumEncryptionEditResponse,
31+
)
2332

2433
__all__ = ["OriginPostQuantumEncryptionResource", "AsyncOriginPostQuantumEncryptionResource"]
2534

@@ -44,6 +53,59 @@ def with_streaming_response(self) -> OriginPostQuantumEncryptionResourceWithStre
4453
"""
4554
return OriginPostQuantumEncryptionResourceWithStreamingResponse(self)
4655

56+
def edit(
57+
self,
58+
*,
59+
zone_id: str,
60+
value: Literal["preferred", "supported", "off"],
61+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
62+
# The extra values given here take precedence over values defined on the client or passed to this method.
63+
extra_headers: Headers | None = None,
64+
extra_query: Query | None = None,
65+
extra_body: Body | None = None,
66+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
67+
) -> Optional[OriginPostQuantumEncryptionEditResponse]:
68+
"""
69+
Instructs Cloudflare to use Post-Quantum (PQ) key agreement algorithms when
70+
connecting to your origin. Preferred instructs Cloudflare to opportunistically
71+
send a Post-Quantum keyshare in the first message to the origin (for fastest
72+
connections when the origin supports and prefers PQ), supported means that PQ
73+
algorithms are advertised but only used when requested by the origin, and off
74+
means that PQ algorithms are not advertised
75+
76+
Args:
77+
zone_id: Identifier
78+
79+
value: Value of the Origin Post Quantum Encryption Setting.
80+
81+
extra_headers: Send extra headers
82+
83+
extra_query: Add additional query parameters to the request
84+
85+
extra_body: Add additional JSON properties to the request
86+
87+
timeout: Override the client-level default timeout for this request, in seconds
88+
"""
89+
if not zone_id:
90+
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
91+
return self._patch(
92+
f"/zones/{zone_id}/cache/origin_post_quantum_encryption",
93+
body=maybe_transform(
94+
{"value": value}, origin_post_quantum_encryption_edit_params.OriginPostQuantumEncryptionEditParams
95+
),
96+
options=make_request_options(
97+
extra_headers=extra_headers,
98+
extra_query=extra_query,
99+
extra_body=extra_body,
100+
timeout=timeout,
101+
post_parser=ResultWrapper[Optional[OriginPostQuantumEncryptionEditResponse]]._unwrapper,
102+
),
103+
cast_to=cast(
104+
Type[Optional[OriginPostQuantumEncryptionEditResponse]],
105+
ResultWrapper[OriginPostQuantumEncryptionEditResponse],
106+
),
107+
)
108+
47109
def get(
48110
self,
49111
*,
@@ -112,6 +174,59 @@ def with_streaming_response(self) -> AsyncOriginPostQuantumEncryptionResourceWit
112174
"""
113175
return AsyncOriginPostQuantumEncryptionResourceWithStreamingResponse(self)
114176

177+
async def edit(
178+
self,
179+
*,
180+
zone_id: str,
181+
value: Literal["preferred", "supported", "off"],
182+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
183+
# The extra values given here take precedence over values defined on the client or passed to this method.
184+
extra_headers: Headers | None = None,
185+
extra_query: Query | None = None,
186+
extra_body: Body | None = None,
187+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
188+
) -> Optional[OriginPostQuantumEncryptionEditResponse]:
189+
"""
190+
Instructs Cloudflare to use Post-Quantum (PQ) key agreement algorithms when
191+
connecting to your origin. Preferred instructs Cloudflare to opportunistically
192+
send a Post-Quantum keyshare in the first message to the origin (for fastest
193+
connections when the origin supports and prefers PQ), supported means that PQ
194+
algorithms are advertised but only used when requested by the origin, and off
195+
means that PQ algorithms are not advertised
196+
197+
Args:
198+
zone_id: Identifier
199+
200+
value: Value of the Origin Post Quantum Encryption Setting.
201+
202+
extra_headers: Send extra headers
203+
204+
extra_query: Add additional query parameters to the request
205+
206+
extra_body: Add additional JSON properties to the request
207+
208+
timeout: Override the client-level default timeout for this request, in seconds
209+
"""
210+
if not zone_id:
211+
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
212+
return await self._patch(
213+
f"/zones/{zone_id}/cache/origin_post_quantum_encryption",
214+
body=await async_maybe_transform(
215+
{"value": value}, origin_post_quantum_encryption_edit_params.OriginPostQuantumEncryptionEditParams
216+
),
217+
options=make_request_options(
218+
extra_headers=extra_headers,
219+
extra_query=extra_query,
220+
extra_body=extra_body,
221+
timeout=timeout,
222+
post_parser=ResultWrapper[Optional[OriginPostQuantumEncryptionEditResponse]]._unwrapper,
223+
),
224+
cast_to=cast(
225+
Type[Optional[OriginPostQuantumEncryptionEditResponse]],
226+
ResultWrapper[OriginPostQuantumEncryptionEditResponse],
227+
),
228+
)
229+
115230
async def get(
116231
self,
117232
*,
@@ -164,6 +279,9 @@ class OriginPostQuantumEncryptionResourceWithRawResponse:
164279
def __init__(self, origin_post_quantum_encryption: OriginPostQuantumEncryptionResource) -> None:
165280
self._origin_post_quantum_encryption = origin_post_quantum_encryption
166281

282+
self.edit = to_raw_response_wrapper(
283+
origin_post_quantum_encryption.edit,
284+
)
167285
self.get = to_raw_response_wrapper(
168286
origin_post_quantum_encryption.get,
169287
)
@@ -173,6 +291,9 @@ class AsyncOriginPostQuantumEncryptionResourceWithRawResponse:
173291
def __init__(self, origin_post_quantum_encryption: AsyncOriginPostQuantumEncryptionResource) -> None:
174292
self._origin_post_quantum_encryption = origin_post_quantum_encryption
175293

294+
self.edit = async_to_raw_response_wrapper(
295+
origin_post_quantum_encryption.edit,
296+
)
176297
self.get = async_to_raw_response_wrapper(
177298
origin_post_quantum_encryption.get,
178299
)
@@ -182,6 +303,9 @@ class OriginPostQuantumEncryptionResourceWithStreamingResponse:
182303
def __init__(self, origin_post_quantum_encryption: OriginPostQuantumEncryptionResource) -> None:
183304
self._origin_post_quantum_encryption = origin_post_quantum_encryption
184305

306+
self.edit = to_streamed_response_wrapper(
307+
origin_post_quantum_encryption.edit,
308+
)
185309
self.get = to_streamed_response_wrapper(
186310
origin_post_quantum_encryption.get,
187311
)
@@ -191,6 +315,9 @@ class AsyncOriginPostQuantumEncryptionResourceWithStreamingResponse:
191315
def __init__(self, origin_post_quantum_encryption: AsyncOriginPost F438 QuantumEncryptionResource) -> None:
192316
self._origin_post_quantum_encryption = origin_post_quantum_encryption
193317

318+
self.edit = async_to_streamed_response_wrapper(
319+
origin_post_quantum_encryption.edit,
320+
)
194321
self.get = async_to_streamed_response_wrapper(
195322
origin_post_quantum_encryption.get,
196323
)

src/cloudflare/types/origin_post_quantum_encryption/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
from __future__ import annotations
44

5+
from .origin_post_quantum_encryption_edit_params import (
6+
OriginPostQuantumEncryptionEditParams as OriginPostQuantumEncryptionEditParams,
7+
)
58
from .origin_post_quantum_encryption_get_response import (
69
OriginPostQuantumEncryptionGetResponse as OriginPostQuantumEncryptionGetResponse,
710
)
11+
from .origin_post_quantum_encryption_edit_response import (
12+
OriginPostQuantumEncryptionEditResponse as OriginPostQuantumEncryptionEditResponse,
13+
)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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 Literal, Required, TypedDict
6+
7+
__all__ = ["OriginPostQuantumEncryptionEditParams"]
8+
9+
10+
class OriginPostQuantumEncryptionEditParams(TypedDict, total=False):
11+
zone_id: Required[str]
12+
"""Identifier"""
13+
14+
value: Required[Literal["preferred", "supported", "off"]]
15+
"""Value of the Origin Post Quantum Encryption Setting."""
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 datetime import datetime
5+
from typing_extensions import Literal
6+
7+
from ..._models import BaseModel
8+
9+
__all__ = ["OriginPostQuantumEncryptionEditResponse"]
10+
11+
12+
class OriginPostQuantumEncryptionEditResponse(BaseModel):
13+
id: Literal["origin_pqe"]
14+
"""Value of the zone setting."""
15+
16+
editable: bool
17+
"""Whether the setting is editable"""
18+
19+
value: Literal["preferred", "supported", "off"]
20+
"""The value of the feature"""
21+
22+
modified_on: Optional[datetime] = None
23+
"""Last time this setting was modified."""

tests/api_resources/test_origin_post_quantum_encryption.py

Lines changed: 108 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,69 @@
99

1010
from cloudflare import Cloudflare, AsyncCloudflare
1111
from tests.utils import assert_matches_type
12-
from cloudflare.types.origin_post_quantum_encryption import OriginPostQuantumEncryptionGetResponse
12+
from cloudflare.types.origin_post_quantum_encryption import (
13+
OriginPostQuantumEncryptionGetResponse,
14+
OriginPostQuantumEncryptionEditResponse,
15+
)
1316

1417
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
1518

1619

1720
class TestOriginPostQuantumEncryption:
1821
parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
1922

23+
@pytest.mark.skip(reason="TODO: investigate broken test")
24+
@parametrize
25+
def test_method_edit(self, client: Cloudflare) -> None:
26+
origin_post_quantum_encryption = client.origin_post_quantum_encryption.edit(
27+
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
28+
value="preferred",
29+
)
30+
assert_matches_type(
31+
Optional[OriginPostQuantumEncryptionEditResponse], origin_post_quantum_encryption, path=["response"]
32+
)
33+
34+
@pytest.mark.skip(reason="TODO: investigate broken test")
35+
@parametrize
36+
def test_raw_response_edit(self, client: Cloudflare) -> None:
37+
response = client.origin_post_quantum_encryption.with_raw_response.edit(
38+
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
39+
value="preferred",
40+
)
41+
42+
assert response.is_closed is True
43+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
44+
origin_post_quantum_encryption = response.parse()
45+
assert_matches_type(
46+
Optional[OriginPostQuantumEncryptionEditResponse], origin_post_quantum_encryption, path=["response"]
47+
)
48+
49+
@pytest.mark.skip(reason="TODO: investigate broken test")
50+
@parametrize
51+
def test_streaming_response_edit(self, client: Cloudflare) -> None:
52+
with client.origin_post_quantum_encryption.with_streaming_response.edit(
53+
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
54+
value="preferred",
55+
) as response:
56+
assert not response.is_closed
57+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
58+
59+
origin_post_quantum_encryption = response.parse()
60+
assert_matches_type(
61+
Optional[OriginPostQuantumEncryptionEditResponse], origin_post_quantum_encryption, path=["response"]
62+
)
63+
64+
assert cast(Any, response.is_closed) is True
65+
66+
@pytest.mark.skip(reason="TODO: investigate broken test")
67+
@parametrize
68+
def test_path_params_edit(self, client: Cloudflare) -> None:
69+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
70+
client.origin_post_quantum_encryption.with_raw_response.edit(
71+
zone_id="",
72+
value="preferred",
73+
)
74+
2075
@pytest.mark.skip(reason="TODO: investigate broken test")
2176
@parametrize
2277
def test_method_get(self, client: Cloudflare) -> None:
@@ -69,6 +124,58 @@ def test_path_params_get(self, client: Cloudflare) -> None:
69124
class TestAsyncOriginPostQuantumEncryption:
70125
parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
71126

127+
@pytest.mark.skip(reason="TODO: investigate broken test")
128+
@parametrize
129+
async def test_method_edit(self, async_client: AsyncCloudflare) -> None:
130+
origin_post_quantum_encryption = await async_client.origin_post_quantum_encryption.edit(
131+
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
132+
value="preferred",
133+
)
134+
assert_matches_type(
135+
Optional[OriginPostQuantumEncryptionEditResponse], origin_post_quantum_encryption, path=["response"]
136+
)
137+
138+
@pytest.mark.skip(reason="TODO: investigate broken test")
139+
@parametrize
140+
async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None:
141+
response = await async_client.origin_post_quantum_encryption.with_raw_response.edit(
142+
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
143+
value="preferred",
144+
)
145+
146+
assert response.is_closed is True
147+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
148+
origin_post_quantum_encryption = await response.parse()
149+
assert_matches_type(
150+
Optional[OriginPostQuantumEncryptionEditResponse], origin_post_quantum_encryption, path=["response"]
151+
)
152+
153+
@pytest.mark.skip(reason="TODO: investigate broken test")
154+
@parametrize
155+
async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None:
156+
async with async_client.origin_post_quantum_encryption.with_streaming_response.edit(
157+
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
158+
value="preferred",
159+
) as response:
160+
assert not response.is_closed
161+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
162+
163+
origin_post_quantum_encryption = await response.parse()
164+
assert_matches_type(
165+
Optional[OriginPostQuantumEncryptionEditResponse], origin_post_quantum_encryption, path=["response"]
166+
)
167+
168+
assert cast(Any, response.is_closed) is True
169+
170+
@pytest.mark.skip(reason="TODO: investigate broken test")
171+
@parametrize
172+
async def test_path_params_edit(self, async_client: AsyncCloudflare) -> None:
173+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
174+
await async_client.origin_post_quantum_encryption.with_raw_response.edit(
175+
zone_id="",
176+
value="preferred",
177+
)
178+
72179
@pytest.mark.skip(reason="TODO: investigate broken test")
73180
@parametrize
74181
async def test_method_get(self, async_client: AsyncCloudflare) -> None:

0 commit comments

Comments
 (0)
0