Plugins¶
Base classes, registry, errors, and template helpers for the Imbi plugin system. Plugin authors should pair this reference with the Authoring Plugins guide, which explains the plugin variations and the contract each must satisfy.
Manifest and Context¶
PluginManifest ¶
Bases: BaseModel
PluginOption ¶
Bases: BaseModel
CredentialField ¶
Bases: BaseModel
DataType ¶
Bases: BaseModel
PluginContext ¶
Bases: BaseModel
Configuration Plugins¶
The configuration variation models a typed key/value store scoped to
a project. Implementations subclass ConfigurationPlugin and declare
plugin_type='configuration' in their manifest.
ConfigurationPlugin ¶
Bases: ABC
Plugins must not stash global state.
A new instance is created per request.
ConfigKey ¶
Bases: BaseModel
ConfigValue ¶
Bases: BaseModel
Logs Plugins¶
The logs variation exposes a search interface against an external log
store. Implementations subclass LogsPlugin and declare
plugin_type='logs' in their manifest.
LogsPlugin ¶
Bases: ABC
histogram
async
¶
histogram(
ctx: PluginContext,
credentials: dict[str, str],
query: LogQuery,
bucket_count: int = 60,
) -> list[LogHistogramBucket]
Return time-bucketed event counts for the histogram view.
Plugins that support histograms should override this method and
set manifest.supports_histogram = True. The default
implementation returns an empty list, which causes the API to
signal that histograms are unavailable for this source.
Source code in src/imbi_common/plugins/base.py
LogQuery ¶
Bases: BaseModel
LogFilter ¶
Bases: BaseModel
LogEntry ¶
Bases: BaseModel
LogResult ¶
Bases: BaseModel
LogHistogramBucket ¶
Bases: BaseModel
A single time bucket in a log histogram response.
Webhook Action Plugins¶
The webhook variation reacts to inbound webhook payloads routed by a
host such as imbi-gateway. Implementations subclass
WebhookActionPlugin and declare plugin_type='webhook' in their
manifest. The host parses the WebhookRule.handler field as
"<plugin_slug>:<action_name>", fetches per-instance credentials via
get_plugin_credentials (see below),
and dispatches by calling run_action.
WebhookActionPlugin ¶
Bases: ABC
Base class for webhook-action plugins.
Webhook action plugins declare a manifest (slug, credentials,
optional configuration options) so operators can install and
configure them like any other plugin, and advertise a static
catalog of actions through :meth:actions. The host
(imbi-gateway) parses WebhookRule.handler as
"<plugin_slug>#<action_name>", looks the plugin up in the
registry, picks the matching :class:ActionDescriptor, validates
the rule's handler_config against
:attr:ActionDescriptor.config_model, and calls
:attr:ActionDescriptor.callable with the uniform signature
captured in :data:WebhookActionCallable.
The plugin class itself carries no runtime dispatch logic -- the
callable lives wherever the descriptor points (typically the
plugin's own actions submodule).
actions
abstractmethod
classmethod
¶
Return the static catalog of actions this plugin exposes.
Implementations should return a fresh list each call so callers
can mutate the result safely. The host validates each
descriptor's callable and config_model ImportStrings at
construction time, so misconfigured paths fail loud during
registry load rather than at request time.
Source code in src/imbi_common/plugins/base.py
Credential Resolution¶
Helpers for hosts that need to fetch decrypted plugin credentials out
of the graph. Routing depends on manifest.auth_type: api_token and
aws-iam-ic read the Fernet-encrypted Plugin.plugin_configuration
blob directly, while oauth2 and oidc walk
Plugin -[:USES_APPLICATION]-> ServiceApplication.
get_plugin_credentials
async
¶
Fetch and decrypt plugin credentials from the graph.
Raises:
| Type | Description |
|---|---|
PluginCredentialsMissing
|
If required credentials are absent or the plugin is not linked to a ServiceApplication. |
Source code in src/imbi_common/plugins/credentials.py
get_plugin_configuration_keys
async
¶
Return the set of credential field names currently set.
The plaintext values themselves are never surfaced to the caller.
Source code in src/imbi_common/plugins/credentials.py
patch_plugin_configuration
async
¶
patch_plugin_configuration(
db: Graph,
plugin_id: str,
updates: dict[str, str | None],
) -> list[str]
Apply a partial update to plugin_configuration.
updates maps field name to new plaintext value. None (or
empty string) removes the field. Existing keys not present in
updates are preserved. Returns the resulting set of populated
keys (no plaintext values).
Source code in src/imbi_common/plugins/credentials.py
Registry¶
Plugin discovery is driven by importlib.metadata entry points under
the imbi.plugins group. The host calls load_plugins() at startup
(and reload_plugins() on demand) to populate the registry.
load_plugins ¶
Discover and load all installed imbi plugins.
Source code in src/imbi_common/plugins/registry.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | |
reload_plugins ¶
get_plugin ¶
Get a registry entry by plugin slug.
Raises:
| Type | Description |
|---|---|
PluginNotFoundError
|
If the slug is not registered. |
Source code in src/imbi_common/plugins/registry.py
list_plugins ¶
RegistryEntry
dataclass
¶
RegistryEntry(
handler_cls: type[ConfigurationPlugin]
| type[LogsPlugin]
| type[IdentityPlugin]
| type[DeploymentPlugin]
| type[LifecyclePlugin]
| type[WebhookActionPlugin],
manifest: PluginManifest,
package_name: str,
package_version: str,
)
LoadResult ¶
Bases: NamedTuple
Errors¶
PluginNotFoundError ¶
Bases: Exception
Raised when a plugin slug is not registered.
PluginUnavailableError ¶
Bases: Exception
Raised when a plugin slug exists in the graph but not the registry.
PluginCredentialsMissing ¶
Bases: Exception
Raised when required credentials are absent for a plugin.
PluginTimeoutError ¶
Bases: Exception
Raised when a plugin call exceeds the configured timeout.
CursorExpiredError ¶
Bases: Exception
Raised by log plugins when a pagination cursor has expired.
Templates¶
Helpers for plugins that build provider-specific query strings from
project context. Substitution is restricted to a fixed whitelist of
variables (project_slug, org_slug, environment, project_id);
unknown variables raise ValueError.
validate_template ¶
Validate a search template string, rejecting unknown variables.
Raises:
| Type | Description |
|---|---|
ValueError
|
If the template references variables not in the whitelist. |
Source code in src/imbi_common/plugins/templates.py
expand_template ¶
Expand a search template substituting whitelisted variables.
Absent variable values are replaced with empty strings. The template is
validated first to reject unknown placeholders, preserving the whitelist
guarantee from :func:validate_template.