@@ -40,6 +40,17 @@ func newHostingAPIWithRegion(d *schema.ResourceData, m interface{}) (*webhosting
40
40
return api , region , nil
41
41
}
42
42
43
+ func newDnsAPIWithRegion (d * schema.ResourceData , m interface {}) (* webhosting.DnsAPI , scw.Region , error ) {
44
+ api := webhosting .NewDnsAPI (meta .ExtractScwClient (m ))
45
+
46
+ region , err := meta .ExtractRegion (d , m )
47
+ if err != nil {
48
+ return nil , "" , err
49
+ }
50
+
51
+ return api , region , nil
52
+ }
53
+
43
54
// NewAPIWithRegionAndID returns a Hosting API with region and ID extracted from the state.
44
55
func NewAPIWithRegionAndID (m interface {}, id string ) (* webhosting.HostingAPI , scw.Region , string , error ) {
45
56
api := webhosting .NewHostingAPI (meta .ExtractScwClient (m ))
@@ -65,3 +76,30 @@ func waitForHosting(ctx context.Context, api *webhosting.HostingAPI, region scw.
65
76
RetryInterval : & retryInterval ,
66
77
}, scw .WithContext (ctx ))
67
78
}
79
+
80
+ func flattenDNSRecords (records []* webhosting.DNSRecord ) []map [string ]interface {} {
81
+ result := []map [string ]interface {}{}
82
+ for _ , r := range records {
83
+ result = append (result , map [string ]interface {}{
84
+ "name" : r .Name ,
85
+ "type" : r .Type .String (),
86
+ "ttl" : r .TTL ,
87
+ "value" : r .Value ,
88
+ "priority" : r .Priority ,
89
+ "status" : r .Status .String (),
90
+ })
91
+ }
92
+ return result
93
+ }
94
+
95
+ func flattenNameServers (servers []* webhosting.Nameserver ) []map [string ]interface {} {
96
+ result := []map [string ]interface {}{}
97
+ for _ , s := range servers {
98
+ result = append (result , map [string ]interface {}{
99
+ "hostname" : s .Hostname ,
100
+ "status" : s .Status .String (),
101
+ "is_default" : s .IsDefault ,
102
+ })
103
+ }
104
+ return result
105
+ }
0 commit comments