Debian Codegraph @

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