forked from cloudflare/cloudflare-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_test.go
More file actions
39 lines (32 loc) · 691 Bytes
/
example_test.go
File metadata and controls
39 lines (32 loc) · 691 Bytes
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
package cloudflare_test
import (
"fmt"
cloudflare "github.com/cloudflare/cloudflare-go"
)
const (
user = "cloudflare@example.org"
domain = "example.com"
apiKey = "deadbeef"
)
func Example() {
api, err := cloudflare.New("deadbeef", "cloudflare@example.org")
if err != nil {
fmt.Println(err)
return
}
// Fetch the zone ID for zone example.org
zoneID, err := api.ZoneIDByName("example.org")
if err != nil {
fmt.Println(err)
return
}
// Fetch all DNS records for example.org
records, err := api.DNSRecords(zoneID, cloudflare.DNSRecord{})
if err != nil {
fmt.Println(err)
return
}
for _, r := range records {
fmt.Printf("%s: %s\n", r.Name, r.Content)
}
}