Debian Codegraph @

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