zone_client.go raw
1 package network
2
3 import liquidweb "github.com/liquidweb/liquidweb-go"
4
5 // ZoneBackend is the interface for network zones.
6 type ZoneBackend interface {
7 Details(int) (*Zone, error)
8 List(*ZoneListParams) (*ZoneList, error)
9 }
10
11 // ZoneClient is the API client for network zones.
12 type ZoneClient struct {
13 Backend liquidweb.Backend
14 }
15
16 // Details fetches the details for a zone.
17 func (c *ZoneClient) Details(id int) (*Zone, error) {
18 var zoneResult *Zone
19 zoneParams := ZoneParams{ID: id}
20
21 err := c.Backend.CallIntoInterface("v1/Network/Zone/detail", zoneParams, zoneResult)
22 if err != nil {
23 return nil, err
24 }
25 return zoneResult, nil
26 }
27
28 // List returns a list of network zones.
29 func (c *ZoneClient) List(params *ZoneListParams) (*ZoneList, error) {
30 zoneList := &ZoneList{}
31
32 err := c.Backend.CallIntoInterface("v1/Network/Zone/list", params, zoneList)
33 if err != nil {
34 return nil, err
35 }
36
37 return zoneList, nil
38 }
39