forked from cloudflare/cloudflare-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
load_balancing_example_test.go
48 lines (40 loc) · 986 Bytes
/
load_balancing_example_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
package cloudflare_test
import (
context "context"
"fmt"
"log"
cloudflare "github.com/cloudflare/cloudflare-go"
)
func ExampleAPI_ListLoadBalancers() {
// Construct a new API object.
api, err := cloudflare.New("deadbeef", "test@example.com")
if err != nil {
log.Fatal(err)
}
// Fetch the zone ID.
id, err := api.ZoneIDByName("example.com") // Assuming example.com exists in your Cloudflare account
if err != nil {
log.Fatal(err)
}
// List LBs configured in zone.
lbList, err := api.ListLoadBalancers(context.Background(), id)
if err != nil {
log.Fatal(err)
}
for _, lb := range lbList {
fmt.Println(lb)
}
}
func ExampleAPI_PoolHealthDetails() {
// Construct a new API object.
api, err := cloudflare.New("deadbeef", "test@example.com")
if err != nil {
log.Fatal(err)
}
// Fetch pool health details.
healthInfo, err := api.PoolHealthDetails(context.Background(), "example-pool-id")
if err != nil {
log.Fatal(err)
}
fmt.Println(healthInfo)
}