Debian Codegraph @

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