diff --git a/.stats.yml b/.stats.yml
index 6ecfe8d..dd47305 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1 +1 @@
-configured_endpoints: 12
+configured_endpoints: 14
diff --git a/api.md b/api.md
index 5fc74d9..cc1fd0b 100644
--- a/api.md
+++ b/api.md
@@ -16,12 +16,14 @@ Methods:
Types:
```python
-from miru_device_sdk.types import CalibrationCreateResponse
+from miru_device_sdk.types import Calibration, CalibrationCreateResponse, CalibrationLatestResponse
```
Methods:
- client.calibrations.create(\*\*params) -> CalibrationCreateResponse
+- client.calibrations.download(report_id) -> BinaryAPIResponse
+- client.calibrations.latest(\*\*params) -> CalibrationLatestResponse
# Deployments
diff --git a/src/miru_device_sdk/resources/calibrations.py b/src/miru_device_sdk/resources/calibrations.py
index ba18216..d910fe2 100644
--- a/src/miru_device_sdk/resources/calibrations.py
+++ b/src/miru_device_sdk/resources/calibrations.py
@@ -4,19 +4,28 @@
import httpx
-from ..types import calibration_create_params
-from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
-from .._utils import maybe_transform, async_maybe_transform
+from ..types import calibration_create_params, calibration_latest_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
from .._resource import SyncAPIResource, AsyncAPIResource
from .._response import (
+ BinaryAPIResponse,
+ AsyncBinaryAPIResponse,
+ StreamedBinaryAPIResponse,
+ AsyncStreamedBinaryAPIResponse,
to_raw_response_wrapper,
to_streamed_response_wrapper,
async_to_raw_response_wrapper,
+ to_custom_raw_response_wrapper,
async_to_streamed_response_wrapper,
+ to_custom_streamed_response_wrapper,
+ async_to_custom_raw_response_wrapper,
+ async_to_custom_streamed_response_wrapper,
)
from .._base_client import make_request_options
from ..types.calibration_create_response import CalibrationCreateResponse
+from ..types.calibration_latest_response import CalibrationLatestResponse
__all__ = ["CalibrationsResource", "AsyncCalibrationsResource"]
@@ -70,16 +79,16 @@ def create(
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. Miru resolves it to one of the component's `aspects`, creating the
- aspect the first time it is reported.
+ 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. Miru resolves it to one of the component's `roles`,
- creating the role the first time it is reported.
+ 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.
@@ -111,6 +120,96 @@ def create(
cast_to=CalibrationCreateResponse,
)
+ def download(
+ self,
+ report_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,
+ ) -> BinaryAPIResponse:
+ """Download the content of a latest calibration by its report ID.
+
+ An older report
+ returns 404.
+
+ 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 report_id:
+ raise ValueError(f"Expected a non-empty value for `report_id` but received {report_id!r}")
+ extra_headers = {"Accept": "application/octet-stream", **(extra_headers or {})}
+ return self._get(
+ path_template("/calibrations/latest/{report_id}/content", report_id=report_id),
+ options=make_request_options(
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ ),
+ cast_to=BinaryAPIResponse,
+ )
+
+ 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,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
+ ) -> CalibrationLatestResponse:
+ """
+ List the latest calibration for each component, role and aspect 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
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ return self._get(
+ "/calibrations/latest",
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ query=maybe_transform(
+ {
+ "aspect": aspect,
+ "component": component,
+ "role": role,
+ },
+ calibration_latest_params.CalibrationLatestParams,
+ ),
+ ),
+ cast_to=CalibrationLatestResponse,
+ )
+
class AsyncCalibrationsResource(AsyncAPIResource):
@cached_property
@@ -161,16 +260,16 @@ async def create(
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. Miru resolves it to one of the component's `aspects`, creating the
- aspect the first time it is reported.
+ 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. Miru resolves it to one of the component's `roles`,
- creating the role the first time it is reported.
+ 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.
@@ -202,6 +301,96 @@ async def create(
cast_to=CalibrationCreateResponse,
)
+ async def download(
+ self,
+ report_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,
+ ) -> AsyncBinaryAPIResponse:
+ """Download the content of a latest calibration by its report ID.
+
+ An older report
+ returns 404.
+
+ 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 report_id:
+ raise ValueError(f"Expected a non-empty value for `report_id` but received {report_id!r}")
+ extra_headers = {"Accept": "application/octet-stream", **(extra_headers or {})}
+ return await self._get(
+ path_template("/calibrations/latest/{report_id}/content", report_id=report_id),
+ options=make_request_options(
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ ),
+ cast_to=AsyncBinaryAPIResponse,
+ )
+
+ 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,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
+ ) -> CalibrationLatestResponse:
+ """
+ List the latest calibration for each component, role and aspect 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
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ return await self._get(
+ "/calibrations/latest",
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ query=await async_maybe_transform(
+ {
+ "aspect": aspect,
+ "component": component,
+ "role": role,
+ },
+ calibration_latest_params.CalibrationLatestParams,
+ ),
+ ),
+ cast_to=CalibrationLatestResponse,
+ )
+
class CalibrationsResourceWithRawResponse:
def __init__(self, calibrations: CalibrationsResource) -> None:
@@ -210,6 +399,13 @@ def __init__(self, calibrations: CalibrationsResource) -> None:
self.create = to_raw_response_wrapper(
calibrations.create,
)
+ self.download = to_custom_raw_response_wrapper(
+ calibrations.download,
+ BinaryAPIResponse,
+ )
+ self.latest = to_raw_response_wrapper(
+ calibrations.latest,
+ )
class AsyncCalibrationsResourceWithRawResponse:
@@ -219,6 +415,13 @@ def __init__(self, calibrations: AsyncCalibrationsResource) -> None:
self.create = async_to_raw_response_wrapper(
calibrations.create,
)
+ self.download = async_to_custom_raw_response_wrapper(
+ calibrations.download,
+ AsyncBinaryAPIResponse,
+ )
+ self.latest = async_to_raw_response_wrapper(
+ calibrations.latest,
+ )
class CalibrationsResourceWithStreamingResponse:
@@ -228,6 +431,13 @@ def __init__(self, calibrations: CalibrationsResource) -> None:
self.create = to_streamed_response_wrapper(
calibrations.create,
)
+ self.download = to_custom_streamed_response_wrapper(
+ calibrations.download,
+ StreamedBinaryAPIResponse,
+ )
+ self.latest = to_streamed_response_wrapper(
+ calibrations.latest,
+ )
class AsyncCalibrationsResourceWithStreamingResponse:
@@ -237,3 +447,10 @@ def __init__(self, calibrations: AsyncCalibrationsResource) -> None:
self.create = async_to_streamed_response_wrapper(
calibrations.create,
)
+ self.download = async_to_custom_streamed_response_wrapper(
+ calibrations.download,
+ AsyncStreamedBinaryAPIResponse,
+ )
+ self.latest = async_to_streamed_response_wrapper(
+ calibrations.latest,
+ )
diff --git a/src/miru_device_sdk/resources/events.py b/src/miru_device_sdk/resources/events.py
index 5e542f0..58eeea9 100644
--- a/src/miru_device_sdk/resources/events.py
+++ b/src/miru_device_sdk/resources/events.py
@@ -58,17 +58,11 @@ def stream(
"""
Subscribe to a Server-Sent Events (SSE) stream of agent lifecycle events.
- The stream replays retained historical events after the cursor, then delivers
- live events as they occur. Events are delivered at-least-once; clients should
- deduplicate by event `id`.
-
- Use the `after` query parameter or `Last-Event-ID` header to resume from a
- previous position. If the cursor is older than the earliest retained event, the
- server returns `410 Gone`.
-
Args:
- after: Event ID cursor. Only events with `id` greater than this value are returned.
- Takes precedence over the `Last-Event-ID` header.
+ after: Event ID cursor to resume from. Retained events with `id` greater than this
+ value are replayed, then live events follow. If the cursor is older than the
+ earliest retained event, the server returns `410 Gone`. Takes precedence over
+ the `Last-Event-ID` header.
types: Event types to receive. If omitted, all event types are sent.
@@ -139,17 +133,11 @@ async def stream(
"""
Subscribe to a Server-Sent Events (SSE) stream of agent lifecycle events.
- The stream replays retained historical events after the cursor, then delivers
- live events as they occur. Events are delivered at-least-once; clients should
- deduplicate by event `id`.
-
- Use the `after` query parameter or `Last-Event-ID` header to resume from a
- previous position. If the cursor is older than the earliest retained event, the
- server returns `410 Gone`.
-
Args:
- after: Event ID cursor. Only events with `id` greater than this value are returned.
- Takes precedence over the `Last-Event-ID` header.
+ after: Event ID cursor to resume from. Retained events with `id` greater than this
+ value are replayed, then live events follow. If the cursor is older than the
+ earliest retained event, the server returns `410 Gone`. Takes precedence over
+ the `Last-Event-ID` header.
types: Event types to receive. If omitted, all event types are sent.
diff --git a/src/miru_device_sdk/types/__init__.py b/src/miru_device_sdk/types/__init__.py
index a9b8a4e..2d3aa0d 100644
--- a/src/miru_device_sdk/types/__init__.py
+++ b/src/miru_device_sdk/types/__init__.py
@@ -7,10 +7,13 @@
from .file_rule import FileRule as FileRule
from .deployment import Deployment as Deployment
from .git_commit import GitCommit as GitCommit
+from .calibration import Calibration as Calibration
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
from .calibration_create_params import CalibrationCreateParams as CalibrationCreateParams
+from .calibration_latest_params import CalibrationLatestParams as CalibrationLatestParams
from .calibration_create_response import CalibrationCreateResponse as CalibrationCreateResponse
+from .calibration_latest_response import CalibrationLatestResponse as CalibrationLatestResponse
diff --git a/src/miru_device_sdk/types/calibration.py b/src/miru_device_sdk/types/calibration.py
new file mode 100644
index 0000000..497b405
--- /dev/null
+++ b/src/miru_device_sdk/types/calibration.py
@@ -0,0 +1,52 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from typing import Optional
+from datetime import datetime
+from typing_extensions import Literal
+
+from .._models import BaseModel
+
+__all__ = ["Calibration"]
+
+
+class Calibration(BaseModel):
+ """The newest calibration the device has for one component, role and aspect."""
+
+ aspect: Optional[str] = None
+ """
+ Slug of the aspect of the unit that was calibrated, as it was reported; null if
+ no aspect was reported.
+ """
+
+ 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`."""
+
+ report_id: str
+ """ID the agent gave the report this calibration came from.
+
+ Download the content with it.
+ """
+
+ reported_at: datetime
+ """Timestamp of when the agent received the calibration."""
+
+ reported_by: Optional[str] = None
+ """
+ Who reported the calibration, as it was reported, such as `Benjamin Smidt`; null
+ 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
+ as `SN-1234`, or null if none was reported. Free text, at most 255 characters.
+ """
diff --git a/src/miru_device_sdk/types/calibration_create_params.py b/src/miru_device_sdk/types/calibration_create_params.py
index b0b3804..46881d9 100644
--- a/src/miru_device_sdk/types/calibration_create_params.py
+++ b/src/miru_device_sdk/types/calibration_create_params.py
@@ -25,8 +25,8 @@ class CalibrationCreateParams(TypedDict, total=False):
"""
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. Miru resolves it to one of the component's `aspects`, creating the
- aspect the first time it is reported.
+ 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
@@ -40,8 +40,8 @@ class CalibrationCreateParams(TypedDict, total=False):
"""
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. Miru resolves it to one of the component's `roles`,
- creating the role the first time it is reported.
+ 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
@@ -61,9 +61,10 @@ class Content(TypedDict, total=False):
"""The content's values, serialized in `format`."""
format: Required[Literal["json", "yaml", "jsonc", "xml", "csv", "text"]]
- """The serialization format of config content.
-
- A config instance is written to the device filesystem in this format.
+ """
+ The serialization format of stored content, such as a config instance or a
+ calibration. A config instance is written to the device filesystem in this
+ format.
- `json`: standard JSON.
- `yaml`: YAML 1.2.
diff --git a/src/miru_device_sdk/types/calibration_latest_params.py b/src/miru_device_sdk/types/calibration_latest_params.py
new file mode 100644
index 0000000..1cef23f
--- /dev/null
+++ b/src/miru_device_sdk/types/calibration_latest_params.py
@@ -0,0 +1,29 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing_extensions import TypedDict
+
+from .._types import SequenceNotStr
+
+__all__ = ["CalibrationLatestParams"]
+
+
+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
new file mode 100644
index 0000000..3543218
--- /dev/null
+++ b/src/miru_device_sdk/types/calibration_latest_response.py
@@ -0,0 +1,13 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from typing import List
+
+from .._models import BaseModel
+from .calibration import Calibration
+
+__all__ = ["CalibrationLatestResponse"]
+
+
+class CalibrationLatestResponse(BaseModel):
+ calibrations: List[Calibration]
+ """The latest calibrations, one for each component, role and aspect."""
diff --git a/src/miru_device_sdk/types/event_stream_params.py b/src/miru_device_sdk/types/event_stream_params.py
index 6f628bb..96be10c 100644
--- a/src/miru_device_sdk/types/event_stream_params.py
+++ b/src/miru_device_sdk/types/event_stream_params.py
@@ -12,10 +12,11 @@
class EventStreamParams(TypedDict, total=False):
after: int
- """Event ID cursor.
+ """Event ID cursor to resume from.
- Only events with `id` greater than this value are returned. Takes precedence
- over the `Last-Event-ID` header.
+ Retained events with `id` greater than this value are replayed, then live events
+ follow. If the cursor is older than the earliest retained event, the server
+ returns `410 Gone`. Takes precedence over the `Last-Event-ID` header.
"""
types: SequenceNotStr[str]
diff --git a/src/miru_device_sdk/types/file_rule.py b/src/miru_device_sdk/types/file_rule.py
index 5c2c7f0..2eb6aae 100644
--- a/src/miru_device_sdk/types/file_rule.py
+++ b/src/miru_device_sdk/types/file_rule.py
@@ -82,14 +82,16 @@ class Upload(BaseModel):
path: str
"""Object-path template for the uploaded file.
- Contains `{upload_id}`, is at most 1024 bytes, has balanced braces, and contains
- no `..` or empty segments. Variables: `{device_id}`, `{device_name}`,
- `{file_name}`, `{upload_id}`, `{bundle_id}`, `{year}`, `{month}`, `{day}`,
- `{hour}`, `{minute}`, `{timezone}`, plus any `source.glob` capture.
- `{bundle_id}` requires `bundle`. The time variables are zero-padded and rendered
- from the file's mtime (its last-modified time, from the device clock) in
- `timezone`; `{timezone}` is that instant's UTC offset in ISO 8601 basic format
- (`+0000`, `-0500`).
+ Contains `{upload_id}` or at least one of `{device_id}`, `{device_name}` or
+ `{bundle_id}`; without `{upload_id}`, a file whose rendered path another upload
+ already holds is not uploaded. It is at most 1024 bytes, has balanced braces,
+ and contains no `..` or empty segments. Variables: `{device_id}`,
+ `{device_name}`, `{file_name}`, `{upload_id}`, `{bundle_id}`, `{year}`,
+ `{month}`, `{day}`, `{hour}`, `{minute}`, `{timezone}`, plus any `source.glob`
+ capture. `{bundle_id}` requires `bundle`. The time variables are zero-padded and
+ rendered from the file's mtime (its last-modified time, from the device clock)
+ in `timezone`; `{timezone}` is that instant's UTC offset in ISO 8601 basic
+ format (`+0000`, `-0500`).
"""
timezone: Literal["utc", "device"]
@@ -125,15 +127,7 @@ class Upload(BaseModel):
class FileRule(BaseModel):
"""
- A file rule declares which files on a device Miru manages and what to do
- with them: upload them to a bucket, delete the local copies once they
- are no longer needed, or both. `retention` is optional and marks the
- rules that delete: when it is absent the device keeps matching files
- indefinitely — Miru never deletes them — and when it is present the rule
- deletes each matching file once its retention guarantee ends. A rule
- that both deletes and uploads always states `retention.require_upload`,
- so whether local deletion waits for the upload is itself an explicit
- decision.
+ A file rule declares which files on a device Miru manages and whether to upload them, delete them, or both.
"""
id: str
diff --git a/tests/api_resources/test_calibrations.py b/tests/api_resources/test_calibrations.py
index ed55579..182dd6d 100644
--- a/tests/api_resources/test_calibrations.py
+++ b/tests/api_resources/test_calibrations.py
@@ -5,11 +5,22 @@
import os
from typing import Any, cast
+import httpx
import pytest
+from respx import MockRouter
from tests.utils import assert_matches_type
from miru_device_sdk import Miru, AsyncMiru
-from miru_device_sdk.types import CalibrationCreateResponse
+from miru_device_sdk.types import (
+ CalibrationCreateResponse,
+ CalibrationLatestResponse,
+)
+from miru_device_sdk._response import (
+ BinaryAPIResponse,
+ AsyncBinaryAPIResponse,
+ StreamedBinaryAPIResponse,
+ AsyncStreamedBinaryAPIResponse,
+)
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
@@ -79,6 +90,100 @@ def test_streaming_response_create(self, client: Miru) -> None:
assert cast(Any, response.is_closed) is True
+ @parametrize
+ @pytest.mark.respx(base_url=base_url)
+ def test_method_download(self, client: Miru, respx_mock: MockRouter) -> None:
+ respx_mock.get("/calibrations/latest/0b6f3c2e-6a51-4e0f-9a43-2f1d7c9e8b10/content").mock(
+ return_value=httpx.Response(200, json={"foo": "bar"})
+ )
+ calibration = client.calibrations.download(
+ "0b6f3c2e-6a51-4e0f-9a43-2f1d7c9e8b10",
+ )
+ assert calibration.is_closed
+ assert calibration.json() == {"foo": "bar"}
+ assert cast(Any, calibration.is_closed) is True
+ assert isinstance(calibration, BinaryAPIResponse)
+
+ @parametrize
+ @pytest.mark.respx(base_url=base_url)
+ def test_raw_response_download(self, client: Miru, respx_mock: MockRouter) -> None:
+ respx_mock.get("/calibrations/latest/0b6f3c2e-6a51-4e0f-9a43-2f1d7c9e8b10/content").mock(
+ return_value=httpx.Response(200, json={"foo": "bar"})
+ )
+
+ calibration = client.calibrations.with_raw_response.download(
+ "0b6f3c2e-6a51-4e0f-9a43-2f1d7c9e8b10",
+ )
+
+ assert calibration.is_closed is True
+ assert calibration.http_request.headers.get("X-Stainless-Lang") == "python"
+ assert calibration.json() == {"foo": "bar"}
+ assert isinstance(calibration, BinaryAPIResponse)
+
+ @parametrize
+ @pytest.mark.respx(base_url=base_url)
+ def test_streaming_response_download(self, client: Miru, respx_mock: MockRouter) -> None:
+ respx_mock.get("/calibrations/latest/0b6f3c2e-6a51-4e0f-9a43-2f1d7c9e8b10/content").mock(
+ return_value=httpx.Response(200, json={"foo": "bar"})
+ )
+ with client.calibrations.with_streaming_response.download(
+ "0b6f3c2e-6a51-4e0f-9a43-2f1d7c9e8b10",
+ ) as calibration:
+ assert not calibration.is_closed
+ assert calibration.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ assert calibration.json() == {"foo": "bar"}
+ assert cast(Any, calibration.is_closed) is True
+ assert isinstance(calibration, StreamedBinaryAPIResponse)
+
+ assert cast(Any, calibration.is_closed) is True
+
+ @parametrize
+ @pytest.mark.respx(base_url=base_url)
+ def test_path_params_download(self, client: Miru) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `report_id` but received ''"):
+ client.calibrations.with_raw_response.download(
+ "",
+ )
+
+ @pytest.mark.skip(reason="Mock server tests are disabled")
+ @parametrize
+ def test_method_latest(self, client: Miru) -> None:
+ calibration = client.calibrations.latest()
+ assert_matches_type(CalibrationLatestResponse, calibration, path=["response"])
+
+ @pytest.mark.skip(reason="Mock server tests are disabled")
+ @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"])
+
+ @pytest.mark.skip(reason="Mock server tests are disabled")
+ @parametrize
+ def test_raw_response_latest(self, client: Miru) -> None:
+ response = client.calibrations.with_raw_response.latest()
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ calibration = response.parse()
+ assert_matches_type(CalibrationLatestResponse, calibration, path=["response"])
+
+ @pytest.mark.skip(reason="Mock server tests are disabled")
+ @parametrize
+ def test_streaming_response_latest(self, client: Miru) -> None:
+ with client.calibrations.with_streaming_response.latest() as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ calibration = response.parse()
+ assert_matches_type(CalibrationLatestResponse, calibration, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
class TestAsyncCalibrations:
parametrize = pytest.mark.parametrize(
@@ -146,3 +251,97 @@ async def test_streaming_response_create(self, async_client: AsyncMiru) -> None:
assert_matches_type(CalibrationCreateResponse, calibration, path=["response"])
assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ @pytest.mark.respx(base_url=base_url)
+ async def test_method_download(self, async_client: AsyncMiru, respx_mock: MockRouter) -> None:
+ respx_mock.get("/calibrations/latest/0b6f3c2e-6a51-4e0f-9a43-2f1d7c9e8b10/content").mock(
+ return_value=httpx.Response(200, json={"foo": "bar"})
+ )
+ calibration = await async_client.calibrations.download(
+ "0b6f3c2e-6a51-4e0f-9a43-2f1d7c9e8b10",
+ )
+ assert calibration.is_closed
+ assert await calibration.json() == {"foo": "bar"}
+ assert cast(Any, calibration.is_closed) is True
+ assert isinstance(calibration, AsyncBinaryAPIResponse)
+
+ @parametrize
+ @pytest.mark.respx(base_url=base_url)
+ async def test_raw_response_download(self, async_client: AsyncMiru, respx_mock: MockRouter) -> None:
+ respx_mock.get("/calibrations/latest/0b6f3c2e-6a51-4e0f-9a43-2f1d7c9e8b10/content").mock(
+ return_value=httpx.Response(200, json={"foo": "bar"})
+ )
+
+ calibration = await async_client.calibrations.with_raw_response.download(
+ "0b6f3c2e-6a51-4e0f-9a43-2f1d7c9e8b10",
+ )
+
+ assert calibration.is_closed is True
+ assert calibration.http_request.headers.get("X-Stainless-Lang") == "python"
+ assert await calibration.json() == {"foo": "bar"}
+ assert isinstance(calibration, AsyncBinaryAPIResponse)
+
+ @parametrize
+ @pytest.mark.respx(base_url=base_url)
+ async def test_streaming_response_download(self, async_client: AsyncMiru, respx_mock: MockRouter) -> None:
+ respx_mock.get("/calibrations/latest/0b6f3c2e-6a51-4e0f-9a43-2f1d7c9e8b10/content").mock(
+ return_value=httpx.Response(200, json={"foo": "bar"})
+ )
+ async with async_client.calibrations.with_streaming_response.download(
+ "0b6f3c2e-6a51-4e0f-9a43-2f1d7c9e8b10",
+ ) as calibration:
+ assert not calibration.is_closed
+ assert calibration.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ assert await calibration.json() == {"foo": "bar"}
+ assert cast(Any, calibration.is_closed) is True
+ assert isinstance(calibration, AsyncStreamedBinaryAPIResponse)
+
+ assert cast(Any, calibration.is_closed) is True
+
+ @parametrize
+ @pytest.mark.respx(base_url=base_url)
+ async def test_path_params_download(self, async_client: AsyncMiru) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `report_id` but received ''"):
+ await async_client.calibrations.with_raw_response.download(
+ "",
+ )
+
+ @pytest.mark.skip(reason="Mock server tests are disabled")
+ @parametrize
+ async def test_method_latest(self, async_client: AsyncMiru) -> None:
+ calibration = await async_client.calibrations.latest()
+ assert_matches_type(CalibrationLatestResponse, calibration, path=["response"])
+
+ @pytest.mark.skip(reason="Mock server tests are disabled")
+ @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"])
+
+ @pytest.mark.skip(reason="Mock server tests are disabled")
+ @parametrize
+ async def test_raw_response_latest(self, async_client: AsyncMiru) -> None:
+ response = await async_client.calibrations.with_raw_response.latest()
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ calibration = await response.parse()
+ assert_matches_type(CalibrationLatestResponse, calibration, path=["response"])
+
+ @pytest.mark.skip(reason="Mock server tests are disabled")
+ @parametrize
+ async def test_streaming_response_latest(self, async_client: AsyncMiru) -> None:
+ async with async_client.calibrations.with_streaming_response.latest() as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ calibration = await response.parse()
+ assert_matches_type(CalibrationLatestResponse, calibration, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
diff --git a/uv.lock b/uv.lock
index 9cb22e5..b7a60b4 100644
--- a/uv.lock
+++ b/uv.lock
@@ -547,7 +547,7 @@ wheels = [
[[package]]
name = "miru-device-sdk"
-version = "0.8.1"
+version = "0.9.0"
source = { editable = "." }
dependencies = [
{ name = "anyio" },