Client¶
The two clients are twins — identical surface, the only difference is await.
SepalClient¶
pysepal_api.SepalClient ¶
SepalClient(
*,
session_id: str | None = None,
module_name: str | None = None,
auth: Auth | None = None,
auth_mode: AuthMode = "auto",
base_url: str | None = None,
timeout: float | Timeout = 30.0,
verify: bool | None = None
)
Synchronous HTTP client for SEPAL services.
Source code in src/pysepal_api/client.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
results_path
instance-attribute
¶
results_path: PurePosixPath | None = (
module_results_path(module_name)
if module_name
else None
)
create
classmethod
¶
create(
*,
session_id: str | None = None,
module_name: str | None = None,
auth: Auth | None = None,
auth_mode: AuthMode = "auto",
base_url: str | None = None,
timeout: float | Timeout = 30.0,
verify: bool | None = None
) -> SepalClient
Build a ready-to-use client. Pure.
results_path is derived arithmetically from module_name; call
ensure_results_dir() off the UI render path to materialise it.
Source code in src/pysepal_api/client.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | |
ensure_results_dir ¶
ensure_results_dir() -> PurePosixPath | None
Create the module results directory on the server.
Network I/O — never call this on a UI render path, and call it once at
startup rather than before every write: it re-issues the request each
time. Returns the absolute results path, or None when the client
has no module_name. Idempotent: files.mkdir swallows 409/403.
Source code in src/pysepal_api/client.py
155 156 157 158 159 160 161 162 163 164 165 | |
request ¶
request(
method: str, url: str, **kwargs: Any
) -> httpx.Response
Issue an arbitrary authenticated request to any SEPAL route.
The typed endpoints (files, tasks, recipes) cover the common
cases; this is the escape hatch for routes the library doesn't model.
Returns the raw httpx.Response with errors mapped to typed exceptions.
kwargs are forwarded to httpx.Client.build_request (params,
json, content, files, headers, …).
Source code in src/pysepal_api/client.py
167 168 169 170 171 172 173 174 175 176 | |
get ¶
get(url: str, **kwargs: Any) -> httpx.Response
Source code in src/pysepal_api/client.py
178 179 | |
post ¶
post(url: str, **kwargs: Any) -> httpx.Response
Source code in src/pysepal_api/client.py
181 182 | |
put ¶
put(url: str, **kwargs: Any) -> httpx.Response
Source code in src/pysepal_api/client.py
184 185 | |
delete ¶
delete(url: str, **kwargs: Any) -> httpx.Response
Source code in src/pysepal_api/client.py
187 188 | |
close ¶
close() -> None
Source code in src/pysepal_api/client.py
190 191 | |
AsyncSepalClient¶
pysepal_api.AsyncSepalClient ¶
AsyncSepalClient(
*,
session_id: str | None = None,
module_name: str | None = None,
auth: Auth | None = None,
auth_mode: AuthMode = "auto",
base_url: str | None = None,
timeout: float | Timeout = 30.0,
verify: bool | None = None
)
Asynchronous twin of SepalClient.
Source code in src/pysepal_api/client.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | |
results_path
instance-attribute
¶
results_path: PurePosixPath | None = (
module_results_path(module_name)
if module_name
else None
)
create
classmethod
¶
create(
*,
session_id: str | None = None,
module_name: str | None = None,
auth: Auth | None = None,
auth_mode: AuthMode = "auto",
base_url: str | None = None,
timeout: float | Timeout = 30.0,
verify: bool | None = None
) -> _AwaitableClient
Build a ready-to-use client. Pure. The result can be awaited or used as an async context manager — both spellings work:
sepal = await AsyncSepalClient.create(...) # long-lived
async with AsyncSepalClient.create(...) as sepal: # scoped
results_path is derived arithmetically from module_name; call
ensure_results_dir() off the UI render path to materialise it.
Source code in src/pysepal_api/client.py
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | |
ensure_results_dir
async
¶
ensure_results_dir() -> PurePosixPath | None
Create the module results directory on the server.
Network I/O — never call this on a UI render path, and call it once at
startup rather than before every write: it re-issues the request each
time. Returns the absolute results path, or None when the client
has no module_name. Idempotent: files.mkdir swallows 409/403.
Source code in src/pysepal_api/client.py
273 274 275 276 277 278 279 280 281 282 283 | |
request
async
¶
request(
method: str, url: str, **kwargs: Any
) -> httpx.Response
Async twin of SepalClient.request. Escape hatch for unmodeled routes.
Source code in src/pysepal_api/client.py
285 286 287 288 289 | |
get
async
¶
get(url: str, **kwargs: Any) -> httpx.Response
Source code in src/pysepal_api/client.py
291 292 | |
post
async
¶
post(url: str, **kwargs: Any) -> httpx.Response
Source code in src/pysepal_api/client.py
294 295 | |
put
async
¶
put(url: str, **kwargs: Any) -> httpx.Response
Source code in src/pysepal_api/client.py
297 298 | |
delete
async
¶
delete(url: str, **kwargs: Any) -> httpx.Response
Source code in src/pysepal_api/client.py
300 301 | |
aclose
async
¶
aclose() -> None
Source code in src/pysepal_api/client.py
303 304 | |