Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_address6template_subnetsegment.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_address6template_subnetsegment
15 short_description: IPv6 subnet segments.
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 address6-template:
29 description: Deprecated, please use "address6_template"
30 type: str
31 address6_template:
32 description: The parameter (address6-template) in requested url.
33 type: str
34 firewall_address6template_subnetsegment:
35 description: The top level parameters set.
36 required: false
37 type: dict
38 suboptions:
39 bits:
40 type: int
41 description: Number of bits.
42 exclusive:
43 type: str
44 description: Enable/disable exclusive value.
45 choices: ['disable', 'enable']
46 id:
47 type: int
48 description: Subnet segment ID.
49 required: true
50 name:
51 type: str
52 description: Subnet segment name.
53 values:
54 type: list
55 elements: dict
56 description: Values.
57 suboptions:
58 name:
59 type: str
60 description: Subnet segment value name.
61 value:
62 type: str
63 description: Subnet segment value.
64 '''
65
66 EXAMPLES = '''
67 - name: Example playbook
68 hosts: fortimanagers
69 gather_facts: false
70 connection: httpapi
71 vars:
72 ansible_httpapi_use_ssl: true
73 ansible_httpapi_validate_certs: false
74 ansible_httpapi_port: 443
75 tasks:
76 - name: IPv6 subnet segments.
77 fortinet.fortimanager.fmgr_firewall_address6template_subnetsegment:
78 bypass_validation: false
79 adom: ansible
80 address6_template: "ansible-name" # name
81 state: present
82 firewall_address6template_subnetsegment:
83 bits: 2
84 exclusive: enable
85 id: 1
86 name: "ansible-name-sub"
87 values:
88 - name: "ansible-name-val"
89 value: "ansible"
90
91 - name: Gathering fortimanager facts
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: Retrieve all the subnet segments in the IPv6 address template
101 fortinet.fortimanager.fmgr_fact:
102 facts:
103 selector: "firewall_address6template_subnetsegment"
104 params:
105 adom: "ansible"
106 address6_template: "ansible-name" # name
107 subnet_segment: "your_value"
108 '''
109
110 RETURN = '''
111 meta:
112 description: The result of the request.
113 type: dict
114 returned: always
115 contains:
116 request_url:
117 description: The full url requested.
118 returned: always
119 type: str
120 sample: /sys/login/user
121 response_code:
122 description: The status of api request.
123 returned: always
124 type: int
125 sample: 0
126 response_data:
127 description: The api response.
128 type: list
129 returned: always
130 response_message:
131 description: The descriptive message of the api response.
132 type: str
133 returned: always
134 sample: OK.
135 system_information:
136 description: The information of the target system.
137 type: dict
138 returned: always
139 rc:
140 description: The status the request.
141 type: int
142 returned: always
143 sample: 0
144 version_check_warning:
145 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
146 type: list
147 returned: complex
148 '''
149 from ansible.module_utils.basic import AnsibleModule
150 from ansible.module_utils.connection import Connection
151 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
152 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
153
154
155 def main():
156 urls_list = [
157 '/pm/config/adom/{adom}/obj/firewall/address6-template/{address6-template}/subnet-segment',
158 '/pm/config/global/obj/firewall/address6-template/{address6-template}/subnet-segment'
159 ]
160 module_arg_spec = {
161 'adom': {'required': True, 'type': 'str'},
162 'address6-template': {'type': 'str', 'api_name': 'address6_template'},
163 'address6_template': {'type': 'str'},
164 'revision_note': {'type': 'str'},
165 'firewall_address6template_subnetsegment': {
166 'type': 'dict', 'v_range': [['6.0.0', '']],
167 'options': {
168 'bits': {'type': 'int'},
169 'exclusive': {'choices': ['disable', 'enable'], 'type': 'str'},
170 'id': {'required': True, 'type': 'int'},
171 'name': {'type': 'str'},
172 'values': {'type': 'list', 'options': {'name': {'type': 'str'}, 'value': {'type': 'str'}}, 'elements': 'dict'}
173 }
174 }
175 }
176
177 module_option_spec = get_module_arg_spec('full crud')
178 module_arg_spec.update(module_option_spec)
179 check_galaxy_version(module_arg_spec)
180 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_address6template_subnetsegment'),
181 supports_check_mode=True)
182 if not module._socket_path:
183 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
184 connection = Connection(module._socket_path)
185 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
186 'id', 'data', module, connection)
187 fmgr.process_crud()
188 module.exit_json(meta=module.params)
189
190
191 if __name__ == '__main__':
192 main()