Compare commits
10 Commits
v0.0.1-alp
...
v0.0.1-alp
| Author | SHA1 | Date | |
|---|---|---|---|
| b3b119c402 | |||
| b4e2400bcf | |||
| 8974e82e78 | |||
| 01e89ca98d | |||
| f85fe28c53 | |||
| 82702848f9 | |||
| c52743effa | |||
| b079790183 | |||
| bae6a964eb | |||
| bab50ebfc4 |
@@ -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) {
|
||||||
|
|||||||
@@ -213,8 +213,12 @@ func (c *Client) do(ctx context.Context, method, relativeURL string, reqBody int
|
|||||||
return fmt.Errorf("unable to parse URL: %s %s %w", method, relativeURL, err)
|
return fmt.Errorf("unable to parse URL: %s %s %w", method, relativeURL, err)
|
||||||
}
|
}
|
||||||
if !strings.HasPrefix(relativeURL, "/") && !reqURL.IsAbs() {
|
if !strings.HasPrefix(relativeURL, "/") && !reqURL.IsAbs() {
|
||||||
|
if strings.Contains(relativeURL, "firewall/zone") {
|
||||||
|
reqURL.Path = path.Join(c.apiV2Path, reqURL.Path)
|
||||||
|
} else {
|
||||||
reqURL.Path = path.Join(c.apiPath, reqURL.Path)
|
reqURL.Path = path.Join(c.apiPath, reqURL.Path)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
url := c.baseURL.ResolveReference(reqURL)
|
url := c.baseURL.ResolveReference(reqURL)
|
||||||
req, err := http.NewRequestWithContext(ctx, method, url.String(), reqReader)
|
req, err := http.NewRequestWithContext(ctx, method, url.String(), reqReader)
|
||||||
|
|||||||
Reference in New Issue
Block a user