Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_dlp_filepattern.py

raw symbols SCIP
1 #!/usr/bin/python
2 from __future__ import absolute_import, division, print_function
3 # Copyright 2019-2024 Fortinet, Inc.
4 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
5
6 __metaclass__ = type
7
8 ANSIBLE_METADATA = {'status': ['preview'],
9 'supported_by': 'community',
10 'metadata_version': '1.1'}
11
12 DOCUMENTATION = '''
13 ---
14 module: fmgr_dlp_filepattern
15 short_description: Configure file patterns used by DLP blocking.
16 version_added: "2.0.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.full_crud
20 options:
21 revision_note:
22 description: The change note that can be specified when an object is created or updated.
23 type: str
24 adom:
25 description: The parameter (adom) in requested url.
26 type: str
27 required: true
28 dlp_filepattern:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 comment:
34 type: str
35 description: Optional comments.
36 entries:
37 type: list
38 elements: dict
39 description: Entries.
40 suboptions:
41 file_type:
42 aliases: ['file-type']
43 type: str
44 description: Select a file type.
45 choices: ['unknown', 'ignored', 'exe', 'elf', 'bat', 'javascript', 'html',
46 'hta', 'msoffice', 'gzip', 'rar', 'tar', 'lzh', 'upx', 'zip',
47 'cab', 'bzip2', 'bzip', 'activemime', 'mime', 'hlp', 'arj',
48 'base64', 'binhex', 'uue', 'fsg', 'aspack', 'msc', 'petite',
49 'jpeg', 'gif', 'tiff', 'png', 'bmp', 'msi', 'mpeg', 'mov',
50 'mp3', 'wma', 'wav', 'pdf', 'avi', 'rm', 'torrent', 'hibun',
51 '7z', 'xz', 'msofficex', 'mach-o', 'dmg', '.net', 'xar', 'chm',
52 'iso', 'crx', 'sis', 'prc', 'class', 'jad', 'cod', 'flac',
53 'registry', 'hwp', 'rpm', 'c/cpp', 'pfile', 'lzip', 'wasm',
54 'sylk', 'shellscript', 'dll', 'jnlp', 'jar', 'css', 'com',
55 'python', 'genscript']
56 filter_type:
57 aliases: ['filter-type']
58 type: str
59 description: Filter by file name pattern or by file type.
60 choices: ['pattern', 'type']
61 pattern:
62 type: str
63 description: Add a file name pattern.
64 id:
65 type: int
66 description: ID.
67 required: true
68 name:
69 type: str
70 description: Name of table containing the file pattern list.
71 '''
72
73 EXAMPLES = '''
74 - name: Example playbook (generated based on argument schema)
75 hosts: fortimanagers
76 connection: httpapi
77 gather_facts: false
78 tasks:
79 - name: Configure file patterns used by DLP blocking.
80 fortinet.fortimanager.fmgr_dlp_filepattern:
81 # workspace_locking_adom: <global or your adom name>
82 adom: <your own value>
83 state: present # <value in [present, absent]>
84 dlp_filepattern:
85 id: 0 # Required variable, integer
86 # comment: <string>
87 # entries:
88 # - file_type: <value in [unknown, ignored, exe, ...]>
89 # filter_type: <value in [pattern, type]>
90 # pattern: <string>
91 # name: <string>
92 '''
93
94 RETURN = '''
95 meta:
96 description: The result of the request.
97 type: dict
98 returned: always
99 contains:
100 request_url:
101 description: The full url requested.
102 returned: always
103 type: str
104 sample: /sys/login/user
105 response_code:
106 description: The status of api request.
107 returned: always
108 type: int
109 sample: 0
110 response_data:
111 description: The api response.
112 type: list
113 returned: always
114 response_message:
115 description: The descriptive message of the api response.
116 type: str
117 returned: always
118 sample: OK.
119 system_information:
120 description: The information of the target system.
121 type: dict
122 returned: always
123 rc:
124 description: The status the request.
125 type: int
126 returned: always
127 sample: 0
128 version_check_warning:
129 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
130 type: list
131 returned: complex
132 '''
133 from ansible.module_utils.basic import AnsibleModule
134 from ansible.module_utils.connection import Connection
135 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
136 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
137
138
139 def main():
140 urls_list = [
141 '/pm/config/adom/{adom}/obj/dlp/filepattern',
142 '/pm/config/global/obj/dlp/filepattern'
143 ]
144 module_arg_spec = {
145 'adom': {'required': True, 'type': 'str'},
146 'revision_note': {'type': 'str'},
147 'dlp_filepattern': {
148 'type': 'dict', 'v_range': [['6.0.0', '']],
149 'options': {
150 'comment': {'type': 'str'},
151 'entries': {
152 'type': 'list',
153 'options': {
154 'file-type': {
155 'choices': [
156 'unknown', 'ignored', 'exe', 'elf', 'bat', 'javascript', 'html', 'hta', 'msoffice', 'gzip', 'rar', 'tar', 'lzh', 'upx',
157 'zip', 'cab', 'bzip2', 'bzip', 'activemime', 'mime', 'hlp', 'arj', 'base64', 'binhex', 'uue', 'fsg', 'aspack', 'msc',
158 'petite', 'jpeg', 'gif', 'tiff', 'png', 'bmp', 'msi', 'mpeg', 'mov', 'mp3', 'wma', 'wav', 'pdf', 'avi', 'rm', 'torrent',
159 'hibun', '7z', 'xz', 'msofficex', 'mach-o', 'dmg', '.net', 'xar', 'chm', 'iso', 'crx', 'sis', 'prc', 'class', 'jad',
160 'cod', 'flac', 'registry', 'hwp', 'rpm', 'c/cpp', 'pfile', 'lzip', 'wasm', 'sylk', 'shellscript', 'dll', 'jnlp', 'jar',
161 'css', 'com', 'python', 'genscript'
162 ],
163 'type': 'str'
164 },
165 'filter-type': {'choices': ['pattern', 'type'], 'type': 'str'},
166 'pattern': {'type': 'str'}
167 },
168 'elements': 'dict'
169 },
170 'id': {'required': True, 'type': 'int'},
171 'name': {'type': 'str'}
172 }
173 }
174 }
175
176 module_option_spec = get_module_arg_spec('full crud')
177 module_arg_spec.update(module_option_spec)
178 check_galaxy_version(module_arg_spec)
179 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'dlp_filepattern'),
180 supports_check_mode=True)
181 if not module._socket_path:
182 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
183 connection = Connection(module._socket_path)
184 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
185 'id', 'data', module, connection)
186 fmgr.process_crud()
187 module.exit_json(meta=module.params)
188
189
190 if __name__ == '__main__':
191 main()