Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_dlp_label.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_label
15 short_description: Configure labels used by DLP blocking.
16 version_added: "2.10.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_label:
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 connector:
37 type: list
38 elements: str
39 description: Name of SDN connector.
40 entries:
41 type: list
42 elements: dict
43 description: Entries.
44 suboptions:
45 guid:
46 type: str
47 description: MPIP label guid.
48 id:
49 type: int
50 description: ID.
51 mpip_label_name:
52 aliases: ['mpip-label-name']
53 type: str
54 description: Name of MPIP label.
55 fortidata_label_name:
56 aliases: ['fortidata-label-name']
57 type: str
58 description: Name of FortiData label
59 mpip_type:
60 aliases: ['mpip-type']
61 type: str
62 description: MPIP label type.
63 choices: ['local', 'remote']
64 name:
65 type: str
66 description: Name of table containing the label.
67 required: true
68 type:
69 type: str
70 description: Label type.
71 choices: ['mpip', 'fortidata']
72 '''
73
74 EXAMPLES = '''
75 - name: Example playbook (generated based on argument schema)
76 hosts: fortimanagers
77 connection: httpapi
78 gather_facts: false
79 tasks:
80 - name: Configure labels used by DLP blocking.
81 fortinet.fortimanager.fmgr_dlp_label:
82 # workspace_locking_adom: <global or your adom name>
83 adom: <your own value>
84 state: present # <value in [present, absent]>
85 dlp_label:
86 name: "your value" # Required variable, string
87 # comment: <string>
88 # connector: <list or string>
89 # entries:
90 # - guid: <string>
91 # id: <integer>
92 # mpip_label_name: <string>
93 # fortidata_label_name: <string>
94 # mpip_type: <value in [local, remote]>
95 # type: <value in [mpip, fortidata]>
96 '''
97
98 RETURN = '''
99 meta:
100 description: The result of the request.
101 type: dict
102 returned: always
103 contains:
104 request_url:
105 description: The full url requested.
106 returned: always
107 type: str
108 sample: /sys/login/user
109 response_code:
110 description: The status of api request.
111 returned: always
112 type: int
113 sample: 0
114 response_data:
115 description: The api response.
116 type: list
117 returned: always
118 response_message:
119 description: The descriptive message of the api response.
120 type: str
121 returned: always
122 sample: OK.
123 system_information:
124 description: The information of the target system.
125 type: dict
126 returned: always
127 rc:
128 description: The status the request.
129 type: int
130 returned: always
131 sample: 0
132 version_check_warning:
133 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
134 type: list
135 returned: complex
136 '''
137 from ansible.module_utils.basic import AnsibleModule
138 from ansible.module_utils.connection import Connection
139 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
140 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
141
142
143 def main():
144 urls_list = [
145 '/pm/config/adom/{adom}/obj/dlp/label',
146 '/pm/config/global/obj/dlp/label'
147 ]
148 module_arg_spec = {
149 'adom': {'required': True, 'type': 'str'},
150 'revision_note': {'type': 'str'},
151 'dlp_label': {
152 'type': 'dict', 'v_range': [['7.6.3', '']],
153 'options': {
154 'comment': {'v_range': [['7.6.3', '']], 'type': 'str'},
155 'connector': {'v_range': [['7.6.3', '']], 'type': 'list', 'elements': 'str'},
156 'entries': {
157 'v_range': [['7.6.3', '']],
158 'type': 'list',
159 'options': {
160 'guid': {'v_range': [['7.6.3', '']], 'type': 'str'},
161 'id': {'v_range': [['7.6.3', '']], 'type': 'int'},
162 'mpip-label-name': {'v_range': [['7.6.3', '']], 'type': 'str'},
163 'fortidata-label-name': {'v_range': [['7.6.4', '']], 'type': 'str'}
164 },
165 'elements': 'dict'
166 },
167 'mpip-type': {'v_range': [['7.6.3', '']], 'choices': ['local', 'remote'], 'type': 'str'},
168 'name': {'v_range': [['7.6.3', '']], 'required': True, 'type': 'str'},
169 'type': {'v_range': [['7.6.3', '']], 'choices': ['mpip', 'fortidata'], 'type': 'str'}
170 }
171 }
172 }
173
174 module_option_spec = get_module_arg_spec('full crud')
175 module_arg_spec.update(module_option_spec)
176 check_galaxy_version(module_arg_spec)
177 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'dlp_label'),
178 supports_check_mode=True)
179 if not module._socket_path:
180 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
181 connection = Connection(module._socket_path)
182 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
183 'name', 'data', module, connection)
184 fmgr.process_crud()
185 module.exit_json(meta=module.params)
186
187
188 if __name__ == '__main__':
189 main()