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 .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.4.1-beta.0"
".": "0.4.1-beta.1"
}
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 14
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/miru-ml%2Fmiru-server-7d0dd143c8ea9bc230d9810d8cfb3fde8b1d4eb48295ebf2db7ea67916fb96c3.yml
openapi_spec_hash: b6667a2e80a356a67bab83f8d5f6e51a
config_hash: 78c50efd3bbfb4969846973cb0609eff
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/miru-ml%2Fmiru-server-1187ba20c7bd5d91919c6e65f71201c9997541aae5ea6b3068b2e8094b4b8d0c.yml
openapi_spec_hash: fd892348c3cd6e7ec5bdce4d8134bf14
config_hash: c47912de5d58c4db1a9ed9e3f82a24a0
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 0.4.1-beta.1 (2025-10-05)

Full Changelog: [v0.4.1-beta.0...v0.4.1-beta.1](https://github.com/miruml/python-server-sdk/compare/v0.4.1-beta.0...v0.4.1-beta.1)

### Features

* **api:** manual updates ([1f24c3f](https://github.com/miruml/python-server-sdk/commit/1f24c3f238e13344e158a909a8444fe6a02534ec))
* **api:** manual updates ([616466d](https://github.com/miruml/python-server-sdk/commit/616466d196871cb65ad48ecccf292be3596043b1))

## 0.4.1-beta.0 (2025-10-05)

Full Changelog: [v0.4.0...v0.4.1-beta.0](https://github.com/miruml/python-server-sdk/compare/v0.4.0...v0.4.1-beta.0)
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ It is generated with [Stainless](https://www.stainless.com/).

## Documentation

The full API of this library can be found in [api.md](api.md).
The REST API documentation can be found on [docs.miruml.com](https://docs.miruml.com). The full API of this library can be found in [api.md](api.md).

## Installation

Expand All @@ -30,6 +30,8 @@ from miru_server_sdk import Miru

client = Miru(
api_key=os.environ.get("MIRU_SERVER_API_KEY"), # This is the default and can be omitted
# or 'production' | 'local'; defaults to "production".
environment="staging",
)

config_instance = client.config_instances.retrieve(
Expand All @@ -54,6 +56,8 @@ from miru_server_sdk import AsyncMiru

client = AsyncMiru(
api_key=os.environ.get("MIRU_SERVER_API_KEY"), # This is the default and can be omitted
# or 'production' | 'local'; defaults to "production".
environment="staging",
)


Expand Down
4 changes: 4 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ before making any information public.
If you encounter security issues that are not directly related to SDKs but pertain to the services
or products provided by Miru, please follow the respective company's security reporting guidelines.

### Miru Terms and Policies

Please contact ben@miruml.com for any questions or concerns regarding the security of our services.

---

Thank you for helping us keep the SDKs and systems they interact with secure.
8 changes: 8 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,11 @@ Methods:

- <code title="get /releases/{release_id}">client.releases.<a href="./src/miru_server_sdk/resources/releases.py">retrieve</a>(release_id, \*\*<a href="src/miru_server_sdk/types/release_retrieve_params.py">params</a>) -> <a href="./src/miru_server_sdk/types/release.py">Release</a></code>
- <code title="get /releases">client.releases.<a href="./src/miru_server_sdk/resources/releases.py">list</a>(\*\*<a href="src/miru_server_sdk/types/release_list_params.py">params</a>) -> <a href="./src/miru_server_sdk/types/release_list_response.py">ReleaseListResponse</a></code>

# Webhooks

Types:

```python
from miru_server_sdk.types import DeploymentValidateWebhookEvent, UnwrapWebhookEvent
```
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[project]
name = "miru_server_sdk"
version = "0.4.1-beta.0"
version = "0.4.1-beta.1"
description = "The official Python library for the miru API"
dynamic = ["readme"]
license = "MIT"
authors = [
{ name = "Miru", email = "" },
{ name = "Miru", email = "ben@miruml.com" },
]
dependencies = [
"httpx>=0.23.0, <1",
Expand Down
14 changes: 13 additions & 1 deletion src/miru_server_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,18 @@
from . import types
from ._types import NOT_GIVEN, Omit, NoneType, NotGiven, Transport, ProxiesTypes, omit, not_given
from ._utils import file_from_path
from ._client import Miru, Client, Stream, Timeout, AsyncMiru, Transport, AsyncClient, AsyncStream, RequestOptions
from ._client import (
ENVIRONMENTS,
Miru,
Client,
Stream,
Timeout,
AsyncMiru,
Transport,
AsyncClient,
AsyncStream,
RequestOptions,
)
from ._models import BaseModel
from ._version import __title__, __version__
from ._response import APIResponse as APIResponse, AsyncAPIResponse as AsyncAPIResponse
Expand Down Expand Up @@ -63,6 +74,7 @@
"AsyncStream",
"Miru",
"AsyncMiru",
"ENVIRONMENTS",
"file_from_path",
"BaseModel",
"DEFAULT_TIMEOUT",
Expand Down
100 changes: 86 additions & 14 deletions src/miru_server_sdk/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from __future__ import annotations

import os
from typing import Any, Mapping
from typing_extensions import Self, override
from typing import Any, Dict, Mapping, cast
from typing_extensions import Self, Literal, override

import httpx

Expand All @@ -21,7 +21,7 @@
)
from ._utils import is_given, get_async_library
from ._version import __version__
from .resources import devices, releases, deployments, config_instances
from .resources import devices, releases, webhooks, deployments, config_instances
from ._streaming import Stream as Stream, AsyncStream as AsyncStream
from ._exceptions import MiruError, APIStatusError
from ._base_client import (
Expand All @@ -30,14 +30,31 @@
AsyncAPIClient,
)

__all__ = ["Timeout", "Transport", "ProxiesTypes", "RequestOptions", "Miru", "AsyncMiru", "Client", "AsyncClient"]
__all__ = [
"ENVIRONMENTS",
"Timeout",
"Transport",
"ProxiesTypes",
"RequestOptions",
"Miru",
"AsyncMiru",
"Client",
"AsyncClient",
]

ENVIRONMENTS: Dict[str, str] = {
"production": "https://configs.api.miruml.com/v1",
"staging": "https://configs.dev.api.miruml.com/v1",
"local": "http://localhost:8080/v1",
}


class Miru(SyncAPIClient):
config_instances: config_instances.ConfigInstancesResource
deployments: deployments.DeploymentsResource
devices: devices.DevicesResource
releases: releases.ReleasesResource
webhooks: webhooks.WebhooksResource
with_raw_response: MiruWithRawResponse
with_streaming_response: MiruWithStreamedResponse

Expand All @@ -46,13 +63,16 @@ class Miru(SyncAPIClient):
host: str
version: str

_environment: Literal["production", "staging", "local"] | NotGiven

def __init__(
self,
*,
api_key: str | None = None,
host: str | None = None,
version: str | None = None,
base_url: str | httpx.URL | None = None,
environment: Literal["production", "staging", "local"] | NotGiven = not_given,
base_url: str | httpx.URL | None | NotGiven = not_given,
timeout: float | Timeout | None | NotGiven = not_given,
max_retries: int = DEFAULT_MAX_RETRIES,
default_headers: Mapping[str, str] | None = None,
Expand Down Expand Up @@ -94,10 +114,31 @@ def __init__(
version = os.environ.get("MIRU_SERVER_VERSION") or "v1"
self.version = version

if base_url is None:
base_url = os.environ.get("MIRU_BASE_URL")
if base_url is None:
base_url = f"https://{host}/{version}"
self._environment = environment

base_url_env = os.environ.get("MIRU_BASE_URL")
if is_given(base_url) and base_url is not None:
# cast required because mypy doesn't understand the type narrowing
base_url = cast("str | httpx.URL", base_url) # pyright: ignore[reportUnnecessaryCast]
elif is_given(environment):
if base_url_env and base_url is not None:
raise ValueError(
"Ambiguous URL; The `MIRU_BASE_URL` env var and the `environment` argument are given. If you want to use the environment, you must pass base_url=None",
)

try:
base_url = ENVIRONMENTS[environment]
except KeyError as exc:
raise ValueError(f"Unknown environment: {environment}") from exc
elif base_url_env is not None:
base_url = base_url_env
else:
self._environment = environment = "production"

try:
base_url = ENVIRONMENTS[environment]
except KeyError as exc:
raise ValueError(f"Unknown environment: {environment}") from exc

super().__init__(
version=__version__,
Expand All @@ -114,6 +155,7 @@ def __init__(
self.deployments = deployments.DeploymentsResource(self)
self.devices = devices.DevicesResource(self)
self.releases = releases.ReleasesResource(self)
self.webhooks = webhooks.WebhooksResource(self)
self.with_raw_response = MiruWithRawResponse(self)
self.with_streaming_response = MiruWithStreamedResponse(self)

Expand Down Expand Up @@ -143,6 +185,7 @@ def copy(
api_key: str | None = None,
host: str | None = None,
version: str | None = None,
environment: Literal["production", "staging", "local"] | None = None,
base_url: str | httpx.URL | None = None,
timeout: float | Timeout | None | NotGiven = not_given,
http_client: httpx.Client | None = None,
Expand Down Expand Up @@ -180,6 +223,7 @@ def copy(
host=host or self.host,
version=version or self.version,
base_url=base_url or self.base_url,
environment=environment or self._environment,
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
http_client=http_client,
max_retries=max_retries if is_given(max_retries) else self.max_retries,
Expand Down Expand Up @@ -231,6 +275,7 @@ class AsyncMiru(AsyncAPIClient):
deployments: deployments.AsyncDeploymentsResource
devices: devices.AsyncDevicesResource
releases: releases.AsyncReleasesResource
webhooks: webhooks.AsyncWebhooksResource
with_raw_response: AsyncMiruWithRawResponse
with_streaming_response: AsyncMiruWithStreamedResponse

Expand All @@ -239,13 +284,16 @@ class AsyncMiru(AsyncAPIClient):
host: str
version: str

_environment: Literal["production", "staging", "local"] | NotGiven

def __init__(
self,
*,
api_key: str | None = None,
host: str | None = None,
version: str | None = None,
base_url: str | httpx.URL | None = None,
environment: Literal["production", "staging", "local"] | NotGiven = not_given,
base_url: str | httpx.URL | None | NotGiven = not_given,
timeout: float | Timeout | None | NotGiven = not_given,
max_retries: int = DEFAULT_MAX_RETRIES,
default_headers: Mapping[str, str] | None = None,
Expand Down Expand Up @@ -287,10 +335,31 @@ def __init__(
version = os.environ.get("MIRU_SERVER_VERSION") or "v1"
self.version = version

if base_url is None:
base_url = os.environ.get("MIRU_BASE_URL")
if base_url is None:
base_url = f"https://{host}/{version}"
self._environment = environment

base_url_env = os.environ.get("MIRU_BASE_URL")
if is_given(base_url) and base_url is not None:
# cast required because mypy doesn't understand the type narrowing
base_url = cast("str | httpx.URL", base_url) # pyright: ignore[reportUnnecessaryCast]
elif is_given(environment):
if base_url_env and base_url is not None:
raise ValueError(
"Ambiguous URL; The `MIRU_BASE_URL` env var and the `environment` argument are given. If you want to use the environment, you must pass base_url=None",
)

try:
base_url = ENVIRONMENTS[environment]
except KeyError as exc:
raise ValueError(f"Unknown environment: {environment}") from exc
elif base_url_env is not None:
base_url = base_url_env
else:
self._environment = environment = "production"

try:
base_url = ENVIRONMENTS[environment]
except KeyError as exc:
raise ValueError(f"Unknown environment: {environment}") from exc

super().__init__(
version=__version__,
Expand All @@ -307,6 +376,7 @@ def __init__(
self.deployments = deployments.AsyncDeploymentsResource(self)
self.devices = devices.AsyncDevicesResource(self)
self.releases = releases.AsyncReleasesResource(self)
self.webhooks = webhooks.AsyncWebhooksResource(self)
self.with_raw_response = AsyncMiruWithRawResponse(self)
self.with_streaming_response = AsyncMiruWithStreamedResponse(self)

Expand Down Expand Up @@ -336,6 +406,7 @@ def copy(
api_key: str | None = None,
host: str | None = None,
version: str | None = None,
environment: Literal["production", "staging", "local"] | None = None,
base_url: str | httpx.URL | None = None,
timeout: float | Timeout | None | NotGiven = not_given,
http_client: httpx.AsyncClient | None = None,
Expand Down Expand Up @@ -373,6 +444,7 @@ def copy(
host=host or self.host,
version=version or self.version,
base_url=base_url or self.base_url,
environment=environment or self._environment,
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
http_client=http_client,
max_retries=max_retries if is_given(max_retries) else self.max_retries,
Expand Down
2 changes: 1 addition & 1 deletion src/miru_server_sdk/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

__title__ = "miru_server_sdk"
__version__ = "0.4.1-beta.0" # x-release-please-version
__version__ = "0.4.1-beta.1" # x-release-please-version
3 changes: 3 additions & 0 deletions src/miru_server_sdk/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
ReleasesResourceWithStreamingResponse,
AsyncReleasesResourceWithStreamingResponse,
)
from .webhooks import WebhooksResource, AsyncWebhooksResource
from .deployments import (
DeploymentsResource,
AsyncDeploymentsResource,
Expand Down Expand Up @@ -58,4 +59,6 @@
"AsyncReleasesResourceWithRawResponse",
"ReleasesResourceWithStreamingResponse",
"AsyncReleasesResourceWithStreamingResponse",
"WebhooksResource",
"AsyncWebhooksResource",
]
Loading