Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_smtp_server.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 = {
25 "metadata_version": "1.1",
26 "status": ["preview"],
27 "supported_by": "community",
28 }
29
30 DOCUMENTATION = """
31 ---
32 module: cp_mgmt_smtp_server
33 short_description: Manages smtp-server objects on Checkpoint over Web Services API
34 description:
35 - Manages smtp-server objects on Checkpoint devices including creating, updating and removing objects.
36 - All operations are performed over Web Services API.
37 - Available from R81.20 management version.
38 version_added: "3.0.0"
39 author: "Eden Brillant (@chkp-edenbr)"
40 options:
41 name:
42 description:
43 - Object name.
44 type: str
45 required: True
46 port:
47 description:
48 - The SMTP port to use.
49 type: int
50 server:
51 description:
52 - The SMTP server address.
53 type: str
54 password:
55 description:
56 - A password for the SMTP server.
57 type: str
58 username:
59 description:
60 - A username for the SMTP server.
61 type: str
62 authentication:
63 description:
64 - Does the mail server requires authentication.
65 type: bool
66 encryption:
67 description:
68 - Encryption type.
69 type: str
70 choices: ['none', 'ssl', 'tls']
71 tags:
72 description:
73 - Collection of tag identifiers.
74 type: list
75 elements: str
76 color:
77 description:
78 - Color of the object. Should be one of existing colors.
79 type: str
80 choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green',
81 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon',
82 'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', 'yellow']
83 comments:
84 description:
85 - Comments string.
86 type: str
87 details_level:
88 description:
89 - 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
90 representation of the object.
91 type: str
92 choices: ['uid', 'standard', 'full']
93 domains_to_process:
94 description:
95 - 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
96 with ignore-warnings true. Valid values are, CURRENT_DOMAIN, ALL_DOMAINS_ON_THIS_SERVER.
97 type: list
98 elements: str
99 ignore_warnings:
100 description:
101 - Apply changes ignoring warnings.
102 type: bool
103 ignore_errors:
104 description:
105 - 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.
106 type: bool
107 extends_documentation_fragment: check_point.mgmt.checkpoint_objects
108 """
109
110 EXAMPLES = """
111 - name: add-smtp-server
112 cp_mgmt_smtp_server:
113 encryption: none
114 name: SMTP1
115 port: '25'
116 server: smtp.example.com
117 state: present
118
119 - name: set-smtp-server
120 cp_mgmt_smtp_server:
121 name: SMTP
122 port: '25'
123 server: smtp.example.com
124 state: present
125
126 - name: delete-smtp-server
127 cp_mgmt_smtp_server:
128 name: SMTP
129 state: absent
130 """
131
132 RETURN = """
133 cp_mgmt_smtp_server:
134 description: The checkpoint object created or updated.
135 returned: always, except when deleting the object.
136 type: dict
137 """
138
139 from ansible.module_utils.basic import AnsibleModule
140 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import (
141 checkpoint_argument_spec_for_objects,
142 api_call,
143 )
144
145
146 def main():
147 argument_spec = dict(
148 name=dict(type="str", required=True),
149 port=dict(type="int"),
150 server=dict(type="str"),
151 password=dict(type="str", no_log=True),
152 username=dict(type="str"),
153 authentication=dict(type="bool"),
154 encryption=dict(type="str", choices=["none", "ssl", "tls"]),
155 tags=dict(type="list", elements="str"),
156 color=dict(
157 type="str",
158 choices=[
159 "aquamarine",
160 "black",
161 "blue",
162 "crete blue",
163 "burlywood",
164 "cyan",
165 "dark green",
166 "khaki",
167 "orchid",
168 "dark orange",
169 "dark sea green",
170 "pink",
171 "turquoise",
172 "dark blue",
173 "firebrick",
174 "brown",
175 "forest green",
176 "gold",
177 "dark gold",
178 "gray",
179 "dark gray",
180 "light green",
181 "lemon chiffon",
182 "coral",
183 "sea green",
184 "sky blue",
185 "magenta",
186 "purple",
187 "slate blue",
188 "violet red",
189 "navy blue",
190 "olive",
191 "orange",
192 "red",
193 "sienna",
194 "yellow",
195 ],
196 ),
197 comments=dict(type="str"),
198 details_level=dict(type="str", choices=["uid", "standard", "full"]),
199 domains_to_process=dict(type="list", elements="str"),
200 ignore_warnings=dict(type="bool"),
201 ignore_errors=dict(type="bool"),
202 )
203 argument_spec.update(checkpoint_argument_spec_for_objects)
204
205 module = AnsibleModule(
206 argument_spec=argument_spec, supports_check_mode=True
207 )
208 api_call_object = "smtp-server"
209
210 result = api_call(module, api_call_object)
211 module.exit_json(**result)
212
213
214 if __name__ == "__main__":
215 main()