Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_add_rules_batch.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 = {
25 "metadata_version": "1.1",
26 "status": ["preview"],
27 "supported_by": "community",
28 }
29
30 DOCUMENTATION = """
31 ---
32 module: cp_mgmt_add_rules_batch
33 short_description: Creates new rules in batch. Use this API to achieve optimum performance when adding more than one rule.
34 description:
35 - Creates new rules in batch. Use this API to achieve optimum performance when adding more than one rule.
36 - Add multiple rules to a layer in a specific position, incrementing position by one for each rule.
37 - Errors and warnings are ignored when using this API, operation will apply changes while ignoring errors. It is not
38 possible to publish changes that contain validations errors. You must use the "show-validations" API to see any
39 validation errors and warnings caused by the batch creation. Supported rules types are access-rule, nat-rule,
40 https-rule and threat-exception.
41 - This module is not idempotent.
42 - All operations are performed over Web Services API.
43 - Available from R81.10 JHF management version.
44 version_added: "3.0.0"
45 author: "Eden Brillant (@chkp-edenbr)"
46 options:
47 objects:
48 description:
49 - Batch of rules separated by types.
50 type: list
51 elements: dict
52 suboptions:
53 layer:
54 description:
55 - Layer name or uid.
56 type: str
57 type:
58 description:
59 - Type of rules to be created. <br>Only types from above are supported.
60 type: str
61 first_position:
62 description:
63 - First rule position.
64 type: str
65 list:
66 description:
67 - List of rules from the same type to be created on the same layer. <br>Use the "add" API reference documentation for a single rule
68 command to find the expected fields for the request. <br>For example, to add access-rules, use the "add-access-rule" command found in the API
69 reference documentation (under Access Control & NAT). <br>Note, "set-if-exists", "ignore-errors", "ignore-warnings" and "details-level" options
70 are not supported when adding a batch of rules.
71 type: list
72 elements: dict
73 auto_publish_session:
74 description:
75 - Publish the current session if changes have been performed after task completes.
76 type: bool
77 extends_documentation_fragment: check_point.mgmt.checkpoint_commands
78 """
79
80 EXAMPLES = """
81 - name: add-rules-batch
82 cp_mgmt_add_rules_batch:
83 objects:
84 - first_position: top
85 layer: Network
86 list:
87 - action: accept
88 name: access rule 1
89 - action: accept
90 name: access rule 2
91 type: access-rule
92 - first_position: top
93 layer: Standard
94 list:
95 - name: nat rule 1
96 - name: nat rule 2
97 type: nat-rule
98 - first_position: top
99 layer: Default Layer
100 list:
101 - name: https rule 1
102 - name: https rule 2
103 type: https-rule
104 """
105
106 RETURN = """
107 cp_mgmt_add_rules_batch:
108 description: The checkpoint add-rules-batch output.
109 returned: always.
110 type: dict
111 """
112
113 from ansible.module_utils.basic import AnsibleModule
114 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import (
115 checkpoint_argument_spec_for_commands,
116 api_command,
117 )
118
119
120 def main():
121 argument_spec = dict(
122 objects=dict(
123 type="list",
124 elements="dict",
125 options=dict(
126 layer=dict(type="str"),
127 type=dict(type="str"),
128 first_position=dict(type="str"),
129 list=dict(type="list", elements="dict"),
130 ),
131 ),
132 auto_publish_session=dict(type="bool"),
133 )
134 argument_spec.update(checkpoint_argument_spec_for_commands)
135
136 module = AnsibleModule(argument_spec=argument_spec)
137
138 command = "add-rules-batch"
139
140 result = api_command(module, command)
141 module.exit_json(**result)
142
143
144 if __name__ == "__main__":
145 main()