diff --git a/.stats.yml b/.stats.yml index 96693b177a2..56f3ed6efde 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1416 +configured_endpoints: 1417 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-cc1685d89cdcb1a8b9f5eada60808601470876a497be8898010890736c20e77f.yml diff --git a/api.md b/api.md index 6376e0683de..db446942c0c 100644 --- a/api.md +++ b/api.md @@ -4812,6 +4812,18 @@ Methods: - client.zero_trust.devices.networks.delete(network_id, \*, account_id) -> Optional - client.zero_trust.devices.networks.get(network_id, \*, account_id) -> Optional +### FleetStatus + +Types: + +```python +from cloudflare.types.zero_trust.devices import FleetStatusGetResponse +``` + +Methods: + +- client.zero_trust.devices.fleet_status.get(device_id, \*, account_id, \*\*params) -> FleetStatusGetResponse + ### Policies Types: diff --git a/src/cloudflare/resources/zero_trust/devices/__init__.py b/src/cloudflare/resources/zero_trust/devices/__init__.py index 3002bba6155..5b55d59405f 100644 --- a/src/cloudflare/resources/zero_trust/devices/__init__.py +++ b/src/cloudflare/resources/zero_trust/devices/__init__.py @@ -64,6 +64,14 @@ DEXTestsResourceWithStreamingResponse, AsyncDEXTestsResourceWithStreamingResponse, ) +from .fleet_status import ( + FleetStatusResource, + AsyncFleetStatusResource, + FleetStatusResourceWithRawResponse, + AsyncFleetStatusResourceWithRawResponse, + FleetStatusResourceWithStreamingResponse, + AsyncFleetStatusResourceWithStreamingResponse, +) from .override_codes import ( OverrideCodesResource, AsyncOverrideCodesResource, @@ -86,6 +94,12 @@ "AsyncNetworksResourceWithRawResponse", "NetworksResourceWithStreamingResponse", "AsyncNetworksResourceWithStreamingResponse", + "FleetStatusResource", + "AsyncFleetStatusResource", + "FleetStatusResourceWithRawResponse", + "AsyncFleetStatusResourceWithRawResponse", + "FleetStatusResourceWithStreamingResponse", + "AsyncFleetStatusResourceWithStreamingResponse", "PoliciesResource", "AsyncPoliciesResource", "PoliciesResourceWithRawResponse", diff --git a/src/cloudflare/resources/zero_trust/devices/devices.py b/src/cloudflare/resources/zero_trust/devices/devices.py index 73e50bc540a..c8da8b5a201 100644 --- a/src/cloudflare/resources/zero_trust/devices/devices.py +++ b/src/cloudflare/resources/zero_trust/devices/devices.py @@ -72,6 +72,14 @@ async_to_streamed_response_wrapper, ) from ...._wrappers import ResultWrapper +from .fleet_status import ( + FleetStatusResource, + AsyncFleetStatusResource, + FleetStatusResourceWithRawResponse, + AsyncFleetStatusResourceWithRawResponse, + FleetStatusResourceWithStreamingResponse, + AsyncFleetStatusResourceWithStreamingResponse, +) from ....pagination import SyncSinglePage, AsyncSinglePage from .override_codes import ( OverrideCodesResource, @@ -99,6 +107,10 @@ def dex_tests(self) -> DEXTestsResource: def networks(self) -> NetworksResource: return NetworksResource(self._client) + @cached_property + def fleet_status(self) -> FleetStatusResource: + return FleetStatusResource(self._client) + @cached_property def policies(self) -> PoliciesResource: return PoliciesResource(self._client) @@ -233,6 +245,10 @@ def dex_tests(self) -> AsyncDEXTestsResource: def networks(self) -> AsyncNetworksResource: return AsyncNetworksResource(self._client) + @cached_property + def fleet_status(self) -> AsyncFleetStatusResource: + return AsyncFleetStatusResource(self._client) + @cached_property def policies(self) -> AsyncPoliciesResource: return AsyncPoliciesResource(self._client) @@ -377,6 +393,10 @@ def dex_tests(self) -> DEXTestsResourceWithRawResponse: def networks(self) -> NetworksResourceWithRawResponse: return NetworksResourceWithRawResponse(self._devices.networks) + @cached_property + def fleet_status(self) -> FleetStatusResourceWithRawResponse: + return FleetStatusResourceWithRawResponse(self._devices.fleet_status) + @cached_property def policies(self) -> PoliciesResourceWithRawResponse: return PoliciesResourceWithRawResponse(self._devices.policies) @@ -421,6 +441,10 @@ def dex_tests(self) -> AsyncDEXTestsResourceWithRawResponse: def networks(self) -> AsyncNetworksResourceWithRawResponse: return AsyncNetworksResourceWithRawResponse(self._devices.networks) + @cached_property + def fleet_status(self) -> AsyncFleetStatusResourceWithRawResponse: + return AsyncFleetStatusResourceWithRawResponse(self._devices.fleet_status) + @cached_property def policies(self) -> AsyncPoliciesResourceWithRawResponse: return AsyncPoliciesResourceWithRawResponse(self._devices.policies) @@ -465,6 +489,10 @@ def dex_tests(self) -> DEXTestsResourceWithStreamingResponse: def networks(self) -> NetworksResourceWithStreamingResponse: return NetworksResourceWithStreamingResponse(self._devices.networks) + @cached_property + def fleet_status(self) -> FleetStatusResourceWithStreamingResponse: + return FleetStatusResourceWithStreamingResponse(self._devices.fleet_status) + @cached_property def policies(self) -> PoliciesResourceWithStreamingResponse: return PoliciesResourceWithStreamingResponse(self._devices.policies) @@ -509,6 +537,10 @@ def dex_tests(self) -> AsyncDEXTestsResourceWithStreamingResponse: def networks(self) -> AsyncNetworksResourceWithStreamingResponse: return AsyncNetworksResourceWithStreamingResponse(self._devices.networks) + @cached_property + def fleet_status(self) -> AsyncFleetStatusResourceWithStreamingResponse: + return AsyncFleetStatusResourceWithStreamingResponse(self._devices.fleet_status) + @cached_property def policies(self) -> AsyncPoliciesResourceWithStreamingResponse: return AsyncPoliciesResourceWithStreamingResponse(self._devices.policies) diff --git a/src/cloudflare/resources/zero_trust/devices/fleet_status.py b/src/cloudflare/resources/zero_trust/devices/fleet_status.py new file mode 100644 index 00000000000..871b776677f --- /dev/null +++ b/src/cloudflare/resources/zero_trust/devices/fleet_status.py @@ -0,0 +1,220 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +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 ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._base_client import make_request_options +from ....types.zero_trust.devices import fleet_status_get_params +from ....types.zero_trust.devices.fleet_status_get_response import FleetStatusGetResponse + +__all__ = ["FleetStatusResource", "AsyncFleetStatusResource"] + + +class FleetStatusResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> FleetStatusResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return the + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return FleetStatusResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> FleetStatusResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return FleetStatusResourceWithStreamingResponse(self) + + def get( + self, + device_id: str, + *, + account_id: str, + since_minutes: float, + colo: str | NotGiven = NOT_GIVEN, + time_now: str | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> FleetStatusGetResponse: + """ + Get the live status of a latest device given device_id from the device_state + table + + Args: + device_id: Device-specific ID, given as UUID v4 + + since_minutes: Number of minutes before current time + + colo: List of data centers to filter results + + time_now: Number of minutes before current time + + 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}") + if not device_id: + raise ValueError(f"Expected a non-empty value for `device_id` but received {device_id!r}") + return self._get( + f"/accounts/{account_id}/devices/{device_id}/fleet-status/live", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "since_minutes": since_minutes, + "colo": colo, + "time_now": time_now, + }, + fleet_status_get_params.FleetStatusGetParams, + ), + ), + cast_to=FleetStatusGetResponse, + ) + + +class AsyncFleetStatusResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncFleetStatusResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return the + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncFleetStatusResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncFleetStatusResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncFleetStatusResourceWithStreamingResponse(self) + + async def get( + self, + device_id: str, + *, + account_id: str, + since_minutes: float, + colo: str | NotGiven = NOT_GIVEN, + time_now: str | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> FleetStatusGetResponse: + """ + Get the live status of a latest device given device_id from the device_state + table + + Args: + device_id: Device-specific ID, given as UUID v4 + + since_minutes: Number of minutes before current time + + colo: List of data centers to filter results + + time_now: Number of minutes before current time + + 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}") + if not device_id: + raise ValueError(f"Expected a non-empty value for `device_id` but received {device_id!r}") + return await self._get( + f"/accounts/{account_id}/devices/{device_id}/fleet-status/live", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "since_minutes": since_minutes, + "colo": colo, + "time_now": time_now, + }, + fleet_status_get_params.FleetStatusGetParams, + ), + ), + cast_to=FleetStatusGetResponse, + ) + + +class FleetStatusResourceWithRawResponse: + def __init__(self, fleet_status: FleetStatusResource) -> None: + self._fleet_status = fleet_status + + self.get = to_raw_response_wrapper( + fleet_status.get, + ) + + +class AsyncFleetStatusResourceWithRawResponse: + def __init__(self, fleet_status: AsyncFleetStatusResource) -> None: + self._fleet_status = fleet_status + + self.get = async_to_raw_response_wrapper( + fleet_status.get, + ) + + +class FleetStatusResourceWithStreamingResponse: + def __init__(self, fleet_status: FleetStatusResource) -> None: + self._fleet_status = fleet_status + + self.get = to_streamed_response_wrapper( + fleet_status.get, + ) + + +class AsyncFleetStatusResourceWithStreamingResponse: + def __init__(self, fleet_status: AsyncFleetStatusResource) -> None: + self._fleet_status = fleet_status + + self.get = async_to_streamed_response_wrapper( + fleet_status.get, + ) diff --git a/src/cloudflare/types/zero_trust/devices/__init__.py b/src/cloudflare/types/zero_trust/devices/__init__.py index 831df46d499..37d71da7a5e 100644 --- a/src/cloudflare/types/zero_trust/devices/__init__.py +++ b/src/cloudflare/types/zero_trust/devices/__init__.py @@ -49,6 +49,7 @@ from .unique_client_id_input import UniqueClientIDInput as UniqueClientIDInput from .unrevoke_create_params import UnrevokeCreateParams as UnrevokeCreateParams from .crowdstrike_input_param import CrowdstrikeInputParam as CrowdstrikeInputParam +from .fleet_status_get_params import FleetStatusGetParams as FleetStatusGetParams from .network_delete_response import NetworkDeleteResponse as NetworkDeleteResponse from .posture_delete_response import PostureDeleteResponse as PostureDeleteResponse from .sentinelone_input_param import SentineloneInputParam as SentineloneInputParam @@ -56,6 +57,7 @@ from .dex_test_delete_response import DEXTestDeleteResponse as DEXTestDeleteResponse from .unrevoke_create_response import UnrevokeCreateResponse as UnrevokeCreateResponse from .domain_joined_input_param import DomainJoinedInputParam as DomainJoinedInputParam +from .fleet_status_get_response import FleetStatusGetResponse as FleetStatusGetResponse from .workspace_one_input_param import WorkspaceOneInputParam as WorkspaceOneInputParam from .split_tunnel_exclude_param import SplitTunnelExcludeParam as SplitTunnelExcludeParam from .split_tunnel_include_param import SplitTunnelIncludeParam as SplitTunnelIncludeParam diff --git a/src/cloudflare/types/zero_trust/devices/fleet_status_get_params.py b/src/cloudflare/types/zero_trust/devices/fleet_status_get_params.py new file mode 100644 index 00000000000..09a81b98c51 --- /dev/null +++ b/src/cloudflare/types/zero_trust/devices/fleet_status_get_params.py @@ -0,0 +1,20 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["FleetStatusGetParams"] + + +class FleetStatusGetParams(TypedDict, total=False): + account_id: Required[str] + + since_minutes: Required[float] + """Number of minutes before current time""" + + colo: str + """List of data centers to filter results""" + + time_now: str + """Number of minutes before current time""" diff --git a/src/cloudflare/types/zero_trust/devices/fleet_status_get_response.py b/src/cloudflare/types/zero_trust/devices/fleet_status_get_response.py new file mode 100644 index 00000000000..f4feee2cb0c --- /dev/null +++ b/src/cloudflare/types/zero_trust/devices/fleet_status_get_response.py @@ -0,0 +1,268 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from pydantic import Field as FieldInfo + +from ...._models import BaseModel + +__all__ = [ + "FleetStatusGetResponse", + "CPUPctByApp", + "DeviceIPV4", + "DeviceIPV4Location", + "DeviceIPV6", + "DeviceIPV6Location", + "GatewayIPV4", + "GatewayIPV4Location", + "GatewayIPV6", + "GatewayIPV6Location", + "ISPIPV4", + "ISPIPV4Location", + "ISPIPV6", + "ISPIPV6Location", + "RamUsedPctByApp", +] + + +class CPUPctByApp(BaseModel): + cpu_pct: Optional[float] = None + + name: Optional[str] = None + + +class DeviceIPV4Location(BaseModel): + city: Optional[str] = None + + country_iso: Optional[str] = None + + state_iso: Optional[str] = None + + zip: Optional[str] = None + + +class DeviceIPV4(BaseModel): + address: Optional[str] = None + + asn: Optional[int] = None + + aso: Optional[str] = None + + location: Optional[DeviceIPV4Location] = None + + netmask: Optional[str] = None + + version: Optional[str] = None + + +class DeviceIPV6Location(BaseModel): + city: Optional[str] = None + + country_iso: Optional[str] = None + + state_iso: Optional[str] = None + + zip: Optional[str] = None + + +class DeviceIPV6(BaseModel): + address: Optional[str] = None + + asn: Optional[int] = None + + aso: Optional[str] = None + + location: Optional[DeviceIPV6Location] = None + + netmask: Optional[str] = None + + version: Optional[str] = None + + +class GatewayIPV4Location(BaseModel): + city: Optional[str] = None + + country_iso: Optional[str] = None + + state_iso: Optional[str] = None + + zip: Optional[str] = None + + +class GatewayIPV4(BaseModel): + address: Optional[str] = None + + asn: Optional[int] = None + + aso: Optional[str] = None + + location: Optional[GatewayIPV4Location] = None + + netmask: Optional[str] = None + + version: Optional[str] = None + + +class GatewayIPV6Location(BaseModel): + city: Optional[str] = None + + country_iso: Optional[str] = None + + state_iso: Optional[str] = None + + zip: Optional[str] = None + + +class GatewayIPV6(BaseModel): + address: Optional[str] = None + + asn: Optional[int] = None + + aso: Optional[str] = None + + location: Optional[GatewayIPV6Location] = None + + netmask: Optional[str] = None + + version: Optional[str] = None + + +class ISPIPV4Location(BaseModel): + city: Optional[str] = None + + country_iso: Optional[str] = None + + state_iso: Optional[str] = None + + zip: Optional[str] = None + + +class ISPIPV4(BaseModel): + address: Optional[str] = None + + asn: Optional[int] = None + + aso: Optional[str] = None + + location: Optional[ISPIPV4Location] = None + + netmask: Optional[str] = None + + version: Optional[str] = None + + +class ISPIPV6Location(BaseModel): + city: Optional[str] = None + + country_iso: Optional[str] = None + + state_iso: Optional[str] = None + + zip: Optional[str] = None + + +class ISPIPV6(BaseModel): + address: Optional[str] = None + + asn: Optional[int] = None + + aso: Optional[str] = None + + location: Optional[ISPIPV6Location] = None + + netmask: Optional[str] = None + + version: Optional[str] = None + + +class RamUsedPctByApp(BaseModel): + name: Optional[str] = None + + ram_used_pct: Optional[float] = None + + +class FleetStatusGetResponse(BaseModel): + colo: str + """Cloudflare colo""" + + device_id: str = FieldInfo(alias="deviceId") + """Device identifier (UUID v4)""" + + mode: str + """The mode under which the WARP client is run""" + + platform: str + """Operating system""" + + status: str + """Network status""" + + timestamp: str + """Timestamp in ISO format""" + + version: str + """WARP client version""" + + always_on: Optional[bool] = FieldInfo(alias="alwaysOn", default=None) + + battery_charging: Optional[bool] = FieldInfo(alias="batteryCharging", default=None) + + battery_cycles: Optional[int] = FieldInfo(alias="batteryCycles", default=None) + + battery_pct: Optional[float] = FieldInfo(alias="batteryPct", default=None) + + connection_type: Optional[str] = FieldInfo(alias="connectionType", default=None) + + cpu_pct: Optional[float] = FieldInfo(alias="cpuPct", default=None) + + cpu_pct_by_app: Optional[List[List[CPUPctByApp]]] = FieldInfo(alias="cpuPctByApp", default=None) + + device_ipv4: Optional[DeviceIPV4] = FieldInfo(alias="deviceIpv4", default=None) + + device_ipv6: Optional[DeviceIPV6] = FieldInfo(alias="deviceIpv6", default=None) + + device_name: Optional[str] = FieldInfo(alias="deviceName", default=None) + """Device identifier (human readable)""" + + disk_read_bps: Optional[int] = FieldInfo(alias="diskReadBps", default=None) + + disk_usage_pct: Optional[float] = FieldInfo(alias="diskUsagePct", default=None) + + disk_write_bps: Optional[int] = FieldInfo(alias="diskWriteBps", default=None) + + doh_subdomain: Optional[str] = FieldInfo(alias="dohSubdomain", default=None) + + estimated_loss_pct: Optional[float] = FieldInfo(alias="estimatedLossPct", default=None) + + firewall_enabled: Optional[bool] = FieldInfo(alias="firewallEnabled", default=None) + + gateway_ipv4: Optional[GatewayIPV4] = FieldInfo(alias="gatewayIpv4", default=None) + + gateway_ipv6: Optional[GatewayIPV6] = FieldInfo(alias="gatewayIpv6", default=None) + + handshake_latency_ms: Optional[float] = FieldInfo(alias="handshakeLatencyMs", default=None) + + isp_ipv4: Optional[ISPIPV4] = FieldInfo(alias="ispIpv4", default=None) + + isp_ipv6: Optional[ISPIPV6] = FieldInfo(alias="ispIpv6", default=None) + + metal: Optional[str] = None + + network_rcvd_bps: Optional[int] = FieldInfo(alias="networkRcvdBps", default=None) + + network_sent_bps: Optional[int] = FieldInfo(alias="networkSentBps", default=None) + + network_ssid: Optional[str] = FieldInfo(alias="networkSsid", default=None) + + person_email: Optional[str] = FieldInfo(alias="personEmail", default=None) + """User contact email address""" + + ram_available_kb: Optional[int] = FieldInfo(alias="ramAvailableKb", default=None) + + ram_used_pct: Optional[float] = FieldInfo(alias="ramUsedPct", default=None) + + ram_used_pct_by_app: Optional[List[List[RamUsedPctByApp]]] = FieldInfo(alias="ramUsedPctByApp", default=None) + + switch_locked: Optional[bool] = FieldInfo(alias="switchLocked", default=None) + + wifi_strength_dbm: Optional[int] = FieldInfo(alias="wifiStrengthDbm", default=None) diff --git a/tests/api_resources/zero_trust/devices/test_fleet_status.py b/tests/api_resources/zero_trust/devices/test_fleet_status.py new file mode 100644 index 00000000000..308864477e0 --- /dev/null +++ b/tests/api_resources/zero_trust/devices/test_fleet_status.py @@ -0,0 +1,150 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.types.zero_trust.devices import FleetStatusGetResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestFleetStatus: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + fleet_status = client.zero_trust.devices.fleet_status.get( + device_id="cb49c27f-7f97-49c5-b6f3-f7c01ead0fd7", + account_id="01a7362d577a6c3019a474fd6f485823", + since_minutes=10, + ) + assert_matches_type(FleetStatusGetResponse, fleet_status, path=["response"]) + + @parametrize + def test_method_get_with_all_params(self, client: Cloudflare) -> None: + fleet_status = client.zero_trust.devices.fleet_status.get( + device_id="cb49c27f-7f97-49c5-b6f3-f7c01ead0fd7", + account_id="01a7362d577a6c3019a474fd6f485823", + since_minutes=10, + colo="SJC", + time_now="2023-10-11T00:00:00Z", + ) + assert_matches_type(FleetStatusGetResponse, fleet_status, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.zero_trust.devices.fleet_status.with_raw_response.get( + device_id="cb49c27f-7f97-49c5-b6f3-f7c01ead0fd7", + account_id="01a7362d577a6c3019a474fd6f485823", + since_minutes=10, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + fleet_status = response.parse() + assert_matches_type(FleetStatusGetResponse, fleet_status, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.zero_trust.devices.fleet_status.with_streaming_response.get( + device_id="cb49c27f-7f97-49c5-b6f3-f7c01ead0fd7", + account_id="01a7362d577a6c3019a474fd6f485823", + since_minutes=10, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + fleet_status = response.parse() + assert_matches_type(FleetStatusGetResponse, fleet_status, 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.fleet_status.with_raw_response.get( + device_id="cb49c27f-7f97-49c5-b6f3-f7c01ead0fd7", + account_id="", + since_minutes=10, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `device_id` but received ''"): + client.zero_trust.devices.fleet_status.with_raw_response.get( + device_id="", + account_id="01a7362d577a6c3019a474fd6f485823", + since_minutes=10, + ) + + +class TestAsyncFleetStatus: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + fleet_status = await async_client.zero_trust.devices.fleet_status.get( + device_id="cb49c27f-7f97-49c5-b6f3-f7c01ead0fd7", + account_id="01a7362d577a6c3019a474fd6f485823", + since_minutes=10, + ) + assert_matches_type(FleetStatusGetResponse, fleet_status, path=["response"]) + + @parametrize + async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: + fleet_status = await async_client.zero_trust.devices.fleet_status.get( + device_id="cb49c27f-7f97-49c5-b6f3-f7c01ead0fd7", + account_id="01a7362d577a6c3019a474fd6f485823", + since_minutes=10, + colo="SJC", + time_now="2023-10-11T00:00:00Z", + ) + assert_matches_type(FleetStatusGetResponse, fleet_status, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.devices.fleet_status.with_raw_response.get( + device_id="cb49c27f-7f97-49c5-b6f3-f7c01ead0fd7", + account_id="01a7362d577a6c3019a474fd6f485823", + since_minutes=10, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + fleet_status = await response.parse() + assert_matches_type(FleetStatusGetResponse, fleet_status, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.devices.fleet_status.with_streaming_response.get( + device_id="cb49c27f-7f97-49c5-b6f3-f7c01ead0fd7", + account_id="01a7362d577a6c3019a474fd6f485823", + since_minutes=10, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + fleet_status = await response.parse() + assert_matches_type(FleetStatusGetResponse, fleet_status, 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.fleet_status.with_raw_response.get( + device_id="cb49c27f-7f97-49c5-b6f3-f7c01ead0fd7", + account_id="", + since_minutes=10, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `device_id` but received ''"): + await async_client.zero_trust.devices.fleet_status.with_raw_response.get( + device_id="", + account_id="01a7362d577a6c3019a474fd6f485823", + since_minutes=10, + )