Skip to content

Examples Index

All example function blocks and plugins shipped with the SDK, organized by topic. Each example is a complete, runnable file.


Getting Started

Example Path Demonstrates
Echo examples/getting-started/echo/echo.py Minimal function block with parameters, results, and registration
Echo test examples/getting-started/echo/test_echo.py Standalone pytest test for a function block
Show version examples/getting-started/show_version/show_version.py Device connection via proxy, DeviceInfoCapability

Function Blocks

Example Path Demonstrates
Config backup examples/use-cases/config_backup/config_backup.py @run_in_thread for blocking I/O, credential handling from context
Device inventory examples/use-cases/device_inventory/device_inventory.py Entity creation with skip_if_identifier_exists, deduplication
Parallel collection examples/concurrency/parallel_collection/parallel_collection.py @run_in_thread + run_parallel() for fan-out across devices
Complex parameters examples/function-blocks/complex_params.py Nested Pydantic models, validators, optional fields
Inventory collector examples/function-blocks/inventory_collector.py WorkflowContext data access, facts, change tracking

Device Connections

Example Path Demonstrates
Config backup capability examples/device-connections/config_backup_capability.py Writing a custom CapabilityInterface and composing proxies
FRR plugin examples/device-connections/frr_plugin.py Complete plugin: BaseConnection + ConnectionPlugin + registration
Best practices examples/device-connections/best_practices.py Context manager, raw connection escape hatch, multi-vendor handling

Existing Examples

Example Path Demonstrates
Ping examples/ping/ping.py Simple function block running ping operations
Show command examples/show_cmd/fb_get_show_cmd.py CLI command execution via device connection
Python eval examples/python_eval/python_eval.py Dynamic Python execution in a function block

Suggested Learning Path

If you are new to the SDK, work through examples in this order:

  1. Echo — understand the minimal structure
  2. Show version — learn device connections
  3. Config backup — see @run_in_thread in action
  4. Parallel collection — fan out across multiple devices
  5. Device inventory — create entities with deduplication
  6. FRR plugin — extend the connection system

Project Template

File Path Purpose
pyproject.toml examples/getting-started/echo/pyproject.toml Minimal project template with SDK dependency and test configuration