Debian Codegraph @

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