|
| 1 | +# Copyright (C) 2026 Marco Fortina |
| 2 | +# SPDX-License-Identifier: AGPL-3.0-or-later |
| 3 | + |
| 4 | +"""Sample external Automax plugin.""" |
| 5 | + |
| 6 | +from __future__ import annotations |
| 7 | + |
| 8 | +from typing import Dict |
| 9 | + |
| 10 | +from automax.core.models import ExecutionContext, PluginResult |
| 11 | +from automax.plugins.base import BasePlugin |
| 12 | + |
| 13 | + |
| 14 | +class CompanyDemoHelloPlugin(BasePlugin): |
| 15 | + """Return a deterministic greeting for package and install smoke tests.""" |
| 16 | + |
| 17 | + name = "company.demo.hello" |
| 18 | + description = "Return a deterministic external plugin greeting." |
| 19 | + category = "company" |
| 20 | + required_params = ("message",) |
| 21 | + optional_params = ("changed",) |
| 22 | + parameter_schema = { |
| 23 | + "message": { |
| 24 | + "type": "string", |
| 25 | + "description": "Greeting message returned by the plugin.", |
| 26 | + "non_empty": True, |
| 27 | + }, |
| 28 | + "changed": { |
| 29 | + "type": "boolean", |
| 30 | + "default": False, |
| 31 | + "description": "Whether the plugin should report a change.", |
| 32 | + }, |
| 33 | + } |
| 34 | + examples = ( |
| 35 | + """- id: hello\n use: company.demo.hello\n with:\n message: hello""", |
| 36 | + ) |
| 37 | + result_fields = { |
| 38 | + "message": "Rendered greeting.", |
| 39 | + "changed": "Whether the plugin reported a change.", |
| 40 | + } |
| 41 | + supports_dry_run = True |
| 42 | + supports_check_mode = True |
| 43 | + |
| 44 | + def execute(self, params: Dict[str, object], context: ExecutionContext) -> PluginResult: |
| 45 | + message = str(params["message"]) |
| 46 | + changed = bool(params.get("changed", False)) |
| 47 | + return PluginResult.success( |
| 48 | + changed=changed, |
| 49 | + message=message, |
| 50 | + data={"message": message, "changed": changed}, |
| 51 | + ) |
0 commit comments