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

from __future__ import annotations

from typing import TYPE_CHECKING, Any

from ansible_collections.snailed.ez_compose.plugins.module_utils import service

if TYPE_CHECKING:
    from ansible_collections.snailed.ez_compose.plugins.module_utils.models import (
        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.common.update(state, {"name": service_name}, update)