49 lines
1.4 KiB
Python
49 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
# pylint: disable=missing-class-docstring, missing-module-docstring, missing-function-docstring
|
|
|
|
from collections.abc import Iterable
|
|
|
|
from pydantic import BaseModel
|
|
|
|
from cmk.server_side_calls.v1 import (
|
|
HostConfig,
|
|
Secret,
|
|
SpecialAgentCommand,
|
|
SpecialAgentConfig,
|
|
)
|
|
|
|
|
|
class MailcowParams(BaseModel):
|
|
hostname: str | None = None
|
|
apikey: Secret | None = None
|
|
port: int | None = None
|
|
no_https: bool = False
|
|
no_cert_check: bool = False
|
|
check_version: bool = False
|
|
|
|
|
|
def agent_mailcow_arguments(
|
|
params: MailcowParams, _host_config: HostConfig
|
|
) -> Iterable[SpecialAgentCommand]:
|
|
command_arguments: list[str | Secret] = []
|
|
if params.hostname is not None:
|
|
command_arguments += ["--hostname", params.hostname]
|
|
if params.apikey is not None:
|
|
command_arguments += ["--apikey", params.apikey.unsafe()]
|
|
if params.port is not None:
|
|
command_arguments += ["--port", str(params.port)]
|
|
if params.no_https:
|
|
command_arguments.append("--no-https")
|
|
if params.no_cert_check:
|
|
command_arguments.append("--no-cert-check")
|
|
if params.check_version:
|
|
command_arguments.append("--check-version")
|
|
yield SpecialAgentCommand(command_arguments=command_arguments)
|
|
|
|
|
|
special_agent_mailcow = SpecialAgentConfig(
|
|
name="mailcow",
|
|
parameter_parser=MailcowParams.model_validate,
|
|
commands_function=agent_mailcow_arguments,
|
|
)
|