Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_dynamic_object.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_dynamic_object
33 short_description: Manages dynamic-object objects on Check Point over Web Services API
34 description:
35 - Manages dynamic-object 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-dynamic-object
81 cp_mgmt_dynamic_object:
82 color: yellow
83 comments: My Dynamic Object 1
84 name: Dynamic_Object_1
85 state: present
86
87 - name: delete-dynamic-object
88 cp_mgmt_dynamic_object:
89 name: Dynamic_Object_2
90 state: absent
91 """
92
93 RETURN = """
94 cp_mgmt_dynamic_object:
95 description: The checkpoint object created or updated.
96 returned: always, except when deleting the object.
97 type: dict
98 """
99
100 from ansible.module_utils.basic import AnsibleModule
101 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import (
102 checkpoint_argument_spec_for_objects,
103 api_call,
104 )
105
106
107 def main():
108 argument_spec = dict(
109 name=dict(type="str", required=True),
110 tags=dict(type="list", elements="str"),
111 color=dict(
112 type="str",
113 choices=[
114 "aquamarine",
115 "black",
116 "blue",
117 "crete blue",
118 "burlywood",
119 "cyan",
120 "dark green",
121 "khaki",
122 "orchid",
123 "dark orange",
124 "dark sea green",
125 "pink",
126 "turquoise",
127 "dark blue",
128 "firebrick",
129 "brown",
130 "forest green",
131 "gold",
132 "dark gold",
133 "gray",
134 "dark gray",
135 "light green",
136 "lemon chiffon",
137 "coral",
138 "sea green",
139 "sky blue",
140 "magenta",
141 "purple",
142 "slate blue",
143 "violet red",
144 "navy blue",
145 "olive",
146 "orange",
147 "red",
148 "sienna",
149 "yellow",
150 ],
151 ),
152 comments=dict(type="str"),
153 details_level=dict(type="str", choices=["uid", "standard", "full"]),
154 ignore_warnings=dict(type="bool"),
155 ignore_errors=dict(type="bool"),
156 )
157 argument_spec.update(checkpoint_argument_spec_for_objects)
158
159 module = AnsibleModule(
160 argument_spec=argument_spec, supports_check_mode=True
161 )
162 api_call_object = "dynamic-object"
163
164 result = api_call(module, api_call_object)
165 module.exit_json(**result)
166
167
168 if __name__ == "__main__":
169 main()