Debian Codegraph @

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