Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_log_exporter.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 #
4 # Ansible module to manage CheckPoint 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 = {'metadata_version': '1.1',
25 'status': ['preview'],
26 'supported_by': 'community'}
27
28 DOCUMENTATION = """
29 ---
30 module: cp_mgmt_log_exporter
31 short_description: Manages log-exporter objects on Checkpoint over Web Services API
32 description:
33 - Manages log-exporter objects on Checkpoint devices including creating, updating and removing objects.
34 - All operations are performed over Web Services API.
35 - Available from R82 JHF management version.
36 version_added: "6.5.0"
37 author: "Dor Berenstein (@chkp-dorbe)"
38 options:
39 name:
40 description:
41 - Object name.
42 type: str
43 required: True
44 target_server:
45 description:
46 - Target server port to which logs are exported.
47 type: str
48 target_port:
49 description:
50 - Port number of the target server.
51 type: int
52 protocol:
53 description:
54 - Protocol used to send logs to the target server.
55 type: str
56 choices: ['udp', 'tcp']
57 enabled:
58 description:
59 - Indicates whether to enable export.
60 type: bool
61 attachments:
62 description:
63 - Log exporter attachments.
64 type: dict
65 suboptions:
66 add_link_to_log_attachment:
67 description:
68 - Indicates whether to add link to log attachment in SmartView.
69 type: bool
70 add_link_to_log_details:
71 description:
72 - Indicates whether to add link to log details in SmartView.
73 type: bool
74 add_log_attachment_id:
75 description:
76 - Indicates whether to add log attachment ID.
77 type: bool
78 data_manipulation:
79 description:
80 - Log exporter data manipulation.
81 type: dict
82 suboptions:
83 aggregate_log_updates:
84 description:
85 - Indicates whether to aggregate log updates.
86 type: bool
87 format:
88 description:
89 - Logs format.
90 type: str
91 choices: ['syslog', 'cef', 'leef', 'generic', 'splunk', 'logrhythm', 'json']
92 color:
93 description:
94 - Color of the object. Should be one of existing colors.
95 type: str
96 choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green',
97 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon',
98 'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', 'yellow']
99 comments:
100 description:
101 - Comments string.
102 type: str
103 details_level:
104 description:
105 - 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
106 representation of the object.
107 type: str
108 choices: ['uid', 'standard', 'full']
109 domains_to_process:
110 description:
111 - Indicates which domains to process the commands on. It cannot be used with the details-level full, must be run from the System Domain only and
112 with ignore-warnings true. Valid values are, CURRENT_DOMAIN, ALL_DOMAINS_ON_THIS_SERVER.
113 type: list
114 elements: str
115 tags:
116 description:
117 - Collection of tag identifiers.
118 type: list
119 elements: str
120 ignore_warnings:
121 description:
122 - Apply changes ignoring warnings.
123 type: bool
124 ignore_errors:
125 description:
126 - 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.
127 type: bool
128 extends_documentation_fragment: check_point.mgmt.checkpoint_objects
129 """
130
131 EXAMPLES = """
132 - name: add-log-exporter
133 cp_mgmt_log_exporter:
134 attachments:
135 add_link_to_log_attachment: true
136 name: newLogExporter
137 protocol: tcp
138 state: present
139 target_port: 1234
140 target_server: 1.2.3.4
141
142 - name: set-log-exporter
143 cp_mgmt_log_exporter:
144 data_manipulation:
145 format: json
146 name: newLogExporter
147 state: present
148 target_port: 999
149
150 - name: delete-log-exporter
151 cp_mgmt_log_exporter:
152 name: newLogExporter
153 state: absent
154 """
155
156 RETURN = """
157 cp_mgmt_log_exporter:
158 description: The checkpoint object created or updated.
159 returned: always, except when deleting the object.
160 type: dict
161 """
162
163 from ansible.module_utils.basic import AnsibleModule
164 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import checkpoint_argument_spec_for_objects, api_call
165
166
167 def main():
168 argument_spec = dict(
169 name=dict(type='str', required=True),
170 target_server=dict(type='str'),
171 target_port=dict(type='int'),
172 protocol=dict(type='str', choices=['udp', 'tcp']),
173 enabled=dict(type='bool'),
174 attachments=dict(type='dict', options=dict(
175 add_link_to_log_attachment=dict(type='bool'),
176 add_link_to_log_details=dict(type='bool'),
177 add_log_attachment_id=dict(type='bool')
178 )),
179 data_manipulation=dict(type='dict', options=dict(
180 aggregate_log_updates=dict(type='bool'),
181 format=dict(type='str', choices=['syslog', 'cef', 'leef', 'generic', 'splunk', 'logrhythm', 'json'])
182 )),
183 color=dict(type='str', choices=['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green',
184 'khaki', 'orchid', 'dark orange', 'dark sea green', 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown',
185 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon', 'coral', 'sea green',
186 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna',
187 'yellow']),
188 comments=dict(type='str'),
189 details_level=dict(type='str', choices=['uid', 'standard', 'full']),
190 domains_to_process=dict(type='list', elements="str"),
191 tags=dict(type='list', elements="str"),
192 ignore_warnings=dict(type='bool'),
193 ignore_errors=dict(type='bool')
194 )
195 argument_spec.update(checkpoint_argument_spec_for_objects)
196
197 module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
198 api_call_object = 'log-exporter'
199
200 result = api_call(module, api_call_object)
201 module.exit_json(**result)
202
203
204 if __name__ == '__main__':
205 main()