Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_addrgrp_dynamicmapping.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_firewall_addrgrp_dynamicmapping
15 short_description: Configure IPv4 address groups.
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 addrgrp:
29 description: The parameter (addrgrp) in requested url.
30 type: str
31 required: true
32 firewall_addrgrp_dynamicmapping:
33 description: The top level parameters set.
34 required: false
35 type: dict
36 suboptions:
37 _scope:
38 type: list
39 elements: dict
40 description: Scope.
41 suboptions:
42 name:
43 type: str
44 description: Name.
45 vdom:
46 type: str
47 description: Vdom.
48 allow_routing:
49 aliases: ['allow-routing']
50 type: str
51 description: Allow routing.
52 choices: ['disable', 'enable']
53 color:
54 type: int
55 description: Color.
56 comment:
57 type: raw
58 description: (dict or str) Comment.
59 exclude:
60 type: str
61 description: Exclude.
62 choices: ['disable', 'enable']
63 exclude_member:
64 aliases: ['exclude-member']
65 type: raw
66 description: (list or str) Exclude member.
67 member:
68 type: raw
69 description: (list or str) Member.
70 tags:
71 type: raw
72 description: (list or str) Tags.
73 uuid:
74 type: str
75 description: Uuid.
76 visibility:
77 type: str
78 description: Visibility.
79 choices: ['disable', 'enable']
80 _image_base64:
81 aliases: ['_image-base64']
82 type: str
83 description: Image base64.
84 global_object:
85 aliases: ['global-object']
86 type: int
87 description: Global object.
88 type:
89 type: str
90 description: Type.
91 choices: ['default', 'array', 'folder']
92 fabric_object:
93 aliases: ['fabric-object']
94 type: str
95 description: Security Fabric global object setting.
96 choices: ['disable', 'enable']
97 category:
98 type: str
99 description: Address group category.
100 choices: ['default', 'ztna-ems-tag', 'ztna-geo-tag', 'telemetry']
101 '''
102
103 EXAMPLES = '''
104 - name: Example playbook
105 hosts: fortimanagers
106 gather_facts: false
107 connection: httpapi
108 vars:
109 ansible_httpapi_use_ssl: true
110 ansible_httpapi_validate_certs: false
111 ansible_httpapi_port: 443
112 tasks:
113 - name: Configure dynamic mappings of IPv4 address group
114 fortinet.fortimanager.fmgr_firewall_addrgrp_dynamicmapping:
115 bypass_validation: false
116 adom: ansible
117 addrgrp: "ansible" # name
118 state: present
119 firewall_addrgrp_dynamicmapping:
120 _scope:
121 - name: FGT_AWS # need a valid device name
122 vdom: root # need a valid vdom name under the device
123 allow_routing: disable
124 color: 1
125 member: "ansible-test1"
126 visibility: enable
127
128 - name: Gathering fortimanager facts
129 hosts: fortimanagers
130 gather_facts: false
131 connection: httpapi
132 vars:
133 ansible_httpapi_use_ssl: true
134 ansible_httpapi_validate_certs: false
135 ansible_httpapi_port: 443
136 tasks:
137 - name: Retrieve all the dynamic mappings of IPv4 address group
138 fortinet.fortimanager.fmgr_fact:
139 facts:
140 selector: "firewall_addrgrp_dynamicmapping"
141 params:
142 adom: "ansible"
143 addrgrp: "ansible-addrgrp4" # name
144 dynamic_mapping: "your_value"
145 '''
146
147 RETURN = '''
148 meta:
149 description: The result of the request.
150 type: dict
151 returned: always
152 contains:
153 request_url:
154 description: The full url requested.
155 returned: always
156 type: str
157 sample: /sys/login/user
158 response_code:
159 description: The status of api request.
160 returned: always
161 type: int
162 sample: 0
163 response_data:
164 description: The api response.
165 type: list
166 returned: always
167 response_message:
168 description: The descriptive message of the api response.
169 type: str
170 returned: always
171 sample: OK.
172 system_information:
173 description: The information of the target system.
174 type: dict
175 returned: always
176 rc:
177 description: The status the request.
178 type: int
179 returned: always
180 sample: 0
181 version_check_warning:
182 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
183 type: list
184 returned: complex
185 '''
186 from ansible.module_utils.basic import AnsibleModule
187 from ansible.module_utils.connection import Connection
188 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
189 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
190
191
192 def main():
193 urls_list = [
194 '/pm/config/adom/{adom}/obj/firewall/addrgrp/{addrgrp}/dynamic_mapping',
195 '/pm/config/global/obj/firewall/addrgrp/{addrgrp}/dynamic_mapping'
196 ]
197 module_arg_spec = {
198 'adom': {'required': True, 'type': 'str'},
199 'addrgrp': {'required': True, 'type': 'str'},
200 'revision_note': {'type': 'str'},
201 'firewall_addrgrp_dynamicmapping': {
202 'type': 'dict', 'v_range': [['6.0.0', '']],
203 'options': {
204 '_scope': {'type': 'list', 'options': {'name': {'type': 'str'}, 'vdom': {'type': 'str'}}, 'elements': 'dict'},
205 'allow-routing': {'choices': ['disable', 'enable'], 'type': 'str'},
206 'color': {'type': 'int'},
207 'comment': {'type': 'raw'},
208 'exclude': {'choices': ['disable', 'enable'], 'type': 'str'},
209 'exclude-member': {'type': 'raw'},
210 'member': {'type': 'raw'},
211 'tags': {'type': 'raw'},
212 'uuid': {'type': 'str'},
213 'visibility': {'choices': ['disable', 'enable'], 'type': 'str'},
214 '_image-base64': {'v_range': [['6.2.2', '']], 'type': 'str'},
215 'global-object': {'v_range': [['6.4.0', '']], 'type': 'int'},
216 'type': {'v_range': [['6.4.0', '']], 'choices': ['default', 'array', 'folder'], 'type': 'str'},
217 'fabric-object': {'v_range': [['6.4.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
218 'category': {'v_range': [['7.0.0', '']], 'choices': ['default', 'ztna-ems-tag', 'ztna-geo-tag', 'telemetry'], 'type': 'str'}
219 }
220 }
221 }
222
223 module_option_spec = get_module_arg_spec('full crud')
224 module_arg_spec.update(module_option_spec)
225 check_galaxy_version(module_arg_spec)
226 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_addrgrp_dynamicmapping'),
227 supports_check_mode=True)
228 if not module._socket_path:
229 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
230 connection = Connection(module._socket_path)
231 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
232 'complex:{{module}}["_scope"][0]["name"]+"/"+{{module}}["_scope"][0]["vdom"]', 'data', module, connection)
233 fmgr.process_crud()
234 module.exit_json(meta=module.params)
235
236
237 if __name__ == '__main__':
238 main()