Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/module_helper/library/msimpleda.py

raw
1 #!/usr/bin/python
2 # Copyright (c) 2021, Alexei Znamensky <[email protected]>
3 #
4 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
5 # SPDX-License-Identifier: GPL-3.0-or-later
6
7 from __future__ import annotations
8
9 DOCUMENTATION = """
10 module: msimpleda
11 author: "Alexei Znamensky (@russoz)"
12 short_description: Simple module for testing DeprecationAttrsMixin
13 description:
14 - Simple module test description.
15 options:
16 a:
17 description: aaaa
18 type: int
19 """
20
21 EXAMPLES = ""
22
23 RETURN = ""
24
25 from ansible_collections.community.general.plugins.module_utils._mh.mixins.deprecate_attrs import ( # noqa: F401, pylint: disable=unused-import
26 DeprecateAttrsMixin,
27 )
28 from ansible_collections.community.general.plugins.module_utils._module_helper import ModuleHelper
29
30
31 class MSimpleDA(ModuleHelper):
32 output_params = ("a",)
33 module = dict(
34 argument_spec=dict(
35 a=dict(type="int"),
36 ),
37 )
38
39 attr1 = "abc"
40 attr2 = "def"
41
42 def __init_module__(self):
43 self._deprecate_attr(
44 "attr2",
45 msg="Attribute attr2 is deprecated",
46 version="9.9.9",
47 collection_name="community.general",
48 target=self.__class__,
49 module=self.module,
50 )
51
52 def __run__(self):
53 if self.vars.a == 1:
54 self.vars.attr1 = self.attr1
55 if self.vars.a == 2:
56 self.vars.attr2 = self.attr2
57
58
59 def main():
60 MSimpleDA.execute()
61
62
63 if __name__ == "__main__":
64 main()