Library for working with Hetzner DNS API
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

API_help.md 9.2 KiB

6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. # hclouddns
  2. --
  3. import "git.blindage.org/21h/hcloud-dns"
  4. ## Usage
  5. #### type HCloudAnswerCreateRecords
  6. ```go
  7. type HCloudAnswerCreateRecords struct {
  8. Records []HCloudRecord `json:"records,omitempty"`
  9. ValidRecords []HCloudRecord `json:"valid_records,omitempty"`
  10. InvalidRecords []HCloudRecord `json:"invalid_records,omitempty"`
  11. Error HCloudError
  12. }
  13. ```
  14. #### type HCloudAnswerDeleteRecord
  15. ```go
  16. type HCloudAnswerDeleteRecord struct {
  17. Error HCloudError
  18. }
  19. ```
  20. #### type HCloudAnswerDeleteZone
  21. ```go
  22. type HCloudAnswerDeleteZone struct {
  23. Error HCloudError
  24. }
  25. ```
  26. #### type HCloudAnswerError
  27. ```go
  28. type HCloudAnswerError struct {
  29. Error HCloudError `json:"error,omitempty"`
  30. }
  31. ```
  32. sometime can be returned HCloudError
  33. #### type HCloudAnswerErrorString
  34. ```go
  35. type HCloudAnswerErrorString struct {
  36. Error string `json:"error,omitempty"`
  37. }
  38. ```
  39. or plain string
  40. #### type HCloudAnswerGetRecord
  41. ```go
  42. type HCloudAnswerGetRecord struct {
  43. Record HCloudRecord `json:"record,omitempty"`
  44. Error HCloudError
  45. }
  46. ```
  47. #### type HCloudAnswerGetRecords
  48. ```go
  49. type HCloudAnswerGetRecords struct {
  50. Records []HCloudRecord `json:"records,omitempty"`
  51. Meta HCloudMeta `json:"meta,omitempty"`
  52. Error HCloudError
  53. }
  54. ```
  55. #### type HCloudAnswerGetZone
  56. ```go
  57. type HCloudAnswerGetZone struct {
  58. Zone HCloudZone `json:"zone,omitempty"`
  59. Error HCloudError
  60. }
  61. ```
  62. #### type HCloudAnswerGetZonePlainText
  63. ```go
  64. type HCloudAnswerGetZonePlainText struct {
  65. ZonePlainText string `json:"zone,omitempty"`
  66. Error HCloudError
  67. }
  68. ```
  69. #### type HCloudAnswerGetZones
  70. ```go
  71. type HCloudAnswerGetZones struct {
  72. Zones []HCloudZone `json:"zones,omitempty"`
  73. Meta HCloudMeta `json:"meta,omitempty"`
  74. Error HCloudError
  75. }
  76. ```
  77. #### type HCloudAnswerUpdateRecords
  78. ```go
  79. type HCloudAnswerUpdateRecords struct {
  80. Records []HCloudRecord `json:"records,omitempty"`
  81. InvalidRecords []HCloudRecord `json:"failed_records,omitempty"`
  82. Error HCloudError
  83. }
  84. ```
  85. #### type HCloudAnswerZoneValidate
  86. ```go
  87. type HCloudAnswerZoneValidate struct {
  88. ParsedRecords int `json:"parsed_records,omitempty"`
  89. ValidRecords []HCloudZone `json:"valid_records,omitempty"`
  90. Error HCloudError
  91. }
  92. ```
  93. #### type HCloudDNS
  94. ```go
  95. type HCloudDNS struct {
  96. }
  97. ```
  98. Base types
  99. #### func New
  100. ```go
  101. func New(t string) *HCloudDNS
  102. ```
  103. New instance
  104. #### func (*HCloudDNS) CreateRecord
  105. ```go
  106. func (d *HCloudDNS) CreateRecord(record HCloudRecord) (HCloudAnswerGetRecord, error)
  107. ```
  108. CreateRecord creates new single record. Accepts HCloudRecord with record to
  109. create, of cource no ID. Returns HCloudAnswerGetRecord with HCloudRecord and
  110. error.
  111. #### func (*HCloudDNS) CreateRecordBulk
  112. ```go
  113. func (d *HCloudDNS) CreateRecordBulk(record []HCloudRecord) (HCloudAnswerCreateRecords, error)
  114. ```
  115. CreateRecordBulk creates many records at once. Accepts array of HCloudRecord,
  116. converts it to json and makes POST to Hetzner. Returns HCloudAnswerCreateRecords
  117. with arrays of HCloudRecord with whole list, valid and invalid, error.
  118. #### func (*HCloudDNS) CreateZone
  119. ```go
  120. func (d *HCloudDNS) CreateZone(zone HCloudZone) (HCloudAnswerGetZone, error)
  121. ```
  122. CreateZone creates new single zone. Accepts HCloudZone with record to create, of
  123. cource no ID. Returns HCloudAnswerGetZone with HCloudZone and error.
  124. #### func (*HCloudDNS) DeleteRecord
  125. ```go
  126. func (d *HCloudDNS) DeleteRecord(ID string) (HCloudAnswerDeleteRecord, error)
  127. ```
  128. DeleteRecord remove record by ID. Accepts single ID string. Returns
  129. HCloudAnswerDeleteRecord and error.
  130. #### func (*HCloudDNS) DeleteZone
  131. ```go
  132. func (d *HCloudDNS) DeleteZone(ID string) (HCloudAnswerDeleteZone, error)
  133. ```
  134. DeleteZone remove zone by ID. Accepts single ID string. Returns
  135. HCloudAnswerDeleteZone with error.
  136. #### func (*HCloudDNS) ExportZoneToString
  137. ```go
  138. func (d *HCloudDNS) ExportZoneToString(zoneID string) (HCloudAnswerGetZonePlainText, error)
  139. ```
  140. ExportZoneToString exports single zone from imported text. Accepts ID and
  141. zonePlainText strings. Returns HCloudAnswerGetZonePlainText with HCloudZone and
  142. error.
  143. #### func (*HCloudDNS) GetRecord
  144. ```go
  145. func (d *HCloudDNS) GetRecord(ID string) (HCloudAnswerGetRecord, error)
  146. ```
  147. GetRecord retrieve one single record by ID. Accepts single ID of record. Returns
  148. HCloudAnswerGetRecord with HCloudRecord and error.
  149. #### func (*HCloudDNS) GetRecords
  150. ```go
  151. func (d *HCloudDNS) GetRecords(params HCloudGetRecordsParams) (HCloudAnswerGetRecords, error)
  152. ```
  153. GetRecords retrieve all records of user. Accepts HCloudGetRecordsParams struct
  154. Returns HCloudAnswerGetRecords with array of HCloudRecord, Meta and error.
  155. #### func (*HCloudDNS) GetZone
  156. ```go
  157. func (d *HCloudDNS) GetZone(ID string) (HCloudAnswerGetZone, error)
  158. ```
  159. GetZone retrieve one single zone by ID. Accepts zone ID string. Returns
  160. HCloudAnswerGetZone with HCloudZone and error
  161. #### func (*HCloudDNS) GetZones
  162. ```go
  163. func (d *HCloudDNS) GetZones(params HCloudGetZonesParams) (HCloudAnswerGetZones, error)
  164. ```
  165. GetZones retrieve all zones of user. Accepts exact name as string, search name
  166. with partial name. Returns HCloudAnswerGetZones with array of HCloudZone, Meta
  167. and error.
  168. #### func (*HCloudDNS) ImportZoneString
  169. ```go
  170. func (d *HCloudDNS) ImportZoneString(zoneID string, zonePlainText string) (HCloudAnswerGetZone, error)
  171. ```
  172. ImportZoneString imports single zone from imported text. Accepts ID and
  173. zonePlainText strings. Returns HCloudAnswerGetZone with HCloudZone and error.
  174. #### func (*HCloudDNS) UpdateRecord
  175. ```go
  176. func (d *HCloudDNS) UpdateRecord(record HCloudRecord) (HCloudAnswerGetRecord, error)
  177. ```
  178. UpdateRecord makes update of single record by ID. Accepts HCloudRecord with
  179. fullfilled fields. Returns HCloudAnswerGetRecord with HCloudRecord and error.
  180. #### func (*HCloudDNS) UpdateRecordBulk
  181. ```go
  182. func (d *HCloudDNS) UpdateRecordBulk(record []HCloudRecord) (HCloudAnswerUpdateRecords, error)
  183. ```
  184. UpdateRecordBulk updates many records at once. Accepts array of HCloudRecord,
  185. converting to json and makes PUT to Hetzner. Returns HCloudAnswerUpdateRecords
  186. with arrays of HCloudRecord with updated and failed, error.
  187. #### func (*HCloudDNS) UpdateZone
  188. ```go
  189. func (d *HCloudDNS) UpdateZone(zone HCloudZone) (HCloudAnswerGetZone, error)
  190. ```
  191. UpdateZone makes update of single zone by ID. Accepts HCloudZone with fullfilled
  192. fields. Returns HCloudAnswerGetZone with HCloudZone and error.
  193. #### func (*HCloudDNS) ValidateZoneString
  194. ```go
  195. func (d *HCloudDNS) ValidateZoneString(zonePlainText string) (HCloudAnswerZoneValidate, error)
  196. ```
  197. ValidateZoneString validate single zone from imported text. Accepts ID and
  198. zonePlainText strings. Returns HCloudAnswerZoneValidate with HCloudZone and
  199. error.
  200. #### type HCloudError
  201. ```go
  202. type HCloudError struct {
  203. Code int `json:"code,omitempty"`
  204. Message string `json:"message,omitempty"`
  205. }
  206. ```
  207. Hetzner errors roundabout. Fuck you Hetzner.
  208. #### type HCloudGetRecordsParams
  209. ```go
  210. type HCloudGetRecordsParams struct {
  211. ZoneID string
  212. Page string
  213. PerPage string
  214. }
  215. ```
  216. #### type HCloudGetZonesParams
  217. ```go
  218. type HCloudGetZonesParams struct {
  219. Name string
  220. SearchName string
  221. Page string
  222. PerPage string
  223. }
  224. ```
  225. #### type HCloudMeta
  226. ```go
  227. type HCloudMeta struct {
  228. Pagination struct {
  229. Page int `json:"page"`
  230. PerPage int `json:"per_page"`
  231. LastPage int `json:"last_page"`
  232. TotalEntries int `json:"total_entries"`
  233. } `json:"pagination,omitempty"`
  234. }
  235. ```
  236. #### type HCloudRecord
  237. ```go
  238. type HCloudRecord struct {
  239. RecordType RecordType `json:"type"`
  240. ID string `json:"id"`
  241. Created string `json:"created"`
  242. Modified string `json:"modified"`
  243. ZoneID string `json:"zone_id"`
  244. Name string `json:"name"`
  245. Value string `json:"value"`
  246. TTL int `json:"ttl"`
  247. }
  248. ```
  249. #### type HCloudZone
  250. ```go
  251. type HCloudZone struct {
  252. ID string `json:"id,omitempty"`
  253. Created string `json:"created,omitempty"`
  254. Modified string `json:"modified,omitempty"`
  255. LegacyDNSHost string `json:"legacy_dns_host,omitempty"`
  256. LegacyNS []string `json:"legacy_ns,omitempty"`
  257. Name string `json:"name,omitempty"`
  258. NS []string `json:"ns,omitempty"`
  259. Owner string `json:"owner,omitempty"`
  260. Paused bool `json:"paused,omitempty"`
  261. Permission string `json:"permission,omitempty"`
  262. Project string `json:"project,omitempty"`
  263. Registrar string `json:"registrar,omitempty"`
  264. Status string `json:"status,omitempty"`
  265. TTL int `json:"ttl,omitempty"`
  266. Verified string `json:"verified,omitempty"`
  267. RecordsCount int `json:"records_count,omitempty"`
  268. IsSecondaryDNS bool `json:"is_secondary_dns,omitempty"`
  269. TXTverification struct {
  270. Name string `json:"name,omitempty"`
  271. Token string `json:"token,omitempty"`
  272. } `json:"txt_verification,omitempty"`
  273. }
  274. ```
  275. #### type RecordType
  276. ```go
  277. type RecordType string
  278. ```
  279. RecordType supported by Hetzner
  280. ```go
  281. const (
  282. A RecordType = "A"
  283. AAAA RecordType = "AAAA"
  284. CNAME RecordType = "CNAME"
  285. MX RecordType = "MX"
  286. NS RecordType = "NS"
  287. TXT RecordType = "TXT"
  288. RP RecordType = "RP"
  289. SOA RecordType = "SOA"
  290. HINFO RecordType = "HINFO"
  291. SRV RecordType = "SRV"
  292. DANE RecordType = "DANE"
  293. TLSA RecordType = "TLSA"
  294. DS RecordType = "DS"
  295. CAA RecordType = "CAA"
  296. )
  297. ```