Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_gtp_policyv2.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_gtp_policyv2
15 short_description: Apply allow or deny action to each GTPv2-c packet.
16 version_added: "2.1.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 gtp:
29 description: The parameter (gtp) in requested url.
30 type: str
31 required: true
32 firewall_gtp_policyv2:
33 description: The top level parameters set.
34 required: false
35 type: dict
36 suboptions:
37 action:
38 type: str
39 description: Action.
40 choices: ['deny', 'allow']
41 apn_sel_mode:
42 aliases: ['apn-sel-mode']
43 type: list
44 elements: str
45 description: APN selection mode.
46 choices: ['ms', 'net', 'vrf']
47 apnmember:
48 type: raw
49 description: (list or str) APN member.
50 id:
51 type: int
52 description: ID.
53 required: true
54 imsi_prefix:
55 aliases: ['imsi-prefix']
56 type: str
57 description: IMSI prefix.
58 max_apn_restriction:
59 aliases: ['max-apn-restriction']
60 type: str
61 description: Maximum APN restriction value.
62 choices: ['all', 'public-1', 'public-2', 'private-1', 'private-2']
63 mei:
64 type: str
65 description: MEI pattern.
66 messages:
67 type: list
68 elements: str
69 description: GTP messages.
70 choices: ['create-ses-req', 'create-ses-res', 'modify-bearer-req',
71 'modify-bearer-res']
72 msisdn_prefix:
73 aliases: ['msisdn-prefix']
74 type: str
75 description: MSISDN prefix.
76 rat_type:
77 aliases: ['rat-type']
78 type: list
79 elements: str
80 description: RAT Type.
81 choices: ['any', 'utran', 'geran', 'wlan', 'gan', 'hspa', 'eutran', 'virtual',
82 'nbiot', 'ltem', 'nr']
83 uli:
84 type: raw
85 description: (list) GTPv2 ULI patterns
86 '''
87
88 EXAMPLES = '''
89 - name: Example playbook (generated based on argument schema)
90 hosts: fortimanagers
91 connection: httpapi
92 gather_facts: false
93 tasks:
94 - name: Apply allow or deny action to each GTPv2-c packet.
95 fortinet.fortimanager.fmgr_firewall_gtp_policyv2:
96 # workspace_locking_adom: <global or your adom name>
97 adom: <your own value>
98 gtp: <your own value>
99 state: present # <value in [present, absent]>
100 firewall_gtp_policyv2:
101 id: 0 # Required variable, integer
102 # action: <value in [deny, allow]>
103 # apn_sel_mode: ["ms", "net", "vrf"]
104 # apnmember: <list or string>
105 # imsi_prefix: <string>
106 # max_apn_restriction: <value in [all, public-1, public-2, ...]>
107 # mei: <string>
108 # messages: ["create-ses-req", "create-ses-res", "modify-bearer-req",
109 # "modify-bearer-res"]
110 # msisdn_prefix: <string>
111 # rat_type: ["any", "utran", "geran", "wlan", "gan", "hspa", "eutran", "virtual",
112 # "nbiot", "ltem", "nr"]
113 # uli: <list or string>
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/gtp/{gtp}/policy-v2',
164 '/pm/config/global/obj/firewall/gtp/{gtp}/policy-v2'
165 ]
166 module_arg_spec = {
167 'adom': {'required': True, 'type': 'str'},
168 'gtp': {'required': True, 'type': 'str'},
169 'revision_note': {'type': 'str'},
170 'firewall_gtp_policyv2': {
171 'type': 'dict', 'v_range': [['6.2.1', '']],
172 'options': {
173 'action': {'v_range': [['6.2.1', '']], 'choices': ['deny', 'allow'], 'type': 'str'},
174 'apn-sel-mode': {'v_range': [['6.2.1', '']], 'type': 'list', 'choices': ['ms', 'net', 'vrf'], 'elements': 'str'},
175 'apnmember': {'v_range': [['6.2.1', '']], 'type': 'raw'},
176 'id': {'v_range': [['6.2.1', '']], 'required': True, 'type': 'int'},
177 'imsi-prefix': {'v_range': [['6.2.1', '']], 'type': 'str'},
178 'max-apn-restriction': {'v_range': [['6.2.1', '']], 'choices': ['all', 'public-1', 'public-2', 'private-1', 'private-2'], 'type': 'str'},
179 'mei': {'v_range': [['6.2.1', '']], 'type': 'str'},
180 'messages': {
181 'v_range': [['6.2.1', '']],
182 'type': 'list',
183 'choices': ['create-ses-req', 'create-ses-res', 'modify-bearer-req', 'modify-bearer-res'],
184 'elements': 'str'
185 },
186 'msisdn-prefix': {'v_range': [['6.2.1', '']], 'type': 'str'},
187 'rat-type': {
188 'v_range': [['6.2.1', '']],
189 'type': 'list',
190 'choices': ['any', 'utran', 'geran', 'wlan', 'gan', 'hspa', 'eutran', 'virtual', 'nbiot', 'ltem', 'nr'],
191 'elements': 'str'
192 },
193 'uli': {'v_range': [['6.2.1', '']], 'type': 'raw'}
194 }
195 }
196 }
197
198 module_option_spec = get_module_arg_spec('full crud')
199 module_arg_spec.update(module_option_spec)
200 check_galaxy_version(module_arg_spec)
201 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_gtp_policyv2'),
202 supports_check_mode=True)
203 if not module._socket_path:
204 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
205 connection = Connection(module._socket_path)
206 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
207 'id', 'data', module, connection)
208 fmgr.process_crud()
209 module.exit_json(meta=module.params)
210
211
212 if __name__ == '__main__':
213 main()