Debian Codegraph @

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