#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (C) 2019 tribe29 GmbH - License: GNU General Public License v2
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and
# conditions defined in the file COPYING, which is part of this source code package.

# pylint: disable=undefined-variable
# type: ignore[name-defined]

from typing import Any, Mapping, Optional, Sequence, Union


def agent_proxmox_ve_arguments(
    params: Mapping[str, Any], hostname: str, ipaddress: Optional[str]
) -> Sequence[Union[str, tuple[str, str, str]]]:
    return [
        elem
        for chunk in (
            ("-u", params["username"]) if "username" in params else (),
            ("-p", passwordstore_get_cmdline("%s", params["password"]))
            if "password" in params
            else (),
            ("--port", params["port"]) if "port" in params else (),
            ("--no-cert-check",) if params.get("no-cert-check") else (),
            ("--timeout", params["timeout"]) if "timeout" in params else (),
            ("--log-cutoff-weeks", params["log-cutoff-weeks"])
            if "log-cutoff-weeks" in params
            else (),
            (hostname,),
        )
        for elem in chunk
    ]


special_agent_info["proxmox_ve"] = agent_proxmox_ve_arguments
