Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_security_zone.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 #
4 # Ansible module to manage Check Point 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_security_zone
33 short_description: Manages security-zone objects on Check Point over Web Services API
34 description:
35 - Manages security-zone objects on Check Point devices including creating, updating and removing objects.
36 - All operations are performed over Web Services API.
37 - Available from R80 management version.
38 version_added: "1.0.0"
39 author: "Or Soffer (@chkp-orso)"
40 options:
41 name:
42 description:
43 - Object name.
44 type: str
45 required: True
46 tags:
47 description:
48 - Collection of tag identifiers.
49 type: list
50 elements: str
51 color:
52 description:
53 - Color of the object. Should be one of existing colors.
54 type: str
55 choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green',
56 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon',
57 'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', 'yellow']
58 comments:
59 description:
60 - Comments string.
61 type: str
62 details_level:
63 description:
64 - 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
65 representation of the object.
66 type: str
67 choices: ['uid', 'standard', 'full']
68 ignore_warnings:
69 description:
70 - Apply changes ignoring warnings.
71 type: bool
72 ignore_errors:
73 description:
74 - 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.
75 type: bool
76 extends_documentation_fragment: check_point.mgmt.checkpoint_objects
77 """
78
79 EXAMPLES = """
80 - name: add-security-zone
81 cp_mgmt_security_zone:
82 color: yellow
83 comments: My Security Zone 1
84 name: SZone1
85 state: present
86
87 - name: set-security-zone
88 cp_mgmt_security_zone:
89 name: SZone1
90 state: present
91
92 - name: delete-security-zone
93 cp_mgmt_security_zone:
94 name: SZone2
95 state: absent
96 """
97
98 RETURN = """
99 cp_mgmt_security_zone:
100 description: The checkpoint object created or updated.
101 returned: always, except when deleting the object.
102 type: dict
103 """
104
105 from ansible.module_utils.basic import AnsibleModule
106 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import (
107 checkpoint_argument_spec_for_objects,
108 api_call,
109 )
110
111
112 def main():
113 argument_spec = dict(
114 name=dict(type="str", required=True),
115 tags=dict(type="list", elements="str"),
116 color=dict(
117 type="str",
118 choices=[
119 "aquamarine",
120 "black",
121 "blue",
122 "crete blue",
123 "burlywood",
124 "cyan",
125 "dark green",
126 "khaki",
127 "orchid",
128 "dark orange",
129 "dark sea green",
130 "pink",
131 "turquoise",
132 "dark blue",
133 "firebrick",
134 "brown",
135 "forest green",
136 "gold",
137 "dark gold",
138 "gray",
139 "dark gray",
140 "light green",
141 "lemon chiffon",
142 "coral",
143 "sea green",
144 "sky blue",
145 "magenta",
146 "purple",
147 "slate blue",
148 "violet red",
149 "navy blue",
150 "olive",
151 "orange",
152 "red",
153 "sienna",
154 "yellow",
155 ],
156 ),
157 comments=dict(type="str"),
158 details_level=dict(type="str", choices=["uid", "standard", "full"]),
159 ignore_warnings=dict(type="bool"),
160 ignore_errors=dict(type="bool"),
161 )
162 argument_spec.update(checkpoint_argument_spec_for_objects)
163
164 module = AnsibleModule(
165 argument_spec=argument_spec, supports_check_mode=True
166 )
167 api_call_object = "security-zone"
168
169 result = api_call(module, api_call_object)
170 module.exit_json(**result)
171
172
173 if __name__ == "__main__":
174 main()