render-lab-tasks-http 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,11 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.py[cod]
4
+ .pytest_cache/
5
+ .mypy_cache/
6
+ .ruff_cache/
7
+ dist/
8
+ *.egg-info/
9
+ .env
10
+ .env.*
11
+ !.env.example
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Render Lab
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,68 @@
1
+ Metadata-Version: 2.5
2
+ Name: render-lab-tasks-http
3
+ Version: 0.1.0
4
+ Summary: http tasks for Render Workflows
5
+ Project-URL: Repository, https://github.com/render-lab/render-tasks-python
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Requires-Python: >=3.12
9
+ Requires-Dist: httpx<0.29,>=0.28
10
+ Requires-Dist: render-lab-tasks-core<0.2,>=0.1.1
11
+ Requires-Dist: render==1.0.1
12
+ Description-Content-Type: text/markdown
13
+
14
+ # render-lab-tasks-http
15
+
16
+ Python port of all 6 registered tasks in the pinned TypeScript pack at
17
+ `45f9c2d44bd28e01ae9813e0d2ff56ee6c533816`. Python 3.12+.
18
+
19
+ Install this distribution and its dependencies:
20
+
21
+ ```sh
22
+ pip install render-lab-tasks-http==0.1.0
23
+ ```
24
+
25
+ Import definitions from `render_lab_tasks_http.tasks`; combine `app` objects
26
+ with `Workflows.from_workflows(...)`. JSON fields retain TS spelling; functions
27
+ use snake_case. Package root imports are inert.
28
+
29
+ ## Tasks
30
+
31
+ | Registered name | Python export (also exposes `_impl`) |
32
+ | --- | --- |
33
+ | `http.download` | `download` |
34
+ | `http.graphql` | `graphql` |
35
+ | `http.paginate` | `paginate` |
36
+ | `http.poll` | `poll` |
37
+ | `http.request` | `request` |
38
+ | `http.webhookVerify` | `webhook_verify` |
39
+
40
+ ## Dependencies and retries
41
+
42
+ Raw implementations accept context first and keyword-only `deps`. The `.client`
43
+ module exports typed `Port`, `Deps`, and `Client` classes. Inject a fake port, or
44
+ pass a caller-owned `httpx.AsyncClient` to `Client`. Default dependencies close
45
+ their client after one operation. Credentials resolve at first use. Transport
46
+ retries are disabled; `retry.py` owns durable policies. DTO types are in `.types`.
47
+ Requires core >=0.1.1.
48
+
49
+ ## Environment
50
+
51
+ No environment variables. Caller-provided headers carry authentication.
52
+
53
+ ## Verification and limitations
54
+
55
+ 4xx (including 429) are returned; network failures and 5xx raise. Polling makes one
56
+ request per attempt and requires a nonempty predicate. Only application/json
57
+ responses populate `json`. `timeoutMs` and `intervalHintMs` remain TS compatibility
58
+ hints: the default transport uses 30 seconds and the durable poll policy uses five
59
+ seconds. Paginate follows Link headers for at most maxPages (default 10).
60
+ Download decodes UTF-8 text then base64-encodes it; it is not a binary file API.
61
+ Python rejects download output above 1 MiB. Signature verification is HMAC only;
62
+ the caller owns replay protection. URLs and pagination links must be trusted.
63
+
64
+ Shared fixtures execute the actual pinned TS implementations and compare Python
65
+ outputs and requests. Sanity's SDK calls are translated into separately asserted
66
+ REST requests. These are hermetic checks, not real account or hosted verification.
67
+ See [the testing backlog](https://github.com/render-lab/render-tasks-python/issues/1)
68
+ and the root verification tracker. Licensed under MIT.
@@ -0,0 +1,55 @@
1
+ # render-lab-tasks-http
2
+
3
+ Python port of all 6 registered tasks in the pinned TypeScript pack at
4
+ `45f9c2d44bd28e01ae9813e0d2ff56ee6c533816`. Python 3.12+.
5
+
6
+ Install this distribution and its dependencies:
7
+
8
+ ```sh
9
+ pip install render-lab-tasks-http==0.1.0
10
+ ```
11
+
12
+ Import definitions from `render_lab_tasks_http.tasks`; combine `app` objects
13
+ with `Workflows.from_workflows(...)`. JSON fields retain TS spelling; functions
14
+ use snake_case. Package root imports are inert.
15
+
16
+ ## Tasks
17
+
18
+ | Registered name | Python export (also exposes `_impl`) |
19
+ | --- | --- |
20
+ | `http.download` | `download` |
21
+ | `http.graphql` | `graphql` |
22
+ | `http.paginate` | `paginate` |
23
+ | `http.poll` | `poll` |
24
+ | `http.request` | `request` |
25
+ | `http.webhookVerify` | `webhook_verify` |
26
+
27
+ ## Dependencies and retries
28
+
29
+ Raw implementations accept context first and keyword-only `deps`. The `.client`
30
+ module exports typed `Port`, `Deps`, and `Client` classes. Inject a fake port, or
31
+ pass a caller-owned `httpx.AsyncClient` to `Client`. Default dependencies close
32
+ their client after one operation. Credentials resolve at first use. Transport
33
+ retries are disabled; `retry.py` owns durable policies. DTO types are in `.types`.
34
+ Requires core >=0.1.1.
35
+
36
+ ## Environment
37
+
38
+ No environment variables. Caller-provided headers carry authentication.
39
+
40
+ ## Verification and limitations
41
+
42
+ 4xx (including 429) are returned; network failures and 5xx raise. Polling makes one
43
+ request per attempt and requires a nonempty predicate. Only application/json
44
+ responses populate `json`. `timeoutMs` and `intervalHintMs` remain TS compatibility
45
+ hints: the default transport uses 30 seconds and the durable poll policy uses five
46
+ seconds. Paginate follows Link headers for at most maxPages (default 10).
47
+ Download decodes UTF-8 text then base64-encodes it; it is not a binary file API.
48
+ Python rejects download output above 1 MiB. Signature verification is HMAC only;
49
+ the caller owns replay protection. URLs and pagination links must be trusted.
50
+
51
+ Shared fixtures execute the actual pinned TS implementations and compare Python
52
+ outputs and requests. Sanity's SDK calls are translated into separately asserted
53
+ REST requests. These are hermetic checks, not real account or hosted verification.
54
+ See [the testing backlog](https://github.com/render-lab/render-tasks-python/issues/1)
55
+ and the root verification tracker. Licensed under MIT.
@@ -0,0 +1,22 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.27,<2"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "render-lab-tasks-http"
7
+ version = "0.1.0"
8
+ description = "http tasks for Render Workflows"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.12"
13
+ dependencies = ["render==1.0.1", "httpx>=0.28,<0.29", "render-lab-tasks-core>=0.1.1,<0.2"]
14
+
15
+ [project.urls]
16
+ Repository = "https://github.com/render-lab/render-tasks-python"
17
+
18
+ [tool.uv.sources]
19
+ render-lab-tasks-core = { workspace = true }
20
+
21
+ [tool.hatch.build.targets.wheel]
22
+ packages = ["src/render_lab_tasks_http"]
@@ -0,0 +1 @@
1
+ """Import .tasks explicitly to register durable tasks."""
@@ -0,0 +1,3 @@
1
+ from render import Workflows
2
+
3
+ app = Workflows()
@@ -0,0 +1,228 @@
1
+ """Injected vendor interface and one-attempt async HTTP adapter."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import base64
6
+ import hmac
7
+ import json
8
+ import os
9
+ import re
10
+ from collections.abc import AsyncIterator, Mapping
11
+ from contextlib import asynccontextmanager
12
+ from dataclasses import dataclass
13
+ from typing import Any, Protocol, cast
14
+
15
+ import httpx
16
+ from render_lab_tasks_core.bounded import MAX_INLINE_MEDIA_BYTES, assert_byte_limit
17
+ from render_lab_tasks_core.http import ApiError, loads_json, pick, query
18
+
19
+ from . import types as t
20
+
21
+ _MISSING = object()
22
+
23
+
24
+ def dot_path(value: Any, path: str) -> Any:
25
+ if not path:
26
+ return value
27
+ for part in path.split("."):
28
+ if isinstance(value, dict):
29
+ value = value.get(part, _MISSING)
30
+ elif isinstance(value, list) and part.isdigit() and int(part) < len(value):
31
+ value = value[int(part)]
32
+ else:
33
+ return _MISSING
34
+ return value
35
+
36
+
37
+ def json_equal(left: Any, right: Any) -> bool:
38
+ """JSON.stringify equality: JS numbers, boolean distinction, and object order."""
39
+ if isinstance(left, bool) or isinstance(right, bool):
40
+ return type(left) is type(right) and left == right
41
+ if isinstance(left, (int, float)) and isinstance(right, (int, float)):
42
+ return float(left) == float(right)
43
+ if isinstance(left, list) and isinstance(right, list):
44
+ return len(left) == len(right) and all(
45
+ json_equal(a, b) for a, b in zip(left, right, strict=True)
46
+ )
47
+ if isinstance(left, dict) and isinstance(right, dict):
48
+
49
+ def keys(value: dict[str, Any]) -> list[str]:
50
+ indices = [
51
+ k
52
+ for k in value
53
+ if k.isascii() and k.isdigit() and str(int(k)) == k and int(k) < 4294967295
54
+ ]
55
+ return sorted(indices, key=int) + [k for k in value if k not in indices]
56
+
57
+ return keys(left) == keys(right) and all(json_equal(v, right[k]) for k, v in left.items())
58
+ return type(left) is type(right) and left == right
59
+
60
+
61
+ class Port(Protocol):
62
+ async def download(self, input: t.DownloadInput) -> t.DownloadResult: ...
63
+ async def graphql(self, input: t.GraphqlInput) -> t.GraphqlResult: ...
64
+ async def paginate(self, input: t.PaginateInput) -> t.PaginateResult: ...
65
+ async def poll(self, input: t.PollInput) -> t.PollResult: ...
66
+ async def request(self, input: t.RequestInput) -> t.RequestResult: ...
67
+ async def webhook_verify(self, input: t.WebhookVerifyInput) -> t.WebhookVerifyResult: ...
68
+
69
+
70
+ @dataclass(frozen=True)
71
+ class Deps:
72
+ http: Port
73
+
74
+
75
+ class Client:
76
+ def __init__(self, http: httpx.AsyncClient, env: Mapping[str, str] | None = None) -> None:
77
+ self.env = os.environ if env is None else env
78
+ self.http = http
79
+
80
+ async def _fetch(self, input: Mapping[str, Any], *, check: bool = True) -> httpx.Response:
81
+ url = input["url"]
82
+ if input.get("query"):
83
+ url += ("&" if "?" in url else "?") + query(input["query"])
84
+ headers = httpx.Headers(input.get("headers", {}))
85
+ body = input.get("body")
86
+ if "body" in input and not isinstance(body, str):
87
+ body = json.dumps(body, ensure_ascii=False, separators=(",", ":"), allow_nan=False)
88
+ if "content-type" not in headers:
89
+ headers["content-type"] = "application/json"
90
+ response = await self.http.request(
91
+ input.get("method", "GET"), url, headers=headers, content=body, follow_redirects=True
92
+ )
93
+ if check and response.status_code >= 500:
94
+ raise ApiError(
95
+ response.status_code,
96
+ f"http.request {input.get('method', 'GET')} {url} failed: "
97
+ f"{response.status_code} {response.text}".strip(),
98
+ )
99
+ return response
100
+
101
+ async def request(self, input: t.RequestInput) -> t.RequestResult:
102
+ response = await self._fetch(input)
103
+ result: t.RequestResult = {
104
+ "status": response.status_code,
105
+ "ok": response.is_success,
106
+ "headers": dict(response.headers),
107
+ "body": response.text,
108
+ }
109
+ if "application/json" in response.headers.get("content-type", "").lower():
110
+ try:
111
+ result["json"] = loads_json(response.content)
112
+ except ValueError:
113
+ pass
114
+ return result
115
+
116
+ async def poll(self, input: t.PollInput) -> t.PollResult:
117
+ response = await self._fetch(input, check=False)
118
+ match = input["until"]
119
+ result: t.PollResult = {
120
+ "status": response.status_code,
121
+ "body": response.text,
122
+ "matched": True,
123
+ }
124
+ parsed: Any = _MISSING
125
+ try:
126
+ if "application/json" not in response.headers.get("content-type", "").lower():
127
+ raise ValueError("Not JSON")
128
+ parsed = loads_json(response.content)
129
+ result["json"] = parsed
130
+ except ValueError:
131
+ pass
132
+ matches = bool(match)
133
+ if "status" in match:
134
+ matches = matches and response.status_code == match["status"]
135
+ if "jsonEquals" in match:
136
+ condition = match["jsonEquals"]
137
+ value = dot_path(parsed, condition["path"])
138
+ matches = matches and value is not _MISSING and json_equal(value, condition["value"])
139
+ if not matches:
140
+ raise RuntimeError(f"http.poll: condition not met (status {response.status_code})")
141
+ return result
142
+
143
+ async def graphql(self, input: t.GraphqlInput) -> t.GraphqlResult:
144
+ response = await self._fetch(
145
+ {
146
+ "url": input["url"],
147
+ "method": "POST",
148
+ "headers": input.get("headers", {}),
149
+ "body": pick(input, "query", "variables", "operationName"),
150
+ }
151
+ )
152
+ try:
153
+ data = loads_json(response.content)
154
+ except ValueError:
155
+ data = {}
156
+ return cast(t.GraphqlResult, pick(data if isinstance(data, dict) else {}, "data", "errors"))
157
+
158
+ async def paginate(self, input: t.PaginateInput) -> t.PaginateResult:
159
+ url = input["url"]
160
+ pages: list[t.Json] = []
161
+ items: list[t.Json] = []
162
+ count = 0
163
+ while url and count < input.get("maxPages", 10):
164
+ args: dict[str, Any] = {"url": url, "headers": input.get("headers", {})}
165
+ if count == 0:
166
+ args["query"] = input.get("query", {})
167
+ response = await self._fetch(args)
168
+ try:
169
+ parsed = loads_json(response.content)
170
+ pages.append(parsed)
171
+ if "itemsPath" in input:
172
+ found = dot_path(parsed, input["itemsPath"])
173
+ if isinstance(found, list):
174
+ items.extend(found)
175
+ except ValueError:
176
+ pass
177
+ url = ""
178
+ for link in response.headers.get("link", "").split(","):
179
+ found_link = re.search(r"<([^>]+)>\s*;\s*(.+)", link)
180
+ if found_link and re.search(r'rel\s*=\s*"?\s*next\s*"?', found_link[2], re.I):
181
+ url = found_link[1]
182
+ break
183
+ count += 1
184
+ return {
185
+ "pages": pages,
186
+ "items": items,
187
+ "count": len(items) if "itemsPath" in input else len(pages),
188
+ }
189
+
190
+ async def download(self, input: t.DownloadInput) -> t.DownloadResult:
191
+ response = await self._fetch(input)
192
+ data = response.text.encode("utf-8")
193
+ assert_byte_limit("http.download content", data, MAX_INLINE_MEDIA_BYTES)
194
+ return {
195
+ "url": input["url"],
196
+ "status": response.status_code,
197
+ "contentType": response.headers.get("content-type", ""),
198
+ "base64": base64.b64encode(data).decode(),
199
+ "bytes": len(data),
200
+ }
201
+
202
+ async def webhook_verify(self, input: t.WebhookVerifyInput) -> t.WebhookVerifyResult:
203
+ algorithm = input.get("algorithm", "sha256")
204
+ if algorithm not in ("sha256", "sha1"):
205
+ raise ValueError("algorithm must be sha256 or sha1")
206
+ digest = hmac.new(input["secret"].encode(), input["payload"].encode(), algorithm)
207
+ signature = (
208
+ digest.hexdigest()
209
+ if input.get("scheme", "hex") == "hex"
210
+ else base64.b64encode(digest.digest()).decode()
211
+ )
212
+ return {"valid": hmac.compare_digest(signature.encode(), input["signature"].encode())}
213
+
214
+
215
+ @asynccontextmanager
216
+ async def dependencies(deps: Deps | None) -> AsyncIterator[Deps]:
217
+ if deps is not None:
218
+ yield deps
219
+ else:
220
+ async with httpx.AsyncClient(
221
+ timeout=30, transport=httpx.AsyncHTTPTransport(retries=0)
222
+ ) as http:
223
+ yield Deps(http=Client(http))
224
+
225
+
226
+ HttpPort = Port
227
+ HttpClient = Client
228
+ HttpDeps = Deps
@@ -0,0 +1,18 @@
1
+ from render import TaskContext
2
+
3
+ from ._app import app
4
+ from .client import Deps, dependencies
5
+ from .retry import HTTP_RETRY
6
+ from .types import DownloadInput, DownloadResult
7
+
8
+
9
+ async def download_impl(
10
+ ctx: TaskContext, input: DownloadInput, *, deps: Deps | None = None
11
+ ) -> DownloadResult:
12
+ async with dependencies(deps) as resolved:
13
+ return await resolved.http.download(input)
14
+
15
+
16
+ @app.task(name="http.download", retry=HTTP_RETRY)
17
+ async def download(ctx: TaskContext, input: DownloadInput) -> DownloadResult:
18
+ return await download_impl(ctx, input)
@@ -0,0 +1,18 @@
1
+ from render import TaskContext
2
+
3
+ from ._app import app
4
+ from .client import Deps, dependencies
5
+ from .retry import HTTP_RETRY
6
+ from .types import GraphqlInput, GraphqlResult
7
+
8
+
9
+ async def graphql_impl(
10
+ ctx: TaskContext, input: GraphqlInput, *, deps: Deps | None = None
11
+ ) -> GraphqlResult:
12
+ async with dependencies(deps) as resolved:
13
+ return await resolved.http.graphql(input)
14
+
15
+
16
+ @app.task(name="http.graphql", retry=HTTP_RETRY)
17
+ async def graphql(ctx: TaskContext, input: GraphqlInput) -> GraphqlResult:
18
+ return await graphql_impl(ctx, input)
@@ -0,0 +1,18 @@
1
+ from render import TaskContext
2
+
3
+ from ._app import app
4
+ from .client import Deps, dependencies
5
+ from .retry import HTTP_RETRY
6
+ from .types import PaginateInput, PaginateResult
7
+
8
+
9
+ async def paginate_impl(
10
+ ctx: TaskContext, input: PaginateInput, *, deps: Deps | None = None
11
+ ) -> PaginateResult:
12
+ async with dependencies(deps) as resolved:
13
+ return await resolved.http.paginate(input)
14
+
15
+
16
+ @app.task(name="http.paginate", retry=HTTP_RETRY)
17
+ async def paginate(ctx: TaskContext, input: PaginateInput) -> PaginateResult:
18
+ return await paginate_impl(ctx, input)
@@ -0,0 +1,16 @@
1
+ from render import TaskContext
2
+
3
+ from ._app import app
4
+ from .client import Deps, dependencies
5
+ from .retry import POLL_RETRY
6
+ from .types import PollInput, PollResult
7
+
8
+
9
+ async def poll_impl(ctx: TaskContext, input: PollInput, *, deps: Deps | None = None) -> PollResult:
10
+ async with dependencies(deps) as resolved:
11
+ return await resolved.http.poll(input)
12
+
13
+
14
+ @app.task(name="http.poll", retry=POLL_RETRY)
15
+ async def poll(ctx: TaskContext, input: PollInput) -> PollResult:
16
+ return await poll_impl(ctx, input)
@@ -0,0 +1,18 @@
1
+ from render import TaskContext
2
+
3
+ from ._app import app
4
+ from .client import Deps, dependencies
5
+ from .retry import HTTP_RETRY
6
+ from .types import RequestInput, RequestResult
7
+
8
+
9
+ async def request_impl(
10
+ ctx: TaskContext, input: RequestInput, *, deps: Deps | None = None
11
+ ) -> RequestResult:
12
+ async with dependencies(deps) as resolved:
13
+ return await resolved.http.request(input)
14
+
15
+
16
+ @app.task(name="http.request", retry=HTTP_RETRY)
17
+ async def request(ctx: TaskContext, input: RequestInput) -> RequestResult:
18
+ return await request_impl(ctx, input)
@@ -0,0 +1,5 @@
1
+ from render import Retry
2
+
3
+ HTTP_RETRY = Retry(max_retries=3, wait_duration_ms=1_000, backoff_scaling=2)
4
+ POLL_RETRY = Retry(max_retries=360, wait_duration_ms=5_000, backoff_scaling=1)
5
+ NO_RETRY = Retry(max_retries=0, wait_duration_ms=0, backoff_scaling=1)
@@ -0,0 +1,23 @@
1
+ from ._app import app
2
+ from .download import download, download_impl
3
+ from .graphql import graphql, graphql_impl
4
+ from .paginate import paginate, paginate_impl
5
+ from .poll import poll, poll_impl
6
+ from .request import request, request_impl
7
+ from .webhook_verify import webhook_verify, webhook_verify_impl
8
+
9
+ __all__ = [
10
+ "app",
11
+ "download",
12
+ "download_impl",
13
+ "graphql",
14
+ "graphql_impl",
15
+ "paginate",
16
+ "paginate_impl",
17
+ "poll",
18
+ "poll_impl",
19
+ "request",
20
+ "request_impl",
21
+ "webhook_verify",
22
+ "webhook_verify_impl",
23
+ ]
@@ -0,0 +1,104 @@
1
+ """JSON contracts ported from the pinned TypeScript pack."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Literal, NotRequired, TypedDict
6
+
7
+
8
+ class PollMatchJsonEquals(TypedDict):
9
+ path: str
10
+ value: Json
11
+
12
+
13
+ type Json = str | float | bool | None | list[Json] | dict[str, Json]
14
+
15
+
16
+ class RequestInput(TypedDict):
17
+ method: NotRequired[
18
+ Literal["GET"] | Literal["POST"] | Literal["PUT"] | Literal["PATCH"] | Literal["DELETE"]
19
+ ]
20
+ url: str
21
+ headers: NotRequired[dict[str, str]]
22
+ query: NotRequired[dict[str, str]]
23
+ body: NotRequired[Json | str]
24
+ timeoutMs: NotRequired[float]
25
+
26
+
27
+ class RequestResult(TypedDict):
28
+ status: float
29
+ ok: bool
30
+ headers: dict[str, str]
31
+ body: str
32
+ json: NotRequired[Json]
33
+
34
+
35
+ class PollInput(TypedDict):
36
+ url: str
37
+ method: NotRequired[Literal["GET"] | Literal["POST"]]
38
+ headers: NotRequired[dict[str, str]]
39
+ until: PollMatch
40
+ intervalHintMs: NotRequired[float]
41
+
42
+
43
+ class PollMatch(TypedDict):
44
+ status: NotRequired[float]
45
+ jsonEquals: NotRequired[PollMatchJsonEquals]
46
+
47
+
48
+ class PollResult(TypedDict):
49
+ status: float
50
+ body: str
51
+ json: NotRequired[Json]
52
+ matched: Literal[True]
53
+
54
+
55
+ class GraphqlInput(TypedDict):
56
+ url: str
57
+ query: str
58
+ variables: NotRequired[dict[str, Json]]
59
+ headers: NotRequired[dict[str, str]]
60
+ operationName: NotRequired[str]
61
+
62
+
63
+ class GraphqlResult(TypedDict):
64
+ data: NotRequired[Json]
65
+ errors: NotRequired[Json]
66
+
67
+
68
+ class PaginateInput(TypedDict):
69
+ url: str
70
+ query: NotRequired[dict[str, str]]
71
+ headers: NotRequired[dict[str, str]]
72
+ maxPages: NotRequired[float]
73
+ itemsPath: NotRequired[str]
74
+
75
+
76
+ class PaginateResult(TypedDict):
77
+ pages: list[Json]
78
+ items: list[Json]
79
+ count: float
80
+
81
+
82
+ class DownloadInput(TypedDict):
83
+ url: str
84
+ headers: NotRequired[dict[str, str]]
85
+
86
+
87
+ class DownloadResult(TypedDict):
88
+ url: str
89
+ status: float
90
+ contentType: str
91
+ base64: str
92
+ bytes: float
93
+
94
+
95
+ class WebhookVerifyInput(TypedDict):
96
+ payload: str
97
+ signature: str
98
+ secret: str
99
+ algorithm: NotRequired[Literal["sha256"] | Literal["sha1"]]
100
+ scheme: NotRequired[Literal["hex"] | Literal["base64"]]
101
+
102
+
103
+ class WebhookVerifyResult(TypedDict):
104
+ valid: bool
@@ -0,0 +1,18 @@
1
+ from render import TaskContext
2
+
3
+ from ._app import app
4
+ from .client import Deps, dependencies
5
+ from .retry import NO_RETRY
6
+ from .types import WebhookVerifyInput, WebhookVerifyResult
7
+
8
+
9
+ async def webhook_verify_impl(
10
+ ctx: TaskContext, input: WebhookVerifyInput, *, deps: Deps | None = None
11
+ ) -> WebhookVerifyResult:
12
+ async with dependencies(deps) as resolved:
13
+ return await resolved.http.webhook_verify(input)
14
+
15
+
16
+ @app.task(name="http.webhookVerify", retry=NO_RETRY)
17
+ async def webhook_verify(ctx: TaskContext, input: WebhookVerifyInput) -> WebhookVerifyResult:
18
+ return await webhook_verify_impl(ctx, input)