Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_gtp_perapnshaper.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_perapnshaper
15 short_description: Per APN shaper.
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_perapnshaper:
33 description: The top level parameters set.
34 required: false
35 type: dict
36 suboptions:
37 apn:
38 type: str
39 description: APN name.
40 id:
41 type: int
42 description: ID.
43 required: true
44 rate_limit:
45 aliases: ['rate-limit']
46 type: int
47 description: Rate limit
48 version:
49 type: int
50 description: GTP version number
51 '''
52
53 EXAMPLES = '''
54 - name: Example playbook
55 hosts: fortimanagers
56 gather_facts: false
57 connection: httpapi
58 vars:
59 ansible_httpapi_use_ssl: true
60 ansible_httpapi_validate_certs: false
61 ansible_httpapi_port: 443
62 tasks:
63 - name: Per APN shaper.
64 fortinet.fortimanager.fmgr_firewall_gtp_perapnshaper:
65 bypass_validation: false
66 adom: FortiCarrier # This is FOC-only object, need a FortiCarrier adom
67 gtp: "ansible-test" # name
68 state: present
69 firewall_gtp_perapnshaper:
70 id: 1
71 rate_limit: 20
72
73 - name: Gathering fortimanager facts
74 hosts: fortimanagers
75 gather_facts: false
76 connection: httpapi
77 vars:
78 ansible_httpapi_use_ssl: true
79 ansible_httpapi_validate_certs: false
80 ansible_httpapi_port: 443
81 tasks:
82 - name: Retrieve all the Per APN shaper in the GTP
83 fortinet.fortimanager.fmgr_fact:
84 facts:
85 selector: "firewall_gtp_perapnshaper"
86 params:
87 adom: "FortiCarrier" # This is FOC-only object, need a FortiCarrier adom
88 gtp: "ansible-test" # name
89 per_apn_shaper: "your_value"
90 '''
91
92 RETURN = '''
93 meta:
94 description: The result of the request.
95 type: dict
96 returned: always
97 contains:
98 request_url:
99 description: The full url requested.
100 returned: always
101 type: str
102 sample: /sys/login/user
103 response_code:
104 description: The status of api request.
105 returned: always
106 type: int
107 sample: 0
108 response_data:
109 description: The api response.
110 type: list
111 returned: always
112 response_message:
113 description: The descriptive message of the api response.
114 type: str
115 returned: always
116 sample: OK.
117 system_information:
118 description: The information of the target system.
119 type: dict
120 returned: always
121 rc:
122 description: The status the request.
123 type: int
124 returned: always
125 sample: 0
126 version_check_warning:
127 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
128 type: list
129 returned: complex
130 '''
131 from ansible.module_utils.basic import AnsibleModule
132 from ansible.module_utils.connection import Connection
133 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
134 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
135
136
137 def main():
138 urls_list = [
139 '/pm/config/adom/{adom}/obj/firewall/gtp/{gtp}/per-apn-shaper',
140 '/pm/config/global/obj/firewall/gtp/{gtp}/per-apn-shaper'
141 ]
142 module_arg_spec = {
143 'adom': {'required': True, 'type': 'str'},
144 'gtp': {'required': True, 'type': 'str'},
145 'revision_note': {'type': 'str'},
146 'firewall_gtp_perapnshaper': {
147 'type': 'dict', 'v_range': [['6.0.0', '']],
148 'options': {'apn': {'type': 'str'}, 'id': {'required': True, 'type': 'int'}, 'rate-limit': {'type': 'int'}, 'version': {'type': 'int'}}
149 }
150 }
151
152 module_option_spec = get_module_arg_spec('full crud')
153 module_arg_spec.update(module_option_spec)
154 check_galaxy_version(module_arg_spec)
155 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_gtp_perapnshaper'),
156 supports_check_mode=True)
157 if not module._socket_path:
158 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
159 connection = Connection(module._socket_path)
160 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
161 'id', 'data', module, connection)
162 fmgr.process_crud()
163 module.exit_json(meta=module.params)
164
165
166 if __name__ == '__main__':
167 main()