Refactor type generator
* Allows for generating top-level types for any embedded struct so
that sub-types can be properly instantiated from calling code
* Specifying `-no-embedded-types` will generate top-level types
rather than embedding the struct
* Refactored "Device" API
* All fields set to `omitempty` because it describes all possible
device types, so effectively any field could be omitted any time
* Fixed `get` call for "Device" API; replacing `rest` with `stat`
* Generated `get` and `update` calls for `Setting*` APIs
* Added `5.14.23` JSON files
This commit is contained in:
committed by
Paul Tyng
parent
79542b4006
commit
35eda4f67b
@@ -23,12 +23,13 @@ type SettingIps struct {
|
||||
NoDelete bool `json:"attr_no_delete,omitempty"`
|
||||
NoEdit bool `json:"attr_no_edit,omitempty"`
|
||||
|
||||
Key string `json:"key"`
|
||||
|
||||
DNSFiltering bool `json:"dns_filtering"`
|
||||
DNSFilters []struct {
|
||||
Filter string `json:"filter,omitempty"` // security|adult|family
|
||||
NetworkID string `json:"network_id"`
|
||||
Version string `json:"version,omitempty"` // v4|v6
|
||||
|
||||
} `json:"dns_filters,omitempty"`
|
||||
EnabledCategories []string `json:"enabled_categories,omitempty"` // emerging-activex|emerging-attackresponse|botcc|emerging-chat|ciarmy|compromised|emerging-dns|emerging-dos|dshield|emerging-exploit|emerging-ftp|emerging-games|emerging-icmp|emerging-icmpinfo|emerging-imap|emerging-inappropriate|emerging-info|emerging-malware|emerging-misc|emerging-mobile|emerging-netbios|emerging-p2p|emerging-policy|emerging-pop3|emerging-rpc|emerging-scada|emerging-scan|emerging-shellcode|emerging-smtp|emerging-snmp|spamhaus|emerging-sql|emerging-telnet|emerging-tftp|tor|emerging-trojan|emerging-useragent|emerging-voip|emerging-webapps|emerging-webclient|emerging-webserver|emerging-worm
|
||||
EndpointScanning bool `json:"endpoint_scanning"`
|
||||
@@ -36,7 +37,6 @@ type SettingIps struct {
|
||||
IPAddress string `json:"ip_address,omitempty"`
|
||||
NetworkID string `json:"network_id"`
|
||||
Version string `json:"version,omitempty"` // v4|v6
|
||||
|
||||
} `json:"honeypot,omitempty"`
|
||||
HoneypotEnabled bool `json:"honeypot_enabled"`
|
||||
IPsMode string `json:"ips_mode,omitempty"` // ids|ips|ipsInline|disabled
|
||||
@@ -55,12 +55,50 @@ type SettingIps struct {
|
||||
Value string `json:"value,omitempty"`
|
||||
} `json:"tracking,omitempty"`
|
||||
Type string `json:"type,omitempty"` // all|track
|
||||
|
||||
} `json:"alerts,omitempty"`
|
||||
Whitelist []struct {
|
||||
Direction string `json:"direction,omitempty"` // both|src|dest
|
||||
Mode string `json:"mode,omitempty"` // ip|subnet|network
|
||||
Value string `json:"value,omitempty"`
|
||||
} `json:"whitelist,omitempty"`
|
||||
} `json:"suppression"`
|
||||
} `json:"suppression,omitempty"`
|
||||
}
|
||||
|
||||
func (c *Client) getSettingIps(ctx context.Context, site string) (*SettingIps, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Data []SettingIps `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/ips", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
return &d, nil
|
||||
}
|
||||
|
||||
func (c *Client) updateSettingIps(ctx context.Context, site string, d *SettingIps) (*SettingIps, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Data []SettingIps `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/ips", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
return &new, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user