Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): api update #2294

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 1480
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-64d4fa2d88511612fbb26659965c2b7b2d016b10e3a96a786e93066817865e4f.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-405af13ac696c25ab9d54a26786eab9bf02e2c2ff817a7ec01a454056dda053c.yml
2 changes: 1 addition & 1 deletion api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4811,7 +4811,7 @@ from cloudflare.types.zero_trust import Device, DeviceGetResponse
Methods:

- <code title="get /accounts/{account_id}/devices">client.zero_trust.devices.<a href="./src/cloudflare/resources/zero_trust/devices/devices.py">list</a>(\*, account_id) -> <a href="./src/cloudflare/types/zero_trust/device.py">SyncSinglePage[Device]</a></code>
- <code title="get /accounts/{account_id}/devices/{device_id}">client.zero_trust.devices.<a href="./src/cloudflare/resources/zero_trust/devices/devices.py">get</a>(device_id, \*, account_id) -> <a href="./src/cloudflare/types/zero_trust/device_get_response.py">DeviceGetResponse</a></code>
- <code title="get /accounts/{account_id}/devices/{device_id}">client.zero_trust.devices.<a href="./src/cloudflare/resources/zero_trust/devices/devices.py">get</a>(device_id, \*, account_id) -> <a href="./src/cloudflare/types/zero_trust/device_get_response.py">Optional[DeviceGetResponse]</a></code>

### DEXTests

Expand Down
52 changes: 21 additions & 31 deletions src/cloudflare/resources/zero_trust/devices/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from typing import Any, cast
from typing import Type, Optional, cast

import httpx

Expand Down Expand Up @@ -197,7 +197,7 @@ def get(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> DeviceGetResponse:
) -> Optional[DeviceGetResponse]:
"""
Fetches details for a single device.

Expand All @@ -216,21 +216,16 @@ def get(
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 cast(
DeviceGetResponse,
self._get(
f"/accounts/{account_id}/devices/{device_id}",
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[DeviceGetResponse]._unwrapper,
),
cast_to=cast(
Any, ResultWrapper[DeviceGetResponse]
), # Union types cannot be passed in as arguments in the type system
return self._get(
f"/accounts/{account_id}/devices/{device_id}",
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[DeviceGetResponse]]._unwrapper,
),
cast_to=cast(Type[Optional[DeviceGetResponse]], ResultWrapper[DeviceGetResponse]),
)


Expand Down Expand Up @@ -335,7 +330,7 @@ async def get(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> DeviceGetResponse:
) -> Optional[DeviceGetResponse]:
"""
Fetches details for a single device.

Expand All @@ -354,21 +349,16 @@ async def get(
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 cast(
DeviceGetResponse,
await self._get(
f"/accounts/{account_id}/devices/{device_id}",
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[DeviceGetResponse]._unwrapper,
),
cast_to=cast(
Any, ResultWrapper[DeviceGetResponse]
), # Union types cannot be passed in as arguments in the type system
return await self._get(
f"/accounts/{account_id}/devices/{device_id}",
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[DeviceGetResponse]]._unwrapper,
),
cast_to=cast(Type[Optional[DeviceGetResponse]], ResultWrapper[DeviceGetResponse]),
)


Expand Down
83 changes: 79 additions & 4 deletions src/cloudflare/types/zero_trust/device_get_response.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,83 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import Union, Optional
from typing_extensions import TypeAlias
from typing import Optional
from datetime import datetime

__all__ = ["DeviceGetResponse"]
from ..._models import BaseModel

DeviceGetResponse: TypeAlias = Union[Optional[str], Optional[object]]
__all__ = ["DeviceGetResponse", "Account", "User"]


class Account(BaseModel):
id: Optional[str] = None

account_type: Optional[str] = None

name: Optional[str] = None
"""The name of the enrolled account."""


class User(BaseModel):
id: Optional[str] = None
"""UUID"""

email: Optional[str] = None
"""The contact email address of the user."""

name: Optional[str] = None
"""The enrolled device user's name."""


class DeviceGetResponse(BaseModel):
id: Optional[str] = None
"""Device ID."""

account: Optional[Account] = None

created: Optional[datetime] = None
"""When the device was created."""

deleted: Optional[bool] = None
"""True if the device was deleted."""

device_type: Optional[str] = None

gateway_device_id: Optional[str] = None

ip: Optional[str] = None
"""IPv4 or IPv6 address."""

key: Optional[str] = None
"""The device's public key."""

key_type: Optional[str] = None
"""Type of the key."""

last_seen: Optional[datetime] = None
"""When the device last connected to Cloudflare services."""

mac_address: Optional[str] = None
"""The device mac address."""

model: Optional[str] = None
"""The device model name."""

name: Optional[str] = None
"""The device name."""

os_version: Optional[str] = None
"""The operating system version."""

serial_number: Optional[str] = None
"""The device serial number."""

tunnel_type: Optional[str] = None
"""Type of the tunnel connection used."""

updated: Optional[datetime] = None
"""When the device was updated."""

user: Optional[User] = None

version: Optional[str] = None
"""The WARP client version."""
14 changes: 7 additions & 7 deletions tests/api_resources/zero_trust/test_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from __future__ import annotations

import os
from typing import Any, cast
from typing import Any, Optional, cast

import pytest

Expand Down Expand Up @@ -62,7 +62,7 @@ def test_method_get(self, client: Cloudflare) -> None:
device_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415",
account_id="699d98642c564d2e855e9661899b7252",
)
assert_matches_type(DeviceGetResponse, device, path=["response"])
assert_matches_type(Optional[DeviceGetResponse], device, path=["response"])

@parametrize
def test_raw_response_get(self, client: Cloudflare) -> None:
Expand All @@ -74,7 +74,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
device = response.parse()
assert_matches_type(DeviceGetResponse, device, path=["response"])
assert_matches_type(Optional[DeviceGetResponse], device, path=["response"])

@parametrize
def test_streaming_response_get(self, client: Cloudflare) -> None:
Expand All @@ -86,7 +86,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"

device = response.parse()
assert_matches_type(DeviceGetResponse, device, path=["response"])
assert_matches_type(Optional[DeviceGetResponse], device, path=["response"])

assert cast(Any, response.is_closed) is True

Expand Down Expand Up @@ -152,7 +152,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None:
device_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415",
account_id="699d98642c564d2e855e9661899b7252",
)
assert_matches_type(DeviceGetResponse, device, path=["response"])
assert_matches_type(Optional[DeviceGetResponse], device, path=["response"])

@parametrize
async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None:
Expand All @@ -164,7 +164,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
device = await response.parse()
assert_matches_type(DeviceGetResponse, device, path=["response"])
assert_matches_type(Optional[DeviceGetResponse], device, path=["response"])

@parametrize
async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None:
Expand All @@ -176,7 +176,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No
assert response.http_request.headers.get("X-Stainless-Lang") == "python"

device = await response.parse()
assert_matches_type(DeviceGetResponse, device, path=["response"])
assert_matches_type(Optional[DeviceGetResponse], device, path=["response"])

assert cast(Any, response.is_closed) is True

Expand Down