Debian Codegraph @

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