Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_group_facts.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_group_facts
33 short_description: Get group objects facts on Check Point over Web Services API
34 description:
35 - Get group objects facts on Check Point 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: "1.0.0"
41 author: "Or Soffer (@chkp-orso)"
42 options:
43 name:
44 description:
45 - Object name.
46 This parameter is relevant only for getting a specific object.
47 type: str
48 show_as_ranges:
49 description:
50 - When true, the group's matched content is displayed as ranges of IP addresses rather than network objects.<br />Objects that are not
51 represented using IP addresses are presented as objects.<br />The 'members' parameter is omitted from the response and instead the 'ranges' parameter
52 is displayed.
53 - Available from R80.20 management version.
54 type: bool
55 details_level:
56 description:
57 - 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
58 representation of the object.
59 type: str
60 choices: ['uid', 'standard', 'full']
61 filter:
62 description:
63 - Search expression to filter objects by. The provided text should be exactly the same as it would be given in SmartConsole Object Explorer. The
64 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
65 name, comment, tags etc.
66 - Available from R81 JHF management version.
67 type: str
68 version_added: "6.4.0"
69 limit:
70 description:
71 - No more than that many results will be returned.
72 This parameter is relevant only for getting few objects.
73 type: int
74 offset:
75 description:
76 - Skip that many results before beginning to return them.
77 This parameter is relevant only for getting few objects.
78 type: int
79 order:
80 description:
81 - Sorts results by the given field. By default the results are sorted in the ascending order by name.
82 This parameter is relevant only for getting few objects.
83 type: list
84 elements: dict
85 suboptions:
86 ASC:
87 description:
88 - Sorts results by the given field in ascending order.
89 type: str
90 choices: ['name']
91 DESC:
92 description:
93 - Sorts results by the given field in descending order.
94 type: str
95 choices: ['name']
96 dereference_group_members:
97 description:
98 - Indicates whether to dereference "members" field by details level for every object in reply.
99 - Available from R80.10 management version.
100 type: bool
101 show_membership:
102 description:
103 - Indicates whether to calculate and show "groups" field for every object in reply.
104 - Available from R80.10 management version.
105 type: bool
106 async_response:
107 description:
108 - Run command in asynchronous mode and return task UID. Use show-task command to check the progress of the task.
109 - Available from R81.20 management version.
110 type: bool
111 domains_to_process:
112 description:
113 - 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
114 with ignore-warnings true. Valid values are, CURRENT_DOMAIN, ALL_DOMAINS_ON_THIS_SERVER.
115 - Available from R81 management version.
116 type: list
117 elements: str
118 version_added: "6.4.0"
119 extends_documentation_fragment: check_point.mgmt.checkpoint_facts
120 """
121
122 EXAMPLES = """
123 - name: show-group
124 cp_mgmt_group_facts:
125 name: Demo_Group
126
127 - name: show-groups
128 cp_mgmt_group_facts:
129 details_level: standard
130 limit: 50
131 offset: 0
132 """
133
134 RETURN = """
135 ansible_facts:
136 description: The checkpoint object facts.
137 returned: always.
138 type: dict
139 """
140
141 from ansible.module_utils.basic import AnsibleModule
142 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import (
143 checkpoint_argument_spec_for_facts,
144 api_call_facts,
145 )
146
147
148 def main():
149 argument_spec = dict(
150 name=dict(type="str"),
151 show_as_ranges=dict(type="bool"),
152 details_level=dict(type="str", choices=["uid", "standard", "full"]),
153 filter=dict(type='str'),
154 limit=dict(type="int"),
155 offset=dict(type="int"),
156 order=dict(
157 type="list",
158 elements="dict",
159 options=dict(
160 ASC=dict(type="str", choices=["name"]),
161 DESC=dict(type="str", choices=["name"]),
162 ),
163 ),
164 dereference_group_members=dict(type="bool"),
165 show_membership=dict(type="bool"),
166 async_response=dict(type="bool"),
167 domains_to_process=dict(type='list', elements="str")
168 )
169 argument_spec.update(checkpoint_argument_spec_for_facts)
170
171 module = AnsibleModule(
172 argument_spec=argument_spec, supports_check_mode=True
173 )
174
175 api_call_object = "group"
176 api_call_object_plural_version = "groups"
177
178 result = api_call_facts(
179 module, api_call_object, api_call_object_plural_version
180 )
181 module.exit_json(ansible_facts=result)
182
183
184 if __name__ == "__main__":
185 main()