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
18 changes: 10 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
name: CI
on:
push:
branches-ignore:
- 'generated'
- 'codegen/**'
- 'integrated/**'
- 'stl-preview-head/**'
- 'stl-preview-base/**'
branches:
- '**'
- '!integrated/**'
- '!stl-preview-head/**'
- '!stl-preview-base/**'
- '!generated'
- '!codegen/**'
- 'codegen/stl/**'
pull_request:
branches-ignore:
- 'stl-preview-head/**'
Expand All @@ -17,7 +19,7 @@ jobs:
timeout-minutes: 10
name: lint
runs-on: ${{ github.repository == 'stainless-sdks/openregister-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')
steps:
- uses: actions/checkout@v6

Expand All @@ -36,7 +38,7 @@ jobs:
run: ./scripts/lint

build:
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')
timeout-minutes: 10
name: build
permissions:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.prism.log
.stdy.log
_dev

__pycache__
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "3.0.3"
".": "3.1.0"
}
8 changes: 4 additions & 4 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 15
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openregister%2Fopenregister-3e550ef1f7516fd49b02364a8cd188082775dd811d3a79ea35894277b39932c7.yml
openapi_spec_hash: 77b2dc3a4de8f91c7d1a31fdb60513ae
config_hash: b9f5716a354cbb7263fcab72fb138615
configured_endpoints: 18
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openregister%2Fopenregister-cdea05542fb87dc7f00544bdd53fd82469ad985a48aa0d96fdd74011464e3a5d.yml
openapi_spec_hash: e49334a0e9b0d800974f7453910ab5ee
config_hash: 6b8c0142ef1c8e22e9ca6b5b834e2a04
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# Changelog

## 3.1.0 (2026-03-27)

Full Changelog: [v3.0.3...v3.1.0](https://github.com/oregister/openregister-python/compare/v3.0.3...v3.1.0)

### Features

* **api:** monitoring endpoints ([2051511](https://github.com/oregister/openregister-python/commit/205151139e0f27c8d731890a0341276bedcddb8d))
* **internal:** implement indices array format for query and form serialization ([87468c0](https://github.com/oregister/openregister-python/commit/87468c0ba7e8be29d701bf25fa6c1d3606d85446))


### Bug Fixes

* **deps:** bump minimum typing-extensions version ([2f29556](https://github.com/oregister/openregister-python/commit/2f29556e998619b9a3118e8ed73a648a93a12860))
* **pydantic:** do not pass `by_alias` unless set ([3027dda](https://github.com/oregister/openregister-python/commit/3027dda1781ce25e428551cb4cbdd4f9b6efddc8))
* sanitize endpoint path params ([924be9b](https://github.com/oregister/openregister-python/commit/924be9b09c0ee804aa934b3615db0c6089d2e224))


### Chores

* **ci:** skip lint on metadata-only changes ([f053a64](https://github.com/oregister/openregister-python/commit/f053a64334e4de4eea8ed8d7977b679b8c8fe019))
* **internal:** tweak CI branches ([4b0ff82](https://github.com/oregister/openregister-python/commit/4b0ff8267fd4ba3b0c6990d87fdd87b7fc1c3fa4))
* **internal:** update gitignore ([26e53e0](https://github.com/oregister/openregister-python/commit/26e53e088b1e334b1adfc6baa54a997831f9ba84))

## 3.0.3 (2026-03-12)

Full Changelog: [v3.0.2...v3.0.3](https://github.com/oregister/openregister-python/compare/v3.0.2...v3.0.3)
Expand Down
14 changes: 14 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,17 @@ Methods:

- <code title="get /v1/person/{person_id}">client.person.<a href="./src/openregister/resources/person.py">get_details_v1</a>(person_id) -> <a href="./src/openregister/types/person_get_details_v1_response.py">PersonGetDetailsV1Response</a></code>
- <code title="get /v1/person/{person_id}/holdings">client.person.<a href="./src/openregister/resources/person.py">get_holdings_v1</a>(person_id) -> <a href="./src/openregister/types/person_get_holdings_v1_response.py">PersonGetHoldingsV1Response</a></code>

# Monitor

Types:

```python
from openregister.types import MonitorCreateResponse, MonitorListResponse
```

Methods:

- <code title="post /v1/monitor">client.monitor.<a href="./src/openregister/resources/monitor.py">create</a>(\*\*<a href="src/openregister/types/monitor_create_params.py">params</a>) -> <a href="./src/openregister/types/monitor_create_response.py">MonitorCreateResponse</a></code>
- <code title="get /v1/monitor">client.monitor.<a href="./src/openregister/resources/monitor.py">list</a>() -> <a href="./src/openregister/types/monitor_list_response.py">MonitorListResponse</a></code>
- <code title="delete /v1/monitor/{entity_id}">client.monitor.<a href="./src/openregister/resources/monitor.py">delete</a>(entity_id) -> None</code>
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "openregister-sdk"
version = "3.0.3"
version = "3.1.0"
description = "The official Python library for the openregister API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand All @@ -11,7 +11,7 @@ authors = [
dependencies = [
"httpx>=0.23.0, <1",
"pydantic>=1.9.0, <3",
"typing-extensions>=4.10, <5",
"typing-extensions>=4.14, <5",
"anyio>=3.5.0, <5",
"distro>=1.7.0, <2",
"sniffio",
Expand Down
39 changes: 38 additions & 1 deletion src/openregister/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@
)

if TYPE_CHECKING:
from .resources import person, search, company, document
from .resources import person, search, company, monitor, document
from .resources.person import PersonResource, AsyncPersonResource
from .resources.search import SearchResource, AsyncSearchResource
from .resources.company import CompanyResource, AsyncCompanyResource
from .resources.monitor import MonitorResource, AsyncMonitorResource
from .resources.document import DocumentResource, AsyncDocumentResource

__all__ = [
Expand Down Expand Up @@ -128,6 +129,12 @@ def person(self) -> PersonResource:

return PersonResource(self)

@cached_property
def monitor(self) -> MonitorResource:
from .resources.monitor import MonitorResource

return MonitorResource(self)

@cached_property
def with_raw_response(self) -> OpenregisterWithRawResponse:
return OpenregisterWithRawResponse(self)
Expand Down Expand Up @@ -320,6 +327,12 @@ def person(self) -> AsyncPersonResource:

return AsyncPersonResource(self)

@cached_property
def monitor(self) -> AsyncMonitorResource:
from .resources.monitor import AsyncMonitorResource

return AsyncMonitorResource(self)

@cached_property
def with_raw_response(self) -> AsyncOpenregisterWithRawResponse:
return AsyncOpenregisterWithRawResponse(self)
Expand Down Expand Up @@ -463,6 +476,12 @@ def person(self) -> person.PersonResourceWithRawResponse:

return PersonResourceWithRawResponse(self._client.person)

@cached_property
def monitor(self) -> monitor.MonitorResourceWithRawResponse:
from .resources.monitor import MonitorResourceWithRawResponse

return MonitorResourceWithRawResponse(self._client.monitor)


class AsyncOpenregisterWithRawResponse:
_client: AsyncOpenregister
Expand Down Expand Up @@ -494,6 +513,12 @@ def person(self) -> person.AsyncPersonResourceWithRawResponse:

return AsyncPersonResourceWithRawResponse(self._client.person)

@cached_property
def monitor(self) -> monitor.AsyncMonitorResourceWithRawResponse:
from .resources.monitor import AsyncMonitorResourceWithRawResponse

return AsyncMonitorResourceWithRawResponse(self._client.monitor)


class OpenregisterWithStreamedResponse:
_client: Openregister
Expand Down Expand Up @@ -525,6 +550,12 @@ def person(self) -> person.PersonResourceWithStreamingResponse:

return PersonResourceWithStreamingResponse(self._client.person)

@cached_property
def monitor(self) -> monitor.MonitorResourceWithStreamingResponse:
from .resources.monitor import MonitorResourceWithStreamingResponse

return MonitorResourceWithStreamingResponse(self._client.monitor)


class AsyncOpenregisterWithStreamedResponse:
_client: AsyncOpenregister
Expand Down Expand Up @@ -556,6 +587,12 @@ def person(self) -> person.AsyncPersonResourceWithStreamingResponse:

return AsyncPersonResourceWithStreamingResponse(self._client.person)

@cached_property
def monitor(self) -> monitor.AsyncMonitorResourceWithStreamingResponse:
from .resources.monitor import AsyncMonitorResourceWithStreamingResponse

return AsyncMonitorResourceWithStreamingResponse(self._client.monitor)


Client = Openregister

Expand Down
11 changes: 9 additions & 2 deletions src/openregister/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import TYPE_CHECKING, Any, Union, Generic, TypeVar, Callable, cast, overload
from datetime import date, datetime
from typing_extensions import Self, Literal
from typing_extensions import Self, Literal, TypedDict

import pydantic
from pydantic.fields import FieldInfo
Expand Down Expand Up @@ -131,6 +131,10 @@ def model_json(model: pydantic.BaseModel, *, indent: int | None = None) -> str:
return model.model_dump_json(indent=indent)


class _ModelDumpKwargs(TypedDict, total=False):
by_alias: bool


def model_dump(
model: pydantic.BaseModel,
*,
Expand All @@ -142,14 +146,17 @@ def model_dump(
by_alias: bool | None = None,
) -> dict[str, Any]:
if (not PYDANTIC_V1) or hasattr(model, "model_dump"):
kwargs: _ModelDumpKwargs = {}
if by_alias is not None:
kwargs["by_alias"] = by_alias
return model.model_dump(
mode=mode,
exclude=exclude,
exclude_unset=exclude_unset,
exclude_defaults=exclude_defaults,
# warnings are not supported in Pydantic v1
warnings=True if PYDANTIC_V1 else warnings,
by_alias=by_alias,
**kwargs,
)
return cast(
"dict[str, Any]",
Expand Down
5 changes: 4 additions & 1 deletion src/openregister/_qs.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ def _stringify_item(
items.extend(self._stringify_item(key, item, opts))
return items
elif array_format == "indices":
raise NotImplementedError("The array indices format is not supported yet")
items = []
for i, item in enumerate(value):
items.extend(self._stringify_item(f"{key}[{i}]", item, opts))
return items
elif array_format == "brackets":
items = []
key = key + "[]"
Expand Down
1 change: 1 addition & 0 deletions src/openregister/_utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from ._path import path_template as path_template
from ._sync import asyncify as asyncify
from ._proxy import LazyProxy as LazyProxy
from ._utils import (
Expand Down
127 changes: 127 additions & 0 deletions src/openregister/_utils/_path.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
from __future__ import annotations

import re
from typing import (
Any,
Mapping,
Callable,
)
from urllib.parse import quote

# Matches '.' or '..' where each dot is either literal or percent-encoded (%2e / %2E).
_DOT_SEGMENT_RE = re.compile(r"^(?:\.|%2[eE]){1,2}$")

_PLACEHOLDER_RE = re.compile(r"\{(\w+)\}")


def _quote_path_segment_part(value: str) -> str:
"""Percent-encode `value` for use in a URI path segment.
Considers characters not in `pchar` set from RFC 3986 §3.3 to be unsafe.
https://datatracker.ietf.org/doc/html/rfc3986#section-3.3
"""
# quote() already treats unreserved characters (letters, digits, and -._~)
# as safe, so we only need to add sub-delims, ':', and '@'.
# Notably, unlike the default `safe` for quote(), / is unsafe and must be quoted.
return quote(value, safe="!$&'()*+,;=:@")


def _quote_query_part(value: str) -> str:
"""Percent-encode `value` for use in a URI query string.
Considers &, = and characters not in `query` set from RFC 3986 §3.4 to be unsafe.
https://datatracker.ietf.org/doc/html/rfc3986#section-3.4
"""
return quote(value, safe="!$'()*+,;:@/?")


def _quote_fragment_part(value: str) -> str:
"""Percent-encode `value` for use in a URI fragment.
Considers characters not in `fragment` set from RFC 3986 §3.5 to be unsafe.
https://datatracker.ietf.org/doc/html/rfc3986#section-3.5
"""
return quote(value, safe="!$&'()*+,;=:@/?")


def _interpolate(
template: str,
values: Mapping[str, Any],
quoter: Callable[[str], str],
) -> str:
"""Replace {name} placeholders in `template`, quoting each value with `quoter`.
Placeholder names are looked up in `values`.
Raises:
KeyError: If a placeholder is not found in `values`.
"""
# re.split with a capturing group returns alternating
# [text, name, text, name, ..., text] elements.
parts = _PLACEHOLDER_RE.split(template)

for i in range(1, len(parts), 2):
name = parts[i]
if name not in values:
raise KeyError(f"a value for placeholder {{{name}}} was not provided")
val = values[name]
if val is None:
parts[i] = "null"
elif isinstance(val, bool):
parts[i] = "true" if val else "false"
else:
parts[i] = quoter(str(values[name]))

return "".join(parts)


def path_template(template: str, /, **kwargs: Any) -> str:
"""Interpolate {name} placeholders in `template` from keyword arguments.
Args:
template: The template string containing {name} placeholders.
**kwargs: Keyword arguments to interpolate into the template.
Returns:
The template with placeholders interpolated and percent-encoded.
Safe characters for percent-encoding are dependent on the URI component.
Placeholders in path and fragment portions are percent-encoded where the `segment`
and `fragment` sets from RFC 3986 respectively are considered safe.
Placeholders in the query portion are percent-encoded where the `query` set from
RFC 3986 §3.3 is considered safe except for = and & characters.
Raises:
KeyError: If a placeholder is not found in `kwargs`.
ValueError: If resulting path contains /./ or /../ segments (including percent-encoded dot-segments).
"""
# Split the template into path, query, and fragment portions.
fragment_template: str | None = None
query_template: str | None = None

rest = template
if "#" in rest:
rest, fragment_template = rest.split("#", 1)
if "?" in rest:
rest, query_template = rest.split("?", 1)
path_template = rest

# Interpolate each portion with the appropriate quoting rules.
path_result = _interpolate(path_template, kwargs, _quote_path_segment_part)

# Reject dot-segments (. and ..) in the final assembled path. The check
# runs after interpolation so that adjacent placeholders or a mix of static
# text and placeholders that together form a dot-segment are caught.
# Also reject percent-encoded dot-segments to protect against incorrectly
# implemented normalization in servers/proxies.
for segment in path_result.split("/"):
if _DOT_SEGMENT_RE.match(segment):
raise ValueError(f"Constructed path {path_result!r} contains dot-segment {segment!r} which is not allowed")

result = path_result
if query_template is not None:
result += "?" + _interpolate(query_template, kwargs, _quote_query_part)
if fragment_template is not None:
result += "#" + _interpolate(fragment_template, kwargs, _quote_fragment_part)

return result
Loading