API Reference¶
This page documents the public API exported from azure_functions_durable_graph.
from azure_functions_durable_graph import (
DurableGraphApp,
GraphManifest,
GraphRegistration,
ManifestBuilder,
RouteAction,
RouteDecision,
)
Public surface
The package exports DurableGraphApp, GraphManifest, GraphRegistration,
ManifestBuilder, RouteAction, and RouteDecision.
Registry and contract internals are not public contracts.
ManifestBuilder¶
Bases: Generic[StateModelT]
Source code in src/azure_functions_durable_graph/manifest.py
Usage example: building a graph¶
from pydantic import BaseModel
from azure_functions_durable_graph import ManifestBuilder, RouteDecision
class AgentState(BaseModel):
query: str
classified: bool = False
response: str | None = None
def classify(state: AgentState) -> dict:
return {"classified": True}
def route(state: AgentState) -> RouteDecision:
return RouteDecision.next("respond")
def respond(state: AgentState) -> dict:
return {"response": f"Answer to: {state.query}"}
builder = ManifestBuilder(graph_name="agent", state_model=AgentState)
builder.set_entrypoint("classify")
builder.add_node("classify", classify, route=route)
builder.add_node("respond", respond, terminal=True)
registration = builder.build()
GraphManifest¶
The manifest is a Pydantic model containing:
graph_name— unique graph identifierversion— semantic version stringgraph_hash— SHA-256 hash of canonical topology JSON (first 16 chars)state_model_name— name of the Pydantic state model classentrypoint— starting node namenodes— dict ofNodeDefinitionobjectsevent_handler_names— sorted list of registered event handler namesmetadata— arbitrary metadata dict
GraphRegistration¶
A dataclass containing:
manifest— the compiledGraphManifeststate_model— the Pydantic state model typenode_handlers— dict mapping handler names to callablesroute_handlers— dict mapping route handler names to callablesevent_handlers— dict mapping event names to callables
RouteDecision¶
Factory methods¶
# Continue to next node
RouteDecision.next("step_two")
# Complete the graph
RouteDecision.complete(note="all done")
# Wait for an external event
RouteDecision.wait_for_event(
event_name="approval",
resume_node="process",
)
RouteAction¶
An enum with values:
RouteAction.NEXT— continue to next nodeRouteAction.COMPLETE— finish the graphRouteAction.WAIT_FOR_EVENT— pause for external event
DurableGraphApp¶
Source code in src/azure_functions_durable_graph/app.py
Import safety
DurableGraphApp requires azure-functions and azure-functions-durable
at import time. In pure unit test environments without these packages,
DurableGraphApp is set to None in __init__.py.
Usage example: wiring a Function App¶
from azure_functions_durable_graph import DurableGraphApp
runtime = DurableGraphApp()
runtime.register_registration(registration)
app = runtime.function_app
HTTP API endpoints¶
DurableGraphApp registers the following endpoints:
| Method | Route | Description |
|---|---|---|
| POST | /api/graphs/{graph_name}/runs |
Start a new graph run |
| GET | /api/runs/{instance_id} |
Get run status |
| POST | /api/runs/{instance_id}/events/{event_name} |
Send an external event |
| POST | /api/runs/{instance_id}/cancel |
Cancel a run |
| GET | /api/openapi.json |
OpenAPI document |
| GET | /api/health |
Health check with registered graphs |
Internal references¶
These modules are useful for advanced extension work but are internal APIs:
registry.py:GraphRegistry,execute_node,resolve_route,apply_eventcontracts.py:OrchestrationInput,NodeExecutionRequest,RouteResolutionRequest,EventApplyRequest,RunStatusEnvelope
For full implementation patterns, see Usage and Architecture.