Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_dynamic_object_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_dynamic_object_facts
33 short_description: Get dynamic-object objects facts on Check Point over Web Services API
34 description:
35 - Get dynamic-object 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 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 - Available from R81 JHF management version.
60 type: str
61 version_added: "6.4.0"
62 limit:
63 description:
64 - No more than that many results will be returned.
65 This parameter is relevant only for getting few objects.
66 type: int
67 offset:
68 description:
69 - Skip that many results before beginning to return them.
70 This parameter is relevant only for getting few objects.
71 type: int
72 order:
73 description:
74 - Sorts results by the given field. By default the results are sorted in the ascending order by name.
75 This parameter is relevant only for getting few objects.
76 type: list
77 elements: dict
78 suboptions:
79 ASC:
80 description:
81 - Sorts results by the given field in ascending order.
82 type: str
83 choices: ['name']
84 DESC:
85 description:
86 - Sorts results by the given field in descending order.
87 type: str
88 choices: ['name']
89 show_membership:
90 description:
91 - Indicates whether to calculate and show "groups" field for every object in reply.
92 - Available from R80.10 management version.
93 type: bool
94 domains_to_process:
95 description:
96 - 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
97 with ignore-warnings true. Valid values are, CURRENT_DOMAIN, ALL_DOMAINS_ON_THIS_SERVER.
98 - Available from R81 management version.
99 type: list
100 elements: str
101 version_added: "6.4.0"
102 extends_documentation_fragment: check_point.mgmt.checkpoint_facts
103 """
104
105 EXAMPLES = """
106 - name: show-dynamic-object
107 cp_mgmt_dynamic_object_facts:
108 name: Dynamic_Object_1
109
110 - name: show-dynamic-objects
111 cp_mgmt_dynamic_object_facts:
112 """
113
114 RETURN = """
115 ansible_facts:
116 description: The checkpoint object facts.
117 returned: always.
118 type: dict
119 """
120
121 from ansible.module_utils.basic import AnsibleModule
122 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import (
123 checkpoint_argument_spec_for_facts,
124 api_call_facts,
125 )
126
127
128 def main():
129 argument_spec = dict(
130 name=dict(type="str"),
131 details_level=dict(type="str", choices=["uid", "standard", "full"]),
132 filter=dict(type='str'),
133 limit=dict(type="int"),
134 offset=dict(type="int"),
135 order=dict(
136 type="list",
137 elements="dict",
138 options=dict(
139 ASC=dict(type="str", choices=["name"]),
140 DESC=dict(type="str", choices=["name"]),
141 ),
142 ),
143 show_membership=dict(type="bool"),
144 domains_to_process=dict(type='list', elements="str")
145 )
146 argument_spec.update(checkpoint_argument_spec_for_facts)
147
148 module = AnsibleModule(
149 argument_spec=argument_spec, supports_check_mode=True
150 )
151
152 api_call_object = "dynamic-object"
153 api_call_object_plural_version = "dynamic-objects"
154
155 result = api_call_facts(
156 module, api_call_object, api_call_object_plural_version
157 )
158 module.exit_json(ansible_facts=result)
159
160
161 if __name__ == "__main__":
162 main()