Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_pkg_central_dnat.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_pkg_central_dnat
15 short_description: Policy package central dnat
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 pkg:
29 description: The parameter (pkg) in requested url.
30 type: str
31 required: true
32 pkg_central_dnat:
33 description: The top level parameters set.
34 required: false
35 type: dict
36 suboptions:
37 name:
38 type: raw
39 description: (list or str) Name.
40 required: true
41 '''
42
43 EXAMPLES = '''
44 - name: Example playbook
45 hosts: fortimanagers
46 gather_facts: false
47 connection: httpapi
48 vars:
49 ansible_httpapi_use_ssl: true
50 ansible_httpapi_validate_certs: false
51 ansible_httpapi_port: 443
52 tasks:
53 - name: Configure DNAT policies.
54 fortinet.fortimanager.fmgr_pkg_central_dnat:
55 bypass_validation: false
56 adom: ansible
57 pkg: ansible
58 state: present
59 pkg_central_dnat:
60 name: "ansible-test-vip" # DNAT policy has dependency with virtual IP, name must be same with a name in Virtual IPs
61
62 - name: Gathering fortimanager facts
63 hosts: fortimanagers
64 gather_facts: false
65 connection: httpapi
66 vars:
67 ansible_httpapi_use_ssl: true
68 ansible_httpapi_validate_certs: false
69 ansible_httpapi_port: 443
70 tasks:
71 - name: Retrieve all the DNAT policies
72 fortinet.fortimanager.fmgr_fact:
73 facts:
74 selector: "pkg_central_dnat"
75 params:
76 adom: "ansible"
77 pkg: "ansible"
78 dnat: "your_value"
79 '''
80
81 RETURN = '''
82 meta:
83 description: The result of the request.
84 type: dict
85 returned: always
86 contains:
87 request_url:
88 description: The full url requested.
89 returned: always
90 type: str
91 sample: /sys/login/user
92 response_code:
93 description: The status of api request.
94 returned: always
95 type: int
96 sample: 0
97 response_data:
98 description: The api response.
99 type: list
100 returned: always
101 response_message:
102 description: The descriptive message of the api response.
103 type: str
104 returned: always
105 sample: OK.
106 system_information:
107 description: The information of the target system.
108 type: dict
109 returned: always
110 rc:
111 description: The status the request.
112 type: int
113 returned: always
114 sample: 0
115 version_check_warning:
116 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
117 type: list
118 returned: complex
119 '''
120 from ansible.module_utils.basic import AnsibleModule
121 from ansible.module_utils.connection import Connection
122 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
123 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
124
125
126 def main():
127 urls_list = [
128 '/pm/config/adom/{adom}/pkg/{pkg}/central/dnat'
129 ]
130 module_arg_spec = {
131 'adom': {'required': True, 'type': 'str'},
132 'pkg': {'required': True, 'type': 'str'},
133 'revision_note': {'type': 'str'},
134 'pkg_central_dnat': {
135 'type': 'dict', 'v_range': [['6.0.0', '']],
136 'options': {'name': {'required': True, 'type': 'raw'}}
137 }
138 }
139
140 module_option_spec = get_module_arg_spec('full crud')
141 module_arg_spec.update(module_option_spec)
142 check_galaxy_version(module_arg_spec)
143 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'pkg_central_dnat'),
144 supports_check_mode=True)
145 if not module._socket_path:
146 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
147 connection = Connection(module._socket_path)
148 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
149 'name', 'data', module, connection)
150 fmgr.process_crud()
151 module.exit_json(meta=module.params)
152
153
154 if __name__ == '__main__':
155 main()