Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_templategroup.py

raw symbols SCIP
1 #!/usr/bin/python
2 from __future__ import absolute_import, division, print_function
3 # Copyright 2019-2024 Fortinet, Inc.
4 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
5
6 __metaclass__ = type
7
8 ANSIBLE_METADATA = {'status': ['preview'],
9 'supported_by': 'community',
10 'metadata_version': '1.1'}
11
12 DOCUMENTATION = '''
13 ---
14 module: fmgr_templategroup
15 short_description: Require device/vdom scope member
16 version_added: "2.0.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.full_crud
20 options:
21 revision_note:
22 description: The change note that can be specified when an object is created or updated.
23 type: str
24 adom:
25 description: The parameter (adom) in requested url.
26 type: str
27 required: true
28 templategroup:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 description:
34 type: str
35 description: Description.
36 member:
37 type: list
38 elements: str
39 description: Member.
40 modification_time:
41 aliases: ['modification-time']
42 type: str
43 description: Modification time.
44 name:
45 type: str
46 description: Name.
47 required: true
48 variables:
49 type: raw
50 description: (list) Variables.
51 option:
52 type: list
53 elements: str
54 description: Option.
55 choices: ['sdwan-overlay', 'sdwan-manager']
56 scope_member:
57 aliases: ['scope member']
58 type: list
59 elements: dict
60 description: Scope member.
61 suboptions:
62 name:
63 type: str
64 description: Name.
65 vdom:
66 type: str
67 description: Vdom.
68 '''
69
70 EXAMPLES = '''
71 - name: Example playbook (generated based on argument schema)
72 hosts: fortimanagers
73 connection: httpapi
74 gather_facts: false
75 tasks:
76 - name: Require device/vdom scope member
77 fortinet.fortimanager.fmgr_templategroup:
78 # workspace_locking_adom: <global or your adom name>
79 adom: <your own value>
80 state: present # <value in [present, absent]>
81 templategroup:
82 name: "your value" # Required variable, string
83 # description: <string>
84 # member: <list or string>
85 # modification_time: <string>
86 # variables: <list or string>
87 # option: ["sdwan-overlay", "sdwan-manager"]
88 # scope_member:
89 # - name: <string>
90 # vdom: <string>
91 '''
92
93 RETURN = '''
94 meta:
95 description: The result of the request.
96 type: dict
97 returned: always
98 contains:
99 request_url:
100 description: The full url requested.
101 returned: always
102 type: str
103 sample: /sys/login/user
104 response_code:
105 description: The status of api request.
106 returned: always
107 type: int
108 sample: 0
109 response_data:
110 description: The api response.
111 type: list
112 returned: always
113 response_message:
114 description: The descriptive message of the api response.
115 type: str
116 returned: always
117 sample: OK.
118 system_information:
119 description: The information of the target system.
120 type: dict
121 returned: always
122 rc:
123 description: The status the request.
124 type: int
125 returned: always
126 sample: 0
127 version_check_warning:
128 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
129 type: list
130 returned: complex
131 '''
132 from ansible.module_utils.basic import AnsibleModule
133 from ansible.module_utils.connection import Connection
134 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
135 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
136
137
138 def main():
139 urls_list = [
140 '/pm/config/adom/{adom}/obj/cli/template-group',
141 '/pm/config/global/obj/cli/template-group'
142 ]
143 module_arg_spec = {
144 'adom': {'required': True, 'type': 'str'},
145 'revision_note': {'type': 'str'},
146 'templategroup': {
147 'type': 'dict', 'v_range': [['6.0.0', '']],
148 'options': {
149 'description': {'type': 'str'},
150 'member': {'type': 'list', 'elements': 'str'},
151 'modification-time': {'v_range': [['6.0.0', '7.0.3']], 'type': 'str'},
152 'name': {'required': True, 'type': 'str'},
153 'variables': {'v_range': [['7.2.3', '']], 'type': 'raw'},
154 'option': {'v_range': [['7.6.0', '']], 'type': 'list', 'choices': ['sdwan-overlay', 'sdwan-manager'], 'elements': 'str'},
155 'scope member': {
156 'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']],
157 'type': 'list',
158 'options': {
159 'name': {'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']], 'type': 'str'},
160 'vdom': {'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']], 'type': 'str'}
161 },
162 'elements': 'dict'
163 }
164 }
165 }
166 }
167
168 module_option_spec = get_module_arg_spec('full crud')
169 module_arg_spec.update(module_option_spec)
170 check_galaxy_version(module_arg_spec)
171 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'templategroup'),
172 supports_check_mode=True)
173 if not module._socket_path:
174 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
175 connection = Connection(module._socket_path)
176 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
177 'name', 'data', module, connection)
178 fmgr.process_crud()
179 module.exit_json(meta=module.params)
180
181
182 if __name__ == '__main__':
183 main()