Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_system_localinpolicy.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_localinpolicy
15 short_description: IPv4 local in policy configuration.
16 version_added: "2.1.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.full_crud
20 options:
21 system_localinpolicy:
22 description: The top level parameters set.
23 required: false
24 type: dict
25 suboptions:
26 action:
27 type: str
28 description:
29 - Action performed on traffic matching this policy.
30 - drop - Drop traffic matching this policy
31 - reject - Reject traffic matching this policy.
32 - accept - Allow traffic matching this policy.
33 choices: ['drop', 'reject', 'accept']
34 dport:
35 type: int
36 description: Destination port number
37 dst:
38 type: str
39 description: Destination IP and mask.
40 id:
41 type: int
42 description: Entry number.
43 required: true
44 intf:
45 type: str
46 description: Incoming interface name.
47 protocol:
48 type: str
49 description:
50 - Traffic protocol.
51 - tcp - TCP only.
52 - udp - UDP only.
53 - tcp_udp - Both TCP and UDP.
54 choices: ['tcp', 'udp', 'tcp_udp']
55 src:
56 type: str
57 description: Source IP and mask.
58 description:
59 type: str
60 description: Description.
61 '''
62
63 EXAMPLES = '''
64 - name: Example playbook (generated based on argument schema)
65 hosts: fortimanagers
66 connection: httpapi
67 gather_facts: false
68 tasks:
69 - name: IPv4 local in policy configuration.
70 fortinet.fortimanager.fmgr_system_localinpolicy:
71 # workspace_locking_adom: <global or your adom name>
72 state: present # <value in [present, absent]>
73 system_localinpolicy:
74 id: 0 # Required variable, integer
75 # action: <value in [drop, reject, accept]>
76 # dport: <integer>
77 # dst: <string>
78 # intf: <string>
79 # protocol: <value in [tcp, udp, tcp_udp]>
80 # src: <string>
81 # description: <string>
82 '''
83
84 RETURN = '''
85 meta:
86 description: The result of the request.
87 type: dict
88 returned: always
89 contains:
90 request_url:
91 description: The full url requested.
92 returned: always
93 type: str
94 sample: /sys/login/user
95 response_code:
96 description: The status of api request.
97 returned: always
98 type: int
99 sample: 0
100 response_data:
101 description: The api response.
102 type: list
103 returned: always
104 response_message:
105 description: The descriptive message of the api response.
106 type: str
107 returned: always
108 sample: OK.
109 system_information:
110 description: The information of the target system.
111 type: dict
112 returned: always
113 rc:
114 description: The status the request.
115 type: int
116 returned: always
117 sample: 0
118 version_check_warning:
119 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
120 type: list
121 returned: complex
122 '''
123 from ansible.module_utils.basic import AnsibleModule
124 from ansible.module_utils.connection import Connection
125 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
126 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
127
128
129 def main():
130 urls_list = [
131 '/cli/global/system/local-in-policy'
132 ]
133 module_arg_spec = {
134 'system_localinpolicy': {
135 'type': 'dict', 'v_range': [['7.2.0', '']],
136 'options': {
137 'action': {'v_range': [['7.2.0', '']], 'choices': ['drop', 'reject', 'accept'], 'type': 'str'},
138 'dport': {'v_range': [['7.2.0', '']], 'type': 'int'},
139 'dst': {'v_range': [['7.2.0', '']], 'type': 'str'},
140 'id': {'v_range': [['7.2.0', '']], 'required': True, 'type': 'int'},
141 'intf': {'v_range': [['7.2.0', '']], 'type': 'str'},
142 'protocol': {'v_range': [['7.2.0', '']], 'choices': ['tcp', 'udp', 'tcp_udp'], 'type': 'str'},
143 'src': {'v_range': [['7.2.0', '']], 'type': 'str'},
144 'description': {'v_range': [['7.6.4', '']], 'type': 'str'}
145 }
146 }
147 }
148
149 module_option_spec = get_module_arg_spec('full crud')
150 module_arg_spec.update(module_option_spec)
151 check_galaxy_version(module_arg_spec)
152 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'system_localinpolicy'),
153 supports_check_mode=True)
154 if not module._socket_path:
155 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
156 connection = Connection(module._socket_path)
157 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
158 'id', 'data', module, connection)
159 fmgr.process_crud()
160 module.exit_json(meta=module.params)
161
162
163 if __name__ == '__main__':
164 main()