Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_switchcontroller_acl_ingress.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_switchcontroller_acl_ingress
15 short_description: Configure ingress ACL policies to be applied on managed FortiSwitch ports.
16 version_added: "2.2.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 switchcontroller_acl_ingress:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 action:
34 type: dict
35 description: Action.
36 suboptions:
37 count:
38 type: str
39 description: Enable/disable count.
40 choices: ['disable', 'enable']
41 drop:
42 type: str
43 description: Enable/disable drop.
44 choices: ['disable', 'enable']
45 classifier:
46 type: dict
47 description: Classifier.
48 suboptions:
49 dst_ip_prefix:
50 aliases: ['dst-ip-prefix']
51 type: str
52 description: Destination IP address to be matched.
53 dst_mac:
54 aliases: ['dst-mac']
55 type: str
56 description: Destination MAC address to be matched.
57 src_ip_prefix:
58 aliases: ['src-ip-prefix']
59 type: str
60 description: Source IP address to be matched.
61 src_mac:
62 aliases: ['src-mac']
63 type: str
64 description: Source MAC address to be matched.
65 vlan:
66 type: int
67 description: VLAN ID to be matched.
68 description:
69 type: str
70 description: Description for the ACL policy.
71 id:
72 type: int
73 description: ACL ID.
74 required: true
75 '''
76
77 EXAMPLES = '''
78 - name: Example playbook (generated based on argument schema)
79 hosts: fortimanagers
80 connection: httpapi
81 gather_facts: false
82 tasks:
83 - name: Configure ingress ACL policies to be applied on managed FortiSwitch ports.
84 fortinet.fortimanager.fmgr_switchcontroller_acl_ingress:
85 # workspace_locking_adom: <global or your adom name>
86 adom: <your own value>
87 state: present # <value in [present, absent]>
88 switchcontroller_acl_ingress:
89 id: 0 # Required variable, integer
90 # action:
91 # count: <value in [disable, enable]>
92 # drop: <value in [disable, enable]>
93 # classifier:
94 # dst_ip_prefix: <string>
95 # dst_mac: <string>
96 # src_ip_prefix: <string>
97 # src_mac: <string>
98 # vlan: <integer>
99 # description: <string>
100 '''
101
102 RETURN = '''
103 meta:
104 description: The result of the request.
105 type: dict
106 returned: always
107 contains:
108 request_url:
109 description: The full url requested.
110 returned: always
111 type: str
112 sample: /sys/login/user
113 response_code:
114 description: The status of api request.
115 returned: always
116 type: int
117 sample: 0
118 response_data:
119 description: The api response.
120 type: list
121 returned: always
122 response_message:
123 description: The descriptive message of the api response.
124 type: str
125 returned: always
126 sample: OK.
127 system_information:
128 description: The information of the target system.
129 type: dict
130 returned: always
131 rc:
132 description: The status the request.
133 type: int
134 returned: always
135 sample: 0
136 version_check_warning:
137 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
138 type: list
139 returned: complex
140 '''
141 from ansible.module_utils.basic import AnsibleModule
142 from ansible.module_utils.connection import Connection
143 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
144 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
145
146
147 def main():
148 urls_list = [
149 '/pm/config/adom/{adom}/obj/switch-controller/acl/ingress',
150 '/pm/config/global/obj/switch-controller/acl/ingress'
151 ]
152 module_arg_spec = {
153 'adom': {'required': True, 'type': 'str'},
154 'revision_note': {'type': 'str'},
155 'switchcontroller_acl_ingress': {
156 'type': 'dict', 'v_range': [['7.4.0', '']],
157 'options': {
158 'action': {
159 'v_range': [['7.4.0', '']],
160 'type': 'dict',
161 'options': {
162 'count': {'v_range': [['7.4.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
163 'drop': {'v_range': [['7.4.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'}
164 }
165 },
166 'classifier': {
167 'v_range': [['7.4.0', '']],
168 'type': 'dict',
169 'options': {
170 'dst-ip-prefix': {'v_range': [['7.4.0', '']], 'type': 'str'},
171 'dst-mac': {'v_range': [['7.4.0', '']], 'type': 'str'},
172 'src-ip-prefix': {'v_range': [['7.4.0', '']], 'type': 'str'},
173 'src-mac': {'v_range': [['7.4.0', '']], 'type': 'str'},
174 'vlan': {'v_range': [['7.4.0', '']], 'type': 'int'}
175 }
176 },
177 'description': {'v_range': [['7.4.0', '']], 'type': 'str'},
178 'id': {'v_range': [['7.4.0', '']], 'required': True, 'type': 'int'}
179 }
180 }
181 }
182
183 module_option_spec = get_module_arg_spec('full crud')
184 module_arg_spec.update(module_option_spec)
185 check_galaxy_version(module_arg_spec)
186 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'switchcontroller_acl_ingress'),
187 supports_check_mode=True)
188 if not module._socket_path:
189 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
190 connection = Connection(module._socket_path)
191 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
192 'id', 'data', module, connection)
193 fmgr.process_crud()
194 module.exit_json(meta=module.params)
195
196
197 if __name__ == '__main__':
198 main()