Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_gtp_ieremovepolicy.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_ieremovepolicy
15 short_description: IE remove 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_ieremovepolicy:
33 description: The top level parameters set.
34 required: false
35 type: dict
36 suboptions:
37 id:
38 type: int
39 description: ID.
40 required: true
41 remove_ies:
42 aliases: ['remove-ies']
43 type: list
44 elements: str
45 description: GTP IEs to be removed.
46 choices: ['apn-restriction', 'rat-type', 'rai', 'uli', 'imei']
47 sgsn_addr:
48 aliases: ['sgsn-addr']
49 type: str
50 description: SGSN address name.
51 sgsn_addr6:
52 aliases: ['sgsn-addr6']
53 type: str
54 description: SGSN IPv6 address name.
55 '''
56
57 EXAMPLES = '''
58 - name: Example playbook
59 hosts: fortimanagers
60 gather_facts: false
61 connection: httpapi
62 vars:
63 ansible_httpapi_use_ssl: true
64 ansible_httpapi_validate_certs: false
65 ansible_httpapi_port: 443
66 tasks:
67 - name: IE remove policy.
68 fortinet.fortimanager.fmgr_firewall_gtp_ieremovepolicy:
69 bypass_validation: false
70 adom: FortiCarrier # This is FOC-only object, need a FortiCarrier adom
71 gtp: "ansible-test" # name
72 state: present
73 firewall_gtp_ieremovepolicy:
74 id: 1
75 remove_ies:
76 - apn-restriction
77 - rat-type
78 - rai
79 - uli
80 - imei
81 sgsn_addr: "your_value"
82
83 - name: Gathering fortimanager facts
84 hosts: fortimanagers
85 gather_facts: false
86 connection: httpapi
87 vars:
88 ansible_httpapi_use_ssl: true
89 ansible_httpapi_validate_certs: false
90 ansible_httpapi_port: 443
91 tasks:
92 - name: Retrieve all the IE remove policys in the GTP
93 fortinet.fortimanager.fmgr_fact:
94 facts:
95 selector: "firewall_gtp_ieremovepolicy"
96 params:
97 adom: "FortiCarrier" # This is FOC-only object, need a FortiCarrier adom
98 gtp: "ansible-test" # name
99 ie_remove_policy: "your_value"
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/firewall/gtp/{gtp}/ie-remove-policy',
150 '/pm/config/global/obj/firewall/gtp/{gtp}/ie-remove-policy'
151 ]
152 module_arg_spec = {
153 'adom': {'required': True, 'type': 'str'},
154 'gtp': {'required': True, 'type': 'str'},
155 'revision_note': {'type': 'str'},
156 'firewall_gtp_ieremovepolicy': {
157 'type': 'dict', 'v_range': [['6.0.0', '']],
158 'options': {
159 'id': {'required': True, 'type': 'int'},
160 'remove-ies': {'type': 'list', 'choices': ['apn-restriction', 'rat-type', 'rai', 'uli', 'imei'], 'elements': 'str'},
161 'sgsn-addr': {'type': 'str'},
162 'sgsn-addr6': {'v_range': [['6.4.2', '']], 'type': 'str'}
163 }
164 }
165 }
166
167 module_option_spec = get_module_arg_spec('full crud')
168 module_arg_spec.update(module_option_spec)
169 check_galaxy_version(module_arg_spec)
170 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_gtp_ieremovepolicy'),
171 supports_check_mode=True)
172 if not module._socket_path:
173 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
174 connection = Connection(module._socket_path)
175 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
176 'id', 'data', module, connection)
177 fmgr.process_crud()
178 module.exit_json(meta=module.params)
179
180
181 if __name__ == '__main__':
182 main()