Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_smtp_server_facts.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_facts
33 short_description: Get smtp-server objects facts on Checkpoint over Web Services API
34 description:
35 - Get smtp-server objects facts on Checkpoint devices.
36 - All operations are performed over Web Services API.
37 - This module handles both operations, get a specific object and get several objects,
38 For getting a specific object use the parameter 'name'.
39 - Available from R81.20 management version.
40 version_added: "3.0.0"
41 author: "Eden Brillant (@chkp-edenbr)"
42 options:
43 name:
44 description:
45 - Object name.
46 This parameter is relevant only for getting a specific object.
47 type: str
48 details_level:
49 description:
50 - 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
51 representation of the object.
52 type: str
53 choices: ['uid', 'standard', 'full']
54 filter:
55 description:
56 - Search expression to filter objects by. The provided text should be exactly the same as it would be given in SmartConsole Object Explorer. The
57 logical operators in the expression ('AND', 'OR') should be provided in capital letters. The search involves both a IP search and a textual search in
58 name, comment, tags etc.
59 type: str
60 limit:
61 description:
62 - The maximal number of returned results.
63 This parameter is relevant only for getting few objects.
64 type: int
65 offset:
66 description:
67 - Number of the results to initially skip.
68 This parameter is relevant only for getting few objects.
69 type: int
70 order:
71 description:
72 - Sorts the results by search criteria. Automatically sorts the results by Name, in the ascending order.
73 This parameter is relevant only for getting few objects.
74 type: list
75 elements: dict
76 suboptions:
77 ASC:
78 description:
79 - Sorts results by the given field in ascending order.
80 type: str
81 choices: ['name']
82 DESC:
83 description:
84 - Sorts results by the given field in descending order.
85 type: str
86 choices: ['name']
87 domains_to_process:
88 description:
89 - 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
90 with ignore-warnings true. Valid values are, CURRENT_DOMAIN, ALL_DOMAINS_ON_THIS_SERVER.
91 type: list
92 elements: str
93 extends_documentation_fragment: check_point.mgmt.checkpoint_facts
94 """
95
96 EXAMPLES = """
97 - name: show-smtp-server
98 cp_mgmt_smtp_server_facts:
99 name: SMTP
100
101 - name: show-smtp-servers
102 cp_mgmt_smtp_server_facts:
103 details_level: standard
104 limit: 50
105 offset: 0
106 """
107
108 RETURN = """
109 ansible_facts:
110 description: The checkpoint object facts.
111 returned: always.
112 type: dict
113 """
114
115 from ansible.module_utils.basic import AnsibleModule
116 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import (
117 checkpoint_argument_spec_for_facts,
118 api_call_facts,
119 )
120
121
122 def main():
123 argument_spec = dict(
124 name=dict(type="str"),
125 details_level=dict(type="str", choices=["uid", "standard", "full"]),
126 filter=dict(type="str"),
127 limit=dict(type="int"),
128 offset=dict(type="int"),
129 order=dict(
130 type="list",
131 elements="dict",
132 options=dict(
133 ASC=dict(type="str", choices=["name"]),
134 DESC=dict(type="str", choices=["name"]),
135 ),
136 ),
137 domains_to_process=dict(type="list", elements="str"),
138 )
139 argument_spec.update(checkpoint_argument_spec_for_facts)
140
141 module = AnsibleModule(
142 argument_spec=argument_spec, supports_check_mode=True
143 )
144
145 api_call_object = "smtp-server"
146 api_call_object_plural_version = "smtp-servers"
147
148 result = api_call_facts(
149 module, api_call_object, api_call_object_plural_version
150 )
151 module.exit_json(ansible_facts=result)
152
153
154 if __name__ == "__main__":
155 main()