Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_gtp_imsi.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_imsi
15 short_description: IMSI.
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_imsi:
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 apnmember:
42 type: raw
43 description: (list or str) APN member.
44 id:
45 type: int
46 description: ID.
47 required: true
48 mcc_mnc:
49 aliases: ['mcc-mnc']
50 type: str
51 description: MCC MNC.
52 msisdn_prefix:
53 aliases: ['msisdn-prefix']
54 type: str
55 description: MSISDN prefix.
56 selection_mode:
57 aliases: ['selection-mode']
58 type: list
59 elements: str
60 description: APN selection mode.
61 choices: ['ms', 'net', 'vrf']
62 '''
63
64 EXAMPLES = '''
65 - name: Example playbook
66 hosts: fortimanagers
67 gather_facts: false
68 connection: httpapi
69 vars:
70 ansible_httpapi_use_ssl: true
71 ansible_httpapi_validate_certs: false
72 ansible_httpapi_port: 443
73 tasks:
74 - name: IMSI.
75 fortinet.fortimanager.fmgr_firewall_gtp_imsi:
76 bypass_validation: false
77 adom: FortiCarrier # This is FOC-only object, need a FortiCarrier adom
78 gtp: "ansible-test" # name
79 state: present
80 firewall_gtp_imsi:
81 action: allow # <value in [allow, deny]>
82 apnmember: "your_value"
83 id: 1
84 msisdn_prefix: "ansible"
85 selection_mode:
86 - ms
87 - net
88 - vrf
89
90 - name: Gathering fortimanager facts
91 hosts: fortimanagers
92 gather_facts: false
93 connection: httpapi
94 vars:
95 ansible_httpapi_use_ssl: true
96 ansible_httpapi_validate_certs: false
97 ansible_httpapi_port: 443
98 tasks:
99 - name: Retrieve all the IMSIs in the GTP
100 fortinet.fortimanager.fmgr_fact:
101 facts:
102 selector: "firewall_gtp_imsi"
103 params:
104 adom: "FortiCarrier" # This is FOC-only object, need a FortiCarrier adom
105 gtp: "ansible-test" # name
106 imsi: "your_value"
107 '''
108
109 RETURN = '''
110 meta:
111 description: The result of the request.
112 type: dict
113 returned: always
114 contains:
115 request_url:
116 description: The full url requested.
117 returned: always
118 type: str
119 sample: /sys/login/user
120 response_code:
121 description: The status of api request.
122 returned: always
123 type: int
124 sample: 0
125 response_data:
126 description: The api response.
127 type: list
128 returned: always
129 response_message:
130 description: The descriptive message of the api response.
131 type: str
132 returned: always
133 sample: OK.
134 system_information:
135 description: The information of the target system.
136 type: dict
137 returned: always
138 rc:
139 description: The status the request.
140 type: int
141 returned: always
142 sample: 0
143 version_check_warning:
144 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
145 type: list
146 returned: complex
147 '''
148 from ansible.module_utils.basic import AnsibleModule
149 from ansible.module_utils.connection import Connection
150 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
151 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
152
153
154 def main():
155 urls_list = [
156 '/pm/config/adom/{adom}/obj/firewall/gtp/{gtp}/imsi',
157 '/pm/config/global/obj/firewall/gtp/{gtp}/imsi'
158 ]
159 module_arg_spec = {
160 'adom': {'required': True, 'type': 'str'},
161 'gtp': {'required': True, 'type': 'str'},
162 'revision_note': {'type': 'str'},
163 'firewall_gtp_imsi': {
164 'type': 'dict', 'v_range': [['6.0.0', '']],
165 'options': {
166 'action': {'choices': ['allow', 'deny'], 'type': 'str'},
167 'apnmember': {'type': 'raw'},
168 'id': {'required': True, 'type': 'int'},
169 'mcc-mnc': {'type': 'str'},
170 'msisdn-prefix': {'type': 'str'},
171 'selection-mode': {'type': 'list', 'choices': ['ms', 'net', 'vrf'], 'elements': 'str'}
172 }
173 }
174 }
175
176 module_option_spec = get_module_arg_spec('full crud')
177 module_arg_spec.update(module_option_spec)
178 check_galaxy_version(module_arg_spec)
179 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_gtp_imsi'),
180 supports_check_mode=True)
181 if not module._socket_path:
182 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
183 connection = Connection(module._socket_path)
184 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
185 'id', 'data', module, connection)
186 fmgr.process_crud()
187 module.exit_json(meta=module.params)
188
189
190 if __name__ == '__main__':
191 main()