Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_service_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_service_group
33 short_description: Manages service-group objects on Check Point over Web Services API
34 description:
35 - Manages service-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-service-group
91 cp_mgmt_service_group:
92 members:
93 - https
94 - bootp
95 - nisplus
96 - HP-OpCdistm
97 name: New Service Group 1
98 state: present
99
100 - name: set-service-group
101 cp_mgmt_service_group:
102 name: New Service Group 1
103 members:
104 - https
105 - bootp
106 - nisplus
107 state: present
108
109 - name: delete-service-group
110 cp_mgmt_service_group:
111 name: New Service Group 1
112 state: absent
113 """
114
115 RETURN = """
116 cp_mgmt_service_group:
117 description: The checkpoint object created or updated.
118 returned: always, except when deleting the object.
119 type: dict
120 """
121
122 from ansible.module_utils.basic import AnsibleModule
123 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import (
124 checkpoint_argument_spec_for_objects,
125 api_call,
126 )
127
128
129 def main():
130 argument_spec = dict(
131 name=dict(type="str", required=True),
132 members=dict(type="list", elements="str"),
133 tags=dict(type="list", elements="str"),
134 color=dict(
135 type="str",
136 choices=[
137 "aquamarine",
138 "black",
139 "blue",
140 "crete blue",
141 "burlywood",
142 "cyan",
143 "dark green",
144 "khaki",
145 "orchid",
146 "dark orange",
147 "dark sea green",
148 "pink",
149 "turquoise",
150 "dark blue",
151 "firebrick",
152 "brown",
153 "forest green",
154 "gold",
155 "dark gold",
156 "gray",
157 "dark gray",
158 "light green",
159 "lemon chiffon",
160 "coral",
161 "sea green",
162 "sky blue",
163 "magenta",
164 "purple",
165 "slate blue",
166 "violet red",
167 "navy blue",
168 "olive",
169 "orange",
170 "red",
171 "sienna",
172 "yellow",
173 ],
174 ),
175 comments=dict(type="str"),
176 details_level=dict(type="str", choices=["uid", "standard", "full"]),
177 groups=dict(type="list", elements="str"),
178 ignore_warnings=dict(type="bool"),
179 ignore_errors=dict(type="bool"),
180 )
181 argument_spec.update(checkpoint_argument_spec_for_objects)
182
183 module = AnsibleModule(
184 argument_spec=argument_spec, supports_check_mode=True
185 )
186 api_call_object = "service-group"
187
188 result = api_call(module, api_call_object)
189 module.exit_json(**result)
190
191
192 if __name__ == "__main__":
193 main()