feat(device_settings): swap list to get endpoint

This commit is contained in:
stainless-app[bot] 2025-05-13 00:46:26 +00:00
parent 7e4626961b
commit 977d5c7201
4 changed files with 164 additions and 164 deletions

View file

@ -1,4 +1,4 @@
configured_endpoints: 1727
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-3ceecccb58d541adca7fe096feb5f83dc1513ef46c142cd06c270753beb5e3e8.yml
openapi_spec_hash: c14e6f07f356890c9436bae49ef2f64b
config_hash: a6e6811bbcdb987dc4a77afbbaae9e4f
config_hash: 66d9798004c132e26b37bb84735b9968

2
api.md
View file

@ -5478,8 +5478,8 @@ from cloudflare.types.zero_trust.devices import DeviceSettings
Methods:
- <code title="put /accounts/{account_id}/devices/settings">client.zero_trust.devices.settings.<a href="./src/cloudflare/resources/zero_trust/devices/settings.py">update</a>(\*, account_id, \*\*<a href="src/cloudflare/types/zero_trust/devices/setting_update_params.py">params</a>) -> <a href="./src/cloudflare/types/zero_trust/devices/device_settings.py">Optional[DeviceSettings]</a></code>
- <code title="get /accounts/{account_id}/devices/settings">client.zero_trust.devices.settings.<a href="./src/cloudflare/resources/zero_trust/devices/settings.py">list</a>(\*, account_id) -> <a href="./src/cloudflare/types/zero_trust/devices/device_settings.py">Optional[DeviceSettings]</a></code>
- <code title="patch /accounts/{account_id}/devices/settings">client.zero_trust.devices.settings.<a href="./src/cloudflare/resources/zero_trust/devices/settings.py">edit</a>(\*, account_id, \*\*<a href="src/cloudflare/types/zero_trust/devices/setting_edit_params.py">params</a>) -> <a href="./src/cloudflare/types/zero_trust/devices/device_settings.py">Optional[DeviceSettings]</a></code>
- <code title="get /accounts/{account_id}/devices/settings">client.zero_trust.devices.settings.<a href="./src/cloudflare/resources/zero_trust/devices/settings.py">get</a>(\*, account_id) -> <a href="./src/cloudflare/types/zero_trust/devices/device_settings.py">Optional[DeviceSettings]</a></code>
### Unrevoke

View file

@ -107,43 +107,6 @@ class SettingsResource(SyncAPIResource):
cast_to=cast(Type[Optional[DeviceSettings]], ResultWrapper[DeviceSettings]),
)
def list(
self,
*,
account_id: str,
# 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[DeviceSettings]:
"""
Describes the current device settings for a Zero Trust account.
Args:
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 account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
return self._get(
f"/accounts/{account_id}/devices/settings",
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[DeviceSettings]]._unwrapper,
),
cast_to=cast(Type[Optional[DeviceSettings]], ResultWrapper[DeviceSettings]),
)
def edit(
self,
*,
@ -207,6 +170,43 @@ class SettingsResource(SyncAPIResource):
cast_to=cast(Type[Optional[DeviceSettings]], ResultWrapper[DeviceSettings]),
)
def get(
self,
*,
account_id: str,
# 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[DeviceSettings]:
"""
Describes the current device settings for a Zero Trust account.
Args:
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 account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
return self._get(
f"/accounts/{account_id}/devices/settings",
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[DeviceSettings]]._unwrapper,
),
cast_to=cast(Type[Optional[DeviceSettings]], ResultWrapper[DeviceSettings]),
)
class AsyncSettingsResource(AsyncAPIResource):
@cached_property
@ -291,43 +291,6 @@ class AsyncSettingsResource(AsyncAPIResource):
cast_to=cast(Type[Optional[DeviceSettings]], ResultWrapper[DeviceSettings]),
)
async def list(
self,
*,
account_id: str,
# 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[DeviceSettings]:
"""
Describes the current device settings for a Zero Trust account.
Args:
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 account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
return await self._get(
f"/accounts/{account_id}/devices/settings",
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[DeviceSettings]]._unwrapper,
),
cast_to=cast(Type[Optional[DeviceSettings]], ResultWrapper[DeviceSettings]),
)
async def edit(
self,
*,
@ -391,6 +354,43 @@ class AsyncSettingsResource(AsyncAPIResource):
cast_to=cast(Type[Optional[DeviceSettings]], ResultWrapper[DeviceSettings]),
)
async def get(
self,
*,
account_id: str,
# 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[DeviceSettings]:
"""
Describes the current device settings for a Zero Trust account.
Args:
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 account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
return await self._get(
f"/accounts/{account_id}/devices/settings",
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[DeviceSettings]]._unwrapper,
),
cast_to=cast(Type[Optional[DeviceSettings]], ResultWrapper[DeviceSettings]),
)
class SettingsResourceWithRawResponse:
def __init__(self, settings: SettingsResource) -> None:
@ -399,12 +399,12 @@ class SettingsResourceWithRawResponse:
self.update = to_raw_response_wrapper(
settings.update,
)
self.list = to_raw_response_wrapper(
settings.list,
)
self.edit = to_raw_response_wrapper(
settings.edit,
)
self.get = to_raw_response_wrapper(
settings.get,
)
class AsyncSettingsResourceWithRawResponse:
@ -414,12 +414,12 @@ class AsyncSettingsResourceWithRawResponse:
self.update = async_to_raw_response_wrapper(
settings.update,
)
self.list = async_to_raw_response_wrapper(
settings.list,
)
self.edit = async_to_raw_response_wrapper(
settings.edit,
)
self.get = async_to_raw_response_wrapper(
settings.get,
)
class SettingsResourceWithStreamingResponse:
@ -429,12 +429,12 @@ class SettingsResourceWithStreamingResponse:
self.update = to_streamed_response_wrapper(
settings.update,
)
self.list = to_streamed_response_wrapper(
settings.list,
)
self.edit = to_streamed_response_wrapper(
settings.edit,
)
self.get = to_streamed_response_wrapper(
settings.get,
)
class AsyncSettingsResourceWithStreamingResponse:
@ -444,9 +444,9 @@ class AsyncSettingsResourceWithStreamingResponse:
self.update = async_to_streamed_response_wrapper(
settings.update,
)
self.list = async_to_streamed_response_wrapper(
settings.list,
)
self.edit = async_to_streamed_response_wrapper(
settings.edit,
)
self.get = async_to_streamed_response_wrapper(
settings.get,
)

View file

@ -67,44 +67,6 @@ class TestSettings:
account_id="",
)
@parametrize
def test_method_list(self, client: Cloudflare) -> None:
setting = client.zero_trust.devices.settings.list(
account_id="699d98642c564d2e855e9661899b7252",
)
assert_matches_type(Optional[DeviceSettings], setting, path=["response"])
@parametrize
def test_raw_response_list(self, client: Cloudflare) -> None:
response = client.zero_trust.devices.settings.with_raw_response.list(
account_id="699d98642c564d2e855e9661899b7252",
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
setting = response.parse()
assert_matches_type(Optional[DeviceSettings], setting, path=["response"])
@parametrize
def test_streaming_response_list(self, client: Cloudflare) -> None:
with client.zero_trust.devices.settings.with_streaming_response.list(
account_id="699d98642c564d2e855e9661899b7252",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
setting = response.parse()
assert_matches_type(Optional[DeviceSettings], setting, path=["response"])
assert cast(Any, response.is_closed) is True
@parametrize
def test_path_params_list(self, client: Cloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
client.zero_trust.devices.settings.with_raw_response.list(
account_id="",
)
@parametrize
def test_method_edit(self, client: Cloudflare) -> None:
setting = client.zero_trust.devices.settings.edit(
@ -155,6 +117,44 @@ class TestSettings:
account_id="",
)
@parametrize
def test_method_get(self, client: Cloudflare) -> None:
setting = client.zero_trust.devices.settings.get(
account_id="699d98642c564d2e855e9661899b7252",
)
assert_matches_type(Optional[DeviceSettings], setting, path=["response"])
@parametrize
def test_raw_response_get(self, client: Cloudflare) -> None:
response = client.zero_trust.devices.settings.with_raw_response.get(
account_id="699d98642c564d2e855e9661899b7252",
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
setting = response.parse()
assert_matches_type(Optional[DeviceSettings], setting, path=["response"])
@parametrize
def test_streaming_response_get(self, client: Cloudflare) -> None:
with client.zero_trust.devices.settings.with_streaming_response.get(
account_id="699d98642c564d2e855e9661899b7252",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
setting = response.parse()
assert_matches_type(Optional[DeviceSettings], setting, path=["response"])
assert cast(Any, response.is_closed) is True
@parametrize
def test_path_params_get(self, client: Cloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
client.zero_trust.devices.settings.with_raw_response.get(
account_id="",
)
class TestAsyncSettings:
parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
@ -209,44 +209,6 @@ class TestAsyncSettings:
account_id="",
)
@parametrize
async def test_method_list(self, async_client: AsyncCloudflare) -> None:
setting = await async_client.zero_trust.devices.settings.list(
account_id="699d98642c564d2e855e9661899b7252",
)
assert_matches_type(Optional[DeviceSettings], setting, path=["response"])
@parametrize
async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None:
response = await async_client.zero_trust.devices.settings.with_raw_response.list(
account_id="699d98642c564d2e855e9661899b7252",
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
setting = await response.parse()
assert_matches_type(Optional[DeviceSettings], setting, path=["response"])
@parametrize
async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None:
async with async_client.zero_trust.devices.settings.with_streaming_response.list(
account_id="699d98642c564d2e855e9661899b7252",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
setting = await response.parse()
assert_matches_type(Optional[DeviceSettings], setting, path=["response"])
assert cast(Any, response.is_closed) is True
@parametrize
async def test_path_params_list(self, async_client: AsyncCloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
await async_client.zero_trust.devices.settings.with_raw_response.list(
account_id="",
)
@parametrize
async def test_method_edit(self, async_client: AsyncCloudflare) -> None:
setting = await async_client.zero_trust.devices.settings.edit(
@ -296,3 +258,41 @@ class TestAsyncSettings:
await async_client.zero_trust.devices.settings.with_raw_response.edit(
account_id="",
)
@parametrize
async def test_method_get(self, async_client: AsyncCloudflare) -> None:
setting = await async_client.zero_trust.devices.settings.get(
account_id="699d98642c564d2e855e9661899b7252",
)
assert_matches_type(Optional[DeviceSettings], setting, path=["response"])
@parametrize
async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None:
response = await async_client.zero_trust.devices.settings.with_raw_response.get(
account_id="699d98642c564d2e855e9661899b7252",
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
setting = await response.parse()
assert_matches_type(Optional[DeviceSettings], setting, path=["response"])
@parametrize
async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None:
async with async_client.zero_trust.devices.settings.with_streaming_response.get(
account_id="699d98642c564d2e855e9661899b7252",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
setting = await response.parse()
assert_matches_type(Optional[DeviceSettings], setting, path=["response"])
assert cast(Any, response.is_closed) is True
@parametrize
async def test_path_params_get(self, async_client: AsyncCloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
await async_client.zero_trust.devices.settings.with_raw_response.get(
account_id="",
)