Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_internetserviceextension_entry.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_internetserviceextension_entry
15 short_description: Entries added to the Internet Service extension database.
16 version_added: "2.10.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 internet-service-extension:
29 description: Deprecated, please use "internet_service_extension"
30 type: str
31 internet_service_extension:
32 description: The parameter (internet-service-extension) in requested url.
33 type: str
34 firewall_internetserviceextension_entry:
35 description: The top level parameters set.
36 required: false
37 type: dict
38 suboptions:
39 addr_mode:
40 aliases: ['addr-mode']
41 type: str
42 description: Address mode
43 choices: ['ipv4', 'ipv6']
44 dst:
45 type: list
46 elements: str
47 description: Destination address or address group name.
48 dst6:
49 type: list
50 elements: str
51 description: Destination address6 or address6 group name.
52 id:
53 type: int
54 description: Entry ID
55 required: true
56 port_range:
57 aliases: ['port-range']
58 type: list
59 elements: dict
60 description: Port range.
61 suboptions:
62 end_port:
63 aliases: ['end-port']
64 type: int
65 description: Integer value for ending TCP/UDP/SCTP destination port in range
66 id:
67 type: int
68 description: Custom entry port range ID.
69 start_port:
70 aliases: ['start-port']
71 type: int
72 description: Integer value for starting TCP/UDP/SCTP destination port in range
73 protocol:
74 type: int
75 description: Integer value for the protocol type as defined by IANA
76 '''
77
78 EXAMPLES = '''
79 - name: Example playbook (generated based on argument schema)
80 hosts: fortimanagers
81 connection: httpapi
82 gather_facts: false
83 tasks:
84 - name: Entries added to the Internet Service extension database.
85 fortinet.fortimanager.fmgr_firewall_internetserviceextension_entry:
86 # workspace_locking_adom: <global or your adom name>
87 adom: <your own value>
88 internet_service_extension: <your own value>
89 state: present # <value in [present, absent]>
90 firewall_internetserviceextension_entry:
91 id: 0 # Required variable, integer
92 # addr_mode: <value in [ipv4, ipv6]>
93 # dst: <list or string>
94 # dst6: <list or string>
95 # port_range:
96 # - end_port: <integer>
97 # id: <integer>
98 # start_port: <integer>
99 # protocol: <integer>
100 '''
101
102 RETURN = '''
103 meta:
104 description: The result of the request.
105 type: dict
106 returned: always
107 contains:
108 request_url:
109 description: The full url requested.
110 returned: always
111 type: str
112 sample: /sys/login/user
113 response_code:
114 description: The status of api request.
115 returned: always
116 type: int
117 sample: 0
118 response_data:
119 description: The api response.
120 type: list
121 returned: always
122 response_message:
123 description: The descriptive message of the api response.
124 type: str
125 returned: always
126 sample: OK.
127 system_information:
128 description: The information of the target system.
129 type: dict
130 returned: always
131 rc:
132 description: The status the request.
133 type: int
134 returned: always
135 sample: 0
136 version_check_warning:
137 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
138 type: list
139 returned: complex
140 '''
141 from ansible.module_utils.basic import AnsibleModule
142 from ansible.module_utils.connection import Connection
143 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
144 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
145
146
147 def main():
148 urls_list = [
149 '/pm/config/adom/{adom}/obj/firewall/internet-service-extension/{internet-service-extension}/entry',
150 '/pm/config/global/obj/firewall/internet-service-extension/{internet-service-extension}/entry'
151 ]
152 module_arg_spec = {
153 'adom': {'required': True, 'type': 'str'},
154 'internet-service-extension': {'type': 'str', 'api_name': 'internet_service_extension'},
155 'internet_service_extension': {'type': 'str'},
156 'revision_note': {'type': 'str'},
157 'firewall_internetserviceextension_entry': {
158 'type': 'dict', 'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']],
159 'options': {
160 'addr-mode': {'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']], 'choices': ['ipv4', 'ipv6'], 'type': 'str'},
161 'dst': {'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']], 'type': 'list', 'elements': 'str'},
162 'dst6': {'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']], 'type': 'list', 'elements': 'str'},
163 'id': {'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']], 'required': True, 'type': 'int'},
164 'port-range': {
165 'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']],
166 'type': 'list',
167 'options': {
168 'end-port': {'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']], 'type': 'int'},
169 'id': {'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']], 'type': 'int'},
170 'start-port': {'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']], 'type': 'int'}
171 },
172 'elements': 'dict'
173 },
174 'protocol': {'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']], 'type': 'int'}
175 }
176 }
177 }
178
179 module_option_spec = get_module_arg_spec('full crud')
180 module_arg_spec.update(module_option_spec)
181 check_galaxy_version(module_arg_spec)
182 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_internetserviceextension_entry'),
183 supports_check_mode=True)
184 if not module._socket_path:
185 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
186 connection = Connection(module._socket_path)
187 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
188 'id', 'data', module, connection)
189 fmgr.process_crud()
190 module.exit_json(meta=module.params)
191
192
193 if __name__ == '__main__':
194 main()