Skip to content

Commit 57addaf

Browse files
authored
feat: ledger facade parity with the TypeScript client, and the SEC text operations (#230)
## Summary Brings the Python client level with the TypeScript client's 2.5.0: the ledger facade methods for reconciling items, the obligation sweep and the close overrides, plus a regeneration that picks up the SEC filing-text operations the API gained in v1.15.5 and v1.15.6. ## Changes **Regenerated SDK** (first commit; `robosystems_client/api/`, `robosystems_client/models/`) - Three new operations: `describe_filing`, `read_text`, `search_text`, with their request, response and envelope models (28 new files). - `ResolvedReportInfo` gains an optional `links` (`FilingLinks`). - The checked-in `schema.graphql` did not change. **Hand-written facade** (second commit; `robosystems_client/clients/ledger_client.py`) - `list_event_blocks` takes `is_reconciling_item`. - `preview_reconciling_item(graph_id, event_id)`: what changed and what each treatment would do. Writes nothing. - `resolve_reconciling_item(graph_id, event_id, *, disposition, posting_date, status, note, reference_event_id)`. - `promote_obligations(graph_id, *, dispatch_handlers)`. - `close_period` takes `allow_stranded_obligations`, `allow_reconciling_items` and `allow_unposted_source_events`. It already took the other two. New parameters are appended, so positional callers are unaffected. **GraphQL documents** (`graphql/operations/ledger/`, with `graphql/generated/` regenerated by `just generate-graphql`) - `ListLedgerEventBlocks`: the `isReconcilingItem` variable and argument. - `GetLedgerFiscalCalendar`: selects `unpostedSourceEventCount` and `unpostedSourceEventSample`. It already selected the reconciling-item pair. ## Compatibility ADDITIVE. - Regeneration: compared the emitted models. Only new files, new exports in `models/__init__.py`, and one new optional field. No field became required and nothing was dropped. - Facade: new methods and new keyword parameters that default to unset. Nothing `robosystems-integration-template` imports changes. - The fiscal calendar model now carries two more fields, which the query selects. The deployed API (v1.15.6) returns them; an API older than the release that added them would reject the selection. ## Testing - `just test-all`: 617 passed, 17 skipped; ruff check and format clean; typecheck 0 errors. - `just generate-graphql` re-run after formatting produces no diff, so the CI drift gate is clean. - New tests in `tests/test_ledger_client.py`: the filter variable and its presence in the query, each new close override on the wire and the unset ones off it, the request body of each new method, and the calendar's new fields. - The regeneration was run against a local backend on `main`. None of the new methods or operations was called against a live graph. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
2 parents 3654318 + 34ff61c commit 57addaf

37 files changed

Lines changed: 4034 additions & 14 deletions
Lines changed: 282 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,282 @@
1+
from http import HTTPStatus
2+
from typing import Any
3+
from urllib.parse import quote
4+
5+
import httpx
6+
7+
from ... import errors
8+
from ...client import AuthenticatedClient, Client
9+
from ...models.describe_filing_request import DescribeFilingRequest
10+
from ...models.error_response import ErrorResponse
11+
from ...models.operation_envelope_describe_filing_response import (
12+
OperationEnvelopeDescribeFilingResponse,
13+
)
14+
from ...types import UNSET, Response, Unset
15+
16+
17+
def _get_kwargs(
18+
graph_id: str,
19+
*,
20+
body: DescribeFilingRequest,
21+
idempotency_key: None | str | Unset = UNSET,
22+
) -> dict[str, Any]:
23+
headers: dict[str, Any] = {}
24+
if not isinstance(idempotency_key, Unset):
25+
headers["Idempotency-Key"] = idempotency_key
26+
27+
_kwargs: dict[str, Any] = {
28+
"method": "post",
29+
"url": "/extensions/roboledger/{graph_id}/operations/describe-filing".format(
30+
graph_id=quote(str(graph_id), safe=""),
31+
),
32+
}
33+
34+
_kwargs["json"] = body.to_dict()
35+
36+
headers["Content-Type"] = "application/json"
37+
38+
_kwargs["headers"] = headers
39+
return _kwargs
40+
41+
42+
def _parse_response(
43+
*, client: AuthenticatedClient | Client, response: httpx.Response
44+
) -> ErrorResponse | OperationEnvelopeDescribeFilingResponse | None:
45+
if response.status_code == 200:
46+
response_200 = OperationEnvelopeDescribeFilingResponse.from_dict(response.json())
47+
48+
return response_200
49+
50+
if response.status_code == 400:
51+
response_400 = ErrorResponse.from_dict(response.json())
52+
53+
return response_400
54+
55+
if response.status_code == 401:
56+
response_401 = ErrorResponse.from_dict(response.json())
57+
58+
return response_401
59+
60+
if response.status_code == 403:
61+
response_403 = ErrorResponse.from_dict(response.json())
62+
63+
return response_403
64+
65+
if response.status_code == 404:
66+
response_404 = ErrorResponse.from_dict(response.json())
67+
68+
return response_404
69+
70+
if response.status_code == 409:
71+
response_409 = ErrorResponse.from_dict(response.json())
72+
73+
return response_409
74+
75+
if response.status_code == 422:
76+
response_422 = ErrorResponse.from_dict(response.json())
77+
78+
return response_422
79+
80+
if response.status_code == 429:
81+
response_429 = ErrorResponse.from_dict(response.json())
82+
83+
return response_429
84+
85+
if response.status_code == 500:
86+
response_500 = ErrorResponse.from_dict(response.json())
87+
88+
return response_500
89+
90+
if client.raise_on_unexpected_status:
91+
raise errors.UnexpectedStatus(response.status_code, response.content)
92+
else:
93+
return None
94+
95+
96+
def _build_response(
97+
*, client: AuthenticatedClient | Client, response: httpx.Response
98+
) -> Response[ErrorResponse | OperationEnvelopeDescribeFilingResponse]:
99+
return Response(
100+
status_code=HTTPStatus(response.status_code),
101+
content=response.content,
102+
headers=response.headers,
103+
parsed=_parse_response(client=client, response=response),
104+
)
105+
106+
107+
def sync_detailed(
108+
graph_id: str,
109+
*,
110+
client: AuthenticatedClient,
111+
body: DescribeFilingRequest,
112+
idempotency_key: None | str | Unset = UNSET,
113+
) -> Response[ErrorResponse | OperationEnvelopeDescribeFilingResponse]:
114+
"""Describe Filing
115+
116+
How one filing is laid out: entity, periods, statements and disclosures by role, axes, and its text
117+
— the Items of a 10-K or 10-Q and its largest text blocks, each with the character offset `read-
118+
text` pages from. On the SEC shared repository the filing is read from its public folder — its own
119+
document, from any processed year — and a `ticker` picks it: the latest annual report, narrowed by
120+
`fiscal_year` / `period_type`, or one `accession`, or with `form: 8-K` the latest earnings release
121+
and its exhibits. SEC only: a ledger files no document, and its sections read through `disclosures`
122+
and `information-block`.
123+
124+
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
125+
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
126+
127+
Args:
128+
graph_id (str):
129+
idempotency_key (None | str | Unset):
130+
body (DescribeFilingRequest): Request for the describe-filing view op — how a filing is
131+
laid out.
132+
133+
Raises:
134+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
135+
httpx.TimeoutException: If the request takes longer than Client.timeout.
136+
137+
Returns:
138+
Response[ErrorResponse | OperationEnvelopeDescribeFilingResponse]
139+
"""
140+
141+
kwargs = _get_kwargs(
142+
graph_id=graph_id,
143+
body=body,
144+
idempotency_key=idempotency_key,
145+
)
146+
147+
response = client.get_httpx_client().request(
148+
**kwargs,
149+
)
150+
151+
return _build_response(client=client, response=response)
152+
153+
154+
def sync(
155+
graph_id: str,
156+
*,
157+
client: AuthenticatedClient,
158+
body: DescribeFilingRequest,
159+
idempotency_key: None | str | Unset = UNSET,
160+
) -> ErrorResponse | OperationEnvelopeDescribeFilingResponse | None:
161+
"""Describe Filing
162+
163+
How one filing is laid out: entity, periods, statements and disclosures by role, axes, and its text
164+
— the Items of a 10-K or 10-Q and its largest text blocks, each with the character offset `read-
165+
text` pages from. On the SEC shared repository the filing is read from its public folder — its own
166+
document, from any processed year — and a `ticker` picks it: the latest annual report, narrowed by
167+
`fiscal_year` / `period_type`, or one `accession`, or with `form: 8-K` the latest earnings release
168+
and its exhibits. SEC only: a ledger files no document, and its sections read through `disclosures`
169+
and `information-block`.
170+
171+
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
172+
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
173+
174+
Args:
175+
graph_id (str):
176+
idempotency_key (None | str | Unset):
177+
body (DescribeFilingRequest): Request for the describe-filing view op — how a filing is
178+
laid out.
179+
180+
Raises:
181+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
182+
httpx.TimeoutException: If the request takes longer than Client.timeout.
183+
184+
Returns:
185+
ErrorResponse | OperationEnvelopeDescribeFilingResponse
186+
"""
187+
188+
return sync_detailed(
189+
graph_id=graph_id,
190+
client=client,
191+
body=body,
192+
idempotency_key=idempotency_key,
193+
).parsed
194+
195+
196+
async def asyncio_detailed(
197+
graph_id: str,
198+
*,
199+
client: AuthenticatedClient,
200+
body: DescribeFilingRequest,
201+
idempotency_key: None | str | Unset = UNSET,
202+
) -> Response[ErrorResponse | OperationEnvelopeDescribeFilingResponse]:
203+
"""Describe Filing
204+
205+
How one filing is laid out: entity, periods, statements and disclosures by role, axes, and its text
206+
— the Items of a 10-K or 10-Q and its largest text blocks, each with the character offset `read-
207+
text` pages from. On the SEC shared repository the filing is read from its public folder — its own
208+
document, from any processed year — and a `ticker` picks it: the latest annual report, narrowed by
209+
`fiscal_year` / `period_type`, or one `accession`, or with `form: 8-K` the latest earnings release
210+
and its exhibits. SEC only: a ledger files no document, and its sections read through `disclosures`
211+
and `information-block`.
212+
213+
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
214+
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
215+
216+
Args:
217+
graph_id (str):
218+
idempotency_key (None | str | Unset):
219+
body (DescribeFilingRequest): Request for the describe-filing view op — how a filing is
220+
laid out.
221+
222+
Raises:
223+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
224+
httpx.TimeoutException: If the request takes longer than Client.timeout.
225+
226+
Returns:
227+
Response[ErrorResponse | OperationEnvelopeDescribeFilingResponse]
228+
"""
229+
230+
kwargs = _get_kwargs(
231+
graph_id=graph_id,
232+
body=body,
233+
idempotency_key=idempotency_key,
234+
)
235+
236+
response = await client.get_async_httpx_client().request(**kwargs)
237+
238+
return _build_response(client=client, response=response)
239+
240+
241+
async def asyncio(
242+
graph_id: str,
243+
*,
244+
client: AuthenticatedClient,
245+
body: DescribeFilingRequest,
246+
idempotency_key: None | str | Unset = UNSET,
247+
) -> ErrorResponse | OperationEnvelopeDescribeFilingResponse | None:
248+
"""Describe Filing
249+
250+
How one filing is laid out: entity, periods, statements and disclosures by role, axes, and its text
251+
— the Items of a 10-K or 10-Q and its largest text blocks, each with the character offset `read-
252+
text` pages from. On the SEC shared repository the filing is read from its public folder — its own
253+
document, from any processed year — and a `ticker` picks it: the latest annual report, narrowed by
254+
`fiscal_year` / `period_type`, or one `accession`, or with `form: 8-K` the latest earnings release
255+
and its exhibits. SEC only: a ledger files no document, and its sections read through `disclosures`
256+
and `information-block`.
257+
258+
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
259+
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
260+
261+
Args:
262+
graph_id (str):
263+
idempotency_key (None | str | Unset):
264+
body (DescribeFilingRequest): Request for the describe-filing view op — how a filing is
265+
laid out.
266+
267+
Raises:
268+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
269+
httpx.TimeoutException: If the request takes longer than Client.timeout.
270+
271+
Returns:
272+
ErrorResponse | OperationEnvelopeDescribeFilingResponse
273+
"""
274+
275+
return (
276+
await asyncio_detailed(
277+
graph_id=graph_id,
278+
client=client,
279+
body=body,
280+
idempotency_key=idempotency_key,
281+
)
282+
).parsed

0 commit comments

Comments
 (0)