Lapidary Reference
ClientBase
Bases: ABC
Source code in docs/lapidary/src/lapidary/runtime/client_base.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
|
lapidary_authenticate(*auth_args, **auth_kwargs)
Register named Auth instances for future use with methods that require authentication.
Source code in docs/lapidary/src/lapidary/runtime/client_base.py
55 56 57 58 59 60 61 |
|
lapidary_deauthenticate(*sec_names)
Remove reference to a given Auth instance. Calling with no parameters removes all references
Source code in docs/lapidary/src/lapidary/runtime/client_base.py
63 64 65 66 67 |
|
FormExplode
Bases: MultimapSerializationStyle
Source code in docs/lapidary/src/lapidary/runtime/model/param_serialization.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
|
serialize_object(_name, value)
classmethod
Disregard name, return a map of {key: value}
Source code in docs/lapidary/src/lapidary/runtime/model/param_serialization.py
189 190 191 192 |
|
HttpErrorResponse
Bases: Generic[Body, Headers]
, LapidaryResponseError
Base error class for declared HTTP error responses - 4XX & 5XX. Python doesn't fully support parametrized exception types, but extending types can concretize it.
Source code in docs/lapidary/src/lapidary/runtime/model/error.py
26 27 28 29 30 31 32 33 34 35 36 |
|
LapidaryResponseError
Bases: LapidaryError
Base class for errors that wrap the response
Source code in docs/lapidary/src/lapidary/runtime/model/error.py
18 19 |
|
Metadata
Bases: WebArg
Annotation for models that hold other WebArg fields
Source code in docs/lapidary/src/lapidary/runtime/annotations.py
21 22 |
|
UnexpectedResponse
Bases: LapidaryResponseError
Base error class for undeclared responses
Source code in docs/lapidary/src/lapidary/runtime/model/error.py
39 40 41 42 43 44 |
|
iter_pages(fn, cursor_param_name, get_cursor)
Create a function that returns an async iterator over pages from the async operation function :param:fn
.
The returned function can be called with the same parameters as :param:fn
(except for the cursor parameter),
and returns an async iterator that yields results from :param:fn
, handling pagination automatically.
The function :param:fn
will be called initially without the cursor parameter and then called with the cursor parameter
as long as :param:get_cursor
can extract a cursor from the result.
Example:
.. code:: python
async for page in iter_pages(client.fn, 'cursor', extractor_fn)(parameter=value):
# Process page
Typically, an API will use the same paging pattern for all operations supporting it, so it's a good idea to write a shortcut function:
.. code:: python
from lapidary.runtime import iter_pages as _iter_pages
def iter_pages[P, R](fn: Callable[P, Awaitable[R]]) -> Callable[P, AsyncIterable[R]]:
return _iter_pages(fn, 'cursor', lambda result: ...)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fn |
Callable[P, Awaitable[R]]
|
An async function that retrieves a page of data. |
required |
cursor_param_name |
str
|
The name of the cursor parameter in :param: |
required |
get_cursor |
Callable[[R], Optional[C]]
|
A function that extracts a cursor value from the result of :param: |
required |
Source code in docs/lapidary/src/lapidary/runtime/paging.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
|