-
Notifications
You must be signed in to change notification settings - Fork 133
/
data_domain_zone.go
59 lines (50 loc) · 1.25 KB
/
data_domain_zone.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package ovh
import (
"fmt"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func dataSourceDomainZone() *schema.Resource {
return &schema.Resource{
Read: dataSourceDomainZoneRead,
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
},
// Computed
"has_dns_anycast": {
Type: schema.TypeBool,
Computed: true,
},
"dnssec_supported": {
Type: schema.TypeBool,
Computed: true,
},
"name_servers": {
Type: schema.TypeSet,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
Set: schema.HashString,
},
"last_update": {
Type: schema.TypeString,
Computed: true,
},
},
}
}
func dataSourceDomainZoneRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
zoneName := d.Get("name").(string)
dz := &DomainZone{}
err := config.OVHClient.Get(fmt.Sprintf("/domain/zone/%s", zoneName), &dz)
if err != nil {
return fmt.Errorf("Error calling /domain/zone/%s:\n\t %q", zoneName, err)
}
d.SetId(zoneName)
d.Set("has_dns_anycast", dz.HasDnsAnycast)
d.Set("dnssec_supported", dz.DnssecSupported)
d.Set("last_update", dz.LastUpdate)
d.Set("name_servers", dz.NameServers)
return nil
}