Skip to content

Commit 803597f

Browse files
jfrench9claude
andauthored
feat(ledger): add promote-obligations outbox + set-write-policy APIs (#127)
## Summary Regenerates the `robosystems_client` to incorporate two new server-side capabilities: **period-drafts outbox disposition** (promote obligations) and **connection write-policy management**. This is an auto-generated client update reflecting new ledger API surface area. ## Key Accomplishments ### New API Endpoints - **`set_connection_write_policy`** — Allows configuring the write policy on a connection (e.g., controlling write access semantics). Includes sync and async variants with full HTTP response support. - **`op_promote_obligations`** — New ledger extension operation to promote obligations from period drafts via the outbox disposition pattern. Supports sync and async execution with detailed error handling. ### New Models - `SetWritePolicyRequest` / `SetWritePolicyRequestWritePolicy` — Request payload and write-policy enum for the connection write-policy endpoint. - `PromoteObligationsRequest` / `PromoteObligationsResponse` — Request/response models for the promote-obligations operation. - `PromoteObligationsResponseErrorsItem` — Structured error representation for partial failures during obligation promotion. - `OperationEnvelopePromoteObligationsResponse` / `OperationEnvelopePromoteObligationsResponseStatus` — Envelope wrapper with status tracking for the async operation pattern. ### Modified Models - `ConnectionResponse` — Extended with new fields to reflect write-policy state on connections. - `RuleVariableLite` — Expanded with additional optional attributes (significant additions to the model). - `CreateEventBlockRequest` / `EventBlockEnvelope` — Minor adjustments (likely field-level type or optionality changes). ### GraphQL - Updated `ledger` query module exports to include new query definitions. ## Breaking Changes - **`CreateEventBlockRequest`** and **`EventBlockEnvelope`** have been modified — consumers constructing these models directly should verify field compatibility. - **`RuleVariableLite`** has significant new fields — existing code using `to_dict()` or pattern-matching on this model may need updates. - **`ConnectionResponse`** has new fields — generally additive but deserializers with strict schemas should be reviewed. ## Testing Notes - Since this is a generated client, verify that the upstream OpenAPI spec matches the generated output. - Integration tests should cover the new `set_connection_write_policy` and `op_promote_obligations` endpoints against a staging ledger instance. - Validate that existing consumers of modified models (`RuleVariableLite`, `ConnectionResponse`, `CreateEventBlockRequest`, `EventBlockEnvelope`) continue to serialize/deserialize correctly. - Test both sync and async code paths for the new API endpoints. ## Infrastructure Considerations - No new dependencies are introduced — this is purely additive/modified Python model and API client code. - Downstream services consuming the client library will need to update their dependency version to access the new APIs. - The new outbox disposition pattern (promote obligations) may require corresponding server-side configuration for the ledger extension to be active. --- 🤖 Generated with [Claude Code](https://claude.ai/code) **Branch Info:** - Source: `feature/outbox` - Target: `main` - Type: feature Co-Authored-By: Claude <noreply@anthropic.com>
2 parents af3e971 + a5b21a7 commit 803597f

15 files changed

Lines changed: 1152 additions & 9 deletions
Lines changed: 259 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,259 @@
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.connection_response import ConnectionResponse
10+
from ...models.error_response import ErrorResponse
11+
from ...models.http_validation_error import HTTPValidationError
12+
from ...models.set_write_policy_request import SetWritePolicyRequest
13+
from ...types import Response
14+
15+
16+
def _get_kwargs(
17+
graph_id: str,
18+
connection_id: str,
19+
*,
20+
body: SetWritePolicyRequest,
21+
) -> dict[str, Any]:
22+
headers: dict[str, Any] = {}
23+
24+
_kwargs: dict[str, Any] = {
25+
"method": "put",
26+
"url": "/v1/graphs/{graph_id}/connections/{connection_id}/write-policy".format(
27+
graph_id=quote(str(graph_id), safe=""),
28+
connection_id=quote(str(connection_id), safe=""),
29+
),
30+
}
31+
32+
_kwargs["json"] = body.to_dict()
33+
34+
headers["Content-Type"] = "application/json"
35+
36+
_kwargs["headers"] = headers
37+
return _kwargs
38+
39+
40+
def _parse_response(
41+
*, client: AuthenticatedClient | Client, response: httpx.Response
42+
) -> ConnectionResponse | ErrorResponse | HTTPValidationError | None:
43+
if response.status_code == 200:
44+
response_200 = ConnectionResponse.from_dict(response.json())
45+
46+
return response_200
47+
48+
if response.status_code == 400:
49+
response_400 = ErrorResponse.from_dict(response.json())
50+
51+
return response_400
52+
53+
if response.status_code == 401:
54+
response_401 = ErrorResponse.from_dict(response.json())
55+
56+
return response_401
57+
58+
if response.status_code == 403:
59+
response_403 = ErrorResponse.from_dict(response.json())
60+
61+
return response_403
62+
63+
if response.status_code == 404:
64+
response_404 = ErrorResponse.from_dict(response.json())
65+
66+
return response_404
67+
68+
if response.status_code == 422:
69+
response_422 = HTTPValidationError.from_dict(response.json())
70+
71+
return response_422
72+
73+
if response.status_code == 429:
74+
response_429 = ErrorResponse.from_dict(response.json())
75+
76+
return response_429
77+
78+
if response.status_code == 500:
79+
response_500 = ErrorResponse.from_dict(response.json())
80+
81+
return response_500
82+
83+
if client.raise_on_unexpected_status:
84+
raise errors.UnexpectedStatus(response.status_code, response.content)
85+
else:
86+
return None
87+
88+
89+
def _build_response(
90+
*, client: AuthenticatedClient | Client, response: httpx.Response
91+
) -> Response[ConnectionResponse | ErrorResponse | HTTPValidationError]:
92+
return Response(
93+
status_code=HTTPStatus(response.status_code),
94+
content=response.content,
95+
headers=response.headers,
96+
parsed=_parse_response(client=client, response=response),
97+
)
98+
99+
100+
def sync_detailed(
101+
graph_id: str,
102+
connection_id: str,
103+
*,
104+
client: AuthenticatedClient,
105+
body: SetWritePolicyRequest,
106+
) -> Response[ConnectionResponse | ErrorResponse | HTTPValidationError]:
107+
"""Set Connection Write Policy
108+
109+
Opt a connection into or out of outbound write-back. 'qb_authoritative' makes QuickBooks the source
110+
of truth — RoboSystems-originated entries (manual JEs, schedule drafts) publish to QuickBooks when
111+
executed or at close. 'native' keeps RoboSystems authoritative with no write-back. This is the
112+
explicit operator opt-in for writing to your books of record.
113+
114+
Args:
115+
graph_id (str):
116+
connection_id (str): Unique connection identifier
117+
body (SetWritePolicyRequest): Request to set a connection's source-of-truth write policy.
118+
119+
The explicit operator opt-in for outbound write-back. `hybrid` is omitted
120+
until its code path ships.
121+
122+
Raises:
123+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
124+
httpx.TimeoutException: If the request takes longer than Client.timeout.
125+
126+
Returns:
127+
Response[ConnectionResponse | ErrorResponse | HTTPValidationError]
128+
"""
129+
130+
kwargs = _get_kwargs(
131+
graph_id=graph_id,
132+
connection_id=connection_id,
133+
body=body,
134+
)
135+
136+
response = client.get_httpx_client().request(
137+
**kwargs,
138+
)
139+
140+
return _build_response(client=client, response=response)
141+
142+
143+
def sync(
144+
graph_id: str,
145+
connection_id: str,
146+
*,
147+
client: AuthenticatedClient,
148+
body: SetWritePolicyRequest,
149+
) -> ConnectionResponse | ErrorResponse | HTTPValidationError | None:
150+
"""Set Connection Write Policy
151+
152+
Opt a connection into or out of outbound write-back. 'qb_authoritative' makes QuickBooks the source
153+
of truth — RoboSystems-originated entries (manual JEs, schedule drafts) publish to QuickBooks when
154+
executed or at close. 'native' keeps RoboSystems authoritative with no write-back. This is the
155+
explicit operator opt-in for writing to your books of record.
156+
157+
Args:
158+
graph_id (str):
159+
connection_id (str): Unique connection identifier
160+
body (SetWritePolicyRequest): Request to set a connection's source-of-truth write policy.
161+
162+
The explicit operator opt-in for outbound write-back. `hybrid` is omitted
163+
until its code path ships.
164+
165+
Raises:
166+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
167+
httpx.TimeoutException: If the request takes longer than Client.timeout.
168+
169+
Returns:
170+
ConnectionResponse | ErrorResponse | HTTPValidationError
171+
"""
172+
173+
return sync_detailed(
174+
graph_id=graph_id,
175+
connection_id=connection_id,
176+
client=client,
177+
body=body,
178+
).parsed
179+
180+
181+
async def asyncio_detailed(
182+
graph_id: str,
183+
connection_id: str,
184+
*,
185+
client: AuthenticatedClient,
186+
body: SetWritePolicyRequest,
187+
) -> Response[ConnectionResponse | ErrorResponse | HTTPValidationError]:
188+
"""Set Connection Write Policy
189+
190+
Opt a connection into or out of outbound write-back. 'qb_authoritative' makes QuickBooks the source
191+
of truth — RoboSystems-originated entries (manual JEs, schedule drafts) publish to QuickBooks when
192+
executed or at close. 'native' keeps RoboSystems authoritative with no write-back. This is the
193+
explicit operator opt-in for writing to your books of record.
194+
195+
Args:
196+
graph_id (str):
197+
connection_id (str): Unique connection identifier
198+
body (SetWritePolicyRequest): Request to set a connection's source-of-truth write policy.
199+
200+
The explicit operator opt-in for outbound write-back. `hybrid` is omitted
201+
until its code path ships.
202+
203+
Raises:
204+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
205+
httpx.TimeoutException: If the request takes longer than Client.timeout.
206+
207+
Returns:
208+
Response[ConnectionResponse | ErrorResponse | HTTPValidationError]
209+
"""
210+
211+
kwargs = _get_kwargs(
212+
graph_id=graph_id,
213+
connection_id=connection_id,
214+
body=body,
215+
)
216+
217+
response = await client.get_async_httpx_client().request(**kwargs)
218+
219+
return _build_response(client=client, response=response)
220+
221+
222+
async def asyncio(
223+
graph_id: str,
224+
connection_id: str,
225+
*,
226+
client: AuthenticatedClient,
227+
body: SetWritePolicyRequest,
228+
) -> ConnectionResponse | ErrorResponse | HTTPValidationError | None:
229+
"""Set Connection Write Policy
230+
231+
Opt a connection into or out of outbound write-back. 'qb_authoritative' makes QuickBooks the source
232+
of truth — RoboSystems-originated entries (manual JEs, schedule drafts) publish to QuickBooks when
233+
executed or at close. 'native' keeps RoboSystems authoritative with no write-back. This is the
234+
explicit operator opt-in for writing to your books of record.
235+
236+
Args:
237+
graph_id (str):
238+
connection_id (str): Unique connection identifier
239+
body (SetWritePolicyRequest): Request to set a connection's source-of-truth write policy.
240+
241+
The explicit operator opt-in for outbound write-back. `hybrid` is omitted
242+
until its code path ships.
243+
244+
Raises:
245+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
246+
httpx.TimeoutException: If the request takes longer than Client.timeout.
247+
248+
Returns:
249+
ConnectionResponse | ErrorResponse | HTTPValidationError
250+
"""
251+
252+
return (
253+
await asyncio_detailed(
254+
graph_id=graph_id,
255+
connection_id=connection_id,
256+
client=client,
257+
body=body,
258+
)
259+
).parsed

0 commit comments

Comments
 (0)