Compare commits

...

15 Commits

2 changed files with 10 additions and 9 deletions

View File

@@ -14,25 +14,23 @@ type FirewallZone struct {
// NoEdit bool `json:"attr_no_edit,omitempty"` // NoEdit bool `json:"attr_no_edit,omitempty"`
Name string `json:"name"` Name string `json:"name"`
Description string `json:"desc"` DefaultZone bool `json:"default_zone,omitempty"`
DefaultZone bool `json:default_zone,omitempty` NetworkIDs []string `json:"network_ids,omitempty"`
NetworkIDs []string `json:network_ids,omitempty` ZoneKey string `json:"zone_key,omitempty"`
// Role string `json:"role"` // Role string `json:"role"`
} }
func (c *Client) ListFirewallZones(ctx context.Context, site string) ([]FirewallZone, error) { func (c *Client) ListFirewallZones(ctx context.Context, site string) ([]FirewallZone, error) {
var respBody struct { var respBody []FirewallZone
Meta meta `json:"meta"`
Data []FirewallZone `json:"data"`
}
err := c.do(ctx, "GET", fmt.Sprintf("site/%s/firewall/zone", site), nil, &respBody) err := c.do(ctx, "GET", fmt.Sprintf("site/%s/firewall/zone", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return respBody.Data, nil return respBody, nil
} }
func (c *Client) GetFirewallZone(ctx context.Context, site, id string) (*FirewallZone, error) { func (c *Client) GetFirewallZone(ctx context.Context, site, id string) (*FirewallZone, error) {

View File

@@ -13,6 +13,7 @@ import (
"path" "path"
"strings" "strings"
"sync" "sync"
"log"
) )
const ( const (
@@ -274,6 +275,8 @@ func (c *Client) do(ctx context.Context, method, relativeURL string, reqBody int
// TODO: check rc in addition to status code? // TODO: check rc in addition to status code?
log.Printf("%+v", respBody)
log.Printf("%+v", resp.Body)
err = json.NewDecoder(resp.Body).Decode(respBody) err = json.NewDecoder(resp.Body).Decode(respBody)
if err != nil { if err != nil {
return fmt.Errorf("unable to decode body: %s %s %w", method, relativeURL, err) return fmt.Errorf("unable to decode body: %s %s %w", method, relativeURL, err)