Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_service_sctp.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_sctp
33 short_description: Manages service-sctp objects on Check Point over Web Services API
34 description:
35 - Manages service-sctp 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 port:
47 description:
48 - Port number. To specify a port range add a hyphen between the lowest and the highest port numbers, for example 44-45.
49 type: str
50 aggressive_aging:
51 description:
52 - Sets short (aggressive) timeouts for idle connections.
53 type: dict
54 suboptions:
55 default_timeout:
56 description:
57 - Default aggressive aging timeout in seconds.
58 type: int
59 enable:
60 description:
61 - N/A
62 type: bool
63 timeout:
64 description:
65 - Aggressive aging timeout in seconds.
66 type: int
67 use_default_timeout:
68 description:
69 - N/A
70 type: bool
71 keep_connections_open_after_policy_installation:
72 description:
73 - Keep connections open after policy has been installed even if they are not allowed under the new policy. This overrides the settings in the
74 Connection Persistence page. If you change this property, the change will not affect open connections, but only future connections.
75 type: bool
76 match_for_any:
77 description:
78 - Indicates whether this service is used when 'Any' is set as the rule's service and there are several service objects with the same source port
79 and protocol.
80 type: bool
81 session_timeout:
82 description:
83 - Time (in seconds) before the session times out.
84 type: int
85 source_port:
86 description:
87 - Source port number. To specify a port range add a hyphen between the lowest and the highest port numbers, for example 44-45.
88 type: str
89 sync_connections_on_cluster:
90 description:
91 - Enables state-synchronized High Availability or Load Sharing on a ClusterXL or OPSEC-certified cluster.
92 type: bool
93 tags:
94 description:
95 - Collection of tag identifiers.
96 type: list
97 elements: str
98 use_default_session_timeout:
99 description:
100 - Use default virtual session timeout.
101 - Available from R80.10 management version.
102 type: bool
103 color:
104 description:
105 - Color of the object. Should be one of existing colors.
106 type: str
107 choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green',
108 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon',
109 'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', 'yellow']
110 comments:
111 description:
112 - Comments string.
113 type: str
114 details_level:
115 description:
116 - 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
117 representation of the object.
118 type: str
119 choices: ['uid', 'standard', 'full']
120 groups:
121 description:
122 - Collection of group identifiers.
123 type: list
124 elements: str
125 ignore_warnings:
126 description:
127 - Apply changes ignoring warnings.
128 type: bool
129 ignore_errors:
130 description:
131 - 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.
132 type: bool
133 extends_documentation_fragment: check_point.mgmt.checkpoint_objects
134 """
135
136 EXAMPLES = """
137 - name: add-service-sctp
138 cp_mgmt_service_sctp:
139 aggressive_aging:
140 enable: true
141 timeout: 360
142 use_default_timeout: false
143 keep_connections_open_after_policy_installation: false
144 match_for_any: true
145 name: New_SCTP_Service_1
146 port: 5669
147 session_timeout: 0
148 state: present
149 sync_connections_on_cluster: true
150
151 - name: set-service-sctp
152 cp_mgmt_service_sctp:
153 aggressive_aging:
154 default_timeout: 3600
155 color: green
156 name: New_SCTP_Service_1
157 port: 5656
158 state: present
159
160 - name: delete-service-sctp
161 cp_mgmt_service_sctp:
162 name: New_SCTP_Service_2
163 state: absent
164 """
165
166 RETURN = """
167 cp_mgmt_service_sctp:
168 description: The checkpoint object created or updated.
169 returned: always, except when deleting the object.
170 type: dict
171 """
172
173 from ansible.module_utils.basic import AnsibleModule
174 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import (
175 checkpoint_argument_spec_for_objects,
176 api_call,
177 )
178
179
180 def main():
181 argument_spec = dict(
182 name=dict(type="str", required=True),
183 port=dict(type="str"),
184 aggressive_aging=dict(
185 type="dict",
186 options=dict(
187 default_timeout=dict(type="int"),
188 enable=dict(type="bool"),
189 timeout=dict(type="int"),
190 use_default_timeout=dict(type="bool"),
191 ),
192 ),
193 keep_connections_open_after_policy_installation=dict(type="bool"),
194 match_for_any=dict(type="bool"),
195 session_timeout=dict(type="int"),
196 source_port=dict(type="str"),
197 sync_connections_on_cluster=dict(type="bool"),
198 tags=dict(type="list", elements="str"),
199 use_default_session_timeout=dict(type="bool"),
200 color=dict(
201 type="str",
202 choices=[
203 "aquamarine",
204 "black",
205 "blue",
206 "crete blue",
207 "burlywood",
208 "cyan",
209 "dark green",
210 "khaki",
211 "orchid",
212 "dark orange",
213 "dark sea green",
214 "pink",
215 "turquoise",
216 "dark blue",
217 "firebrick",
218 "brown",
219 "forest green",
220 "gold",
221 "dark gold",
222 "gray",
223 "dark gray",
224 "light green",
225 "lemon chiffon",
226 "coral",
227 "sea green",
228 "sky blue",
229 "magenta",
230 "purple",
231 "slate blue",
232 "violet red",
233 "navy blue",
234 "olive",
235 "orange",
236 "red",
237 "sienna",
238 "yellow",
239 ],
240 ),
241 comments=dict(type="str"),
242 details_level=dict(type="str", choices=["uid", "standard", "full"]),
243 groups=dict(type="list", elements="str"),
244 ignore_warnings=dict(type="bool"),
245 ignore_errors=dict(type="bool"),
246 )
247 argument_spec.update(checkpoint_argument_spec_for_objects)
248
249 module = AnsibleModule(
250 argument_spec=argument_spec, supports_check_mode=True
251 )
252 api_call_object = "service-sctp"
253
254 result = api_call(module, api_call_object)
255 module.exit_json(**result)
256
257
258 if __name__ == "__main__":
259 main()