From fd579d1c14e72044e13a33b6b54f7366fc0a23ed Mon Sep 17 00:00:00 2001 From: stlc-bot Date: Tue, 17 Nov 2026 09:21:31 +0000 Subject: [PATCH] chore: regenerate SDK from openapi config Stainless-Generated-From: 4d45c90a47ebf1030e935c87105bfe3b55903462 --- .stats.yml | 2 +- api.md | 7 +- src/miru_device_sdk/_client.py | 4 +- src/miru_device_sdk/resources/agent.py | 51 +++++ src/miru_device_sdk/resources/calibrations.py | 195 +++++++++++------- src/miru_device_sdk/resources/device.py | 51 ----- src/miru_device_sdk/types/__init__.py | 3 +- .../types/agent_sync_response.py | 37 ++++ src/miru_device_sdk/types/calibration.py | 20 +- .../types/calibration_create_params.py | 16 -- .../types/calibration_invalidate_params.py | 25 +++ .../types/calibration_latest_params.py | 15 -- .../types/calibration_latest_response.py | 2 +- .../types/device_retrieve_response.py | 25 ++- .../types/device_sync_response.py | 28 --- tests/api_resources/test_agent.py | 58 +++++- tests/api_resources/test_calibrations.py | 103 ++++++++- tests/api_resources/test_device.py | 58 +----- tests/test_client.py | 4 +- tests/test_device_api.py | 6 +- 20 files changed, 428 insertions(+), 282 deletions(-) create mode 100644 src/miru_device_sdk/types/agent_sync_response.py create mode 100644 src/miru_device_sdk/types/calibration_invalidate_params.py delete mode 100644 src/miru_device_sdk/types/device_sync_response.py diff --git a/.stats.yml b/.stats.yml index dd47305..c254947 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1 @@ -configured_endpoints: 14 +configured_endpoints: 15 diff --git a/api.md b/api.md index cc1fd0b..e929844 100644 --- a/api.md +++ b/api.md @@ -3,12 +3,13 @@ Types: ```python -from miru_device_sdk.types import AgentHealthResponse, AgentVersionResponse +from miru_device_sdk.types import AgentHealthResponse, AgentSyncResponse, AgentVersionResponse ``` Methods: - client.agent.health() -> AgentHealthResponse +- client.agent.sync() -> AgentSyncResponse - client.agent.version() -> AgentVersionResponse # Calibrations @@ -23,6 +24,7 @@ Methods: - client.calibrations.create(\*\*params) -> CalibrationCreateResponse - client.calibrations.download(report_id) -> BinaryAPIResponse +- client.calibrations.invalidate(\*\*params) -> Calibration - client.calibrations.latest(\*\*params) -> CalibrationLatestResponse # Deployments @@ -43,13 +45,12 @@ Methods: Types: ```python -from miru_device_sdk.types import DeviceRetrieveResponse, DeviceSyncResponse +from miru_device_sdk.types import DeviceRetrieveResponse ``` Methods: - client.device.retrieve() -> DeviceRetrieveResponse -- client.device.sync() -> DeviceSyncResponse # FileRules diff --git a/src/miru_device_sdk/_client.py b/src/miru_device_sdk/_client.py index b9d1cd7..3e5e15c 100644 --- a/src/miru_device_sdk/_client.py +++ b/src/miru_device_sdk/_client.py @@ -170,7 +170,7 @@ def __init__( if base_url is None: base_url = os.environ.get("MIRU_BASE_URL") if base_url is None: - base_url = f"http://localhost/v0.2" + base_url = f"http://localhost/v0.3" if http_client is None: http_client = _build_sync_httpx_client( socket_path=socket_path, @@ -448,7 +448,7 @@ def __init__( if base_url is None: base_url = os.environ.get("MIRU_BASE_URL") if base_url is None: - base_url = f"http://localhost/v0.2" + base_url = f"http://localhost/v0.3" if http_client is None: http_client = _build_async_httpx_client( socket_path=socket_path, diff --git a/src/miru_device_sdk/resources/agent.py b/src/miru_device_sdk/resources/agent.py index 6741e89..de2ad67 100644 --- a/src/miru_device_sdk/resources/agent.py +++ b/src/miru_device_sdk/resources/agent.py @@ -14,6 +14,7 @@ async_to_streamed_response_wrapper, ) from .._base_client import make_request_options +from ..types.agent_sync_response import AgentSyncResponse from ..types.agent_health_response import AgentHealthResponse from ..types.agent_version_response import AgentVersionResponse @@ -59,6 +60,25 @@ def health( cast_to=AgentHealthResponse, ) + def sync( + self, + *, + # 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, + ) -> AgentSyncResponse: + """Manually force a device sync with the edits made in the dashboard.""" + return self._post( + "/sync", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=AgentSyncResponse, + ) + def version( self, *, @@ -118,6 +138,25 @@ async def health( cast_to=AgentHealthResponse, ) + async def sync( + self, + *, + # 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, + ) -> AgentSyncResponse: + """Manually force a device sync with the edits made in the dashboard.""" + return await self._post( + "/sync", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=AgentSyncResponse, + ) + async def version( self, *, @@ -145,6 +184,9 @@ def __init__(self, agent: AgentResource) -> None: self.health = to_raw_response_wrapper( agent.health, ) + self.sync = to_raw_response_wrapper( + agent.sync, + ) self.version = to_raw_response_wrapper( agent.version, ) @@ -157,6 +199,9 @@ def __init__(self, agent: AsyncAgentResource) -> None: self.health = async_to_raw_response_wrapper( agent.health, ) + self.sync = async_to_raw_response_wrapper( + agent.sync, + ) self.version = async_to_raw_response_wrapper( agent.version, ) @@ -169,6 +214,9 @@ def __init__(self, agent: AgentResource) -> None: self.health = to_streamed_response_wrapper( agent.health, ) + self.sync = to_streamed_response_wrapper( + agent.sync, + ) self.version = to_streamed_response_wrapper( agent.version, ) @@ -181,6 +229,9 @@ def __init__(self, agent: AsyncAgentResource) -> None: self.health = async_to_streamed_response_wrapper( agent.health, ) + self.sync = async_to_streamed_response_wrapper( + agent.sync, + ) self.version = async_to_streamed_response_wrapper( agent.version, ) diff --git a/src/miru_device_sdk/resources/calibrations.py b/src/miru_device_sdk/resources/calibrations.py index d910fe2..8eaa96a 100644 --- a/src/miru_device_sdk/resources/calibrations.py +++ b/src/miru_device_sdk/resources/calibrations.py @@ -4,7 +4,7 @@ import httpx -from ..types import calibration_create_params, calibration_latest_params +from ..types import calibration_create_params, calibration_latest_params, calibration_invalidate_params from .._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given from .._utils import path_template, maybe_transform, async_maybe_transform from .._compat import cached_property @@ -24,6 +24,7 @@ async_to_custom_streamed_response_wrapper, ) from .._base_client import make_request_options +from ..types.calibration import Calibration from ..types.calibration_create_response import CalibrationCreateResponse from ..types.calibration_latest_response import CalibrationLatestResponse @@ -55,9 +56,7 @@ def create( *, component: str, content: calibration_create_params.Content, - aspect: str | Omit = omit, reported_by: str | Omit = omit, - role: str | Omit = omit, serial_number: str | Omit = omit, # 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. @@ -77,19 +76,9 @@ def create( content: The calibration's content, at most 1 MiB. The agent uploads it to Miru unchanged. - aspect: Slug of the aspect of the unit that was calibrated, when it has more than one, - e.g. `intrinsics` vs `extrinsics`, or `pose` vs `joint-offsets`. Validated like - a slug; `null` is reserved. Miru resolves it to one of the component's - `aspects`, creating the aspect the first time it is reported. - reported_by: Who reported the calibration, as the device knows them, such as `Benjamin Smidt`. Free text, at most 255 characters. Miru stores it unchanged. - role: Slug of the role the calibrated unit fills on the device, such as `left` or - `front-left`. Distinguishes several units of one component on a device. - Validated like a slug; `null` is reserved. Miru resolves it to one of the - component's `roles`, creating the role the first time it is reported. - serial_number: Serial number of the physical unit that was calibrated, not of the device, such as `SN-1234`. Free text, at most 255 characters. @@ -107,9 +96,7 @@ def create( { "component": component, "content": content, - "aspect": aspect, "reported_by": reported_by, - "role": role, "serial_number": serial_number, }, calibration_create_params.CalibrationCreateParams, @@ -131,10 +118,8 @@ def download( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> BinaryAPIResponse: - """Download the content of a latest calibration by its report ID. - - An older report - returns 404. + """ + Download the content of a latest calibration by its report ID. Args: extra_headers: Send extra headers @@ -156,12 +141,60 @@ def download( cast_to=BinaryAPIResponse, ) + def invalidate( + self, + *, + component: str, + reason: str, + report_id: str | Omit = omit, + # 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, + ) -> Calibration: + """ + Mark a component's latest calibration invalid. + + Args: + component: Slug of the component whose latest calibration to invalidate, such as `arm`. + + reason: Why the calibration is no longer valid, such as `power cycle`. Free text, at + most 512 characters, and not blank. + + report_id: Report ID of the calibration the caller expects to be `component`'s latest. If + it is not `component`'s current latest calibration, the agent invalidates + nothing. Leave it out to invalidate whatever is latest. + + 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 + """ + return self._post( + "/calibrations/latest/invalidate", + body=maybe_transform( + { + "component": component, + "reason": reason, + "report_id": report_id, + }, + calibration_invalidate_params.CalibrationInvalidateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=Calibration, + ) + def latest( self, *, - aspect: SequenceNotStr[str] | Omit = omit, component: SequenceNotStr[str] | Omit = omit, - role: SequenceNotStr[str] | Omit = omit, # 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, @@ -170,19 +203,11 @@ def latest( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> CalibrationLatestResponse: """ - List the latest calibration for each component, role and aspect on the device. + List the latest calibration for each component on the device. Args: - aspect: The aspect slugs to filter by; `null` matches calibrations reported without an - aspect. Aspect slugs are unique only within a component, so filter by component - too to match one component's aspect. - component: The component slugs to filter by. - role: The role slugs to filter by; `null` matches calibrations reported without a - role. Role slugs are unique only within a component, so filter by component too - to match one component's role. - extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -198,14 +223,7 @@ def latest( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - query=maybe_transform( - { - "aspect": aspect, - "component": component, - "role": role, - }, - calibration_latest_params.CalibrationLatestParams, - ), + query=maybe_transform({"component": component}, calibration_latest_params.CalibrationLatestParams), ), cast_to=CalibrationLatestResponse, ) @@ -236,9 +254,7 @@ async def create( *, component: str, content: calibration_create_params.Content, - aspect: str | Omit = omit, reported_by: str | Omit = omit, - role: str | Omit = omit, serial_number: str | Omit = omit, # 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. @@ -258,19 +274,9 @@ async def create( content: The calibration's content, at most 1 MiB. The agent uploads it to Miru unchanged. - aspect: Slug of the aspect of the unit that was calibrated, when it has more than one, - e.g. `intrinsics` vs `extrinsics`, or `pose` vs `joint-offsets`. Validated like - a slug; `null` is reserved. Miru resolves it to one of the component's - `aspects`, creating the aspect the first time it is reported. - reported_by: Who reported the calibration, as the device knows them, such as `Benjamin Smidt`. Free text, at most 255 characters. Miru stores it unchanged. - role: Slug of the role the calibrated unit fills on the device, such as `left` or - `front-left`. Distinguishes several units of one component on a device. - Validated like a slug; `null` is reserved. Miru resolves it to one of the - component's `roles`, creating the role the first time it is reported. - serial_number: Serial number of the physical unit that was calibrated, not of the device, such as `SN-1234`. Free text, at most 255 characters. @@ -288,9 +294,7 @@ async def create( { "component": component, "content": content, - "aspect": aspect, "reported_by": reported_by, - "role": role, "serial_number": serial_number, }, calibration_create_params.CalibrationCreateParams, @@ -312,10 +316,8 @@ async def download( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncBinaryAPIResponse: - """Download the content of a latest calibration by its report ID. - - An older report - returns 404. + """ + Download the content of a latest calibration by its report ID. Args: extra_headers: Send extra headers @@ -337,12 +339,60 @@ async def download( cast_to=AsyncBinaryAPIResponse, ) + async def invalidate( + self, + *, + component: str, + reason: str, + report_id: str | Omit = omit, + # 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, + ) -> Calibration: + """ + Mark a component's latest calibration invalid. + + Args: + component: Slug of the component whose latest calibration to invalidate, such as `arm`. + + reason: Why the calibration is no longer valid, such as `power cycle`. Free text, at + most 512 characters, and not blank. + + report_id: Report ID of the calibration the caller expects to be `component`'s latest. If + it is not `component`'s current latest calibration, the agent invalidates + nothing. Leave it out to invalidate whatever is latest. + + 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 + """ + return await self._post( + "/calibrations/latest/invalidate", + body=await async_maybe_transform( + { + "component": component, + "reason": reason, + "report_id": report_id, + }, + calibration_invalidate_params.CalibrationInvalidateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=Calibration, + ) + async def latest( self, *, - aspect: SequenceNotStr[str] | Omit = omit, component: SequenceNotStr[str] | Omit = omit, - role: SequenceNotStr[str] | Omit = omit, # 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, @@ -351,19 +401,11 @@ async def latest( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> CalibrationLatestResponse: """ - List the latest calibration for each component, role and aspect on the device. + List the latest calibration for each component on the device. Args: - aspect: The aspect slugs to filter by; `null` matches calibrations reported without an - aspect. Aspect slugs are unique only within a component, so filter by component - too to match one component's aspect. - component: The component slugs to filter by. - role: The role slugs to filter by; `null` matches calibrations reported without a - role. Role slugs are unique only within a component, so filter by component too - to match one component's role. - extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -380,12 +422,7 @@ async def latest( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform( - { - "aspect": aspect, - "component": component, - "role": role, - }, - calibration_latest_params.CalibrationLatestParams, + {"component": component}, calibration_latest_params.CalibrationLatestParams ), ), cast_to=CalibrationLatestResponse, @@ -403,6 +440,9 @@ def __init__(self, calibrations: CalibrationsResource) -> None: calibrations.download, BinaryAPIResponse, ) + self.invalidate = to_raw_response_wrapper( + calibrations.invalidate, + ) self.latest = to_raw_response_wrapper( calibrations.latest, ) @@ -419,6 +459,9 @@ def __init__(self, calibrations: AsyncCalibrationsResource) -> None: calibrations.download, AsyncBinaryAPIResponse, ) + self.invalidate = async_to_raw_response_wrapper( + calibrations.invalidate, + ) self.latest = async_to_raw_response_wrapper( calibrations.latest, ) @@ -435,6 +478,9 @@ def __init__(self, calibrations: CalibrationsResource) -> None: calibrations.download, StreamedBinaryAPIResponse, ) + self.invalidate = to_streamed_response_wrapper( + calibrations.invalidate, + ) self.latest = to_streamed_response_wrapper( calibrations.latest, ) @@ -451,6 +497,9 @@ def __init__(self, calibrations: AsyncCalibrationsResource) -> None: calibrations.download, AsyncStreamedBinaryAPIResponse, ) + self.invalidate = async_to_streamed_response_wrapper( + calibrations.invalidate, + ) self.latest = async_to_streamed_response_wrapper( calibrations.latest, ) diff --git a/src/miru_device_sdk/resources/device.py b/src/miru_device_sdk/resources/device.py index 22b0a15..50452b9 100644 --- a/src/miru_device_sdk/resources/device.py +++ b/src/miru_device_sdk/resources/device.py @@ -14,7 +14,6 @@ async_to_streamed_response_wrapper, ) from .._base_client import make_request_options -from ..types.device_sync_response import DeviceSyncResponse from ..types.device_retrieve_response import DeviceRetrieveResponse __all__ = ["DeviceResource", "AsyncDeviceResource"] @@ -59,25 +58,6 @@ def retrieve( cast_to=DeviceRetrieveResponse, ) - def sync( - self, - *, - # 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, - ) -> DeviceSyncResponse: - """Manually force a device sync with the edits made in the dashboard.""" - return self._post( - "/device/sync", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=DeviceSyncResponse, - ) - class AsyncDeviceResource(AsyncAPIResource): @cached_property @@ -118,25 +98,6 @@ async def retrieve( cast_to=DeviceRetrieveResponse, ) - async def sync( - self, - *, - # 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, - ) -> DeviceSyncResponse: - """Manually force a device sync with the edits made in the dashboard.""" - return await self._post( - "/device/sync", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=DeviceSyncResponse, - ) - class DeviceResourceWithRawResponse: def __init__(self, device: DeviceResource) -> None: @@ -145,9 +106,6 @@ def __init__(self, device: DeviceResource) -> None: self.retrieve = to_raw_response_wrapper( device.retrieve, ) - self.sync = to_raw_response_wrapper( - device.sync, - ) class AsyncDeviceResourceWithRawResponse: @@ -157,9 +115,6 @@ def __init__(self, device: AsyncDeviceResource) -> None: self.retrieve = async_to_raw_response_wrapper( device.retrieve, ) - self.sync = async_to_raw_response_wrapper( - device.sync, - ) class DeviceResourceWithStreamingResponse: @@ -169,9 +124,6 @@ def __init__(self, device: DeviceResource) -> None: self.retrieve = to_streamed_response_wrapper( device.retrieve, ) - self.sync = to_streamed_response_wrapper( - device.sync, - ) class AsyncDeviceResourceWithStreamingResponse: @@ -181,6 +133,3 @@ def __init__(self, device: AsyncDeviceResource) -> None: self.retrieve = async_to_streamed_response_wrapper( device.retrieve, ) - self.sync = async_to_streamed_response_wrapper( - device.sync, - ) diff --git a/src/miru_device_sdk/types/__init__.py b/src/miru_device_sdk/types/__init__.py index 2d3aa0d..b3f0320 100644 --- a/src/miru_device_sdk/types/__init__.py +++ b/src/miru_device_sdk/types/__init__.py @@ -8,8 +8,8 @@ from .deployment import Deployment as Deployment from .git_commit import GitCommit as GitCommit from .calibration import Calibration as Calibration +from .agent_sync_response import AgentSyncResponse as AgentSyncResponse from .event_stream_params import EventStreamParams as EventStreamParams -from .device_sync_response import DeviceSyncResponse as DeviceSyncResponse from .agent_health_response import AgentHealthResponse as AgentHealthResponse from .agent_version_response import AgentVersionResponse as AgentVersionResponse from .device_retrieve_response import DeviceRetrieveResponse as DeviceRetrieveResponse @@ -17,3 +17,4 @@ from .calibration_latest_params import CalibrationLatestParams as CalibrationLatestParams from .calibration_create_response import CalibrationCreateResponse as CalibrationCreateResponse from .calibration_latest_response import CalibrationLatestResponse as CalibrationLatestResponse +from .calibration_invalidate_params import CalibrationInvalidateParams as CalibrationInvalidateParams diff --git a/src/miru_device_sdk/types/agent_sync_response.py b/src/miru_device_sdk/types/agent_sync_response.py new file mode 100644 index 0000000..6f4914a --- /dev/null +++ b/src/miru_device_sdk/types/agent_sync_response.py @@ -0,0 +1,37 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from .._models import BaseModel + +__all__ = ["AgentSyncResponse"] + + +class AgentSyncResponse(BaseModel): + code: Literal["success", "network_connection_error", "in_cooldown"] + """The result of attempting to sync the device.""" + + cooldown_ends_in_secs: int + """ + Seconds until the cooldown ends, rounded up, as measured by the agent when it + built this response. `0` exactly when `in_cooldown` is false. + """ + + in_cooldown: bool + """Whether the device is currently in cooldown.""" + + last_attempted_sync_secs_ago: int + """ + Seconds since the device last _attempted_ to sync, as measured by the agent when + it built this response. + """ + + last_synced_secs_ago: Optional[int] = None + """ + Seconds since the device last synced, as measured by the agent when it built + this response, or null if it hasn't synced since the agent last started. + """ + + message: str + """The message of the result.""" diff --git a/src/miru_device_sdk/types/calibration.py b/src/miru_device_sdk/types/calibration.py index 497b405..55a8295 100644 --- a/src/miru_device_sdk/types/calibration.py +++ b/src/miru_device_sdk/types/calibration.py @@ -10,17 +10,17 @@ class Calibration(BaseModel): - """The newest calibration the device has for one component, role and aspect.""" + """The newest calibration the device has for one component.""" - aspect: Optional[str] = None + component: str + """Slug of the component the calibrated unit belongs to.""" + + invalidated_at: Optional[datetime] = None """ - Slug of the aspect of the unit that was calibrated, as it was reported; null if - no aspect was reported. + Timestamp of when a device app marked this calibration invalid, or null if it is + valid. A newer calibration for the component replaces it. """ - component: str - """Slug of the component the calibrated unit belongs to, as it was reported.""" - object: Literal["calibration"] """The object type, which is always `calibration`.""" @@ -39,12 +39,6 @@ class Calibration(BaseModel): if no one was reported. """ - role: Optional[str] = None - """ - Slug of the role the calibrated unit fills on the device, as it was reported; - null if no role was reported. - """ - serial_number: Optional[str] = None """ Serial number of the physical unit that was calibrated, not of the device, such diff --git a/src/miru_device_sdk/types/calibration_create_params.py b/src/miru_device_sdk/types/calibration_create_params.py index 46881d9..c278cc5 100644 --- a/src/miru_device_sdk/types/calibration_create_params.py +++ b/src/miru_device_sdk/types/calibration_create_params.py @@ -21,14 +21,6 @@ class CalibrationCreateParams(TypedDict, total=False): The agent uploads it to Miru unchanged. """ - aspect: str - """ - Slug of the aspect of the unit that was calibrated, when it has more than one, - e.g. `intrinsics` vs `extrinsics`, or `pose` vs `joint-offsets`. Validated like - a slug; `null` is reserved. Miru resolves it to one of the component's - `aspects`, creating the aspect the first time it is reported. - """ - reported_by: str """Who reported the calibration, as the device knows them, such as `Benjamin Smidt`. @@ -36,14 +28,6 @@ class CalibrationCreateParams(TypedDict, total=False): Free text, at most 255 characters. Miru stores it unchanged. """ - role: str - """ - Slug of the role the calibrated unit fills on the device, such as `left` or - `front-left`. Distinguishes several units of one component on a device. - Validated like a slug; `null` is reserved. Miru resolves it to one of the - component's `roles`, creating the role the first time it is reported. - """ - serial_number: str """ Serial number of the physical unit that was calibrated, not of the device, such diff --git a/src/miru_device_sdk/types/calibration_invalidate_params.py b/src/miru_device_sdk/types/calibration_invalidate_params.py new file mode 100644 index 0000000..01066fb --- /dev/null +++ b/src/miru_device_sdk/types/calibration_invalidate_params.py @@ -0,0 +1,25 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["CalibrationInvalidateParams"] + + +class CalibrationInvalidateParams(TypedDict, total=False): + component: Required[str] + """Slug of the component whose latest calibration to invalidate, such as `arm`.""" + + reason: Required[str] + """Why the calibration is no longer valid, such as `power cycle`. + + Free text, at most 512 characters, and not blank. + """ + + report_id: str + """Report ID of the calibration the caller expects to be `component`'s latest. + + If it is not `component`'s current latest calibration, the agent invalidates + nothing. Leave it out to invalidate whatever is latest. + """ diff --git a/src/miru_device_sdk/types/calibration_latest_params.py b/src/miru_device_sdk/types/calibration_latest_params.py index 1cef23f..e8bd38b 100644 --- a/src/miru_device_sdk/types/calibration_latest_params.py +++ b/src/miru_device_sdk/types/calibration_latest_params.py @@ -10,20 +10,5 @@ class CalibrationLatestParams(TypedDict, total=False): - aspect: SequenceNotStr[str] - """ - The aspect slugs to filter by; `null` matches calibrations reported without an - aspect. Aspect slugs are unique only within a component, so filter by component - too to match one component's aspect. - """ - component: SequenceNotStr[str] """The component slugs to filter by.""" - - role: SequenceNotStr[str] - """The role slugs to filter by; `null` matches calibrations reported without a - role. - - Role slugs are unique only within a component, so filter by component too to - match one component's role. - """ diff --git a/src/miru_device_sdk/types/calibration_latest_response.py b/src/miru_device_sdk/types/calibration_latest_response.py index 3543218..4e6979a 100644 --- a/src/miru_device_sdk/types/calibration_latest_response.py +++ b/src/miru_device_sdk/types/calibration_latest_response.py @@ -10,4 +10,4 @@ class CalibrationLatestResponse(BaseModel): calibrations: List[Calibration] - """The latest calibrations, one for each component, role and aspect.""" + """The latest calibrations, one for each component.""" diff --git a/src/miru_device_sdk/types/device_retrieve_response.py b/src/miru_device_sdk/types/device_retrieve_response.py index ac28565..2ddc3b0 100644 --- a/src/miru_device_sdk/types/device_retrieve_response.py +++ b/src/miru_device_sdk/types/device_retrieve_response.py @@ -1,6 +1,6 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from datetime import datetime +from typing import Optional from typing_extensions import Literal from .._models import BaseModel @@ -12,14 +12,25 @@ class DeviceRetrieveResponse(BaseModel): id: str """ID of the device.""" - last_connected_at: datetime - """Timestamp of the last successful connection event with the backend.""" + last_connected_secs_ago: Optional[int] = None + """ + Seconds since the device last connected to the backend, as measured by the agent + when it built this response, or null if it hasn't connected since the agent last + started. + """ - last_disconnected_at: datetime - """Timestamp of the last successful disconnection event with the backend.""" + last_disconnected_secs_ago: Optional[int] = None + """ + Seconds since the device last disconnected from the backend, as measured by the + agent when it built this response, or null if it hasn't disconnected since the + agent last started. + """ - last_synced_at: datetime - """Timestamp of when the device was last synced.""" + last_synced_secs_ago: Optional[int] = None + """ + Seconds since the device last synced, as measured by the agent when it built + this response, or null if it hasn't synced since the agent last started. + """ name: str """Name of the device.""" diff --git a/src/miru_device_sdk/types/device_sync_response.py b/src/miru_device_sdk/types/device_sync_response.py deleted file mode 100644 index 5924c03..0000000 --- a/src/miru_device_sdk/types/device_sync_response.py +++ /dev/null @@ -1,28 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from datetime import datetime -from typing_extensions import Literal - -from .._models import BaseModel - -__all__ = ["DeviceSyncResponse"] - - -class DeviceSyncResponse(BaseModel): - code: Literal["success", "network_connection_error", "in_cooldown"] - """The result of attempting to sync the device.""" - - cooldown_ends_at: datetime - """Timestamp of when the cooldown will end.""" - - in_cooldown: bool - """Whether the device is currently in cooldown.""" - - last_attempted_sync_at: datetime - """Timestamp of when the last _attempted_ sync occurred.""" - - last_synced_at: datetime - """Timestamp of when the device was last synced.""" - - message: str - """The message of the result.""" diff --git a/tests/api_resources/test_agent.py b/tests/api_resources/test_agent.py index 54beff6..07f1b3d 100644 --- a/tests/api_resources/test_agent.py +++ b/tests/api_resources/test_agent.py @@ -9,7 +9,7 @@ from tests.utils import assert_matches_type from miru_device_sdk import Miru, AsyncMiru -from miru_device_sdk.types import AgentHealthResponse, AgentVersionResponse +from miru_device_sdk.types import AgentSyncResponse, AgentHealthResponse, AgentVersionResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -45,6 +45,34 @@ def test_streaming_response_health(self, client: Miru) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_sync(self, client: Miru) -> None: + agent = client.agent.sync() + assert_matches_type(AgentSyncResponse, agent, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_sync(self, client: Miru) -> None: + response = client.agent.with_raw_response.sync() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + agent = response.parse() + assert_matches_type(AgentSyncResponse, agent, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_sync(self, client: Miru) -> None: + with client.agent.with_streaming_response.sync() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + agent = response.parse() + assert_matches_type(AgentSyncResponse, agent, path=["response"]) + + assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_method_version(self, client: Miru) -> None: @@ -107,6 +135,34 @@ async def test_streaming_response_health(self, async_client: AsyncMiru) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_sync(self, async_client: AsyncMiru) -> None: + agent = await async_client.agent.sync() + assert_matches_type(AgentSyncResponse, agent, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_sync(self, async_client: AsyncMiru) -> None: + response = await async_client.agent.with_raw_response.sync() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + agent = await response.parse() + assert_matches_type(AgentSyncResponse, agent, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_sync(self, async_client: AsyncMiru) -> None: + async with async_client.agent.with_streaming_response.sync() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + agent = await response.parse() + assert_matches_type(AgentSyncResponse, agent, path=["response"]) + + assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_method_version(self, async_client: AsyncMiru) -> None: diff --git a/tests/api_resources/test_calibrations.py b/tests/api_resources/test_calibrations.py index 182dd6d..a5d316e 100644 --- a/tests/api_resources/test_calibrations.py +++ b/tests/api_resources/test_calibrations.py @@ -12,6 +12,7 @@ from tests.utils import assert_matches_type from miru_device_sdk import Miru, AsyncMiru from miru_device_sdk.types import ( + Calibration, CalibrationCreateResponse, CalibrationLatestResponse, ) @@ -49,9 +50,7 @@ def test_method_create_with_all_params(self, client: Miru) -> None: "data": '{\n "enable_autonomy": true,\n "enable_remote_control": true,\n "max_payload_kg": 10.0\n}\n', "format": "json", }, - aspect="pose", reported_by="Benjamin Smidt", - role="front-left", serial_number="SN-1234", ) assert_matches_type(CalibrationCreateResponse, calibration, path=["response"]) @@ -146,6 +145,53 @@ def test_path_params_download(self, client: Miru) -> None: "", ) + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_invalidate(self, client: Miru) -> None: + calibration = client.calibrations.invalidate( + component="arm", + reason="power cycle", + ) + assert_matches_type(Calibration, calibration, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_invalidate_with_all_params(self, client: Miru) -> None: + calibration = client.calibrations.invalidate( + component="arm", + reason="power cycle", + report_id="0b6f3c2e-6a51-4e0f-9a43-2f1d7c9e8b10", + ) + assert_matches_type(Calibration, calibration, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_invalidate(self, client: Miru) -> None: + response = client.calibrations.with_raw_response.invalidate( + component="arm", + reason="power cycle", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + calibration = response.parse() + assert_matches_type(Calibration, calibration, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_invalidate(self, client: Miru) -> None: + with client.calibrations.with_streaming_response.invalidate( + component="arm", + reason="power cycle", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + calibration = response.parse() + assert_matches_type(Calibration, calibration, path=["response"]) + + assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_method_latest(self, client: Miru) -> None: @@ -156,9 +202,7 @@ def test_method_latest(self, client: Miru) -> None: @parametrize def test_method_latest_with_all_params(self, client: Miru) -> None: calibration = client.calibrations.latest( - aspect=["pose"], component=["arm"], - role=["front-left"], ) assert_matches_type(CalibrationLatestResponse, calibration, path=["response"]) @@ -211,9 +255,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncMiru) -> N "data": '{\n "enable_autonomy": true,\n "enable_remote_control": true,\n "max_payload_kg": 10.0\n}\n', "format": "json", }, - aspect="pose", reported_by="Benjamin Smidt", - role="front-left", serial_number="SN-1234", ) assert_matches_type(CalibrationCreateResponse, calibration, path=["response"]) @@ -308,6 +350,53 @@ async def test_path_params_download(self, async_client: AsyncMiru) -> None: "", ) + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_invalidate(self, async_client: AsyncMiru) -> None: + calibration = await async_client.calibrations.invalidate( + component="arm", + reason="power cycle", + ) + assert_matches_type(Calibration, calibration, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_invalidate_with_all_params(self, async_client: AsyncMiru) -> None: + calibration = await async_client.calibrations.invalidate( + component="arm", + reason="power cycle", + report_id="0b6f3c2e-6a51-4e0f-9a43-2f1d7c9e8b10", + ) + assert_matches_type(Calibration, calibration, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_invalidate(self, async_client: AsyncMiru) -> None: + response = await async_client.calibrations.with_raw_response.invalidate( + component="arm", + reason="power cycle", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + calibration = await response.parse() + assert_matches_type(Calibration, calibration, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_invalidate(self, async_client: AsyncMiru) -> None: + async with async_client.calibrations.with_streaming_response.invalidate( + component="arm", + reason="power cycle", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + calibration = await response.parse() + assert_matches_type(Calibration, calibration, path=["response"]) + + assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_method_latest(self, async_client: AsyncMiru) -> None: @@ -318,9 +407,7 @@ async def test_method_latest(self, async_client: AsyncMiru) -> None: @parametrize async def test_method_latest_with_all_params(self, async_client: AsyncMiru) -> None: calibration = await async_client.calibrations.latest( - aspect=["pose"], component=["arm"], - role=["front-left"], ) assert_matches_type(CalibrationLatestResponse, calibration, path=["response"]) diff --git a/tests/api_resources/test_device.py b/tests/api_resources/test_device.py index 59bcb77..63d3780 100644 --- a/tests/api_resources/test_device.py +++ b/tests/api_resources/test_device.py @@ -9,7 +9,7 @@ from tests.utils import assert_matches_type from miru_device_sdk import Miru, AsyncMiru -from miru_device_sdk.types import DeviceSyncResponse, DeviceRetrieveResponse +from miru_device_sdk.types import DeviceRetrieveResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -45,34 +45,6 @@ def test_streaming_response_retrieve(self, client: Miru) -> None: assert cast(Any, response.is_closed) is True - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_sync(self, client: Miru) -> None: - device = client.device.sync() - assert_matches_type(DeviceSyncResponse, device, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_sync(self, client: Miru) -> None: - response = client.device.with_raw_response.sync() - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - device = response.parse() - assert_matches_type(DeviceSyncResponse, device, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_sync(self, client: Miru) -> None: - with client.device.with_streaming_response.sync() as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - device = response.parse() - assert_matches_type(DeviceSyncResponse, device, path=["response"]) - - assert cast(Any, response.is_closed) is True - class TestAsyncDevice: parametrize = pytest.mark.parametrize( @@ -106,31 +78,3 @@ async def test_streaming_response_retrieve(self, async_client: AsyncMiru) -> Non assert_matches_type(DeviceRetrieveResponse, device, path=["response"]) assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_sync(self, async_client: AsyncMiru) -> None: - device = await async_client.device.sync() - assert_matches_type(DeviceSyncResponse, device, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_sync(self, async_client: AsyncMiru) -> None: - response = await async_client.device.with_raw_response.sync() - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - device = await response.parse() - assert_matches_type(DeviceSyncResponse, device, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_sync(self, async_client: AsyncMiru) -> None: - async with async_client.device.with_streaming_response.sync() as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - device = await response.parse() - assert_matches_type(DeviceSyncResponse, device, path=["response"]) - - assert cast(Any, response.is_closed) is True diff --git a/tests/test_client.py b/tests/test_client.py index c2042ae..ec609d4 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -723,7 +723,7 @@ def test_socket_path_not_applied_when_client_supplied(self) -> None: custom_transport = httpx.HTTPTransport() custom_http_client = httpx.Client( transport=custom_transport, - base_url="http://localhost/v0.2", + base_url="http://localhost/v0.3", follow_redirects=True, limits=httpx.Limits(max_connections=100, max_keepalive_connections=20), ) @@ -1661,7 +1661,7 @@ async def test_socket_path_not_applied_when_client_supplied(self) -> None: custom_transport = httpx.AsyncHTTPTransport() custom_http_client = httpx.AsyncClient( transport=custom_transport, - base_url="http://localhost/v0.2", + base_url="http://localhost/v0.3", follow_redirects=True, limits=httpx.Limits(max_connections=100, max_keepalive_connections=20), ) diff --git a/tests/test_device_api.py b/tests/test_device_api.py index 10e335e..e0954a9 100644 --- a/tests/test_device_api.py +++ b/tests/test_device_api.py @@ -194,7 +194,7 @@ def test_sends_to_discovered_port_with_token(self, tmp_path: Path) -> None: with agent.client() as client: assert client.agent.health().status == "ok" request = agent.requests[0] - assert str(request.url) == "http://127.0.0.1:43210/v0.2/health" + assert str(request.url) == "http://127.0.0.1:43210/v0.3/health" assert request.headers["Host"] == "127.0.0.1:43210" assert request.headers["Authorization"] == "Bearer tok" @@ -286,11 +286,11 @@ def handler(request: httpx.Request) -> httpx.Response: agent_transport="tcp", discovery_file=str(tmp_path / "absent.json"), bearer_token="explicit", - base_url="http://127.0.0.1:43210/v0.2", + base_url="http://127.0.0.1:43210/v0.3", http_client=httpx.Client(transport=httpx.MockTransport(handler)), ) as client: client.agent.health() - assert str(requests[0].url) == "http://127.0.0.1:43210/v0.2/health" + assert str(requests[0].url) == "http://127.0.0.1:43210/v0.3/health" assert requests[0].headers["Authorization"] == "Bearer explicit" def test_unix_socket_sends_no_token(self) -> None: