| 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 = { |
| 25 |
"metadata_version": "1.1", |
| 26 |
"status": ["deprecated"], |
| 27 |
"supported_by": "community", |
| 28 |
} |
| 29 |
|
| 30 |
DOCUMENTATION = """ |
| 31 |
--- |
| 32 |
module: cp_mgmt_show_tasks |
| 33 |
short_description: Retrieve all tasks and show their progress and details. |
| 34 |
description: |
| 35 |
- Retrieve all tasks and show their progress and details. |
| 36 |
- All operations are performed over Web Services API. |
| 37 |
- Available from R80.20 management version. |
| 38 |
version_added: "2.0.0" |
| 39 |
author: "Or Soffer (@chkp-orso)" |
| 40 |
deprecated: |
| 41 |
alternative: cp_mgmt_task_facts |
| 42 |
why: Newer single facts module released. |
| 43 |
removed_at_date: '2024-11-01' |
| 44 |
options: |
| 45 |
initiator: |
| 46 |
description: |
| 47 |
- Initiator's name. If name isn't specified, tasks from all initiators will be shown. |
| 48 |
type: str |
| 49 |
status: |
| 50 |
description: |
| 51 |
- Status. |
| 52 |
type: str |
| 53 |
choices: ['successful', 'failed', 'in-progress', 'all'] |
| 54 |
from_date: |
| 55 |
description: |
| 56 |
- 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 |
| 57 |
Management server's timezone is used. |
| 58 |
type: str |
| 59 |
to_date: |
| 60 |
description: |
| 61 |
- 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, |
| 62 |
the Management server's timezone is used. |
| 63 |
type: str |
| 64 |
limit: |
| 65 |
description: |
| 66 |
- The maximal number of returned results. |
| 67 |
type: int |
| 68 |
offset: |
| 69 |
description: |
| 70 |
- Number of the results to initially skip. |
| 71 |
type: int |
| 72 |
order: |
| 73 |
description: |
| 74 |
- Sorts results by the given field. By default the results are sorted in the descending order by the task's last update date. |
| 75 |
type: list |
| 76 |
elements: dict |
| 77 |
suboptions: |
| 78 |
ASC: |
| 79 |
description: |
| 80 |
- Sorts results by the given field in ascending order. |
| 81 |
type: str |
| 82 |
choices: ['name'] |
| 83 |
DESC: |
| 84 |
description: |
| 85 |
- Sorts results by the given field in descending order. |
| 86 |
type: str |
| 87 |
choices: ['name'] |
| 88 |
details_level: |
| 89 |
description: |
| 90 |
- 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 |
| 91 |
representation of the object. |
| 92 |
type: str |
| 93 |
choices: ['uid', 'standard', 'full'] |
| 94 |
extends_documentation_fragment: check_point.mgmt.checkpoint_commands |
| 95 |
""" |
| 96 |
|
| 97 |
EXAMPLES = """ |
| 98 |
- name: show-tasks |
| 99 |
cp_mgmt_show_tasks: |
| 100 |
from_date: '2018-05-23T08:00:00' |
| 101 |
initiator: admin1 |
| 102 |
status: successful |
| 103 |
""" |
| 104 |
|
| 105 |
RETURN = """ |
| 106 |
cp_mgmt_show_tasks: |
| 107 |
description: The checkpoint show-tasks output. |
| 108 |
returned: always. |
| 109 |
type: dict |
| 110 |
""" |
| 111 |
|
| 112 |
from ansible.module_utils.basic import AnsibleModule |
| 113 |
from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import ( |
| 114 |
checkpoint_argument_spec_for_commands, |
| 115 |
api_command, |
| 116 |
) |
| 117 |
|
| 118 |
|
| 119 |
def main(): |
| 120 |
argument_spec = dict( |
| 121 |
initiator=dict(type="str"), |
| 122 |
status=dict( |
| 123 |
type="str", choices=["successful", "failed", "in-progress", "all"] |
| 124 |
), |
| 125 |
from_date=dict(type="str"), |
| 126 |
to_date=dict(type="str"), |
| 127 |
limit=dict(type="int"), |
| 128 |
offset=dict(type="int"), |
| 129 |
order=dict( |
| 130 |
type="list", |
| 131 |
elements="dict", |
| 132 |
options=dict( |
| 133 |
ASC=dict(type="str", choices=["name"]), |
| 134 |
DESC=dict(type="str", choices=["name"]), |
| 135 |
), |
| 136 |
), |
| 137 |
details_level=dict(type="str", choices=["uid", "standard", "full"]), |
| 138 |
) |
| 139 |
argument_spec.update(checkpoint_argument_spec_for_commands) |
| 140 |
|
| 141 |
module = AnsibleModule(argument_spec=argument_spec) |
| 142 |
|
| 143 |
command = "show-tasks" |
| 144 |
|
| 145 |
result = api_command(module, command) |
| 146 |
module.exit_json(**result) |
| 147 |
|
| 148 |
|
| 149 |
if __name__ == "__main__": |
| 150 |
main() |