Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_application_site.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_application_site
33 short_description: Manages application-site objects on Check Point over Web Services API
34 description:
35 - Manages application-site 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 primary_category:
47 description:
48 - Each application is assigned to one primary category based on its most defining aspect.
49 type: str
50 url_list:
51 description:
52 - URLs that determine this particular application.
53 type: list
54 elements: str
55 application_signature:
56 description:
57 - Application signature generated by <a
58 href="https,//supportcenter.checkpoint.com/supportcenter/portal?eventSubmit_doGoviewsolutiondetails=&solutionid=sk103051">Signature Tool</a>.
59 type: str
60 additional_categories:
61 description:
62 - Used to configure or edit the additional categories of a custom application / site used in the Application and URL Filtering or Threat Prevention.
63 type: list
64 elements: str
65 description:
66 description:
67 - A description for the application.
68 type: str
69 tags:
70 description:
71 - Collection of tag identifiers.
72 type: list
73 elements: str
74 urls_defined_as_regular_expression:
75 description:
76 - States whether the URL is defined as a Regular Expression or not.
77 type: bool
78 color:
79 description:
80 - Color of the object. Should be one of existing colors.
81 type: str
82 choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green',
83 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon',
84 'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', 'yellow']
85 comments:
86 description:
87 - Comments string.
88 type: str
89 details_level:
90 description:
91 - 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
92 representation of the object.
93 type: str
94 choices: ['uid', 'standard', 'full']
95 groups:
96 description:
97 - Collection of group identifiers.
98 type: list
99 elements: str
100 ignore_warnings:
101 description:
102 - Apply changes ignoring warnings.
103 type: bool
104 ignore_errors:
105 description:
106 - 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.
107 type: bool
108 extends_documentation_fragment: check_point.mgmt.checkpoint_objects
109 """
110
111 EXAMPLES = """
112 - name: add-application-site
113 cp_mgmt_application_site:
114 additional_categories:
115 - Instant Chat
116 - Supports Streaming
117 - New Application Site Category 1
118 description: My Application Site
119 name: New Application Site 1
120 primary_category: Social Networking
121 state: present
122 url_list:
123 - www.cnet.com
124 - www.stackoverflow.com
125 urls_defined_as_regular_expression: false
126
127 - name: set-application-site
128 cp_mgmt_application_site:
129 description: My New Application Site
130 name: New Application Site 1
131 primary_category: Instant Chat
132 state: present
133 urls_defined_as_regular_expression: true
134
135 - name: delete-application-site
136 cp_mgmt_application_site:
137 name: New Application Site 2
138 state: absent
139 """
140
141 RETURN = """
142 cp_mgmt_application_site:
143 description: The checkpoint object created or updated.
144 returned: always, except when deleting the object.
145 type: dict
146 """
147
148 from ansible.module_utils.basic import AnsibleModule
149 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import (
150 checkpoint_argument_spec_for_objects,
151 api_call,
152 )
153
154
155 def main():
156 argument_spec = dict(
157 name=dict(type="str", required=True),
158 primary_category=dict(type="str"),
159 url_list=dict(type="list", elements="str"),
160 application_signature=dict(type="str"),
161 additional_categories=dict(type="list", elements="str"),
162 description=dict(type="str"),
163 tags=dict(type="list", elements="str"),
164 urls_defined_as_regular_expression=dict(type="bool"),
165 color=dict(
166 type="str",
167 choices=[
168 "aquamarine",
169 "black",
170 "blue",
171 "crete blue",
172 "burlywood",
173 "cyan",
174 "dark green",
175 "khaki",
176 "orchid",
177 "dark orange",
178 "dark sea green",
179 "pink",
180 "turquoise",
181 "dark blue",
182 "firebrick",
183 "brown",
184 "forest green",
185 "gold",
186 "dark gold",
187 "gray",
188 "dark gray",
189 "light green",
190 "lemon chiffon",
191 "coral",
192 "sea green",
193 "sky blue",
194 "magenta",
195 "purple",
196 "slate blue",
197 "violet red",
198 "navy blue",
199 "olive",
200 "orange",
201 "red",
202 "sienna",
203 "yellow",
204 ],
205 ),
206 comments=dict(type="str"),
207 details_level=dict(type="str", choices=["uid", "standard", "full"]),
208 groups=dict(type="list", elements="str"),
209 ignore_warnings=dict(type="bool"),
210 ignore_errors=dict(type="bool"),
211 )
212 argument_spec.update(checkpoint_argument_spec_for_objects)
213
214 module = AnsibleModule(
215 argument_spec=argument_spec, supports_check_mode=True
216 )
217 api_call_object = "application-site"
218
219 result = api_call(module, api_call_object)
220 module.exit_json(**result)
221
222
223 if __name__ == "__main__":
224 main()