Debian Codegraph @

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