Debian Codegraph @

ansible_collections/community/dns/plugins/modules/hetzner_dns_zone_info.py

raw
1 #!/usr/bin/python
2 # Copyright (c) 2021 Felix Fontein
3 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
4 # SPDX-License-Identifier: GPL-3.0-or-later
5
6 from __future__ import annotations
7
8 DOCUMENTATION = r"""
9 module: hetzner_dns_zone_info
10
11 short_description: Retrieve zone information in Hetzner DNS service
12
13 version_added: 2.0.0
14
15 description:
16 - Retrieves zone information in Hetzner DNS service.
17 extends_documentation_fragment:
18 - community.dns._hetzner
19 - community.dns._hetzner.zone_id_type
20 - community.dns._module_zone_info
21 - community.dns._attributes
22 - community.dns._attributes.actiongroup_hetzner
23 - community.dns._attributes.info_module
24 - community.dns._attributes.idempotent_not_modify_state
25
26 attributes:
27 action_group:
28 version_added: 2.4.0
29
30 author:
31 - Markus Bergholz (@markuman) <[email protected]>
32 - Felix Fontein (@felixfontein)
33 """
34
35 EXAMPLES = r"""
36 - name: Retrieve details for foo.com zone
37 community.dns.hetzner_dns_zone_info:
38 zone: foo.com
39 hetzner_token: access_token
40 register: rec
41
42 - name: Retrieve details for zone 23
43 community.dns.hetzner_dns_zone_info:
44 zone_id: 23
45 hetzner_token: access_token
46 """
47
48 RETURN = r"""
49 zone_name:
50 description: The name of the zone.
51 type: int
52 returned: success
53 sample: example.com
54
55 zone_id:
56 description: The ID of the zone.
57 type: str
58 returned: success
59 sample: 23
60
61 zone_info:
62 description:
63 - Extra information returned by the API.
64 type: dict
65 returned: success
66 contains:
67 # TODO: adjust to new API!
68 created:
69 description:
70 - The time when the zone was created.
71 type: str
72 sample: "2021-07-15T19:23:58Z"
73 modified:
74 description:
75 - The time the zone was last modified.
76 type: str
77 sample: "2021-07-15T19:23:58Z"
78 legacy_dns_host:
79 description:
80 # TODO
81 - Unknown.
82 type: str
83 returned: if zone was imported
84 legacy_ns:
85 description:
86 - List of nameservers during import.
87 type: list
88 elements: str
89 returned: if zone was imported
90 ns:
91 description:
92 - List of nameservers the zone should have for using Hetzner's DNS.
93 type: list
94 elements: str
95 owner:
96 description:
97 - Owner of the zone.
98 type: str
99 paused:
100 description:
101 # TODO
102 - Unknown.
103 type: bool
104 sample: true
105 permission:
106 description:
107 - Zone's permissions.
108 type: str
109 project:
110 description:
111 # TODO
112 - Unknown.
113 type: str
114 registrar:
115 description:
116 # TODO
117 - Unknown.
118 type: str
119 status:
120 description:
121 - Status of the zone.
122 - Can be one of V(verified), V(failed) and V(pending).
123 type: str
124 sample: verified
125 # TODO
126 # choices:
127 # - verified
128 # - failed
129 # - pending
130 ttl:
131 description:
132 - TTL of zone.
133 type: int
134 sample: 0
135 verified:
136 description:
137 - Time when zone was verified.
138 type: str
139 sample: "2021-07-15T19:23:58Z"
140 records_count:
141 description:
142 - Number of records associated to this zone.
143 type: int
144 sample: 0
145 is_secondary_dns:
146 description:
147 - Indicates whether the zone is a secondary DNS zone.
148 type: bool
149 sample: true
150 txt_verification:
151 description:
152 - Shape of the TXT record that has to be set to verify a zone.
153 - If name and token are empty, no TXT record needs to be set.
154 type: dict
155 sample: {'name': '', 'token': ''}
156 contains:
157 name:
158 description:
159 - The TXT record's name.
160 type: str
161 token:
162 description:
163 - The TXT record's content.
164 type: str
165 """
166
167 from ansible.module_utils.basic import AnsibleModule
168
169 from ansible_collections.community.dns.plugins.module_utils._argspec import (
170 ModuleOptionProvider,
171 )
172 from ansible_collections.community.dns.plugins.module_utils._hetzner.api import (
173 create_hetzner_api,
174 create_hetzner_argument_spec,
175 create_hetzner_provider_information,
176 )
177 from ansible_collections.community.dns.plugins.module_utils._http import (
178 ModuleHTTPHelper,
179 )
180 from ansible_collections.community.dns.plugins.module_utils._module.zone_info import (
181 create_module_argument_spec,
182 run_module,
183 )
184
185
186 def main() -> None:
187 provider_information = create_hetzner_provider_information()
188 argument_spec = create_hetzner_argument_spec()
189 argument_spec.merge(
190 create_module_argument_spec(provider_information=provider_information)
191 )
192 module = AnsibleModule(supports_check_mode=True, **argument_spec.to_kwargs())
193 option_provider = ModuleOptionProvider(module)
194 run_module(
195 module,
196 lambda: create_hetzner_api(option_provider, ModuleHTTPHelper(module)),
197 provider_information=create_hetzner_provider_information(
198 option_provider=option_provider
199 ),
200 )
201
202
203 if __name__ == "__main__":
204 main()