Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_https_rule_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 = {'metadata_version': '1.1',
25 'status': ['preview'],
26 'supported_by': 'community'}
27
28 DOCUMENTATION = """
29 ---
30 module: cp_mgmt_https_rule_facts
31 short_description: Get https-rule objects facts on Checkpoint over Web Services API
32 description:
33 - Get https-rule objects facts on Checkpoint devices.
34 - All operations are performed over Web Services API.
35 - This module handles both operations, get a specific object and get several objects,
36 For getting a specific object use the parameter 'name'.
37 - Available from R80.40 management version.
38 version_added: "6.0.0"
39 author: "Eden Brillant (@chkp-edenbr)"
40 options:
41 name:
42 description:
43 - Object name. Must be unique in the domain.
44 This parameter is relevant only for getting few objects.
45 type: str
46 layer:
47 description:
48 - Layer that holds the Object. Identified by the Name or UID.
49 type: str
50 details_level:
51 description:
52 - 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
53 representation of the object.
54 type: str
55 choices: ['uid', 'standard', 'full']
56 filter:
57 description:
58 - Search expression to filter the rulebase. The provided text should be exactly the same as it would be given in Smart Console. The logical
59 operators in the expression ('AND', 'OR') should be provided in capital letters. If an operator is not used, the default OR operator applies.
60 type: str
61 filter_settings:
62 description:
63 - Sets filter preferences.
64 type: dict
65 suboptions:
66 search_mode:
67 description:
68 - When set to 'general', both the Full Text Search and Packet Search are enabled. In this mode, Packet Search will not match on 'Any'
69 object, a negated cell or a group-with-exclusion. When the search-mode is set to 'packet', by default, the match on 'Any' object, a negated cell
70 or a group-with-exclusion are enabled. packet-search-settings may be provided to change the default behavior.
71 type: str
72 choices: ['general', 'packet']
73 packet_search_settings:
74 description:
75 - When 'search-mode' is set to 'packet', this object allows to set the packet search preferences.
76 type: dict
77 suboptions:
78 expand_group_members:
79 description:
80 - When true, if the search expression contains a UID or a name of a group object, results will include rules that match on at
81 least one member of the group.
82 type: bool
83 expand_group_with_exclusion_members:
84 description:
85 - When true, if the search expression contains a UID or a name of a group-with-exclusion object, results will include rules that
86 match at least one member of the "include" part and is not a member of the "except" part.
87 type: bool
88 match_on_any:
89 description:
90 - Whether to match on 'Any' object.
91 type: bool
92 match_on_group_with_exclusion:
93 description:
94 - Whether to match on a group-with-exclusion.
95 type: bool
96 match_on_negate:
97 description:
98 - Whether to match on a negated cell.
99 type: bool
100 limit:
101 description:
102 - The maximal number of returned results.
103 This parameter is relevant only for getting few objects.
104 type: int
105 offset:
106 description:
107 - Number of the results to initially skip.
108 This parameter is relevant only for getting few objects.
109 type: int
110 order:
111 description:
112 - Sorts the results by search criteria. Automatically sorts the results by Name, in the ascending order.
113 This parameter is relevant only for getting few objects.
114 type: list
115 elements: dict
116 suboptions:
117 ASC:
118 description:
119 - Sorts results by the given field in ascending order.
120 type: str
121 choices: ['name']
122 DESC:
123 description:
124 - Sorts results by the given field in descending order.
125 type: str
126 choices: ['name']
127 package:
128 description:
129 - Name of the package.
130 type: str
131 use_object_dictionary:
132 description:
133 - Receiving the mapping between the objects id and the whole objects.
134 type: bool
135 dereference_group_members:
136 description:
137 - Indicates whether to dereference "members" field by details level for every object in reply.
138 type: bool
139 show_membership:
140 description:
141 - Indicates whether to calculate and show "groups" field for every object in reply.
142 type: bool
143 extends_documentation_fragment: check_point.mgmt.checkpoint_facts
144 """
145
146 EXAMPLES = """
147 - name: show-https-rule
148 cp_mgmt_https_rule_facts:
149 name: FirstRule
150 layer: Default Outbound Layer
151
152 - name: show-https-rulebase
153 cp_mgmt_https_rule_facts:
154 details_level: standard
155 limit: 20
156 name: Default Outbound Layer
157 offset: 0
158 use_object_dictionary: false
159 """
160
161 RETURN = """
162 ansible_facts:
163 description: The checkpoint object facts.
164 returned: always.
165 type: dict
166 """
167
168 from ansible.module_utils.basic import AnsibleModule
169 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import checkpoint_argument_spec_for_facts, api_call_facts_for_rule
170
171
172 def main():
173 argument_spec = dict(
174 name=dict(type='str'),
175 layer=dict(type='str'),
176 details_level=dict(type='str', choices=['uid', 'standard', 'full']),
177 filter=dict(type='str'),
178 filter_settings=dict(type='dict', options=dict(
179 search_mode=dict(type='str', choices=['general', 'packet']),
180 packet_search_settings=dict(type='dict', options=dict(
181 expand_group_members=dict(type='bool'),
182 expand_group_with_exclusion_members=dict(type='bool'),
183 match_on_any=dict(type='bool'),
184 match_on_group_with_exclusion=dict(type='bool'),
185 match_on_negate=dict(type='bool')
186 ))
187 )),
188 limit=dict(type='int'),
189 offset=dict(type='int'),
190 order=dict(type='list', elements='dict', options=dict(
191 ASC=dict(type='str', choices=['name']),
192 DESC=dict(type='str', choices=['name'])
193 )),
194 package=dict(type='str'),
195 use_object_dictionary=dict(type='bool'),
196 dereference_group_members=dict(type='bool'),
197 show_membership=dict(type='bool')
198 )
199 argument_spec.update(checkpoint_argument_spec_for_facts)
200
201 module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
202
203 api_call_object = "https-rule"
204 api_call_object_plural_version = "https-rulebase"
205
206 result = api_call_facts_for_rule(module, api_call_object, api_call_object_plural_version)
207 module.exit_json(ansible_facts=result)
208
209
210 if __name__ == '__main__':
211 main()