Skip to content

Commit

Permalink
feat(origin_post_quantum_encryption): swap PUT for PATCH operation (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Jan 6, 2025
1 parent bdb21a5 commit f6b6e83
Show file tree
Hide file tree
Showing 7 changed files with 285 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 1489
configured_endpoints: 1490
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d52d1344e2e65f3eda2fe8fff8c7d95cebf7cad134af21eaf9d6d5b6a04d783a.yml
6 changes: 5 additions & 1 deletion api.md
Original file line number Diff line number Diff line change
Expand Up @@ -7792,11 +7792,15 @@ Methods:
Types:

```python
from cloudflare.types.origin_post_quantum_encryption import OriginPostQuantumEncryptionGetResponse
from cloudflare.types.origin_post_quantum_encryption import (
OriginPostQuantumEncryptionEditResponse,
OriginPostQuantumEncryptionGetResponse,
)
```

Methods:

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

# Speed
Expand Down
127 changes: 127 additions & 0 deletions src/cloudflare/resources/origin_post_quantum_encryption.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
from __future__ import annotations

from typing import Type, Optional, cast
from typing_extensions import Literal

import httpx

from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from .._utils import (
maybe_transform,
async_maybe_transform,
)
from .._compat import cached_property
from .._resource import SyncAPIResource, AsyncAPIResource
from .._response import (
Expand All @@ -17,9 +22,13 @@
)
from .._wrappers import ResultWrapper
from .._base_client import make_request_options
from ..types.origin_post_quantum_encryption import origin_post_quantum_encryption_edit_params
from ..types.origin_post_quantum_encryption.origin_post_quantum_encryption_get_response import (
OriginPostQuantumEncryptionGetResponse,
)
from ..types.origin_post_quantum_encryption.origin_post_quantum_encryption_edit_response import (
OriginPostQuantumEncryptionEditResponse,
)

__all__ = ["OriginPostQuantumEncryptionResource", "AsyncOriginPostQuantumEncryptionResource"]

Expand All @@ -44,6 +53,59 @@ def with_streaming_response(self) -> OriginPostQuantumEncryptionResourceWithStre
"""
return OriginPostQuantumEncryptionResourceWithStreamingResponse(self)

def edit(
self,
*,
zone_id: str,
value: Literal["preferred", "supported", "off"],
# 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,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[OriginPostQuantumEncryptionEditResponse]:
"""
Instructs Cloudflare to use Post-Quantum (PQ) key agreement algorithms when
connecting to your origin. Preferred instructs Cloudflare to opportunistically
send a Post-Quantum keyshare in the first message to the origin (for fastest
connections when the origin supports and prefers PQ), supported means that PQ
algorithms are advertised but only used when requested by the origin, and off
means that PQ algorithms are not advertised
Args:
zone_id: Identifier
value: Value of the Origin Post Quantum Encryption Setting.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not zone_id:
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
return self._patch(
f"/zones/{zone_id}/cache/origin_post_quantum_encryption",
body=maybe_transform(
{"value": value}, origin_post_quantum_encryption_edit_params.OriginPostQuantumEncryptionEditParams
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[OriginPostQuantumEncryptionEditResponse]]._unwrapper,
),
cast_to=cast(
Type[Optional[OriginPostQuantumEncryptionEditResponse]],
ResultWrapper[OriginPostQuantumEncryptionEditResponse],
),
)

def get(
self,
*,
Expand Down Expand Up @@ -112,6 +174,59 @@ def with_streaming_response(self) -> AsyncOriginPostQuantumEncryptionResourceWit
"""
return AsyncOriginPostQuantumEncryptionResourceWithStreamingResponse(self)

async def edit(
self,
*,
zone_id: str,
value: Literal["preferred", "supported", "off"],
# 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,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[OriginPostQuantumEncryptionEditResponse]:
"""
Instructs Cloudflare to use Post-Quantum (PQ) key agreement algorithms when
connecting to your origin. Preferred instructs Cloudflare to opportunistically
send a Post-Quantum keyshare in the first message to the origin (for fastest
connections when the origin supports and prefers PQ), supported means that PQ
algorithms are advertised but only used when requested by the origin, and off
means that PQ algorithms are not advertised
Args:
zone_id: Identifier
value: Value of the Origin Post Quantum Encryption Setting.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not zone_id:
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
return await self._patch(
f"/zones/{zone_id}/cache/origin_post_quantum_encryption",
body=await async_maybe_transform(
{"value": value}, origin_post_quantum_encryption_edit_params.OriginPostQuantumEncryptionEditParams
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[OriginPostQuantumEncryptionEditResponse]]._unwrapper,
),
cast_to=cast(
Type[Optional[OriginPostQuantumEncryptionEditResponse]],
ResultWrapper[OriginPostQuantumEncryptionEditResponse],
),
)

async def get(
self,
*,
Expand Down Expand Up @@ -164,6 +279,9 @@ class OriginPostQuantumEncryptionResourceWithRawResponse:
def __init__(self, origin_post_quantum_encryption: OriginPostQuantumEncryptionResource) -> None:
self._origin_post_quantum_encryption = origin_post_quantum_encryption

self.edit = to_raw_response_wrapper(
origin_post_quantum_encryption.edit,
)
self.get = to_raw_response_wrapper(
origin_post_quantum_encryption.get,
)
Expand All @@ -173,6 +291,9 @@ class AsyncOriginPostQuantumEncryptionResourceWithRawResponse:
def __init__(self, origin_post_quantum_encryption: AsyncOriginPostQuantumEncryptionResource) -> None:
self._origin_post_quantum_encryption = origin_post_quantum_encryption

self.edit = async_to_raw_response_wrapper(
origin_post_quantum_encryption.edit,
)
self.get = async_to_raw_response_wrapper(
origin_post_quantum_encryption.get,
)
Expand All @@ -182,6 +303,9 @@ class OriginPostQuantumEncryptionResourceWithStreamingResponse:
def __init__(self, origin_post_quantum_encryption: OriginPostQuantumEncryptionResource) -> None:
self._origin_post_quantum_encryption = origin_post_quantum_encryption

self.edit = to_streamed_response_wrapper(
origin_post_quantum_encryption.edit,
)
self.get = to_streamed_response_wrapper(
origin_post_quantum_encryption.get,
)
Expand All @@ -191,6 +315,9 @@ class AsyncOriginPostQuantumEncryptionResourceWithStreamingResponse:
def __init__(self, origin_post_quantum_encryption: AsyncOriginPostQuantumEncryptionResource) -> None:
self._origin_post_quantum_encryption = origin_post_quantum_encryption

self.edit = async_to_streamed_response_wrapper(
origin_post_quantum_encryption.edit,
)
self.get = async_to_streamed_response_wrapper(
origin_post_quantum_encryption.get,
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

from __future__ import annotations

from .origin_post_quantum_encryption_edit_params import (
OriginPostQuantumEncryptionEditParams as OriginPostQuantumEncryptionEditParams,
)
from .origin_post_quantum_encryption_get_response import (
OriginPostQuantumEncryptionGetResponse as OriginPostQuantumEncryptionGetResponse,
)
from .origin_post_quantum_encryption_edit_response import (
OriginPostQuantumEncryptionEditResponse as OriginPostQuantumEncryptionEditResponse,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

from typing_extensions import Literal, Required, TypedDict

__all__ = ["OriginPostQuantumEncryptionEditParams"]


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

value: Required[Literal["preferred", "supported", "off"]]
"""Value of the Origin Post Quantum Encryption Setting."""
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import Optional
from datetime import datetime
from typing_extensions import Literal

from ..._models import BaseModel

__all__ = ["OriginPostQuantumEncryptionEditResponse"]


class OriginPostQuantumEncryptionEditResponse(BaseModel):
id: Literal["origin_pqe"]
"""Value of the zone setting."""

editable: bool
"""Whether the setting is editable"""

value: Literal["preferred", "supported", "off"]
"""The value of the feature"""

modified_on: Optional[datetime] = None
"""Last time this setting was modified."""
109 changes: 108 additions & 1 deletion tests/api_resources/test_origin_post_quantum_encryption.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,69 @@

from cloudflare import Cloudflare, AsyncCloudflare
from tests.utils import assert_matches_type
from cloudflare.types.origin_post_quantum_encryption import OriginPostQuantumEncryptionGetResponse
from cloudflare.types.origin_post_quantum_encryption import (
OriginPostQuantumEncryptionGetResponse,
OriginPostQuantumEncryptionEditResponse,
)

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


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

@pytest.mark.skip(reason="TODO: investigate broken test")
@parametrize
def test_method_edit(self, client: Cloudflare) -> None:
origin_post_quantum_encryption = client.origin_post_quantum_encryption.edit(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
value="preferred",
)
assert_matches_type(
Optional[OriginPostQuantumEncryptionEditResponse], origin_post_quantum_encryption, path=["response"]
)

@pytest.mark.skip(reason="TODO: investigate broken test")
@parametrize
def test_raw_response_edit(self, client: Cloudflare) -> None:
response = client.origin_post_quantum_encryption.with_raw_response.edit(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
value="preferred",
)

assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
origin_post_quantum_encryption = response.parse()
assert_matches_type(
Optional[OriginPostQuantumEncryptionEditResponse], origin_post_quantum_encryption, path=["response"]
)

@pytest.mark.skip(reason="TODO: investigate broken test")
@parametrize
def test_streaming_response_edit(self, client: Cloudflare) -> None:
with client.origin_post_quantum_encryption.with_streaming_response.edit(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
value="preferred",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"

origin_post_quantum_encryption = response.parse()
assert_matches_type(
Optional[OriginPostQuantumEncryptionEditResponse], origin_post_quantum_encryption, path=["response"]
)

assert cast(Any, response.is_closed) is True

@pytest.mark.skip(reason="TODO: investigate broken test")
@parametrize
def test_path_params_edit(self, client: Cloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
client.origin_post_quantum_encryption.with_raw_response.edit(
zone_id="",
value="preferred",
)

@pytest.mark.skip(reason="TODO: investigate broken test")
@parametrize
def test_method_get(self, client: Cloudflare) -> None:
Expand Down Expand Up @@ -69,6 +124,58 @@ def test_path_params_get(self, client: Cloudflare) -> None:
class TestAsyncOriginPostQuantumEncryption:
parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])

@pytest.mark.skip(reason="TODO: investigate broken test")
@parametrize
async def test_method_edit(self, async_client: AsyncCloudflare) -> None:
origin_post_quantum_encryption = await async_client.origin_post_quantum_encryption.edit(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
value="preferred",
)
assert_matches_type(
Optional[OriginPostQuantumEncryptionEditResponse], origin_post_quantum_encryption, path=["response"]
)

@pytest.mark.skip(reason="TODO: investigate broken test")
@parametrize
async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None:
response = await async_client.origin_post_quantum_encryption.with_raw_response.edit(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
value="preferred",
)

assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
origin_post_quantum_encryption = await response.parse()
assert_matches_type(
Optional[OriginPostQuantumEncryptionEditResponse], origin_post_quantum_encryption, path=["response"]
)

@pytest.mark.skip(reason="TODO: investigate broken test")
@parametrize
async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None:
async with async_client.origin_post_quantum_encryption.with_streaming_response.edit(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
value="preferred",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"

origin_post_quantum_encryption = await response.parse()
assert_matches_type(
Optional[OriginPostQuantumEncryptionEditResponse], origin_post_quantum_encryption, path=["response"]
)

assert cast(Any, response.is_closed) is True

@pytest.mark.skip(reason="TODO: investigate broken test")
@parametrize
async def test_path_params_edit(self, async_client: AsyncCloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
await async_client.origin_post_quantum_encryption.with_raw_response.edit(
zone_id="",
value="preferred",
)

@pytest.mark.skip(reason="TODO: investigate broken test")
@parametrize
async def test_method_get(self, async_client: AsyncCloudflare) -> None:
Expand Down

0 comments on commit f6b6e83

Please sign in to comment.