Logo

Autoschematic

GitHub
Cluster Login

Outputs and Virtual Addresses

Outputs are how a connector exposes remote metadata that should not live in the user-editable body. The Grafana connector returns outputs from both get() and op_exec():

return GetResponse(
    exists=True,
    resource_definition=json.dumps(body, indent=2).encode(),
    outputs={"id": ds_id},
)
return GetResponse(
    exists=True,
    resource_definition=json.dumps(dashboard, indent=2).encode(),
    outputs={
        "id": db_id,
        "version": version,
        "folder_id": str(meta.get("folderId", "")),
    },
)

On the write side, exec_datasource() and exec_dashboard() return OpExecResponse values that include the IDs or versions discovered during create and update calls.

For Grafana, that is enough. Its addresses already contain stable remote identifiers:

  • datasources use grafana/datasources/[name].json
  • dashboards use grafana/dashboards/[uid].json

Because of that, the default virtual-address behavior from the Python SDK is correct:

async def addr_virt_to_phy(self, addr: str) -> VirtToPhyResponse:
    return VirtToPhyNull(addr)


async def addr_phy_to_virt(self, addr: str) -> str | None:
    return addr

(TODO: provide an example of decoding outputs to implement virtual addressing!)

Only override these methods when the user-facing path does not yet contain the canonical remote identifier. In that case:

  • return VirtToPhyPresent(path) when you can map the virtual path to a concrete physical path
  • return VirtToPhyDeferred(reads=[...]) when the mapping depends on outputs that may appear later
  • return VirtToPhyNotPresent() when the virtual resource does not exist yet

Practical rules:

  • Use outputs for server-assigned IDs, versions, or parent references that are useful later.
  • Return the same output keys from get() whenever they are known, not only from op_exec().
  • Leave virtual-address methods alone unless your API genuinely needs them. Most connectors, including the Grafana example, do not.

Reference files: