Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_system_npu_icmpratectrl.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_icmpratectrl
15 short_description: Configure the rate of ICMP messages generated by this FortiGate.
16 version_added: "2.6.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_icmpratectrl:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 icmp_v4_bucket_size:
34 aliases: ['icmp-v4-bucket-size']
35 type: int
36 description: Bucket size used in the token bucket algorithm for controlling the flow of ICMPv4 packets
37 icmp_v4_rate:
38 aliases: ['icmp-v4-rate']
39 type: int
40 description: Average rate of ICMPv4 packets that allowed to be generated per second
41 icmp_v6_bucket_size:
42 aliases: ['icmp-v6-bucket-size']
43 type: int
44 description: Bucket size used in the token bucket algorithm for controlling the flow of ICMPv6 packets
45 icmp_v6_rate:
46 aliases: ['icmp-v6-rate']
47 type: int
48 description: Average rate of ICMPv6 packets that allowed to be generated per second
49 '''
50
51 EXAMPLES = '''
52 - name: Example playbook (generated based on argument schema)
53 hosts: fortimanagers
54 connection: httpapi
55 gather_facts: false
56 tasks:
57 - name: Configure the rate of ICMP messages generated by this FortiGate.
58 fortinet.fortimanager.fmgr_system_npu_icmpratectrl:
59 # workspace_locking_adom: <global or your adom name>
60 adom: <your own value>
61 system_npu_icmpratectrl:
62 # icmp_v4_bucket_size: <integer>
63 # icmp_v4_rate: <integer>
64 # icmp_v6_bucket_size: <integer>
65 # icmp_v6_rate: <integer>
66 '''
67
68 RETURN = '''
69 meta:
70 description: The result of the request.
71 type: dict
72 returned: always
73 contains:
74 request_url:
75 description: The full url requested.
76 returned: always
77 type: str
78 sample: /sys/login/user
79 response_code:
80 description: The status of api request.
81 returned: always
82 type: int
83 sample: 0
84 response_data:
85 description: The api response.
86 type: list
87 returned: always
88 response_message:
89 description: The descriptive message of the api response.
90 type: str
91 returned: always
92 sample: OK.
93 system_information:
94 description: The information of the target system.
95 type: dict
96 returned: always
97 rc:
98 description: The status the request.
99 type: int
100 returned: always
101 sample: 0
102 version_check_warning:
103 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
104 type: list
105 returned: complex
106 '''
107 from ansible.module_utils.basic import AnsibleModule
108 from ansible.module_utils.connection import Connection
109 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
110 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
111
112
113 def main():
114 urls_list = [
115 '/pm/config/adom/{adom}/obj/system/npu/icmp-rate-ctrl',
116 '/pm/config/global/obj/system/npu/icmp-rate-ctrl'
117 ]
118 module_arg_spec = {
119 'adom': {'required': True, 'type': 'str'},
120 'revision_note': {'type': 'str'},
121 'system_npu_icmpratectrl': {
122 'type': 'dict', 'v_range': [['7.4.3', '']],
123 'options': {
124 'icmp-v4-bucket-size': {'v_range': [['7.4.3', '']], 'type': 'int'},
125 'icmp-v4-rate': {'v_range': [['7.4.3', '']], 'type': 'int'},
126 'icmp-v6-bucket-size': {'v_range': [['7.4.3', '']], 'type': 'int'},
127 'icmp-v6-rate': {'v_range': [['7.4.3', '']], 'type': 'int'}
128 }
129 }
130 }
131
132 module_option_spec = get_module_arg_spec('partial crud')
133 module_arg_spec.update(module_option_spec)
134 check_galaxy_version(module_arg_spec)
135 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'system_npu_icmpratectrl'),
136 supports_check_mode=True)
137 if not module._socket_path:
138 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
139 connection = Connection(module._socket_path)
140 fmgr = NAPIManager('partial crud', module_arg_spec, urls_list,
141 None, 'data', module, connection)
142 fmgr.process_partial_crud()
143 module.exit_json(meta=module.params)
144
145
146 if __name__ == '__main__':
147 main()