|
| 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": ["preview"], |
| 27 | + "supported_by": "community", |
| 28 | +} |
| 29 | + |
| 30 | +DOCUMENTATION = """ |
| 31 | +--- |
| 32 | +module: cp_mgmt_add_data_center_query |
| 33 | +short_description: Adds data-center-query objects on Checkpoint over Web Services API |
| 34 | +description: |
| 35 | + - Adds data-center-query objects on Checkpoint devices. |
| 36 | + - All operations are performed over Web Services API. |
| 37 | + - Available from R81 management version. |
| 38 | +version_added: "6.9.0" |
| 39 | +author: "Dor Berenstein (@chkp-dorbe)" |
| 40 | +options: |
| 41 | + name: |
| 42 | + description: |
| 43 | + - Object name. |
| 44 | + type: str |
| 45 | + required: True |
| 46 | + query_rules: |
| 47 | + description: |
| 48 | + - Data Center Query Rules.<br>There is an 'AND' operation between multiple Query Rules. |
| 49 | + type: list |
| 50 | + elements: dict |
| 51 | + suboptions: |
| 52 | + key_type: |
| 53 | + description: |
| 54 | + - The type of the "key" parameter.<br>Use "predefined" for these keys, type-in-data-center, name-in-data-center, and ip-address.<br>Use |
| 55 | + "tag" to query the Data Center tag's property. |
| 56 | + type: str |
| 57 | + choices: ['predefined', 'tag'] |
| 58 | + key: |
| 59 | + description: |
| 60 | + - Defines in which Data Center property to query.<br>For key-type "predefined", use these keys, type-in-data-center, |
| 61 | + name-in-data-center, and ip-address.<br>For key-type "tag", use the Data Center tag key to query.<br>Keys are case-insensitive. |
| 62 | + type: str |
| 63 | + values: |
| 64 | + description: |
| 65 | + - The value(s) of the Data Center property to match the Query Rule.<br>Values are case-insensitive.<br>There is an 'OR' operation |
| 66 | + between multiple values.<br>For key-type "predefined" and key 'ip-address', the values must be an IPv4 or IPv6 address.<br>For key-type "tag", the |
| 67 | + values must be the Data Center tag values. |
| 68 | + type: list |
| 69 | + elements: str |
| 70 | + data_centers: |
| 71 | + description: |
| 72 | + - Collection of Data Center servers identified by the name or UID. use "All" to select all data centers. |
| 73 | + type: list |
| 74 | + elements: str |
| 75 | + color: |
| 76 | + description: |
| 77 | + - Color of the object. Should be one of existing colors. |
| 78 | + type: str |
| 79 | + choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green', |
| 80 | + 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon', |
| 81 | + 'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', 'yellow'] |
| 82 | + comments: |
| 83 | + description: |
| 84 | + - Comments string. |
| 85 | + type: str |
| 86 | + details_level: |
| 87 | + description: |
| 88 | + - 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 |
| 89 | + representation of the object. |
| 90 | + type: str |
| 91 | + choices: ['uid', 'standard', 'full'] |
| 92 | + tags: |
| 93 | + description: |
| 94 | + - Collection of tag identifiers. |
| 95 | + type: list |
| 96 | + elements: str |
| 97 | + ignore_warnings: |
| 98 | + description: |
| 99 | + - Apply changes ignoring warnings. |
| 100 | + type: bool |
| 101 | + ignore_errors: |
| 102 | + description: |
| 103 | + - Apply changes ignoring errors. You won't be able to publish such a changes. If ignore-warnings flag was omitted - warnings will also be ignored. |
| 104 | + type: bool |
| 105 | +extends_documentation_fragment: check_point.mgmt.checkpoint_commands |
| 106 | +""" |
| 107 | + |
| 108 | +EXAMPLES = """ |
| 109 | +- name: add-data-center-query |
| 110 | + cp_mgmt_add_data_center_query: |
| 111 | + name: data-center-query1 |
| 112 | +""" |
| 113 | + |
| 114 | +RETURN = """ |
| 115 | +cp_mgmt_add_data_center_query: |
| 116 | + description: The checkpoint add-data-center-query output. |
| 117 | + returned: always. |
| 118 | + type: dict |
| 119 | +""" |
| 120 | + |
| 121 | +from ansible.module_utils.basic import AnsibleModule |
| 122 | +from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import ( |
| 123 | + checkpoint_argument_spec_for_commands, |
| 124 | + api_command, |
| 125 | +) |
| 126 | + |
| 127 | + |
| 128 | +def main(): |
| 129 | + argument_spec = dict( |
| 130 | + name=dict(type="str", required=True), |
| 131 | + query_rules=dict( |
| 132 | + type="list", |
| 133 | + elements="dict", |
| 134 | + options=dict( |
| 135 | + key_type=dict(type="str", choices=["predefined", "tag"]), |
| 136 | + key=dict(type="str", no_log=False), |
| 137 | + values=dict(type="list", elements="str"), |
| 138 | + ), |
| 139 | + ), |
| 140 | + data_centers=dict(type="list", elements="str"), |
| 141 | + color=dict( |
| 142 | + type="str", |
| 143 | + choices=[ |
| 144 | + "aquamarine", |
| 145 | + "black", |
| 146 | + "blue", |
| 147 | + "crete blue", |
| 148 | + "burlywood", |
| 149 | + "cyan", |
| 150 | + "dark green", |
| 151 | + "khaki", |
| 152 | + "orchid", |
| 153 | + "dark orange", |
| 154 | + "dark sea green", |
| 155 | + "pink", |
| 156 | + "turquoise", |
| 157 | + "dark blue", |
| 158 | + "firebrick", |
| 159 | + "brown", |
| 160 | + "forest green", |
| 161 | + "gold", |
| 162 | + "dark gold", |
| 163 | + "gray", |
| 164 | + "dark gray", |
| 165 | + "light green", |
| 166 | + "lemon chiffon", |
| 167 | + "coral", |
| 168 | + "sea green", |
| 169 | + "sky blue", |
| 170 | + "magenta", |
| 171 | + "purple", |
| 172 | + "slate blue", |
| 173 | + "violet red", |
| 174 | + "navy blue", |
| 175 | + "olive", |
| 176 | + "orange", |
| 177 | + "red", |
| 178 | + "sienna", |
| 179 | + "yellow", |
| 180 | + ], |
| 181 | + ), |
| 182 | + comments=dict(type="str"), |
| 183 | + details_level=dict(type="str", choices=["uid", "standard", "full"]), |
| 184 | + tags=dict(type="list", elements="str"), |
| 185 | + ignore_warnings=dict(type="bool"), |
| 186 | + ignore_errors=dict(type="bool"), |
| 187 | + ) |
| 188 | + argument_spec.update(checkpoint_argument_spec_for_commands) |
| 189 | + |
| 190 | + module = AnsibleModule(argument_spec=argument_spec) |
| 191 | + |
| 192 | + command = "add-data-center-query" |
| 193 | + |
| 194 | + result = api_command(module, command) |
| 195 | + module.exit_json(**result) |
| 196 | + |
| 197 | + |
| 198 | +if __name__ == "__main__": |
| 199 | + main() |
0 commit comments