Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_group_with_exclusion.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_group_with_exclusion
33 short_description: Manages group-with-exclusion objects on Check Point over Web Services API
34 description:
35 - Manages group-with-exclusion 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 except:
47 description:
48 - Name or UID of an object which the group excludes.
49 type: str
50 include:
51 description:
52 - Name or UID of an object which the group includes.
53 type: str
54 tags:
55 description:
56 - Collection of tag identifiers.
57 type: list
58 elements: str
59 color:
60 description:
61 - Color of the object. Should be one of existing colors.
62 type: str
63 choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green',
64 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon',
65 'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', 'yellow']
66 comments:
67 description:
68 - Comments string.
69 type: str
70 details_level:
71 description:
72 - 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
73 representation of the object.
74 type: str
75 choices: ['uid', 'standard', 'full']
76 groups:
77 description:
78 - Collection of group identifiers.
79 type: list
80 elements: str
81 ignore_warnings:
82 description:
83 - Apply changes ignoring warnings.
84 type: bool
85 ignore_errors:
86 description:
87 - 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.
88 type: bool
89 extends_documentation_fragment: check_point.mgmt.checkpoint_objects
90 """
91
92 EXAMPLES = """
93 - name: add-group-with-exclusion
94 cp_mgmt_group_with_exclusion:
95 except: New Group 2
96 include: New Group 1
97 name: Group with exclusion
98 state: present
99
100 - name: set-group-with-exclusion
101 cp_mgmt_group_with_exclusion:
102 except: New Group 1
103 include: New Group 2
104 name: Group with exclusion
105 state: present
106
107 - name: delete-group-with-exclusion
108 cp_mgmt_group_with_exclusion:
109 name: Group with exclusion
110 state: absent
111 """
112
113 RETURN = """
114 cp_mgmt_group_with_exclusion:
115 description: The checkpoint object created or updated.
116 returned: always, except when deleting the object.
117 type: dict
118 """
119
120 from ansible.module_utils.basic import AnsibleModule
121 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import (
122 checkpoint_argument_spec_for_objects,
123 api_call,
124 )
125
126
127 def main():
128 argument_spec = dict(
129 name=dict(type="str", required=True),
130 include=dict(type="str"),
131 tags=dict(type="list", elements="str"),
132 color=dict(
133 type="str",
134 choices=[
135 "aquamarine",
136 "black",
137 "blue",
138 "crete blue",
139 "burlywood",
140 "cyan",
141 "dark green",
142 "khaki",
143 "orchid",
144 "dark orange",
145 "dark sea green",
146 "pink",
147 "turquoise",
148 "dark blue",
149 "firebrick",
150 "brown",
151 "forest green",
152 "gold",
153 "dark gold",
154 "gray",
155 "dark gray",
156 "light green",
157 "lemon chiffon",
158 "coral",
159 "sea green",
160 "sky blue",
161 "magenta",
162 "purple",
163 "slate blue",
164 "violet red",
165 "navy blue",
166 "olive",
167 "orange",
168 "red",
169 "sienna",
170 "yellow",
171 ],
172 ),
173 comments=dict(type="str"),
174 details_level=dict(type="str", choices=["uid", "standard", "full"]),
175 groups=dict(type="list", elements="str"),
176 ignore_warnings=dict(type="bool"),
177 ignore_errors=dict(type="bool"),
178 )
179 argument_spec["except"] = dict(type="str")
180 argument_spec.update(checkpoint_argument_spec_for_objects)
181
182 module = AnsibleModule(
183 argument_spec=argument_spec, supports_check_mode=True
184 )
185 api_call_object = "group-with-exclusion"
186
187 result = api_call(module, api_call_object)
188 module.exit_json(**result)
189
190
191 if __name__ == "__main__":
192 main()