Python API Reference¶
These pages document the authored Python API that provider authors use to build Gestalt integrations, authentication providers, caches, and S3 backends.
Public authoring surface for Gestalt Python providers.
The package is published as gestalt-sdk and imported as gestalt.
Provider authors typically build integrations around the re-exported symbols
documented in the Sphinx reference:
from gestalt import Model, Plugin, operation
class SearchInput(Model):
query: str
plugin = Plugin("search")
@plugin.operation(title="Search")
def search(params: SearchInput):
return {"query": params.query}
Generated protobuf bindings remain available under gestalt.gen, but the
authored reference documentation focuses on the handwritten SDK surface.
The supported import surface is the top-level gestalt package:
from gestalt import Model, Plugin, Cache, IndexedDB, S3
Generated protobuf bindings remain available through gestalt.gen, but
the authored reference below focuses on the handwritten SDK API that provider
authors use directly.
Catalog protocol types¶
These top-level exports are generated protocol message types that the SDK re-exports for lower-level catalog integration work.
- class Catalog¶
- class CatalogOperation¶
- class CatalogParameter¶
- class OperationAnnotations¶
Provider interfaces¶
Runtime kinds supported by the Python SDK. |
|
Descriptive metadata returned by |
|
Base interface shared by provider-style runtimes. |
|
Optional mixin for providers that expose descriptive metadata. |
|
Optional mixin for providers that support health checks. |
|
Optional mixin for providers that emit startup warnings. |
|
Optional mixin for providers with explicit shutdown work. |
|
Wrap a provider and registration callback for integration runtimes. |
|
Base class for authentication providers. |
|
Optional mixin for providers that validate external bearer tokens. |
|
Optional mixin for providers that control session lifetimes. |
|
Base class for secret-provider runtimes. |
|
Base class for cache-provider runtimes. |
|
Base class for S3-compatible object store runtimes. |
|
- class ProviderMetadata(kind, name='', display_name='', description='', version='')[source]¶
Descriptive metadata returned by
MetadataProvider.- Parameters:
kind (ProviderKind | str)
name (str)
display_name (str)
description (str)
version (str)
- class MetadataProvider[source]¶
Optional mixin for providers that expose descriptive metadata.
- class PluginProviderAdapter(kind, provider, register_services)[source]¶
Wrap a provider and registration callback for integration runtimes.
- Parameters:
kind (ProviderKind | str)
provider (PluginProvider)
register_services (RegisterServices)
- class AuthenticationProvider[source]¶
Base class for authentication providers.
- begin_login(request)[source]¶
Begin an interactive login flow.
- Parameters:
request (Any)
- Return type:
Any
- class ExternalTokenValidator[source]¶
Optional mixin for providers that validate external bearer tokens.
- class CacheProvider[source]¶
Base class for cache-provider runtimes.
- get(key)[source]¶
Return a cached value or
Noneif the key is missing.- Parameters:
key (str)
- Return type:
bytes | None
- get_many(keys)[source]¶
Return the subset of
keysthat currently exist.- Parameters:
keys (list[str])
- Return type:
dict[str, bytes]
- set(key, value, ttl=None)[source]¶
Store
valueforkeywith an optional time-to-live.- Parameters:
key (str)
value (bytes)
ttl (timedelta | None)
- Return type:
None
- set_many(entries, ttl=None)[source]¶
Store multiple cache entries using repeated
set()calls.- Parameters:
entries (list[CacheEntry])
ttl (dt.timedelta | None)
- Return type:
None
- delete(key)[source]¶
Delete a cache entry and report whether it existed.
- Parameters:
key (str)
- Return type:
bool
- delete_many(keys)[source]¶
Delete a batch of cache keys and return the number removed.
- Parameters:
keys (list[str])
- Return type:
int
Auth protocol types¶
These generated authentication message types are also re-exported from
gestalt so provider code can type or construct lower-level protocol
payloads without reaching into private modules.
- class AuthenticatedUser¶
- class BeginLoginRequest¶
- class BeginLoginResponse¶
- class CompleteLoginRequest¶
Cache client¶
Cache key and value pair used by batch operations. |
|
Client for a host-provided Gestalt cache provider. |
|
Return the environment variable name for a cache socket binding. |
- class CacheEntry(key, value)[source]¶
Cache key and value pair used by batch operations.
- Parameters:
key (str)
value (bytes)
- class Cache(name=None)[source]¶
Client for a host-provided Gestalt cache provider.
- Parameters:
name (str | None)
- get(key)[source]¶
Return the cached value for
keyif it exists.- Parameters:
key (str)
- Return type:
bytes | None
- get_many(keys)[source]¶
Return the subset of
keysthat currently exist.- Parameters:
keys (list[str])
- Return type:
dict[str, bytes]
- set(key, value, ttl=None)[source]¶
Store
valueforkeywith an optional TTL.- Parameters:
key (str)
value (bytes)
ttl (timedelta | None)
- Return type:
None
- set_many(entries, ttl=None)[source]¶
Store multiple cache entries with one RPC.
- Parameters:
entries (Iterable[CacheEntry])
ttl (timedelta | None)
- Return type:
None
- delete(key)[source]¶
Delete
keyand return whether an entry existed.- Parameters:
key (str)
- Return type:
bool
- delete_many(keys)[source]¶
Delete multiple keys and return the number removed.
- Parameters:
keys (list[str])
- Return type:
int
IndexedDB client¶
int([x]) -> integer int(x, base=10) -> integer |
|
int([x]) -> integer int(x, base=10) -> integer |
|
int([x]) -> integer int(x, base=10) -> integer |
|
int([x]) -> integer int(x, base=10) -> integer |
|
Return the environment variable name for an IndexedDB socket binding. |
|
Raised when an IndexedDB record, store, or cursor target is missing. |
|
Raised when an IndexedDB object already exists. |
|
Lower and upper bounds for a cursor or range query. |
|
Definition for an index within an object store. |
|
Schema definition for an object store. |
|
Client for a host-provided IndexedDB-compatible store. |
|
Client bound to a single IndexedDB object store. |
|
Client bound to a secondary index on an object store. |
|
Stateful cursor over object store or index results. |
- CURSOR_NEXT = 0¶
int([x]) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4
- CURSOR_NEXT_UNIQUE = 1¶
int([x]) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4
- CURSOR_PREV = 2¶
int([x]) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4
- CURSOR_PREV_UNIQUE = 3¶
int([x]) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4
- indexeddb_socket_env(name=None)[source]¶
Return the environment variable name for an IndexedDB socket binding.
- Parameters:
name (str | None)
- Return type:
str
- exception NotFoundError[source]¶
Raised when an IndexedDB record, store, or cursor target is missing.
- class KeyRange(lower=None, upper=None, lower_open=False, upper_open=False)[source]¶
Lower and upper bounds for a cursor or range query.
- Parameters:
lower (Any)
upper (Any)
lower_open (bool)
upper_open (bool)
- class IndexSchema(name, key_path=<factory>, unique=False)[source]¶
Definition for an index within an object store.
- Parameters:
name (str)
key_path (list[str])
unique (bool)
- class ObjectStoreSchema(indexes=<factory>)[source]¶
Schema definition for an object store.
- Parameters:
indexes (list[IndexSchema])
- class IndexedDB(name=None)[source]¶
Client for a host-provided IndexedDB-compatible store.
- Parameters:
name (str | None)
- create_object_store(name, schema=None)[source]¶
Create an object store with an optional schema.
- Parameters:
name (str)
schema (ObjectStoreSchema | None)
- Return type:
None
- delete_object_store(name)[source]¶
Delete an object store by name.
- Parameters:
name (str)
- Return type:
None
- object_store(name)[source]¶
Return a client bound to an object store.
- Parameters:
name (str)
- Return type:
- class ObjectStore(stub, store)[source]¶
Client bound to a single IndexedDB object store.
- Parameters:
stub (Any)
store (str)
- get_key(id)[source]¶
Return the canonical key for a primary key lookup.
- Parameters:
id (str)
- Return type:
str
- put(record)[source]¶
Insert or replace a record.
- Parameters:
record (dict[str, Any])
- Return type:
None
- get_all(key_range=None)[source]¶
Return all records that fall within
key_range.- Parameters:
key_range (KeyRange | None)
- Return type:
list[dict[str, Any]]
- get_all_keys(key_range=None)[source]¶
Return all primary keys that fall within
key_range.- Parameters:
key_range (KeyRange | None)
- Return type:
list[str]
- count(key_range=None)[source]¶
Return the number of matching records.
- Parameters:
key_range (KeyRange | None)
- Return type:
int
- delete_range(key_range)[source]¶
Delete all records within
key_range.- Parameters:
key_range (KeyRange)
- Return type:
int
- class Index(stub, store, index)[source]¶
Client bound to a secondary index on an object store.
- Parameters:
stub (Any)
store (str)
index (str)
- get(*values)[source]¶
Fetch the first matching record for the indexed values.
- Parameters:
values (Any)
- Return type:
dict[str, Any]
- get_key(*values)[source]¶
Fetch the first matching primary key for the indexed values.
- Parameters:
values (Any)
- Return type:
str
- get_all(*values, key_range=None)[source]¶
Return all records matching the indexed values and key range.
- Parameters:
values (Any)
key_range (KeyRange | None)
- Return type:
list[dict[str, Any]]
- get_all_keys(*values, key_range=None)[source]¶
Return all primary keys matching the indexed values and key range.
- Parameters:
values (Any)
key_range (KeyRange | None)
- Return type:
list[str]
- count(*values, key_range=None)[source]¶
Return the number of records matching the indexed values.
- Parameters:
values (Any)
key_range (KeyRange | None)
- Return type:
int
- delete(*values)[source]¶
Delete records matching the indexed values.
- Parameters:
values (Any)
- Return type:
int
- class Cursor(stub, store, *, key_range=None, direction=CURSOR_NEXT, keys_only=False, index='', values=())[source]¶
Stateful cursor over object store or index results.
- Parameters:
stub (Any)
store (str)
key_range (KeyRange | None)
direction (int)
keys_only (bool)
index (str)
values (tuple[Any, ...])
- continue_to_key(key)[source]¶
Advance the cursor to
keyor the next greater entry.- Parameters:
key (Any)
- Return type:
bool
- property key: Any¶
Current key for the cursor entry.
- property primary_key: str | None¶
Current primary key for the cursor entry.
- property value: dict[str, Any]¶
Current record value for the cursor entry.
S3 client¶
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str |
|
Return the environment variable name for an S3 socket binding. |
|
Raised when the requested object does not exist. |
|
Raised when conditional request headers fail. |
|
Raised when a requested byte range is invalid. |
|
Reference to an S3 object, optionally pinned to a version. |
|
Object metadata returned by S3 operations. |
|
Inclusive byte range used for object reads. |
|
Conditional and ranged read options for an object request. |
|
Metadata and precondition options for object writes. |
|
Query options for listing objects within a bucket. |
|
One page of object-listing results. |
|
Conditional headers for copy operations. |
|
HTTP methods supported by presigned object URLs. |
|
Options for generating a presigned object URL. |
|
Presigned URL response returned by the provider. |
|
Streaming object body reader returned by |
|
Client for a host-provided Gestalt S3 runtime. |
|
Convenience wrapper for a single S3 object reference. |
- ENV_S3_SOCKET = 'GESTALT_S3_SOCKET'¶
str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.
- s3_socket_env(name=None)[source]¶
Return the environment variable name for an S3 socket binding.
- Parameters:
name (str | None)
- Return type:
str
- class ObjectRef(bucket, key, version_id='')[source]¶
Reference to an S3 object, optionally pinned to a version.
- Parameters:
bucket (str)
key (str)
version_id (str)
- class ObjectMeta(ref, etag='', size=0, content_type='', last_modified=None, metadata=<factory>, storage_class='')[source]¶
Object metadata returned by S3 operations.
- Parameters:
ref (ObjectRef)
etag (str)
size (int)
content_type (str)
last_modified (datetime | None)
metadata (dict[str, str])
storage_class (str)
- class ByteRange(start=None, end=None)[source]¶
Inclusive byte range used for object reads.
- Parameters:
start (int | None)
end (int | None)
- class ReadOptions(range=None, if_match='', if_none_match='', if_modified_since=None, if_unmodified_since=None)[source]¶
Conditional and ranged read options for an object request.
- Parameters:
range (ByteRange | None)
if_match (str)
if_none_match (str)
if_modified_since (datetime | None)
if_unmodified_since (datetime | None)
- class WriteOptions(content_type='', cache_control='', content_disposition='', content_encoding='', content_language='', metadata=<factory>, if_match='', if_none_match='')[source]¶
Metadata and precondition options for object writes.
- Parameters:
content_type (str)
cache_control (str)
content_disposition (str)
content_encoding (str)
content_language (str)
metadata (dict[str, str])
if_match (str)
if_none_match (str)
- class ListOptions(bucket, prefix='', delimiter='', continuation_token='', start_after='', max_keys=0)[source]¶
Query options for listing objects within a bucket.
- Parameters:
bucket (str)
prefix (str)
delimiter (str)
continuation_token (str)
start_after (str)
max_keys (int)
- class ListPage(objects=<factory>, common_prefixes=<factory>, next_continuation_token='', has_more=False)[source]¶
One page of object-listing results.
- Parameters:
objects (list[ObjectMeta])
common_prefixes (list[str])
next_continuation_token (str)
has_more (bool)
- class CopyOptions(if_match='', if_none_match='')[source]¶
Conditional headers for copy operations.
- Parameters:
if_match (str)
if_none_match (str)
- class PresignOptions(method=None, expires=None, content_type='', content_disposition='', headers=<factory>)[source]¶
Options for generating a presigned object URL.
- Parameters:
method (PresignMethod | str | None)
expires (timedelta | None)
content_type (str)
content_disposition (str)
headers (dict[str, str])
- class PresignResult(url, method=None, expires_at=None, headers=<factory>)[source]¶
Presigned URL response returned by the provider.
- Parameters:
url (str)
method (PresignMethod | str | None)
expires_at (datetime | None)
headers (dict[str, str])
- class S3ReadStream(stream)[source]¶
Streaming object body reader returned by
S3.read_object().- Parameters:
stream (Any)
- __exit__(*args)[source]¶
Close the stream at the end of a context manager block.
- Parameters:
args (Any)
- Return type:
None
- class S3(name=None)[source]¶
Client for a host-provided Gestalt S3 runtime.
- Parameters:
name (str | None)
- object(bucket, key)[source]¶
Return an object helper for the latest version.
- Parameters:
bucket (str)
key (str)
- Return type:
- object_version(bucket, key, version_id)[source]¶
Return an object helper pinned to a specific version.
- Parameters:
bucket (str)
key (str)
version_id (str)
- Return type:
- head_object(ref)[source]¶
Fetch metadata for an object without reading its body.
- Parameters:
ref (ObjectRef)
- Return type:
- read_object(ref, opts=None)[source]¶
Open a streaming read for an object.
- Parameters:
ref (ObjectRef)
opts (ReadOptions | None)
- Return type:
tuple[ObjectMeta, S3ReadStream]
- write_object(ref, body=None, opts=None)[source]¶
Write an object body and return the resulting metadata.
- Parameters:
ref (ObjectRef)
body (bytes | bytearray | memoryview | BinaryIO | Iterable[bytes] | None)
opts (WriteOptions | None)
- Return type:
- list_objects(opts)[source]¶
List objects within a bucket.
- Parameters:
opts (ListOptions)
- Return type:
- copy_object(source, destination, opts=None)[source]¶
Copy an object and return metadata for the destination.
- Parameters:
source (ObjectRef)
destination (ObjectRef)
opts (CopyOptions | None)
- Return type:
- presign_object(ref, opts=None)[source]¶
Generate a presigned URL for an object operation.
- Parameters:
ref (ObjectRef)
opts (PresignOptions | None)
- Return type:
- create_object_access_url(ref, opts=None)[source]¶
Create a host-mediated object access URL.
- Parameters:
ref (ObjectRef)
opts (PresignOptions | None)
- Return type:
- create_access_url(ref, opts=None)[source]¶
Create a host-mediated object access URL.
- Parameters:
ref (ObjectRef)
opts (PresignOptions | None)
- Return type:
- class S3Object(client, ref)[source]¶
Convenience wrapper for a single S3 object reference.
- stream(opts=None)[source]¶
Open a streaming read for the object.
- Parameters:
opts (ReadOptions | None)
- Return type:
tuple[ObjectMeta, S3ReadStream]
- bytes(opts=None)[source]¶
Read the full object body as bytes.
- Parameters:
opts (ReadOptions | None)
- Return type:
bytes
- text(opts=None, *, encoding='utf-8')[source]¶
Read the full object body as text.
- Parameters:
opts (ReadOptions | None)
encoding (str)
- Return type:
str
- json(opts=None)[source]¶
Read and decode the full object body as JSON.
- Parameters:
opts (ReadOptions | None)
- Return type:
Any
- write(body=None, opts=None)[source]¶
Write an object body.
- Parameters:
body (bytes | bytearray | memoryview | BinaryIO | Iterable[bytes] | None)
opts (WriteOptions | None)
- Return type:
- write_bytes(body, opts=None)[source]¶
Write bytes to the object.
- Parameters:
body (bytes | bytearray | memoryview)
opts (WriteOptions | None)
- Return type:
- write_text(body, opts=None, *, encoding='utf-8')[source]¶
Encode and write text to the object.
- Parameters:
body (str)
opts (WriteOptions | None)
encoding (str)
- Return type:
- write_json(value, opts=None)[source]¶
Encode and write JSON to the object.
- Parameters:
value (Any)
opts (WriteOptions | None)
- Return type:
- presign(opts=None)[source]¶
Generate a presigned URL for this object.
- Parameters:
opts (PresignOptions | None)
- Return type:
- create_access_url(opts=None)[source]¶
Create a host-mediated object access URL for this object.
- Parameters:
opts (PresignOptions | None)
- Return type: