Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_objects_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_objects_facts
33 short_description: Get objects objects facts on Checkpoint over Web Services API
34 description:
35 - Get 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 R80 management version.
40 version_added: "3.0.0"
41 author: "Eden Brillant (@chkp-edenbr)"
42 options:
43 uid:
44 description:
45 - Object unique identifier.
46 type: str
47 uids:
48 description:
49 - List of UIDs of the objects to retrieve.
50 - Available from R81.10 JHF management version.
51 type: list
52 elements: str
53 filter:
54 description:
55 - Search expression to filter objects by. The provided text should be exactly the same as it would be given in Smart Console. The logical
56 operators in the expression ('AND', 'OR') should be provided in capital letters. By default, the search involves both a textual search and a IP
57 search. To use IP search only, set the "ip-only" parameter to true.
58 - Available from R80.10 management version.
59 type: str
60 ip_only:
61 description:
62 - If using "filter", use this field to search objects by their IP address only, without involving the textual search.<br><br>IP search use
63 cases<br>&nbsp;&nbsp;&nbsp;&nbsp; <ul><li>Full IPv4 address matches for,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - Hosts, Check Point
64 Hosts and Gateways with exact IPv4 match or with interfaces which subnet contains the search
65 address<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - IPv4 Networks and IPv4 Address Ranges that contain the search address</li>
66 <br>&nbsp;&nbsp;&nbsp;&nbsp; <li>Partial IPv4 address matches for,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - Hosts, Networks, Check Point
67 Hosts and Gateways with IPv4 address that starts from the search address<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - Hosts, Check Point
68 Hosts and Gateways with interfaces which subnet address starts from the search address<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - IPv4
69 Address Ranges with first address or last address that starts from the search address<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - IPv4
70 Networks and IPv4 Address Ranges that contain the network derived from the search address supplemented with missing octets (all
71 zeroes)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - Hosts, Check Point Hosts and Gateways with interfaces which subnet contains the network
72 derived from the search address supplemented with missing octets (all zeroes)</li><br>&nbsp;&nbsp;&nbsp;&nbsp; <li>IPv6
73 address,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - Not supported</li></ul><br><br> * Check Point Host is a server of type Network Policy
74 Management, Logging & Status, SmartEvent, etc.<br> * When one IP address is checked to start from another (partial) IP address - only full octets are
75 considered <br> * Check Examples part for IP search examples.
76 - Available from R80.10 management version.
77 type: bool
78 limit:
79 description:
80 - The maximal number of returned results.
81 This parameter is relevant only for getting a specific object.
82 type: int
83 offset:
84 description:
85 - Number of the results to initially skip.
86 This parameter is relevant only for getting a specific object.
87 type: int
88 order:
89 description:
90 - Sorts the results by search criteria. Automatically sorts the results by Name, in the ascending order.
91 This parameter is relevant only for getting a specific object.
92 type: list
93 elements: dict
94 suboptions:
95 ASC:
96 description:
97 - Sorts results by the given field in ascending order.
98 type: str
99 choices: ['name']
100 DESC:
101 description:
102 - Sorts results by the given field in descending order.
103 type: str
104 choices: ['name']
105 type:
106 description:
107 - The objects' type, e.g., host, service-tcp, network, address-range...
108 type: str
109 dereference_group_members:
110 description:
111 - Indicates whether to dereference "members" field by details level for every object in reply.
112 - Available from R80.10 management version.
113 type: bool
114 show_membership:
115 description:
116 - Indicates whether to calculate and show "groups" field for every object in reply.
117 - Available from R80.10 management version.
118 type: bool
119 details_level:
120 description:
121 - 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
122 representation of the object.
123 type: str
124 choices: ['uid', 'standard', 'full']
125 domains_to_process:
126 description:
127 - 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
128 with ignore-warnings true. Valid values are, CURRENT_DOMAIN, ALL_DOMAINS_ON_THIS_SERVER.
129 - Available from R81 management version.
130 type: list
131 elements: str
132 extends_documentation_fragment: check_point.mgmt.checkpoint_facts
133 """
134
135 EXAMPLES = """
136 - name: show-objects
137 cp_mgmt_objects_facts:
138 limit: 50
139 offset: 0
140 order:
141 - ASC: name
142 type: group
143
144 - name: show-object
145 cp_mgmt_objects_facts:
146 uid: ef82887c-d08f-49a3-a18f-a376be633848
147 """
148
149 RETURN = """
150 ansible_facts:
151 description: The checkpoint object facts.
152 returned: always.
153 type: dict
154 """
155
156 from ansible.module_utils.basic import AnsibleModule
157 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import (
158 checkpoint_argument_spec_for_facts,
159 api_call_facts,
160 )
161
162
163 def main():
164 argument_spec = dict(
165 uid=dict(type="str"),
166 uids=dict(type="list", elements="str"),
167 filter=dict(type="str"),
168 ip_only=dict(type="bool"),
169 limit=dict(type="int"),
170 offset=dict(type="int"),
171 order=dict(
172 type="list",
173 elements="dict",
174 options=dict(
175 ASC=dict(type="str", choices=["name"]),
176 DESC=dict(type="str", choices=["name"]),
177 ),
178 ),
179 type=dict(type="str"),
180 dereference_group_members=dict(type="bool"),
181 show_membership=dict(type="bool"),
182 details_level=dict(type="str", choices=["uid", "standard", "full"]),
183 domains_to_process=dict(type="list", elements="str"),
184 )
185 argument_spec.update(checkpoint_argument_spec_for_facts)
186
187 module = AnsibleModule(
188 argument_spec=argument_spec, supports_check_mode=True
189 )
190
191 api_call_object = "object"
192 api_call_object_plural_version = "objects"
193
194 result = api_call_facts(
195 module, api_call_object, api_call_object_plural_version
196 )
197 module.exit_json(ansible_facts=result)
198
199
200 if __name__ == "__main__":
201 main()