|
| 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_export_access_rulebase |
| 31 | +short_description: Retrieve the entire content of an Access Rules layer. |
| 32 | +description: |
| 33 | + - Retrieve the entire content of an Access Rules layer. The reply features a list of objects; Each object in the reply may be a section of the layer, |
| 34 | + with all its rules in, or a rule itself, for the case of rules which are under the global section. In case a rule has an Access Layer applied on it, the |
| 35 | + entire content of the inline layer will be included in the reply as well. |
| 36 | + - All operations are performed over Web Services API. |
| 37 | + - Available from R82.20 Management version. |
| 38 | +version_added: "6.9.0" |
| 39 | +author: "Eden Brillant (@chkp-edenbr)" |
| 40 | +options: |
| 41 | + name: |
| 42 | + description: |
| 43 | + - Object name. Must be unique in the domain. |
| 44 | + type: str |
| 45 | + package: |
| 46 | + description: |
| 47 | + - Name of the package. |
| 48 | + type: str |
| 49 | + show_expiration_settings: |
| 50 | + description: |
| 51 | + - Indicates whether to calculate and show "expiration date settings" field in reply. |
| 52 | + type: bool |
| 53 | + show_hits: |
| 54 | + description: |
| 55 | + - Show hitcount data. |
| 56 | + type: bool |
| 57 | + use_object_dictionary: |
| 58 | + description: |
| 59 | + - N/A |
| 60 | + type: bool |
| 61 | + hits_settings: |
| 62 | + description: |
| 63 | + - Hitcount settings, define the range if hits to show. |
| 64 | + type: dict |
| 65 | + suboptions: |
| 66 | + from_date: |
| 67 | + description: |
| 68 | + - Format, YYYY-MM-DD, YYYY-mm-ddThh,mm,ss. |
| 69 | + type: str |
| 70 | + target: |
| 71 | + description: |
| 72 | + - Target gateway name or UID. |
| 73 | + type: str |
| 74 | + to_date: |
| 75 | + description: |
| 76 | + - Format, YYYY-MM-DD, YYYY-mm-ddThh,mm,ss. |
| 77 | + type: str |
| 78 | + dereference_group_members: |
| 79 | + description: |
| 80 | + - Indicates whether to dereference "members" field by details level for every object in reply. |
| 81 | + type: bool |
| 82 | + show_membership: |
| 83 | + description: |
| 84 | + - Indicates whether to calculate and show "groups" field for every object in reply. |
| 85 | + type: bool |
| 86 | +extends_documentation_fragment: check_point.mgmt.checkpoint_commands |
| 87 | +""" |
| 88 | + |
| 89 | +EXAMPLES = """ |
| 90 | +- name: export-access-rulebase |
| 91 | + cp_mgmt_export_access_rulebase: |
| 92 | + name: Corp-Access |
| 93 | +""" |
| 94 | + |
| 95 | +RETURN = """ |
| 96 | +cp_mgmt_export_access_rulebase: |
| 97 | + description: The checkpoint export-access-rulebase output. |
| 98 | + returned: always. |
| 99 | + type: dict |
| 100 | +""" |
| 101 | + |
| 102 | +from ansible.module_utils.basic import AnsibleModule |
| 103 | +from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import checkpoint_argument_spec_for_commands, api_command |
| 104 | + |
| 105 | + |
| 106 | +def main(): |
| 107 | + argument_spec = dict( |
| 108 | + name=dict(type='str'), |
| 109 | + package=dict(type='str'), |
| 110 | + show_expiration_settings=dict(type='bool'), |
| 111 | + show_hits=dict(type='bool'), |
| 112 | + use_object_dictionary=dict(type='bool'), |
| 113 | + hits_settings=dict(type='dict', options=dict( |
| 114 | + from_date=dict(type='str'), |
| 115 | + target=dict(type='str'), |
| 116 | + to_date=dict(type='str') |
| 117 | + )), |
| 118 | + dereference_group_members=dict(type='bool'), |
| 119 | + show_membership=dict(type='bool') |
| 120 | + ) |
| 121 | + argument_spec.update(checkpoint_argument_spec_for_commands) |
| 122 | + |
| 123 | + module = AnsibleModule(argument_spec=argument_spec) |
| 124 | + |
| 125 | + command = "export-access-rulebase" |
| 126 | + |
| 127 | + result = api_command(module, command) |
| 128 | + module.exit_json(**result) |
| 129 | + |
| 130 | + |
| 131 | +if __name__ == '__main__': |
| 132 | + main() |
0 commit comments