Debian Codegraph @

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