Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_set_nat_rule.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": ["deprecated"],
27 "supported_by": "community",
28 }
29
30 DOCUMENTATION = """
31 ---
32 module: cp_mgmt_set_nat_rule
33 short_description: Edit existing object using object name or uid.
34 description:
35 - Edit existing object using object name or uid.
36 - All operations are performed over Web Services API.
37 - Available from R80 management version.
38 version_added: "2.0.0"
39 author: "Or Soffer (@chkp-orso)"
40 deprecated:
41 alternative: cp_mgmt_nat_rule
42 why: Newer and updated module released with more functionality.
43 removed_at_date: '2024-11-01'
44 options:
45 rule_number:
46 description:
47 - Rule number.
48 type: str
49 package:
50 description:
51 - Name of the package.
52 type: str
53 enabled:
54 description:
55 - Enable/Disable the rule.
56 type: bool
57 install_on:
58 description:
59 - Which Gateways identified by the name or UID to install the policy on.
60 type: list
61 elements: str
62 method:
63 description:
64 - Nat method.
65 type: str
66 choices: ['static', 'hide', 'nat64', 'nat46']
67 new_position:
68 description:
69 - New position in the rulebase.
70 type: str
71 original_destination:
72 description:
73 - Original destination.
74 type: str
75 original_service:
76 description:
77 - Original service.
78 type: str
79 original_source:
80 description:
81 - Original source.
82 type: str
83 translated_destination:
84 description:
85 - Translated destination.
86 type: str
87 translated_service:
88 description:
89 - Translated service.
90 type: str
91 translated_source:
92 description:
93 - Translated source.
94 type: str
95 comments:
96 description:
97 - Comments string.
98 type: str
99 details_level:
100 description:
101 - 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
102 representation of the object.
103 type: str
104 choices: ['uid', 'standard', 'full']
105 ignore_warnings:
106 description:
107 - Apply changes ignoring warnings.
108 type: bool
109 ignore_errors:
110 description:
111 - 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.
112 type: bool
113 extends_documentation_fragment: check_point.mgmt.checkpoint_commands
114 """
115
116 EXAMPLES = """
117 - name: set-nat-rule
118 cp_mgmt_set_nat_rule:
119 comments: rule for RND members RNDNetwork-> RND to Internal Network
120 enabled: false
121 original_service: ssh_version_2
122 original_source: Any
123 package: standard
124 """
125
126 RETURN = """
127 cp_mgmt_set_nat_rule:
128 description: The checkpoint set-nat-rule output.
129 returned: always.
130 type: dict
131 """
132
133 from ansible.module_utils.basic import AnsibleModule
134 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import (
135 checkpoint_argument_spec_for_commands,
136 api_command,
137 )
138
139
140 def main():
141 argument_spec = dict(
142 rule_number=dict(type="str"),
143 package=dict(type="str"),
144 enabled=dict(type="bool"),
145 install_on=dict(type="list", elements="str"),
146 method=dict(type="str", choices=["static", "hide", "nat64", "nat46"]),
147 new_position=dict(type="str"),
148 original_destination=dict(type="str"),
149 original_service=dict(type="str"),
150 original_source=dict(type="str"),
151 translated_destination=dict(type="str"),
152 translated_service=dict(type="str"),
153 translated_source=dict(type="str"),
154 comments=dict(type="str"),
155 details_level=dict(type="str", choices=["uid", "standard", "full"]),
156 ignore_warnings=dict(type="bool"),
157 ignore_errors=dict(type="bool"),
158 )
159 argument_spec.update(checkpoint_argument_spec_for_commands)
160
161 module = AnsibleModule(argument_spec=argument_spec)
162
163 command = "set-nat-rule"
164
165 result = api_command(module, command)
166 module.exit_json(**result)
167
168
169 if __name__ == "__main__":
170 main()