Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_pm_pblock_obj.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_pm_pblock_obj
15 short_description: Policy block adom
16 version_added: "2.1.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.full_crud
20 options:
21 adom:
22 description: The parameter (adom) in requested url.
23 type: str
24 required: true
25 pkg_path:
26 description: The parameter (pkg_path) in requested url.
27 type: str
28 required: true
29 pm_pblock_obj:
30 description: The top level parameters set.
31 required: false
32 type: dict
33 suboptions:
34 name:
35 type: str
36 description: Name.
37 required: true
38 oid:
39 type: int
40 description: Oid.
41 package_settings:
42 aliases: ['package settings']
43 type: dict
44 description: Package settings.
45 suboptions:
46 central_nat:
47 aliases: ['central-nat']
48 type: str
49 description: Central nat.
50 choices: ['disable', 'enable']
51 consolidated_firewall_mode:
52 aliases: ['consolidated-firewall-mode']
53 type: str
54 description: Consolidated firewall mode.
55 choices: ['disable', 'enable']
56 fwpolicy_implicit_log:
57 aliases: ['fwpolicy-implicit-log']
58 type: str
59 description: Fwpolicy implicit log.
60 choices: ['disable', 'enable']
61 fwpolicy6_implicit_log:
62 aliases: ['fwpolicy6-implicit-log']
63 type: str
64 description: Fwpolicy6 implicit log.
65 choices: ['disable', 'enable']
66 inspection_mode:
67 aliases: ['inspection-mode']
68 type: str
69 description: Inspection mode.
70 choices: ['proxy', 'flow']
71 ngfw_mode:
72 aliases: ['ngfw-mode']
73 type: str
74 description: Ngfw mode.
75 choices: ['profile-based', 'policy-based']
76 policy_offload_level:
77 aliases: ['policy-offload-level']
78 type: str
79 description: Policy offload level.
80 choices: ['disable', 'default', 'dos-offload', 'full-offload']
81 ssl_ssh_profile:
82 aliases: ['ssl-ssh-profile']
83 type: str
84 description: Ssl ssh profile.
85 type:
86 type: str
87 description: Type.
88 choices: ['pblock']
89 '''
90
91 EXAMPLES = '''
92 - name: Example playbook (generated based on argument schema)
93 hosts: fortimanagers
94 connection: httpapi
95 gather_facts: false
96 tasks:
97 - name: Policy block adom
98 fortinet.fortimanager.fmgr_pm_pblock_obj:
99 # workspace_locking_adom: <global or your adom name>
100 adom: <your own value>
101 pkg_path: <your own value>
102 state: present # <value in [present, absent]>
103 pm_pblock_obj:
104 name: "your value" # Required variable, string
105 # oid: <integer>
106 # package_settings:
107 # central_nat: <value in [disable, enable]>
108 # consolidated_firewall_mode: <value in [disable, enable]>
109 # fwpolicy_implicit_log: <value in [disable, enable]>
110 # fwpolicy6_implicit_log: <value in [disable, enable]>
111 # inspection_mode: <value in [proxy, flow]>
112 # ngfw_mode: <value in [profile-based, policy-based]>
113 # policy_offload_level: <value in [disable, default, dos-offload, ...]>
114 # ssl_ssh_profile: <string>
115 # type: <value in [pblock]>
116 '''
117
118 RETURN = '''
119 meta:
120 description: The result of the request.
121 type: dict
122 returned: always
123 contains:
124 request_url:
125 description: The full url requested.
126 returned: always
127 type: str
128 sample: /sys/login/user
129 response_code:
130 description: The status of api request.
131 returned: always
132 type: int
133 sample: 0
134 response_data:
135 description: The api response.
136 type: list
137 returned: always
138 response_message:
139 description: The descriptive message of the api response.
140 type: str
141 returned: always
142 sample: OK.
143 system_information:
144 description: The information of the target system.
145 type: dict
146 returned: always
147 rc:
148 description: The status the request.
149 type: int
150 returned: always
151 sample: 0
152 version_check_warning:
153 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
154 type: list
155 returned: complex
156 '''
157 from ansible.module_utils.basic import AnsibleModule
158 from ansible.module_utils.connection import Connection
159 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
160 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
161
162
163 def main():
164 urls_list = [
165 '/pm/pblock/adom/{adom}/{pkg_path}'
166 ]
167 module_arg_spec = {
168 'adom': {'required': True, 'type': 'str'},
169 'pkg_path': {'required': True, 'type': 'str'},
170 'pm_pblock_obj': {
171 'type': 'dict', 'v_range': [['7.0.3', '']],
172 'options': {
173 'name': {'v_range': [['7.0.3', '']], 'required': True, 'type': 'str'},
174 'oid': {'v_range': [['7.0.3', '']], 'type': 'int'},
175 'package settings': {
176 'v_range': [['7.0.3', '']],
177 'type': 'dict',
178 'options': {
179 'central-nat': {'v_range': [['7.0.3', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
180 'consolidated-firewall-mode': {'v_range': [['7.0.3', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
181 'fwpolicy-implicit-log': {'v_range': [['7.0.3', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
182 'fwpolicy6-implicit-log': {'v_range': [['7.0.3', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
183 'inspection-mode': {'v_range': [['7.0.3', '']], 'choices': ['proxy', 'flow'], 'type': 'str'},
184 'ngfw-mode': {'v_range': [['7.0.3', '']], 'choices': ['profile-based', 'policy-based'], 'type': 'str'},
185 'policy-offload-level': {
186 'v_range': [['7.0.3', '']],
187 'choices': ['disable', 'default', 'dos-offload', 'full-offload'],
188 'type': 'str'
189 },
190 'ssl-ssh-profile': {'v_range': [['7.0.3', '']], 'type': 'str'}
191 }
192 },
193 'type': {'v_range': [['7.0.3', '']], 'choices': ['pblock'], 'type': 'str'}
194 }
195 }
196 }
197
198 module_option_spec = get_module_arg_spec('full crud')
199 module_arg_spec.update(module_option_spec)
200 check_galaxy_version(module_arg_spec)
201 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'pm_pblock_obj'),
202 supports_check_mode=True)
203 if not module._socket_path:
204 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
205 connection = Connection(module._socket_path)
206 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
207 'name', 'data', module, connection)
208 fmgr.process_crud()
209 module.exit_json(meta=module.params)
210
211
212 if __name__ == '__main__':
213 main()