-
Notifications
You must be signed in to change notification settings - Fork 3
/
client_zones_test.go
62 lines (49 loc) · 1.1 KB
/
client_zones_test.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
60
61
62
package cloudflare
import (
"log"
"golang.org/x/net/context"
)
// ExampleZones_List - Lists all zones.
func ExampleZones_List() {
var client *Client
ctx := context.Background()
zones, err := client.Zones.List(ctx)
if err != nil {
log.Fatal(err)
}
for _, zone := range zones {
log.Printf("%s", zone.Name)
}
}
// ExampleZones_Details - Gets zone details by ID.
func ExampleZones_Details() {
var client *Client
ctx := context.Background()
zones, err := client.Zones.List(ctx)
if err != nil {
log.Fatal(err)
} else if len(zones) == 0 {
log.Fatal("No zones were found")
}
zone, err := client.Zones.Details(ctx, zones[0].ID)
if err != nil {
log.Fatal(err)
}
log.Printf("Got %s = %#v", zones[0].ID, zone)
}
// ExampleZones_Delete - Deletes zone by ID.
func ExampleZones_Delete() {
var client *Client
ctx := context.Background()
zones, err := client.Zones.List(ctx)
if err != nil {
log.Fatal(err)
} else if len(zones) == 0 {
log.Fatal("No zones were found")
}
err = client.Zones.Delete(ctx, zones[0].ID)
if err != nil {
log.Fatal(err)
}
log.Printf("Deleted %s", zones[0].ID)
}