Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_dlp_filepattern_entries.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_entries
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 filepattern:
29 description: The parameter (filepattern) in requested url.
30 type: str
31 required: true
32 dlp_filepattern_entries:
33 description: The top level parameters set.
34 required: false
35 type: dict
36 suboptions:
37 file_type:
38 aliases: ['file-type']
39 type: str
40 description: Select a file type.
41 choices: ['unknown', 'ignored', 'exe', 'elf', 'bat', 'javascript', 'html', 'hta',
42 'msoffice', 'gzip', 'rar', 'tar', 'lzh', 'upx', 'zip', 'cab', 'bzip2',
43 'bzip', 'activemime', 'mime', 'hlp', 'arj', 'base64', 'binhex', 'uue',
44 'fsg', 'aspack', 'msc', 'petite', 'jpeg', 'gif', 'tiff', 'png', 'bmp',
45 'msi', 'mpeg', 'mov', 'mp3', 'wma', 'wav', 'pdf', 'avi', 'rm',
46 'torrent', 'hibun', '7z', 'xz', 'msofficex', 'mach-o', 'dmg', '.net',
47 'xar', 'chm', 'iso', 'crx', 'sis', 'prc', 'class', 'jad', 'cod', 'flac',
48 'registry', 'hwp', 'rpm', 'c/cpp', 'pfile', 'lzip', 'wasm', 'sylk',
49 'shellscript', 'dll', 'jnlp', 'jar', 'css', 'com', 'python', 'genscript']
50 filter_type:
51 aliases: ['filter-type']
52 type: str
53 description: Filter by file name pattern or by file type.
54 choices: ['pattern', 'type']
55 pattern:
56 type: str
57 description: Add a file name pattern.
58 '''
59
60 EXAMPLES = '''
61 - name: Example playbook (generated based on argument schema)
62 hosts: fortimanagers
63 connection: httpapi
64 gather_facts: false
65 tasks:
66 - name: Configure file patterns used by DLP blocking.
67 fortinet.fortimanager.fmgr_dlp_filepattern_entries:
68 # workspace_locking_adom: <global or your adom name>
69 adom: <your own value>
70 filepattern: <your own value>
71 state: present # <value in [present, absent]>
72 dlp_filepattern_entries:
73 # file_type: <value in [unknown, ignored, exe, ...]>
74 # filter_type: <value in [pattern, type]>
75 # pattern: <string>
76 '''
77
78 RETURN = '''
79 meta:
80 description: The result of the request.
81 type: dict
82 returned: always
83 contains:
84 request_url:
85 description: The full url requested.
86 returned: always
87 type: str
88 sample: /sys/login/user
89 response_code:
90 description: The status of api request.
91 returned: always
92 type: int
93 sample: 0
94 response_data:
95 description: The api response.
96 type: list
97 returned: always
98 response_message:
99 description: The descriptive message of the api response.
100 type: str
101 returned: always
102 sample: OK.
103 system_information:
104 description: The information of the target system.
105 type: dict
106 returned: always
107 rc:
108 description: The status the request.
109 type: int
110 returned: always
111 sample: 0
112 version_check_warning:
113 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
114 type: list
115 returned: complex
116 '''
117 from ansible.module_utils.basic import AnsibleModule
118 from ansible.module_utils.connection import Connection
119 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
120 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
121
122
123 def main():
124 urls_list = [
125 '/pm/config/adom/{adom}/obj/dlp/filepattern/{filepattern}/entries',
126 '/pm/config/global/obj/dlp/filepattern/{filepattern}/entries'
127 ]
128 module_arg_spec = {
129 'adom': {'required': True, 'type': 'str'},
130 'filepattern': {'required': True, 'type': 'str'},
131 'revision_note': {'type': 'str'},
132 'dlp_filepattern_entries': {
133 'type': 'dict', 'v_range': [['6.0.0', '']],
134 'options': {
135 'file-type': {
136 'choices': [
137 'unknown', 'ignored', 'exe', 'elf', 'bat', 'javascript', 'html', 'hta', 'msoffice', 'gzip', 'rar', 'tar', 'lzh', 'upx', 'zip',
138 'cab', 'bzip2', 'bzip', 'activemime', 'mime', 'hlp', 'arj', 'base64', 'binhex', 'uue', 'fsg', 'aspack', 'msc', 'petite', 'jpeg',
139 'gif', 'tiff', 'png', 'bmp', 'msi', 'mpeg', 'mov', 'mp3', 'wma', 'wav', 'pdf', 'avi', 'rm', 'torrent', 'hibun', '7z', 'xz',
140 'msofficex', 'mach-o', 'dmg', '.net', 'xar', 'chm', 'iso', 'crx', 'sis', 'prc', 'class', 'jad', 'cod', 'flac', 'registry', 'hwp',
141 'rpm', 'c/cpp', 'pfile', 'lzip', 'wasm', 'sylk', 'shellscript', 'dll', 'jnlp', 'jar', 'css', 'com', 'python', 'genscript'
142 ],
143 'type': 'str'
144 },
145 'filter-type': {'choices': ['pattern', 'type'], 'type': 'str'},
146 'pattern': {'type': 'str'}
147 }
148 }
149 }
150
151 module_option_spec = get_module_arg_spec('full crud')
152 module_arg_spec.update(module_option_spec)
153 check_galaxy_version(module_arg_spec)
154 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'dlp_filepattern_entries'),
155 supports_check_mode=True)
156 if not module._socket_path:
157 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
158 connection = Connection(module._socket_path)
159 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
160 None, 'data', module, connection)
161 fmgr.process_crud()
162 module.exit_json(meta=module.params)
163
164
165 if __name__ == '__main__':
166 main()