Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_task_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_task_facts
31 short_description: Get task objects facts on Checkpoint over Web Services API
32 description:
33 - Get task 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.20 management version.
38 version_added: "5.0.0"
39 author: "Eden Brillant (@chkp-edenbr)"
40 options:
41 task_id:
42 description:
43 - Unique identifier of one or more tasks.
44 type: list
45 elements: str
46 details_level:
47 description:
48 - 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
49 representation of the object.
50 type: str
51 choices: ['uid', 'standard', 'full']
52 initiator:
53 description:
54 - Initiator's name. If name isn't specified, tasks from all initiators will be shown.
55 type: str
56 status:
57 description:
58 - Status.
59 type: str
60 choices: ['successful', 'failed', 'in-progress', 'all']
61 from_date:
62 description:
63 - The date from which tracking tasks is to be performed, by the task's last update date. ISO 8601. If timezone isn't specified in the input, the
64 Management server's timezone is used.
65 type: str
66 to_date:
67 description:
68 - The date until which tracking tasks is to be performed, by the task's last update date. ISO 8601. If timezone isn't specified in the input,
69 the Management server's timezone is used.
70 type: str
71 limit:
72 description:
73 - The maximal number of returned results.
74 This parameter is relevant only for getting few objects.
75 type: int
76 offset:
77 description:
78 - Number of the results to initially skip.
79 This parameter is relevant only for getting few objects.
80 type: int
81 order:
82 description:
83 - Sorts results by the given field. By default the results are sorted in the descending order by the task's last update date.
84 This parameter is relevant only for getting few objects.
85 type: list
86 elements: dict
87 suboptions:
88 ASC:
89 description:
90 - Sorts results by the given field in ascending order.
91 type: str
92 choices: ['name']
93 DESC:
94 description:
95 - Sorts results by the given field in descending order.
96 type: str
97 choices: ['name']
98 extends_documentation_fragment: check_point.mgmt.checkpoint_facts
99 """
100
101 EXAMPLES = """
102 - name: show-task
103 cp_mgmt_task_facts:
104 task_id: 2eec70e5-78a8-4bdb-9a76-cfb5601d0bcb
105
106 - name: show-tasks
107 cp_mgmt_task_facts:
108 from_date: '2018-05-23T08:00:00'
109 initiator: admin1
110 status: successful
111 """
112
113 RETURN = """
114 ansible_facts:
115 description: The checkpoint object facts.
116 returned: always.
117 type: dict
118 """
119
120 from ansible.module_utils.basic import AnsibleModule
121 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import checkpoint_argument_spec_for_facts, api_call_facts
122
123
124 def main():
125 argument_spec = dict(
126 task_id=dict(type='list', elements='str'),
127 details_level=dict(type='str', choices=['uid', 'standard', 'full']),
128 initiator=dict(type='str'),
129 status=dict(type='str', choices=['successful', 'failed', 'in-progress', 'all']),
130 from_date=dict(type='str'),
131 to_date=dict(type='str'),
132 limit=dict(type='int'),
133 offset=dict(type='int'),
134 order=dict(type='list', elements='dict', options=dict(
135 ASC=dict(type='str', choices=['name']),
136 DESC=dict(type='str', choices=['name'])
137 ))
138 )
139 argument_spec.update(checkpoint_argument_spec_for_facts)
140
141 module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
142
143 api_call_object = "task"
144 api_call_object_plural_version = "tasks"
145
146 result = api_call_facts(module, api_call_object, api_call_object_plural_version)
147 module.exit_json(ansible_facts=result)
148
149
150 if __name__ == '__main__':
151 main()