Debian Codegraph @

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