Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_system_npu_dosoptions.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_system_npu_dosoptions
15 short_description: NPU DoS configurations.
16 version_added: "2.2.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.partial_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 system_npu_dosoptions:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 npu_dos_meter_mode:
34 aliases: ['npu-dos-meter-mode']
35 type: str
36 description: Set DoS meter NPU offloading mode.
37 choices: ['local', 'global']
38 npu_dos_synproxy_mode:
39 aliases: ['npu-dos-synproxy-mode']
40 type: str
41 description: Set NPU DoS SYNPROXY mode.
42 choices: ['synack2ack', 'pass-synack']
43 npu_dos_tpe_mode:
44 aliases: ['npu-dos-tpe-mode']
45 type: str
46 description: Enable/disable insertion of DoS meter ID to session table.
47 choices: ['disable', 'enable']
48 '''
49
50 EXAMPLES = '''
51 - name: Example playbook (generated based on argument schema)
52 hosts: fortimanagers
53 connection: httpapi
54 gather_facts: false
55 tasks:
56 - name: NPU DoS configurations.
57 fortinet.fortimanager.fmgr_system_npu_dosoptions:
58 # workspace_locking_adom: <global or your adom name>
59 adom: <your own value>
60 system_npu_dosoptions:
61 # npu_dos_meter_mode: <value in [local, global]>
62 # npu_dos_synproxy_mode: <value in [synack2ack, pass-synack]>
63 # npu_dos_tpe_mode: <value in [disable, enable]>
64 '''
65
66 RETURN = '''
67 meta:
68 description: The result of the request.
69 type: dict
70 returned: always
71 contains:
72 request_url:
73 description: The full url requested.
74 returned: always
75 type: str
76 sample: /sys/login/user
77 response_code:
78 description: The status of api request.
79 returned: always
80 type: int
81 sample: 0
82 response_data:
83 description: The api response.
84 type: list
85 returned: always
86 response_message:
87 description: The descriptive message of the api response.
88 type: str
89 returned: always
90 sample: OK.
91 system_information:
92 description: The information of the target system.
93 type: dict
94 returned: always
95 rc:
96 description: The status the request.
97 type: int
98 returned: always
99 sample: 0
100 version_check_warning:
101 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
102 type: list
103 returned: complex
104 '''
105 from ansible.module_utils.basic import AnsibleModule
106 from ansible.module_utils.connection import Connection
107 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
108 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
109
110
111 def main():
112 urls_list = [
113 '/pm/config/adom/{adom}/obj/system/npu/dos-options',
114 '/pm/config/global/obj/system/npu/dos-options'
115 ]
116 module_arg_spec = {
117 'adom': {'required': True, 'type': 'str'},
118 'revision_note': {'type': 'str'},
119 'system_npu_dosoptions': {
120 'type': 'dict', 'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '']],
121 'options': {
122 'npu-dos-meter-mode': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '']], 'choices': ['local', 'global'], 'type': 'str'},
123 'npu-dos-synproxy-mode': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '']], 'choices': ['synack2ack', 'pass-synack'], 'type': 'str'},
124 'npu-dos-tpe-mode': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'}
125 }
126 }
127 }
128
129 module_option_spec = get_module_arg_spec('partial crud')
130 module_arg_spec.update(module_option_spec)
131 check_galaxy_version(module_arg_spec)
132 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'system_npu_dosoptions'),
133 supports_check_mode=True)
134 if not module._socket_path:
135 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
136 connection = Connection(module._socket_path)
137 fmgr = NAPIManager('partial crud', module_arg_spec, urls_list,
138 None, 'data', module, connection)
139 fmgr.process_partial_crud()
140 module.exit_json(meta=module.params)
141
142
143 if __name__ == '__main__':
144 main()