Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_pfcp.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_firewall_pfcp
15 short_description: Configure PFCP.
16 version_added: "2.12.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 firewall_pfcp:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 denied_log:
34 aliases: ['denied-log']
35 type: str
36 description: Enable/disable logging denied PFCP packets.
37 choices: ['disable', 'enable']
38 forwarded_log:
39 aliases: ['forwarded-log']
40 type: str
41 description: Enable/disable logging forwarded PFCP packets.
42 choices: ['disable', 'enable']
43 invalid_reserved_field:
44 aliases: ['invalid-reserved-field']
45 type: str
46 description: Allow or deny invalid reserved field in PFCP header packets.
47 choices: ['deny', 'allow']
48 log_freq:
49 aliases: ['log-freq']
50 type: int
51 description: Logging frequency of PFCP packets.
52 max_message_length:
53 aliases: ['max-message-length']
54 type: int
55 description: Maximum message length.
56 message_filter:
57 aliases: ['message-filter']
58 type: list
59 elements: str
60 description: PFCP message filter.
61 min_message_length:
62 aliases: ['min-message-length']
63 type: int
64 description: Minimum message length.
65 monitor_mode:
66 aliases: ['monitor-mode']
67 type: str
68 description: PFCP monitor mode.
69 choices: ['disable', 'enable', 'vdom']
70 name:
71 type: str
72 description: PFCP profile name.
73 required: true
74 pfcp_timeout:
75 aliases: ['pfcp-timeout']
76 type: int
77 description: Set PFCP timeout
78 traffic_count_log:
79 aliases: ['traffic-count-log']
80 type: str
81 description: Enable/disable logging session traffic counter.
82 choices: ['disable', 'enable']
83 unknown_version:
84 aliases: ['unknown-version']
85 type: str
86 description: Allow or deny unknown version packets.
87 choices: ['deny', 'allow']
88 '''
89
90 EXAMPLES = '''
91 - name: Example playbook (generated based on argument schema)
92 hosts: fortimanagers
93 connection: httpapi
94 gather_facts: false
95 tasks:
96 - name: Configure PFCP.
97 fortinet.fortimanager.fmgr_firewall_pfcp:
98 # workspace_locking_adom: <global or your adom name>
99 adom: <your own value>
100 state: present # <value in [present, absent]>
101 firewall_pfcp:
102 name: "your value" # Required variable, string
103 # denied_log: <value in [disable, enable]>
104 # forwarded_log: <value in [disable, enable]>
105 # invalid_reserved_field: <value in [deny, allow]>
106 # log_freq: <integer>
107 # max_message_length: <integer>
108 # message_filter: <list or string>
109 # min_message_length: <integer>
110 # monitor_mode: <value in [disable, enable, vdom]>
111 # pfcp_timeout: <integer>
112 # traffic_count_log: <value in [disable, enable]>
113 # unknown_version: <value in [deny, allow]>
114 '''
115
116 RETURN = '''
117 meta:
118 description: The result of the request.
119 type: dict
120 returned: always
121 contains:
122 request_url:
123 description: The full url requested.
124 returned: always
125 type: str
126 sample: /sys/login/user
127 response_code:
128 description: The status of api request.
129 returned: always
130 type: int
131 sample: 0
132 response_data:
133 description: The api response.
134 type: list
135 returned: always
136 response_message:
137 description: The descriptive message of the api response.
138 type: str
139 returned: always
140 sample: OK.
141 system_information:
142 description: The information of the target system.
143 type: dict
144 returned: always
145 rc:
146 description: The status the request.
147 type: int
148 returned: always
149 sample: 0
150 version_check_warning:
151 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
152 type: list
153 returned: complex
154 '''
155 from ansible.module_utils.basic import AnsibleModule
156 from ansible.module_utils.connection import Connection
157 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
158 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
159
160
161 def main():
162 urls_list = [
163 '/pm/config/adom/{adom}/obj/firewall/pfcp',
164 '/pm/config/global/obj/firewall/pfcp'
165 ]
166 module_arg_spec = {
167 'adom': {'required': True, 'type': 'str'},
168 'revision_note': {'type': 'str'},
169 'firewall_pfcp': {
170 'type': 'dict', 'v_range': [['7.6.4', '']],
171 'options': {
172 'denied-log': {'v_range': [['7.6.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
173 'forwarded-log': {'v_range': [['7.6.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
174 'invalid-reserved-field': {'v_range': [['7.6.4', '']], 'choices': ['deny', 'allow'], 'type': 'str'},
175 'log-freq': {'v_range': [['7.6.4', '']], 'type': 'int'},
176 'max-message-length': {'v_range': [['7.6.4', '']], 'type': 'int'},
177 'message-filter': {'v_range': [['7.6.4', '']], 'type': 'list', 'elements': 'str'},
178 'min-message-length': {'v_range': [['7.6.4', '']], 'type': 'int'},
179 'monitor-mode': {'v_range': [['7.6.4', '']], 'choices': ['disable', 'enable', 'vdom'], 'type': 'str'},
180 'name': {'v_range': [['7.6.4', '']], 'required': True, 'type': 'str'},
181 'pfcp-timeout': {'v_range': [['7.6.4', '']], 'type': 'int'},
182 'traffic-count-log': {'v_range': [['7.6.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
183 'unknown-version': {'v_range': [['7.6.4', '']], 'choices': ['deny', 'allow'], 'type': 'str'}
184 }
185 }
186 }
187
188 module_option_spec = get_module_arg_spec('full crud')
189 module_arg_spec.update(module_option_spec)
190 check_galaxy_version(module_arg_spec)
191 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_pfcp'),
192 supports_check_mode=True)
193 if not module._socket_path:
194 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
195 connection = Connection(module._socket_path)
196 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
197 'name', 'data', module, connection)
198 fmgr.process_crud()
199 module.exit_json(meta=module.params)
200
201
202 if __name__ == '__main__':
203 main()