Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_gtp_policy.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_policy
15 short_description: Policy.
16 version_added: "2.0.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_policy:
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: ['allow', 'deny']
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 imei:
55 type: str
56 description: IMEI
57 imsi:
58 type: str
59 description: IMSI prefix.
60 max_apn_restriction:
61 aliases: ['max-apn-restriction']
62 type: str
63 description: Maximum APN restriction value.
64 choices: ['all', 'public-1', 'public-2', 'private-1', 'private-2']
65 messages:
66 type: list
67 elements: str
68 description: GTP messages.
69 choices: ['create-req', 'create-res', 'update-req', 'update-res']
70 msisdn:
71 type: str
72 description: MSISDN prefix.
73 rai:
74 type: str
75 description: RAI pattern.
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']
83 uli:
84 type: str
85 description: ULI pattern.
86 imsi_prefix:
87 aliases: ['imsi-prefix']
88 type: str
89 description: IMSI prefix.
90 msisdn_prefix:
91 aliases: ['msisdn-prefix']
92 type: str
93 description: MSISDN prefix.
94 apn:
95 type: str
96 description: APN subfix.
97 '''
98
99 EXAMPLES = '''
100 - name: Example playbook
101 hosts: fortimanagers
102 gather_facts: false
103 connection: httpapi
104 vars:
105 ansible_httpapi_use_ssl: true
106 ansible_httpapi_validate_certs: false
107 ansible_httpapi_port: 443
108 tasks:
109 - name: Policy.
110 fortinet.fortimanager.fmgr_firewall_gtp_policy:
111 bypass_validation: false
112 adom: FortiCarrier # This is FOC-only object, need a FortiCarrier adom
113 gtp: "ansible-test" # name
114 state: present
115 firewall_gtp_policy:
116 action: allow # <value in [allow, deny]>
117 apn_sel_mode:
118 - ms
119 - net
120 - vrf
121 id: 1
122 max_apn_restriction: public-1 # <value in [all, public-1, public-2, ...]>
123 messages:
124 - create-req
125 - create-res
126 - update-req
127 - update-res
128 rat_type:
129 - any
130 - utran
131 - geran
132 - wlan
133 - gan
134 - hspa
135 - eutran
136 - virtual
137 - nbiot
138
139 - name: Gathering fortimanager facts
140 hosts: fortimanagers
141 gather_facts: false
142 connection: httpapi
143 vars:
144 ansible_httpapi_use_ssl: true
145 ansible_httpapi_validate_certs: false
146 ansible_httpapi_port: 443
147 tasks:
148 - name: Retrieve all the policies in the GTP
149 fortinet.fortimanager.fmgr_fact:
150 facts:
151 selector: "firewall_gtp_policy"
152 params:
153 adom: "FortiCarrier" # This is FOC-only object, need a FortiCarrier adom
154 gtp: "ansible-test" # name
155 policy: "your_value"
156 '''
157
158 RETURN = '''
159 meta:
160 description: The result of the request.
161 type: dict
162 returned: always
163 contains:
164 request_url:
165 description: The full url requested.
166 returned: always
167 type: str
168 sample: /sys/login/user
169 response_code:
170 description: The status of api request.
171 returned: always
172 type: int
173 sample: 0
174 response_data:
175 description: The api response.
176 type: list
177 returned: always
178 response_message:
179 description: The descriptive message of the api response.
180 type: str
181 returned: always
182 sample: OK.
183 system_information:
184 description: The information of the target system.
185 type: dict
186 returned: always
187 rc:
188 description: The status the request.
189 type: int
190 returned: always
191 sample: 0
192 version_check_warning:
193 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
194 type: list
195 returned: complex
196 '''
197 from ansible.module_utils.basic import AnsibleModule
198 from ansible.module_utils.connection import Connection
199 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
200 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
201
202
203 def main():
204 urls_list = [
205 '/pm/config/adom/{adom}/obj/firewall/gtp/{gtp}/policy',
206 '/pm/config/global/obj/firewall/gtp/{gtp}/policy'
207 ]
208 module_arg_spec = {
209 'adom': {'required': True, 'type': 'str'},
210 'gtp': {'required': True, 'type': 'str'},
211 'revision_note': {'type': 'str'},
212 'firewall_gtp_policy': {
213 'type': 'dict', 'v_range': [['6.0.0', '']],
214 'options': {
215 'action': {'choices': ['allow', 'deny'], 'type': 'str'},
216 'apn-sel-mode': {'type': 'list', 'choices': ['ms', 'net', 'vrf'], 'elements': 'str'},
217 'apnmember': {'type': 'raw'},
218 'id': {'required': True, 'type': 'int'},
219 'imei': {'type': 'str'},
220 'imsi': {'v_range': [['6.0.0', '7.2.1']], 'type': 'str'},
221 'max-apn-restriction': {'choices': ['all', 'public-1', 'public-2', 'private-1', 'private-2'], 'type': 'str'},
222 'messages': {'type': 'list', 'choices': ['create-req', 'create-res', 'update-req', 'update-res'], 'elements': 'str'},
223 'msisdn': {'v_range': [['6.0.0', '7.2.1']], 'type': 'str'},
224 'rai': {'type': 'str'},
225 'rat-type': {'type': 'list', 'choices': ['any', 'utran', 'geran', 'wlan', 'gan', 'hspa', 'eutran', 'virtual', 'nbiot'], 'elements': 'str'},
226 'uli': {'type': 'str'},
227 'imsi-prefix': {'v_range': [['6.2.0', '']], 'type': 'str'},
228 'msisdn-prefix': {'v_range': [['6.2.0', '']], 'type': 'str'},
229 'apn': {'v_range': [['6.2.0', '6.2.13']], 'type': 'str'}
230 }
231 }
232 }
233
234 module_option_spec = get_module_arg_spec('full crud')
235 module_arg_spec.update(module_option_spec)
236 check_galaxy_version(module_arg_spec)
237 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_gtp_policy'),
238 supports_check_mode=True)
239 if not module._socket_path:
240 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
241 connection = Connection(module._socket_path)
242 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
243 'id', 'data', module, connection)
244 fmgr.process_crud()
245 module.exit_json(meta=module.params)
246
247
248 if __name__ == '__main__':
249 main()