From 652b7e961de929b16f29225ceb4fd264a3782960 Mon Sep 17 00:00:00 2001 From: Sebastian Tobie Date: Sun, 23 Apr 2023 09:08:44 +0200 Subject: [PATCH] added modspec as an helper function. it has the typedefinition that allows the developer to get the required parameters for ansible modules more easily --- plugins/module_utils/generic.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/plugins/module_utils/generic.py b/plugins/module_utils/generic.py index b6c6d23..646c8f5 100644 --- a/plugins/module_utils/generic.py +++ b/plugins/module_utils/generic.py @@ -102,3 +102,21 @@ def systemdbool(b: Union[bool, str]) -> str: elif b is False: return "no" return b + + +def modspec( + argument_spec: Dict[str, Dict[str, Any]], + mutually_exclusive: Sequence[Tuple[str, ...]] = (), + required_together: Sequence[Tuple[str, ...]] = (), + required_one_of: Sequence[Tuple[str, ...]] = (), + required_if: Sequence[Union[Tuple[str, Any, Tuple[str, ...]], Tuple[str, Any, Tuple[str, ...], bool]]] = (), + required_by: Dict[str, Union[str, Tuple[str, ...]]] = {}, +) -> Dict[str, Any]: + return dict( + argument_spec=argument_spec, + mutually_exclusive=mutually_exclusive, + required_together=required_together, + required_one_of=required_one_of, + required_if=required_if, + required_by=required_by, + )