Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_system_dnsdatabase_dnsentry.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_system_dnsdatabase_dnsentry
15 short_description: DNS entry.
16 version_added: "2.12.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 dns-database:
29 description: Deprecated, please use "dns_database"
30 type: str
31 dns_database:
32 description: The parameter (dns-database) in requested url.
33 type: str
34 system_dnsdatabase_dnsentry:
35 description: The top level parameters set.
36 required: false
37 type: dict
38 suboptions:
39 canonical_name:
40 aliases: ['canonical-name']
41 type: str
42 description: Canonical name of the host.
43 hostname:
44 type: str
45 description: Name of the host.
46 id:
47 type: int
48 description: DNS entry ID.
49 required: true
50 ip:
51 type: str
52 description: IPv4 address of the host.
53 ipv6:
54 type: str
55 description: IPv6 address of the host.
56 preference:
57 type: int
58 description: DNS entry preference
59 status:
60 type: str
61 description: Enable/disable resource record status.
62 choices: ['disable', 'enable']
63 ttl:
64 type: int
65 description: Time-to-live for this entry
66 type:
67 type: str
68 description: Resource record type.
69 choices: ['NS', 'MX', 'CNAME', 'A', 'AAAA', 'PTR', 'PTR_V6']
70 '''
71
72 EXAMPLES = '''
73 - name: Example playbook (generated based on argument schema)
74 hosts: fortimanagers
75 connection: httpapi
76 gather_facts: false
77 tasks:
78 - name: DNS entry.
79 fortinet.fortimanager.fmgr_system_dnsdatabase_dnsentry:
80 # workspace_locking_adom: <global or your adom name>
81 adom: <your own value>
82 dns_database: <your own value>
83 state: present # <value in [present, absent]>
84 system_dnsdatabase_dnsentry:
85 id: 0 # Required variable, integer
86 # canonical_name: <string>
87 # hostname: <string>
88 # ip: <string>
89 # ipv6: <string>
90 # preference: <integer>
91 # status: <value in [disable, enable]>
92 # ttl: <integer>
93 # type: <value in [NS, MX, CNAME, ...]>
94 '''
95
96 RETURN = '''
97 meta:
98 description: The result of the request.
99 type: dict
100 returned: always
101 contains:
102 request_url:
103 description: The full url requested.
104 returned: always
105 type: str
106 sample: /sys/login/user
107 response_code:
108 description: The status of api request.
109 returned: always
110 type: int
111 sample: 0
112 response_data:
113 description: The api response.
114 type: list
115 returned: always
116 response_message:
117 description: The descriptive message of the api response.
118 type: str
119 returned: always
120 sample: OK.
121 system_information:
122 description: The information of the target system.
123 type: dict
124 returned: always
125 rc:
126 description: The status the request.
127 type: int
128 returned: always
129 sample: 0
130 version_check_warning:
131 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
132 type: list
133 returned: complex
134 '''
135 from ansible.module_utils.basic import AnsibleModule
136 from ansible.module_utils.connection import Connection
137 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
138 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
139
140
141 def main():
142 urls_list = [
143 '/pm/config/adom/{adom}/obj/system/dns-database/{dns-database}/dns-entry',
144 '/pm/config/global/obj/system/dns-database/{dns-database}/dns-entry'
145 ]
146 module_arg_spec = {
147 'adom': {'required': True, 'type': 'str'},
148 'dns-database': {'type': 'str', 'api_name': 'dns_database'},
149 'dns_database': {'type': 'str'},
150 'revision_note': {'type': 'str'},
151 'system_dnsdatabase_dnsentry': {
152 'type': 'dict', 'v_range': [['7.6.4', '7.6.4']],
153 'options': {
154 'canonical-name': {'v_range': [['7.6.4', '7.6.4']], 'type': 'str'},
155 'hostname': {'v_range': [['7.6.4', '7.6.4']], 'type': 'str'},
156 'id': {'v_range': [['7.6.4', '7.6.4']], 'required': True, 'type': 'int'},
157 'ip': {'v_range': [['7.6.4', '7.6.4']], 'type': 'str'},
158 'ipv6': {'v_range': [['7.6.4', '7.6.4']], 'type': 'str'},
159 'preference': {'v_range': [['7.6.4', '7.6.4']], 'type': 'int'},
160 'status': {'v_range': [['7.6.4', '7.6.4']], 'choices': ['disable', 'enable'], 'type': 'str'},
161 'ttl': {'v_range': [['7.6.4', '7.6.4']], 'type': 'int'},
162 'type': {'v_range': [['7.6.4', '7.6.4']], 'choices': ['NS', 'MX', 'CNAME', 'A', 'AAAA', 'PTR', 'PTR_V6'], 'type': 'str'}
163 }
164 }
165 }
166
167 module_option_spec = get_module_arg_spec('full crud')
168 module_arg_spec.update(module_option_spec)
169 check_galaxy_version(module_arg_spec)
170 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'system_dnsdatabase_dnsentry'),
171 supports_check_mode=True)
172 if not module._socket_path:
173 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
174 connection = Connection(module._socket_path)
175 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
176 'id', 'data', module, connection)
177 fmgr.process_crud()
178 module.exit_json(meta=module.params)
179
180
181 if __name__ == '__main__':
182 main()