Skip to content
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 +1 @@
configured_endpoints: 12
configured_endpoints: 14
4 changes: 3 additions & 1 deletion api.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ Methods:
Types:

```python
from miru_device_sdk.types import CalibrationCreateResponse
from miru_device_sdk.types import Calibration, CalibrationCreateResponse, CalibrationLatestResponse
```

Methods:

- <code title="post /calibrations">client.calibrations.<a href="./src/miru_device_sdk/resources/calibrations.py">create</a>(\*\*<a href="src/miru_device_sdk/types/calibration_create_params.py">params</a>) -> <a href="./src/miru_device_sdk/types/calibration_create_response.py">CalibrationCreateResponse</a></code>
- <code title="get /calibrations/latest/{report_id}/content">client.calibrations.<a href="./src/miru_device_sdk/resources/calibrations.py">download</a>(report_id) -> BinaryAPIResponse</code>
- <code title="get /calibrations/latest">client.calibrations.<a href="./src/miru_device_sdk/resources/calibrations.py">latest</a>(\*\*<a href="src/miru_device_sdk/types/calibration_latest_params.py">params</a>) -> <a href="./src/miru_device_sdk/types/calibration_latest_response.py">CalibrationLatestResponse</a></code>

# Deployments

Expand Down
239 changes: 228 additions & 11 deletions src/miru_device_sdk/resources/calibrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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,
)
28 changes: 8 additions & 20 deletions src/miru_device_sdk/resources/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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.

Expand Down
3 changes: 3 additions & 0 deletions src/miru_device_sdk/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading
Loading