Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_exception_group.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_exception_group
33 short_description: Manages exception-group objects on Check Point over Web Services API
34 description:
35 - Manages exception-group 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 - Object name.
44 type: str
45 required: True
46 applied_profile:
47 description:
48 - The threat profile to apply this group to in the case of apply-on threat-rules-with-specific-profile.
49 - Available from R80.10 management version.
50 type: str
51 applied_threat_rules:
52 description:
53 - The threat rules to apply this group on in the case of apply-on manually-select-threat-rules.
54 - Available from R80.10 management version.
55 type: dict
56 suboptions:
57 add:
58 description:
59 - Adds to collection of values
60 type: list
61 elements: dict
62 suboptions:
63 layer:
64 description:
65 - The layer of the threat rule to which the group is to be attached.
66 type: str
67 name:
68 description:
69 - The name of the threat rule to which the group is to be attached.
70 type: str
71 rule_number:
72 description:
73 - The rule-number of the threat rule to which the group is to be attached.
74 type: str
75 position:
76 description:
77 - Position in the rulebase.
78 type: str
79 apply_on:
80 description:
81 - An exception group can be set to apply on all threat rules, all threat rules which have a specific profile, or those rules manually chosen by the user.
82 - Available from R80.10 management version.
83 type: str
84 choices: ['all-threat-rules', 'all-threat-rules-with-specific-profile', 'manually-select-threat-rules']
85 tags:
86 description:
87 - Collection of tag identifiers.
88 type: list
89 elements: str
90 color:
91 description:
92 - Color of the object. Should be one of existing colors.
93 type: str
94 choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green',
95 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon',
96 'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', 'yellow']
97 comments:
98 description:
99 - Comments string.
100 type: str
101 details_level:
102 description:
103 - 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
104 representation of the object.
105 type: str
106 choices: ['uid', 'standard', 'full']
107 ignore_warnings:
108 description:
109 - Apply changes ignoring warnings.
110 type: bool
111 ignore_errors:
112 description:
113 - 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.
114 type: bool
115 extends_documentation_fragment: check_point.mgmt.checkpoint_objects
116 """
117
118 EXAMPLES = """
119 - name: add-exception-group
120 cp_mgmt_exception_group:
121 applied_threat_rules.0.layer: MyLayer
122 applied_threat_rules.0.name: MyThreatRule
123 apply_on: manually-select-threat-rules
124 name: exception_group_2
125 state: present
126
127 - name: set-exception-group
128 cp_mgmt_exception_group:
129 apply_on: all-threat-rules
130 name: exception_group_2
131 state: present
132 tags: tag3
133
134 - name: delete-exception-group
135 cp_mgmt_exception_group:
136 name: exception_group_2
137 state: absent
138 """
139
140 RETURN = """
141 cp_mgmt_exception_group:
142 description: The checkpoint object created or updated.
143 returned: always, except when deleting the object.
144 type: dict
145 """
146
147 from ansible.module_utils.basic import AnsibleModule
148 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import (
149 checkpoint_argument_spec_for_objects,
150 api_call,
151 )
152
153
154 def main():
155 argument_spec = dict(
156 name=dict(type="str", required=True),
157 applied_profile=dict(type="str"),
158 applied_threat_rules=dict(
159 type="dict",
160 options=dict(
161 add=dict(
162 type="list",
163 elements="dict",
164 options=dict(
165 layer=dict(type="str"),
166 name=dict(type="str"),
167 rule_number=dict(type="str"),
168 position=dict(type="str"),
169 ),
170 )
171 ),
172 ),
173 apply_on=dict(
174 type="str",
175 choices=[
176 "all-threat-rules",
177 "all-threat-rules-with-specific-profile",
178 "manually-select-threat-rules",
179 ],
180 ),
181 tags=dict(type="list", elements="str"),
182 color=dict(
183 type="str",
184 choices=[
185 "aquamarine",
186 "black",
187 "blue",
188 "crete blue",
189 "burlywood",
190 "cyan",
191 "dark green",
192 "khaki",
193 "orchid",
194 "dark orange",
195 "dark sea green",
196 "pink",
197 "turquoise",
198 "dark blue",
199 "firebrick",
200 "brown",
201 "forest green",
202 "gold",
203 "dark gold",
204 "gray",
205 "dark gray",
206 "light green",
207 "lemon chiffon",
208 "coral",
209 "sea green",
210 "sky blue",
211 "magenta",
212 "purple",
213 "slate blue",
214 "violet red",
215 "navy blue",
216 "olive",
217 "orange",
218 "red",
219 "sienna",
220 "yellow",
221 ],
222 ),
223 comments=dict(type="str"),
224 details_level=dict(type="str", choices=["uid", "standard", "full"]),
225 ignore_warnings=dict(type="bool"),
226 ignore_errors=dict(type="bool"),
227 )
228 argument_spec.update(checkpoint_argument_spec_for_objects)
229
230 module = AnsibleModule(
231 argument_spec=argument_spec, supports_check_mode=True
232 )
233 api_call_object = "exception-group"
234
235 result = api_call(module, api_call_object)
236 module.exit_json(**result)
237
238
239 if __name__ == "__main__":
240 main()