Skip to content

Commit 9aa82b6

Browse files
committed
feat: initial sdk-python scaffold
0 parents  commit 9aa82b6

5 files changed

Lines changed: 97 additions & 0 deletions

File tree

.github/workflows/regenerate.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Regenerate Client
2+
3+
on:
4+
repository_dispatch:
5+
types: [openapi-updated]
6+
workflow_dispatch:
7+
8+
jobs:
9+
regenerate:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Fetch merged OpenAPI spec
15+
run: |
16+
curl -sL https://raw.githubusercontent.com/hotdata-dev/www.hotdata.dev/main/api/openapi.yaml \
17+
-o openapi.yaml
18+
19+
- name: Generate client
20+
run: |
21+
npx @openapitools/openapi-generator-cli generate \
22+
-i openapi.yaml \
23+
-g python \
24+
-o generated/ \
25+
--additional-properties=packageName=hotdata,projectName=hotdata
26+
27+
- name: Create PR
28+
uses: peter-evans/create-pull-request@v6
29+
with:
30+
title: "chore: regenerate client from updated OpenAPI spec"
31+
branch: openapi-update
32+
commit-message: "chore: regenerate client from OpenAPI spec"
33+
body: "Auto-generated from updated HotData OpenAPI spec."

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
__pycache__/
2+
*.egg-info/
3+
dist/
4+
build/
5+
.venv/
6+
.env
7+
*.pyc

pyproject.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[project]
2+
name = "hotdata"
3+
version = "0.1.0"
4+
description = "Python client for the HotData API"
5+
requires-python = ">=3.10"
6+
license = "MIT"
7+
dependencies = [
8+
"httpx>=0.27",
9+
"pydantic>=2.0",
10+
]
11+
12+
[build-system]
13+
requires = ["hatchling"]
14+
build-backend = "hatchling.build"
15+
16+
[tool.hatch.build.targets.wheel]
17+
packages = ["src/hotdata"]

src/hotdata/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .client import HotdataClient
2+
3+
__all__ = ["HotdataClient"]

src/hotdata/client.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# This client is a minimal scaffold. It will be replaced by auto-generated
2+
# code from the HotData OpenAPI spec via the regenerate workflow.
3+
4+
from __future__ import annotations
5+
6+
import httpx
7+
8+
9+
class HotdataClient:
10+
"""Minimal HotData API client."""
11+
12+
def __init__(
13+
self,
14+
api_token: str,
15+
workspace_id: str,
16+
base_url: str = "https://api.hotdata.dev",
17+
) -> None:
18+
self.base_url = base_url
19+
self._client = httpx.Client(
20+
base_url=base_url,
21+
headers={
22+
"Authorization": f"Bearer {api_token}",
23+
"X-Workspace-Id": workspace_id,
24+
},
25+
)
26+
27+
def health(self) -> httpx.Response:
28+
return self._client.get("/health")
29+
30+
def __enter__(self) -> HotdataClient:
31+
return self
32+
33+
def __exit__(self, *args: object) -> None:
34+
self._client.close()
35+
36+
def close(self) -> None:
37+
self._client.close()

0 commit comments

Comments
 (0)