Skip to content

Commit f68924a

Browse files
refactor(client): issue requests through a generated transport
The HTTP layer is now generated from the committed OpenAPI spec rather than hand-written, so URLs, query names and multipart encoding follow the spec instead of being restated here. tools/gen_sdk.sh regenerates it with a pinned generator; the tree is committed but never hand-edited. The public surface is unchanged on purpose: same constructor, same return dicts, same exceptions. What was deliberately kept rather than rewritten: - The retry policy, verbatim. Attempt counts, Retry-After on 429, exponential jitter, file rewinding, and the sync/async POST distinction are the contract, and nothing about the transport should restate them. - Transport failures are translated to their `requests` equivalents inside the retried call, not around it, so the retry policy still sees the exception types it is configured to retry. `requests` stays a dependency for those classes because callers catch them by name. - Response fields are read from the JSON body, never from a generated response model: a model exists only for the statuses the spec declares, and error bodies are typed too loosely to read. Only the parameters this client sets are sent. The generated builders write every declared default into a request, and sending a default is not the same as omitting it — it pins a value the server would otherwise choose, and the two diverge as soon as the server's default changes. No transport timeout is configured, as before: api_timeout selects a backend execution mode and is not a socket timeout.
1 parent 79f8d09 commit f68924a

26 files changed

Lines changed: 2739 additions & 100 deletions

‎.gitattributes‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/unstract/api_deployments/sdk_docstudio/** linguist-generated=true

‎pyproject.toml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ authors = [
66
{name = "Zipstack Inc", email = "devsupport@zipstack.com"},
77
]
88
dependencies = [
9+
# The transport layer is generated against httpx; attrs backs its models.
10+
"httpx>=0.27",
11+
"attrs>=23.2",
12+
# Kept for its exception classes, which callers catch by name.
913
"requests>=2.32.3",
1014
"tenacity>=8.2.0",
1115
"click>=8.1",
@@ -64,6 +68,9 @@ lint = [
6468

6569
[tool.ruff]
6670
line-length = 88
71+
# Generated code is overwritten wholesale by tools/gen_sdk.sh, so a lint finding
72+
# there can never be fixed in place.
73+
extend-exclude = ["src/unstract/api_deployments/sdk_docstudio"]
6774

6875
[tool.ruff.lint]
6976
select = ["E", "F", "W", "I"]

0 commit comments

Comments
 (0)