# Copyright: (c) 2024, Luca Bilke <luca@bil.ke>
# MIT License (see LICENSE)

from __future__ import annotations

from typing import TYPE_CHECKING, Any

import ansible_collections.ssnailed.ez_compose.plugins.module_utils.service.common as service  # type: ignore[reportMissingTypeStubs]

if TYPE_CHECKING:
    from ansible_collections.ssnailed.ez_compose.plugins.module_utils.common import (  # type: ignore[reportMissingTypeStubs]
        State,
    )

EXTRA_ARGS = {
    "stop": {"type": "bool", "default": True},
}


def helper(state: State, service_name: str, params: dict[str, Any]) -> State:
    stop: bool = params["stop"]
    project_name: str = state.module.params["name"]

    update: dict[str, Any] = {}

    if stop:
        update["labels"] = {
            "docker-volume-backup.stop-during-backup": project_name,
        }

    return service.update(service_name, state, update)