Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_threat_exception.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 #
4 # Ansible module to manage Check Point Firewall (c) 2019
5 #
6 # Ansible is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # Ansible is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
18 #
19
20 from __future__ import absolute_import, division, print_function
21
22 __metaclass__ = type
23
24 ANSIBLE_METADATA = {
25 "metadata_version": "1.1",
26 "status": ["preview"],
27 "supported_by": "community",
28 }
29
30 DOCUMENTATION = """
31 ---
32 module: cp_mgmt_threat_exception
33 short_description: Manages threat-exception objects on Check Point over Web Services API
34 description:
35 - Manages threat-exception objects on Check Point devices including creating, updating and removing objects.
36 - All operations are performed over Web Services API.
37 - Available from R80 management version.
38 version_added: "1.0.0"
39 author: "Or Soffer (@chkp-orso)"
40 options:
41 name:
42 description:
43 - The name of the exception.
44 type: str
45 required: True
46 position:
47 description:
48 - Position in the rulebase. The use of values "top" and "bottom" may not be idempotent.
49 type: str
50 exception_group_uid:
51 description:
52 - The UID of the exception-group.
53 type: str
54 exception_group_name:
55 description:
56 - The name of the exception-group.
57 type: str
58 layer:
59 description:
60 - Layer that the rule belongs to identified by the name or UID.
61 type: str
62 rule_name:
63 description:
64 - The name of the parent rule.
65 type: str
66 action:
67 description:
68 - Action-the enforced profile.
69 type: str
70 destination:
71 description:
72 - Collection of Network objects identified by the name or UID.
73 type: list
74 elements: str
75 destination_negate:
76 description:
77 - True if negate is set for destination.
78 type: bool
79 enabled:
80 description:
81 - Enable/Disable the rule.
82 type: bool
83 install_on:
84 description:
85 - Which Gateways identified by the name or UID to install the policy on.
86 type: list
87 elements: str
88 protected_scope:
89 description:
90 - Collection of objects defining Protected Scope identified by the name or UID.
91 type: list
92 elements: str
93 protected_scope_negate:
94 description:
95 - True if negate is set for Protected Scope.
96 type: bool
97 protection_or_site:
98 description:
99 - Name of the protection or site.
100 type: list
101 elements: str
102 service:
103 description:
104 - Collection of Network objects identified by the name or UID.
105 type: list
106 elements: str
107 service_negate:
108 description:
109 - True if negate is set for Service.
110 type: bool
111 source:
112 description:
113 - Collection of Network objects identified by the name or UID.
114 type: list
115 elements: str
116 source_negate:
117 description:
118 - True if negate is set for source.
119 type: bool
120 track:
121 description:
122 - Packet tracking.
123 type: str
124 comments:
125 description:
126 - Comments string.
127 type: str
128 details_level:
129 description:
130 - The level of detail for some of the fields in the response can vary from showing only the UID value of the object to a fully detailed
131 representation of the object.
132 type: str
133 choices: ['uid', 'standard', 'full']
134 ignore_warnings:
135 description:
136 - Apply changes ignoring warnings.
137 type: bool
138 ignore_errors:
139 description:
140 - Apply changes ignoring errors. You won't be able to publish such a changes. If ignore-warnings flag was omitted - warnings will also be ignored.
141 type: bool
142 extends_documentation_fragment: check_point.mgmt.checkpoint_objects
143 """
144
145 EXAMPLES = """
146 - name: add-threat-exception
147 cp_mgmt_threat_exception:
148 layer: New Layer 1
149 name: Exception Rule
150 position: 1
151 protected_scope: All_Internet
152 rule_name: Threat Rule 1
153 state: present
154 track: Log
155
156 - name: set-threat-exception
157 cp_mgmt_threat_exception:
158 layer: New Layer 1
159 name: Exception Rule
160 rule_name: Threat Rule 1
161 state: present
162
163 - name: delete-threat-exception
164 cp_mgmt_threat_exception:
165 name: Exception Rule
166 layer: New Layer 1
167 rule_name: Threat Rule 1
168 state: absent
169 """
170
171 RETURN = """
172 cp_mgmt_threat_exception:
173 description: The checkpoint object created or updated.
174 returned: always, except when deleting the object.
175 type: dict
176 """
177
178 from ansible.module_utils.basic import AnsibleModule
179 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import (
180 checkpoint_argument_spec_for_objects,
181 api_call,
182 api_call_for_rule,
183 )
184
185
186 def main():
187 argument_spec = dict(
188 name=dict(type="str", required=True),
189 position=dict(type="str"),
190 exception_group_uid=dict(type="str"),
191 exception_group_name=dict(type="str"),
192 layer=dict(type="str"),
193 rule_name=dict(type="str"),
194 action=dict(type="str"),
195 destination=dict(type="list", elements="str"),
196 destination_negate=dict(type="bool"),
197 enabled=dict(type="bool"),
198 install_on=dict(type="list", elements="str"),
199 protected_scope=dict(type="list", elements="str"),
200 protected_scope_negate=dict(type="bool"),
201 protection_or_site=dict(type="list", elements="str"),
202 service=dict(type="list", elements="str"),
203 service_negate=dict(type="bool"),
204 source=dict(type="list", elements="str"),
205 source_negate=dict(type="bool"),
206 track=dict(type="str"),
207 comments=dict(type="str"),
208 details_level=dict(type="str", choices=["uid", "standard", "full"]),
209 ignore_warnings=dict(type="bool"),
210 ignore_errors=dict(type="bool"),
211 )
212 argument_spec.update(checkpoint_argument_spec_for_objects)
213
214 module = AnsibleModule(
215 argument_spec=argument_spec, supports_check_mode=True
216 )
217 api_call_object = "threat-exception"
218
219 if module.params["position"] is None:
220 result = api_call(module, api_call_object)
221 else:
222 result = api_call_for_rule(module, api_call_object)
223
224 module.exit_json(**result)
225
226
227 if __name__ == "__main__":
228 main()