Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_fmg_variable.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_fmg_variable
15 short_description: Fmg variable
16 version_added: "2.1.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 fmg_variable:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 description:
34 type: str
35 description: Description.
36 dynamic_mapping:
37 type: list
38 elements: dict
39 description: Dynamic mapping.
40 suboptions:
41 _scope:
42 type: list
43 elements: dict
44 description: Scope.
45 suboptions:
46 name:
47 type: str
48 description: Name.
49 vdom:
50 type: str
51 description: Vdom.
52 value:
53 type: str
54 description: Value.
55 name:
56 type: str
57 description: Name.
58 required: true
59 value:
60 type: str
61 description: Value.
62 type:
63 type: str
64 description: Type.
65 choices: ['normal', 'password']
66 '''
67
68 EXAMPLES = '''
69 - name: Example playbook (generated based on argument schema)
70 hosts: fortimanagers
71 connection: httpapi
72 gather_facts: false
73 tasks:
74 - name: Fmg variable
75 fortinet.fortimanager.fmgr_fmg_variable:
76 # workspace_locking_adom: <global or your adom name>
77 adom: <your own value>
78 state: present # <value in [present, absent]>
79 fmg_variable:
80 name: "your value" # Required variable, string
81 # description: <string>
82 # dynamic_mapping:
83 # - _scope:
84 # - name: <string>
85 # vdom: <string>
86 # value: <string>
87 # value: <string>
88 # type: <value in [normal, password]>
89 '''
90
91 RETURN = '''
92 meta:
93 description: The result of the request.
94 type: dict
95 returned: always
96 contains:
97 request_url:
98 description: The full url requested.
99 returned: always
100 type: str
101 sample: /sys/login/user
102 response_code:
103 description: The status of api request.
104 returned: always
105 type: int
106 sample: 0
107 response_data:
108 description: The api response.
109 type: list
110 returned: always
111 response_message:
112 description: The descriptive message of the api response.
113 type: str
114 returned: always
115 sample: OK.
116 system_information:
117 description: The information of the target system.
118 type: dict
119 returned: always
120 rc:
121 description: The status the request.
122 type: int
123 returned: always
124 sample: 0
125 version_check_warning:
126 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
127 type: list
128 returned: complex
129 '''
130 from ansible.module_utils.basic import AnsibleModule
131 from ansible.module_utils.connection import Connection
132 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
133 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
134
135
136 def main():
137 urls_list = [
138 '/pm/config/adom/{adom}/obj/fmg/variable',
139 '/pm/config/global/obj/fmg/variable'
140 ]
141 module_arg_spec = {
142 'adom': {'required': True, 'type': 'str'},
143 'revision_note': {'type': 'str'},
144 'fmg_variable': {
145 'type': 'dict', 'v_range': [['7.2.0', '']],
146 'options': {
147 'description': {'v_range': [['7.2.0', '']], 'type': 'str'},
148 'dynamic_mapping': {
149 'v_range': [['7.2.0', '']],
150 'type': 'list',
151 'options': {
152 '_scope': {
153 'v_range': [['7.2.0', '']],
154 'type': 'list',
155 'options': {'name': {'v_range': [['7.2.0', '']], 'type': 'str'}, 'vdom': {'v_range': [['7.2.0', '']], 'type': 'str'}},
156 'elements': 'dict'
157 },
158 'value': {'v_range': [['7.2.0', '']], 'type': 'str'}
159 },
160 'elements': 'dict'
161 },
162 'name': {'v_range': [['7.2.0', '']], 'required': True, 'type': 'str'},
163 'value': {'v_range': [['7.2.0', '']], 'type': 'str'},
164 'type': {'v_range': [['7.6.4', '']], 'choices': ['normal', 'password'], 'type': 'str'}
165 }
166 }
167 }
168
169 module_option_spec = get_module_arg_spec('full crud')
170 module_arg_spec.update(module_option_spec)
171 check_galaxy_version(module_arg_spec)
172 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'fmg_variable'),
173 supports_check_mode=True)
174 if not module._socket_path:
175 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
176 connection = Connection(module._socket_path)
177 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
178 'name', 'data', module, connection)
179 fmgr.process_crud()
180 module.exit_json(meta=module.params)
181
182
183 if __name__ == '__main__':
184 main()