Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_casb_useractivity_controloptions.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_casb_useractivity_controloptions
15 short_description: CASB control options.
16 version_added: "2.3.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 user-activity:
29 description: Deprecated, please use "user_activity"
30 type: str
31 user_activity:
32 description: The parameter (user-activity) in requested url.
33 type: str
34 casb_useractivity_controloptions:
35 description: The top level parameters set.
36 required: false
37 type: dict
38 suboptions:
39 name:
40 type: str
41 description: CASB control option name.
42 required: true
43 operations:
44 type: list
45 elements: dict
46 description: Operations.
47 suboptions:
48 action:
49 type: str
50 description: CASB operation action.
51 choices: ['append', 'prepend', 'replace', 'new', 'new-on-not-found',
52 'delete']
53 case_sensitive:
54 aliases: ['case-sensitive']
55 type: str
56 description: CASB operation search case sensitive.
57 choices: ['disable', 'enable']
58 direction:
59 type: str
60 description: CASB operation direction.
61 choices: ['request', 'response']
62 header_name:
63 aliases: ['header-name']
64 type: str
65 description: CASB operation header name to search.
66 name:
67 type: str
68 description: CASB control option operation name.
69 search_key:
70 aliases: ['search-key']
71 type: str
72 description: CASB operation key to search.
73 search_pattern:
74 aliases: ['search-pattern']
75 type: str
76 description: CASB operation search pattern.
77 choices: ['simple', 'substr', 'regexp']
78 target:
79 type: str
80 description: CASB operation target.
81 choices: ['header', 'path', 'body']
82 value_from_input:
83 aliases: ['value-from-input']
84 type: str
85 description: Enable/disable value from user input.
86 choices: ['disable', 'enable']
87 values:
88 type: list
89 elements: str
90 description: CASB operation new values.
91 value_name_from_input:
92 aliases: ['value-name-from-input']
93 type: str
94 description: CASB operation value name from user input.
95 status:
96 type: str
97 description: CASB control option status.
98 choices: ['disable', 'enable']
99 '''
100
101 EXAMPLES = '''
102 - name: Example playbook (generated based on argument schema)
103 hosts: fortimanagers
104 connection: httpapi
105 gather_facts: false
106 tasks:
107 - name: CASB control options.
108 fortinet.fortimanager.fmgr_casb_useractivity_controloptions:
109 # workspace_locking_adom: <global or your adom name>
110 adom: <your own value>
111 user_activity: <your own value>
112 state: present # <value in [present, absent]>
113 casb_useractivity_controloptions:
114 name: "your value" # Required variable, string
115 # operations:
116 # - action: <value in [append, prepend, replace, ...]>
117 # case_sensitive: <value in [disable, enable]>
118 # direction: <value in [request, response]>
119 # header_name: <string>
120 # name: <string>
121 # search_key: <string>
122 # search_pattern: <value in [simple, substr, regexp]>
123 # target: <value in [header, path, body]>
124 # value_from_input: <value in [disable, enable]>
125 # values: <list or string>
126 # value_name_from_input: <string>
127 # status: <value in [disable, enable]>
128 '''
129
130 RETURN = '''
131 meta:
132 description: The result of the request.
133 type: dict
134 returned: always
135 contains:
136 request_url:
137 description: The full url requested.
138 returned: always
139 type: str
140 sample: /sys/login/user
141 response_code:
142 description: The status of api request.
143 returned: always
144 type: int
145 sample: 0
146 response_data:
147 description: The api response.
148 type: list
149 returned: always
150 response_message:
151 description: The descriptive message of the api response.
152 type: str
153 returned: always
154 sample: OK.
155 system_information:
156 description: The information of the target system.
157 type: dict
158 returned: always
159 rc:
160 description: The status the request.
161 type: int
162 returned: always
163 sample: 0
164 version_check_warning:
165 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
166 type: list
167 returned: complex
168 '''
169 from ansible.module_utils.basic import AnsibleModule
170 from ansible.module_utils.connection import Connection
171 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
172 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
173
174
175 def main():
176 urls_list = [
177 '/pm/config/adom/{adom}/obj/casb/user-activity/{user-activity}/control-options',
178 '/pm/config/global/obj/casb/user-activity/{user-activity}/control-options'
179 ]
180 module_arg_spec = {
181 'adom': {'required': True, 'type': 'str'},
182 'user-activity': {'type': 'str', 'api_name': 'user_activity'},
183 'user_activity': {'type': 'str'},
184 'revision_note': {'type': 'str'},
185 'casb_useractivity_controloptions': {
186 'type': 'dict', 'v_range': [['7.4.1', '']],
187 'options': {
188 'name': {'v_range': [['7.4.1', '']], 'required': True, 'type': 'str'},
189 'operations': {
190 'v_range': [['7.4.1', '']],
191 'type': 'list',
192 'options': {
193 'action': {
194 'v_range': [['7.4.1', '']],
195 'choices': ['append', 'prepend', 'replace', 'new', 'new-on-not-found', 'delete'],
196 'type': 'str'
197 },
198 'case-sensitive': {'v_range': [['7.4.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
199 'direction': {'v_range': [['7.4.1', '']], 'choices': ['request', 'response'], 'type': 'str'},
200 'header-name': {'v_range': [['7.4.1', '']], 'type': 'str'},
201 'name': {'v_range': [['7.4.1', '']], 'type': 'str'},
202 'search-key': {'v_range': [['7.4.1', '']], 'no_log': True, 'type': 'str'},
203 'search-pattern': {'v_range': [['7.4.1', '']], 'choices': ['simple', 'substr', 'regexp'], 'type': 'str'},
204 'target': {'v_range': [['7.4.1', '']], 'choices': ['header', 'path', 'body'], 'type': 'str'},
205 'value-from-input': {'v_range': [['7.4.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
206 'values': {'v_range': [['7.4.1', '']], 'type': 'list', 'elements': 'str'},
207 'value-name-from-input': {'v_range': [['7.6.4', '']], 'type': 'str'}
208 },
209 'elements': 'dict'
210 },
211 'status': {'v_range': [['7.4.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'}
212 }
213 }
214 }
215
216 module_option_spec = get_module_arg_spec('full crud')
217 module_arg_spec.update(module_option_spec)
218 check_galaxy_version(module_arg_spec)
219 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'casb_useractivity_controloptions'),
220 supports_check_mode=True)
221 if not module._socket_path:
222 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
223 connection = Connection(module._socket_path)
224 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
225 'name', 'data', module, connection)
226 fmgr.process_crud()
227 module.exit_json(meta=module.params)
228
229
230 if __name__ == '__main__':
231 main()