Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_dlp_dictionary.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_dictionary
15 short_description: Configure dictionaries used by DLP blocking.
16 version_added: "2.1.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_dictionary:
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 comment:
42 type: str
43 description: Optional comments.
44 id:
45 type: int
46 description: ID.
47 ignore_case:
48 aliases: ['ignore-case']
49 type: str
50 description: Enable/disable ignore case.
51 choices: ['disable', 'enable']
52 pattern:
53 type: str
54 description: Pattern to match.
55 repeat:
56 type: str
57 description: Enable/disable repeat match.
58 choices: ['disable', 'enable']
59 status:
60 type: str
61 description: Enable/disable this pattern.
62 choices: ['disable', 'enable']
63 type:
64 type: str
65 description: Pattern type to match.
66 match_type:
67 aliases: ['match-type']
68 type: str
69 description: Logical relation between entries
70 choices: ['match-all', 'match-any']
71 name:
72 type: str
73 description: Name of table containing the dictionary.
74 required: true
75 uuid:
76 type: str
77 description: Universally Unique Identifier
78 match_around:
79 aliases: ['match-around']
80 type: str
81 description: Enable/disable match-around support.
82 choices: ['disable', 'enable']
83 fgd_id:
84 aliases: ['fgd-id']
85 type: int
86 description: ID of object in FortiGuard database.
87 '''
88
89 EXAMPLES = '''
90 - name: Example playbook (generated based on argument schema)
91 hosts: fortimanagers
92 connection: httpapi
93 gather_facts: false
94 tasks:
95 - name: Configure dictionaries used by DLP blocking.
96 fortinet.fortimanager.fmgr_dlp_dictionary:
97 # workspace_locking_adom: <global or your adom name>
98 adom: <your own value>
99 state: present # <value in [present, absent]>
100 dlp_dictionary:
101 name: "your value" # Required variable, string
102 # comment: <string>
103 # entries:
104 # - comment: <string>
105 # id: <integer>
106 # ignore_case: <value in [disable, enable]>
107 # pattern: <string>
108 # repeat: <value in [disable, enable]>
109 # status: <value in [disable, enable]>
110 # type: <string>
111 # match_type: <value in [match-all, match-any]>
112 # uuid: <string>
113 # match_around: <value in [disable, enable]>
114 # fgd_id: <integer>
115 '''
116
117 RETURN = '''
118 meta:
119 description: The result of the request.
120 type: dict
121 returned: always
122 contains:
123 request_url:
124 description: The full url requested.
125 returned: always
126 type: str
127 sample: /sys/login/user
128 response_code:
129 description: The status of api request.
130 returned: always
131 type: int
132 sample: 0
133 response_data:
134 description: The api response.
135 type: list
136 returned: always
137 response_message:
138 description: The descriptive message of the api response.
139 type: str
140 returned: always
141 sample: OK.
142 system_information:
143 description: The information of the target system.
144 type: dict
145 returned: always
146 rc:
147 description: The status the request.
148 type: int
149 returned: always
150 sample: 0
151 version_check_warning:
152 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
153 type: list
154 returned: complex
155 '''
156 from ansible.module_utils.basic import AnsibleModule
157 from ansible.module_utils.connection import Connection
158 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
159 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
160
161
162 def main():
163 urls_list = [
164 '/pm/config/adom/{adom}/obj/dlp/dictionary',
165 '/pm/config/global/obj/dlp/dictionary'
166 ]
167 module_arg_spec = {
168 'adom': {'required': True, 'type': 'str'},
169 'revision_note': {'type': 'str'},
170 'dlp_dictionary': {
171 'type': 'dict', 'v_range': [['7.2.0', '']],
172 'options': {
173 'comment': {'v_range': [['7.2.0', '']], 'type': 'str'},
174 'entries': {
175 'v_range': [['7.2.0', '']],
176 'type': 'list',
177 'options': {
178 'comment': {'v_range': [['7.2.0', '']], 'type': 'str'},
179 'id': {'v_range': [['7.2.0', '']], 'type': 'int'},
180 'ignore-case': {'v_range': [['7.2.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
181 'pattern': {'v_range': [['7.2.0', '']], 'type': 'str'},
182 'repeat': {'v_range': [['7.2.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
183 'status': {'v_range': [['7.2.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
184 'type': {'v_range': [['7.2.0', '']], 'type': 'str'}
185 },
186 'elements': 'dict'
187 },
188 'match-type': {'v_range': [['7.2.0', '']], 'choices': ['match-all', 'match-any'], 'type': 'str'},
189 'name': {'v_range': [['7.2.0', '']], 'required': True, 'type': 'str'},
190 'uuid': {'v_range': [['7.2.0', '']], 'type': 'str'},
191 'match-around': {'v_range': [['7.4.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
192 'fgd-id': {'v_range': [['7.6.0', '']], 'type': 'int'}
193 }
194 }
195 }
196
197 module_option_spec = get_module_arg_spec('full crud')
198 module_arg_spec.update(module_option_spec)
199 check_galaxy_version(module_arg_spec)
200 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'dlp_dictionary'),
201 supports_check_mode=True)
202 if not module._socket_path:
203 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
204 connection = Connection(module._socket_path)
205 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
206 'name', 'data', module, connection)
207 fmgr.process_crud()
208 module.exit_json(meta=module.params)
209
210
211 if __name__ == '__main__':
212 main()