diff --git a/example/main.go b/example/main.go index 3f51536..76ccba5 100644 --- a/example/main.go +++ b/example/main.go @@ -4,7 +4,7 @@ import ( "log" "github.com/ureuzy/acos-client-go/pkg/axapi/slb/virtualserver" - "github.com/ureuzy/acos-client-go/pkg/axapi/slb/virtualserver/port" + "github.com/ureuzy/acos-client-go/pkg/axapi/slb/virtualserver/virtualserverport" "github.com/ureuzy/acos-client-go/pkg/client" ) @@ -25,10 +25,10 @@ func main() { log.Fatal(err) } - _, err = c.Slb.VirtualServerPort.CreateList(&port.ListBody{ - ListObjects: port.ListObjects{ - port.Object{PortNumber: 80, Protocol: "http"}, - port.Object{PortNumber: 443, Protocol: "https"}, + _, err = c.Slb.VirtualServerPort.CreateList(&virtualserverport.ListBody{ + ListObjects: virtualserverport.ListObjects{ + virtualserverport.Object{PortNumber: 80, Protocol: "http"}, + virtualserverport.Object{PortNumber: 443, Protocol: "https"}, }, }, virtualServer.Name) if err != nil { diff --git a/pkg/axapi/gslb/gslb.go b/pkg/axapi/gslb/gslb.go index 77bc013..640f6ef 100644 --- a/pkg/axapi/gslb/gslb.go +++ b/pkg/axapi/gslb/gslb.go @@ -4,9 +4,9 @@ import ( "github.com/ureuzy/acos-client-go/pkg/axapi/gslb/policy" "github.com/ureuzy/acos-client-go/pkg/axapi/gslb/serviceip" "github.com/ureuzy/acos-client-go/pkg/axapi/gslb/site" - "github.com/ureuzy/acos-client-go/pkg/axapi/gslb/site/ipserver" + "github.com/ureuzy/acos-client-go/pkg/axapi/gslb/site/siteipserver" "github.com/ureuzy/acos-client-go/pkg/axapi/gslb/zone" - "github.com/ureuzy/acos-client-go/pkg/axapi/gslb/zone/service" + "github.com/ureuzy/acos-client-go/pkg/axapi/gslb/zone/zoneservice" "github.com/ureuzy/acos-client-go/pkg/rest" "github.com/ureuzy/acos-client-go/utils" ) @@ -17,9 +17,9 @@ type Operator struct { Policy rest.Operator[policy.Body, policy.ListBody] ServiceIP rest.Operator[serviceip.Body, serviceip.ListBody] Site rest.Operator[site.Body, site.ListBody] - SiteIPServer rest.Operator[ipserver.Body, ipserver.ListBody] + SiteIPServer rest.Operator[siteipserver.Body, siteipserver.ListBody] Zone rest.Operator[zone.Body, zone.ListBody] - ZoneService rest.Operator[service.Body, service.ListBody] + ZoneService rest.Operator[zoneservice.Body, zoneservice.ListBody] } func New(c utils.HTTPClient) *Operator { @@ -27,8 +27,8 @@ func New(c utils.HTTPClient) *Operator { Policy: policy.New(c, path), ServiceIP: serviceip.New(c, path), Site: site.New(c, path), - SiteIPServer: ipserver.New(c, path), + SiteIPServer: siteipserver.New(c, path), Zone: zone.New(c, path), - ZoneService: service.New(c, path), + ZoneService: zoneservice.New(c, path), } } diff --git a/pkg/axapi/gslb/serviceip/port/port.go b/pkg/axapi/gslb/serviceip/serviceipport/port.go similarity index 96% rename from pkg/axapi/gslb/serviceip/port/port.go rename to pkg/axapi/gslb/serviceip/serviceipport/port.go index f929cc8..af703e9 100644 --- a/pkg/axapi/gslb/serviceip/port/port.go +++ b/pkg/axapi/gslb/serviceip/serviceipport/port.go @@ -1,4 +1,4 @@ -package port +package serviceipport import ( "fmt" diff --git a/pkg/axapi/gslb/serviceip/port/types.go b/pkg/axapi/gslb/serviceip/serviceipport/types.go similarity index 98% rename from pkg/axapi/gslb/serviceip/port/types.go rename to pkg/axapi/gslb/serviceip/serviceipport/types.go index 3a001af..25d679b 100644 --- a/pkg/axapi/gslb/serviceip/port/types.go +++ b/pkg/axapi/gslb/serviceip/serviceipport/types.go @@ -1,4 +1,4 @@ -package port +package serviceipport import "github.com/ureuzy/acos-client-go/pkg/axapi/shared" diff --git a/pkg/axapi/gslb/serviceip/types.go b/pkg/axapi/gslb/serviceip/types.go index faf626c..0c6c2d6 100644 --- a/pkg/axapi/gslb/serviceip/types.go +++ b/pkg/axapi/gslb/serviceip/types.go @@ -1,7 +1,7 @@ package serviceip import ( - "github.com/ureuzy/acos-client-go/pkg/axapi/gslb/serviceip/port" + "github.com/ureuzy/acos-client-go/pkg/axapi/gslb/serviceip/serviceipport" "github.com/ureuzy/acos-client-go/pkg/axapi/shared" ) @@ -19,5 +19,5 @@ type Object struct { HealthCheckProtocolDisable shared.Boolean `json:"health-check-protocol-disable,omitempty"` HealthCheckDisable shared.Boolean `json:"health-check-disable,omitempty"` SamplingEnable []shared.SamplingEnable `json:"sampling-enable,omitempty"` //"enum":["all","hits","recent"] - PortList []port.Port `json:"port-list,omitempty"` + PortList []serviceipport.Port `json:"port-list,omitempty"` } diff --git a/pkg/axapi/gslb/site/ipserver/ipserver.go b/pkg/axapi/gslb/site/siteipserver/ipserver.go similarity index 96% rename from pkg/axapi/gslb/site/ipserver/ipserver.go rename to pkg/axapi/gslb/site/siteipserver/ipserver.go index 40685ef..81e46ae 100644 --- a/pkg/axapi/gslb/site/ipserver/ipserver.go +++ b/pkg/axapi/gslb/site/siteipserver/ipserver.go @@ -1,4 +1,4 @@ -package ipserver +package siteipserver import ( "fmt" diff --git a/pkg/axapi/gslb/site/ipserver/types.go b/pkg/axapi/gslb/site/siteipserver/types.go similarity index 89% rename from pkg/axapi/gslb/site/ipserver/types.go rename to pkg/axapi/gslb/site/siteipserver/types.go index 8d37f0a..a274add 100644 --- a/pkg/axapi/gslb/site/ipserver/types.go +++ b/pkg/axapi/gslb/site/siteipserver/types.go @@ -1,4 +1,4 @@ -package ipserver +package siteipserver import "github.com/ureuzy/acos-client-go/pkg/axapi/shared" diff --git a/pkg/axapi/gslb/site/types.go b/pkg/axapi/gslb/site/types.go index 9652ac3..5aa28ec 100644 --- a/pkg/axapi/gslb/site/types.go +++ b/pkg/axapi/gslb/site/types.go @@ -1,29 +1,29 @@ package site import ( - "github.com/ureuzy/acos-client-go/pkg/axapi/gslb/site/ipserver" + "github.com/ureuzy/acos-client-go/pkg/axapi/gslb/site/siteipserver" "github.com/ureuzy/acos-client-go/pkg/axapi/shared" ) // Object Docs: https://acos.docs.a10networks.com/axapi/521p2/axapiv3/gslb_site.html#site-attributes type Object struct { shared.AxaBase `json:",inline"` - SiteName string `json:"site-name,omitempty"` - AutoMap shared.Boolean `json:"auto-map,omitempty"` - Disable shared.Boolean `json:"disable,omitempty"` - Weight int `json:"weight,omitempty"` - MultipleGeoLocations []string `json:"multiple-geo-locations,omitempty"` - Template string `json:"template,omitempty"` - BwCost int `json:"bw-cost,omitempty"` - Limit int `json:"limit,omitempty"` - Threshold int `json:"threshold,omitempty"` - ProtoAgingTime int `json:"proto-aging-time,omitempty"` - ProtoAgingFast shared.Boolean `json:"proto-aging-fast,omitempty"` - Controller string `json:"controller,omitempty"` - IPServerList []ipserver.IPServer `json:"ip-server-list,omitempty"` - ActiveRdt ActiveRdt `json:"active-rdt,omitempty"` - EasyRdt EasyRdt `json:"easy-rdt,omitempty"` - SlbDevList []SlbDevList `json:"slb-dev-list,omitempty"` + SiteName string `json:"site-name,omitempty"` + AutoMap shared.Boolean `json:"auto-map,omitempty"` + Disable shared.Boolean `json:"disable,omitempty"` + Weight int `json:"weight,omitempty"` + MultipleGeoLocations []string `json:"multiple-geo-locations,omitempty"` + Template string `json:"template,omitempty"` + BwCost int `json:"bw-cost,omitempty"` + Limit int `json:"limit,omitempty"` + Threshold int `json:"threshold,omitempty"` + ProtoAgingTime int `json:"proto-aging-time,omitempty"` + ProtoAgingFast shared.Boolean `json:"proto-aging-fast,omitempty"` + Controller string `json:"controller,omitempty"` + IPServerList []siteipserver.IPServer `json:"ip-server-list,omitempty"` + ActiveRdt ActiveRdt `json:"active-rdt,omitempty"` + EasyRdt EasyRdt `json:"easy-rdt,omitempty"` + SlbDevList []SlbDevList `json:"slb-dev-list,omitempty"` } type ActiveRdt struct { diff --git a/pkg/axapi/gslb/zone/types.go b/pkg/axapi/gslb/zone/types.go index e604380..815bb4d 100644 --- a/pkg/axapi/gslb/zone/types.go +++ b/pkg/axapi/gslb/zone/types.go @@ -1,24 +1,24 @@ package zone import ( - "github.com/ureuzy/acos-client-go/pkg/axapi/gslb/zone/service" + "github.com/ureuzy/acos-client-go/pkg/axapi/gslb/zone/zoneservice" "github.com/ureuzy/acos-client-go/pkg/axapi/shared" ) // Object Docs: https://acos.docs.a10networks.com/axapi/521p2/axapiv3/gslb_zone.html#zone-attributes type Object struct { shared.AxaBase `json:",inline"` - Name string `json:"name,omitempty"` - Disable shared.Boolean `json:"disable,omitempty"` - Policy string `json:"policy,omitempty"` - Template Template `json:"template,omitempty"` - TTL int `json:"ttl,omitempty"` - UseServerTTL shared.Boolean `json:"use-server-ttl,omitempty"` - DNSSOARecord service.DNSSOARecord `json:"dns-soa-record,omitempty"` - SamplingEnable []shared.SamplingEnable `json:"sampling-enable,omitempty"` //"enum":[ "all", "received-query", "sent-response", "proxy-mode-response", "cache-mode-response", "server-mode-response", "sticky-mode-response", "backup-mode-response"] - DNSMXRecordList []service.DNSMXRecord `json:"dns-mx-record-list,omitempty"` - DNSNSRecordList []service.DNSNSRecord `json:"dns-ns-record-list,omitempty"` - ServiceList []service.Service `json:"service-list,omitempty"` + Name string `json:"name,omitempty"` + Disable shared.Boolean `json:"disable,omitempty"` + Policy string `json:"policy,omitempty"` + Template Template `json:"template,omitempty"` + TTL int `json:"ttl,omitempty"` + UseServerTTL shared.Boolean `json:"use-server-ttl,omitempty"` + DNSSOARecord zoneservice.DNSSOARecord `json:"dns-soa-record,omitempty"` + SamplingEnable []shared.SamplingEnable `json:"sampling-enable,omitempty"` //"enum":[ "all", "received-query", "sent-response", "proxy-mode-response", "cache-mode-response", "server-mode-response", "sticky-mode-response", "backup-mode-response"] + DNSMXRecordList []zoneservice.DNSMXRecord `json:"dns-mx-record-list,omitempty"` + DNSNSRecordList []zoneservice.DNSNSRecord `json:"dns-ns-record-list,omitempty"` + ServiceList []zoneservice.Service `json:"service-list,omitempty"` } type Template struct { diff --git a/pkg/axapi/gslb/zone/service/service.go b/pkg/axapi/gslb/zone/zoneservice/service.go similarity index 96% rename from pkg/axapi/gslb/zone/service/service.go rename to pkg/axapi/gslb/zone/zoneservice/service.go index 16c34e8..cb6c98f 100644 --- a/pkg/axapi/gslb/zone/service/service.go +++ b/pkg/axapi/gslb/zone/zoneservice/service.go @@ -1,4 +1,4 @@ -package service +package zoneservice import ( "fmt" diff --git a/pkg/axapi/gslb/zone/service/types.go b/pkg/axapi/gslb/zone/zoneservice/types.go similarity index 99% rename from pkg/axapi/gslb/zone/service/types.go rename to pkg/axapi/gslb/zone/zoneservice/types.go index fdcea52..76a3c42 100644 --- a/pkg/axapi/gslb/zone/service/types.go +++ b/pkg/axapi/gslb/zone/zoneservice/types.go @@ -1,4 +1,4 @@ -package service +package zoneservice import ( "github.com/ureuzy/acos-client-go/pkg/axapi/shared" diff --git a/pkg/axapi/health/health.go b/pkg/axapi/health/health.go index ee9be02..6887782 100644 --- a/pkg/axapi/health/health.go +++ b/pkg/axapi/health/health.go @@ -1,7 +1,7 @@ package health import ( - "github.com/ureuzy/acos-client-go/pkg/axapi/health/monitor" + "github.com/ureuzy/acos-client-go/pkg/axapi/health/healthmonitor" "github.com/ureuzy/acos-client-go/pkg/rest" "github.com/ureuzy/acos-client-go/utils" ) @@ -9,11 +9,11 @@ import ( const path = "health" type Operator struct { - Montitor rest.Operator[monitor.Body, monitor.ListBody] + Montitor rest.Operator[healthmonitor.Body, healthmonitor.ListBody] } func New(c utils.HTTPClient) *Operator { return &Operator{ - Montitor: monitor.New(c, path), + Montitor: healthmonitor.New(c, path), } } diff --git a/pkg/axapi/health/healthmonitor/monitor.go b/pkg/axapi/health/healthmonitor/monitor.go new file mode 100644 index 0000000..26ef8a9 --- /dev/null +++ b/pkg/axapi/health/healthmonitor/monitor.go @@ -0,0 +1,25 @@ +package healthmonitor + +import ( + "fmt" + + "github.com/ureuzy/acos-client-go/pkg/rest" + "github.com/ureuzy/acos-client-go/utils" +) + +// Docs: https://acos.docs.a10networks.com/axapi/521p2/axapiv3/health_monitor.html + +func New(c utils.HTTPClient, basePath string) rest.Operator[Body, ListBody] { + const path = "monitor" + return rest.Rest[Body, ListBody](c, fmt.Sprintf("%s/%s", basePath, path)) +} + +type ListBody struct { + ListObjects `json:"monitor-list,omitempty"` +} + +type Body struct { + Object `json:"monitor,omitempty"` +} + +type ListObjects []Object diff --git a/pkg/axapi/health/monitor/monitor.go b/pkg/axapi/health/healthmonitor/types.go similarity index 92% rename from pkg/axapi/health/monitor/monitor.go rename to pkg/axapi/health/healthmonitor/types.go index 7b893fb..ed6541b 100644 --- a/pkg/axapi/health/monitor/monitor.go +++ b/pkg/axapi/health/healthmonitor/types.go @@ -1,29 +1,6 @@ -package monitor +package healthmonitor -import ( - "fmt" - - "github.com/ureuzy/acos-client-go/pkg/axapi/shared" - "github.com/ureuzy/acos-client-go/pkg/rest" - "github.com/ureuzy/acos-client-go/utils" -) - -// Docs: https://acos.docs.a10networks.com/axapi/521p2/axapiv3/health_monitor.html - -func New(c utils.HTTPClient, basePath string) rest.Operator[Body, ListBody] { - const path = "monitor" - return rest.Rest[Body, ListBody](c, fmt.Sprintf("%s/%s", basePath, path)) -} - -type ListBody struct { - ListObjects `json:"monitor-list,omitempty"` -} - -type Body struct { - Object `json:"monitor,omitempty"` -} - -type ListObjects []Object +import "github.com/ureuzy/acos-client-go/pkg/axapi/shared" type Object struct { shared.AxaBase `json:",inline"` diff --git a/pkg/axapi/slb/slb.go b/pkg/axapi/slb/slb.go index f39c59d..b4a430c 100644 --- a/pkg/axapi/slb/slb.go +++ b/pkg/axapi/slb/slb.go @@ -3,7 +3,7 @@ package slb import ( "github.com/ureuzy/acos-client-go/pkg/axapi/slb/server" "github.com/ureuzy/acos-client-go/pkg/axapi/slb/virtualserver" - "github.com/ureuzy/acos-client-go/pkg/axapi/slb/virtualserver/port" + "github.com/ureuzy/acos-client-go/pkg/axapi/slb/virtualserver/virtualserverport" "github.com/ureuzy/acos-client-go/pkg/rest" "github.com/ureuzy/acos-client-go/utils" ) @@ -13,13 +13,13 @@ const path = "slb" type Operator struct { Server rest.Operator[server.Body, server.ListBody] VirtualServer rest.Operator[virtualserver.Body, virtualserver.ListBody] - VirtualServerPort rest.Operator[port.Body, port.ListBody] + VirtualServerPort rest.Operator[virtualserverport.Body, virtualserverport.ListBody] } func New(c utils.HTTPClient) *Operator { return &Operator{ Server: server.New(c, path), VirtualServer: virtualserver.New(c, path), - VirtualServerPort: port.New(c, path), + VirtualServerPort: virtualserverport.New(c, path), } } diff --git a/pkg/axapi/slb/virtualserver/types.go b/pkg/axapi/slb/virtualserver/types.go index 747046d..6b9743a 100644 --- a/pkg/axapi/slb/virtualserver/types.go +++ b/pkg/axapi/slb/virtualserver/types.go @@ -2,37 +2,37 @@ package virtualserver import ( "github.com/ureuzy/acos-client-go/pkg/axapi/shared" - "github.com/ureuzy/acos-client-go/pkg/axapi/slb/virtualserver/port" + "github.com/ureuzy/acos-client-go/pkg/axapi/slb/virtualserver/virtualserverport" ) // Object Docs: https://documentation.a10networks.com/ACOS/414x/ACOS_4_1_4-P1/html/axapiv3/slb_virtual_server.html#virtual-server-attributes type Object struct { shared.AxaBase `json:",inline"` - ACLID int `json:"acl-id,omitempty"` - ACLName string `json:"acl-name,omitempty"` - ArpDisable shared.Boolean `json:"arp-disable,omitempty"` - Description string `json:"description,omitempty"` - DisableVipAdv shared.Boolean `json:"disable-vip-adv,omitempty"` - EnableDisableAction string `json:"enable-disable-action,omitempty"` - Ethernet int `json:"ethernet,omitempty"` - ExtendedStats shared.Boolean `json:"extended-stats,omitempty"` - HADynamic int `json:"ha-dynamic,omitempty"` - IPAddress string `json:"ip-address"` - IPv6ACL string `json:"ipv6-acl,omitempty"` - IPv6Address string `json:"ipv6-address,omitempty"` - MigrateVIP *MigrateVip `json:"migrate-vip,omitempty"` - Name string `json:"name"` - Netmask string `json:"netmask,omitempty"` - PortList *port.ListObjects `json:"port-list,omitempty"` - RedistributeRouteMap string `json:"redistribute-route-map,omitempty"` - RedistributionFlagged shared.Boolean `json:"redistribution-flagged,omitempty"` - StatsDataAction string `json:"stats-data-action,omitempty"` - TemplateLogging string `json:"template-logging,omitempty"` - TemplatePolicy string `json:"template-policy,omitempty"` - TemplateScaleout string `json:"template-scaleout,omitempty"` - TemplateVirtualServer string `json:"template-virtual-server,omitempty"` - UseIfIP shared.Boolean `json:"use-if-ip,omitempty"` - VRID int `json:"vrid,omitempty"` + ACLID int `json:"acl-id,omitempty"` + ACLName string `json:"acl-name,omitempty"` + ArpDisable shared.Boolean `json:"arp-disable,omitempty"` + Description string `json:"description,omitempty"` + DisableVipAdv shared.Boolean `json:"disable-vip-adv,omitempty"` + EnableDisableAction string `json:"enable-disable-action,omitempty"` + Ethernet int `json:"ethernet,omitempty"` + ExtendedStats shared.Boolean `json:"extended-stats,omitempty"` + HADynamic int `json:"ha-dynamic,omitempty"` + IPAddress string `json:"ip-address"` + IPv6ACL string `json:"ipv6-acl,omitempty"` + IPv6Address string `json:"ipv6-address,omitempty"` + MigrateVIP *MigrateVip `json:"migrate-vip,omitempty"` + Name string `json:"name"` + Netmask string `json:"netmask,omitempty"` + PortList *virtualserverport.ListObjects `json:"port-list,omitempty"` + RedistributeRouteMap string `json:"redistribute-route-map,omitempty"` + RedistributionFlagged shared.Boolean `json:"redistribution-flagged,omitempty"` + StatsDataAction string `json:"stats-data-action,omitempty"` + TemplateLogging string `json:"template-logging,omitempty"` + TemplatePolicy string `json:"template-policy,omitempty"` + TemplateScaleout string `json:"template-scaleout,omitempty"` + TemplateVirtualServer string `json:"template-virtual-server,omitempty"` + UseIfIP shared.Boolean `json:"use-if-ip,omitempty"` + VRID int `json:"vrid,omitempty"` } type ListObjects []Object diff --git a/pkg/axapi/slb/virtualserver/port/port.go b/pkg/axapi/slb/virtualserver/virtualserverport/port.go similarity index 79% rename from pkg/axapi/slb/virtualserver/port/port.go rename to pkg/axapi/slb/virtualserver/virtualserverport/port.go index 70b64fe..34bd85a 100644 --- a/pkg/axapi/slb/virtualserver/port/port.go +++ b/pkg/axapi/slb/virtualserver/virtualserverport/port.go @@ -1,4 +1,4 @@ -package port +package virtualserverport import ( "fmt" @@ -15,3 +15,11 @@ func New(c utils.HTTPClient, basePath string) rest.Operator[Body, ListBody] { const path = "virtual-server/%s/port" return rest.Rest[Body, ListBody](c, fmt.Sprintf("%s/%s", basePath, path)) } + +type ListBody struct { + ListObjects `json:"port-list"` +} + +type Body struct { + Object `json:"port"` +} diff --git a/pkg/axapi/slb/virtualserver/port/types.go b/pkg/axapi/slb/virtualserver/virtualserverport/types.go similarity index 98% rename from pkg/axapi/slb/virtualserver/port/types.go rename to pkg/axapi/slb/virtualserver/virtualserverport/types.go index 507c628..9ab3a4a 100644 --- a/pkg/axapi/slb/virtualserver/port/types.go +++ b/pkg/axapi/slb/virtualserver/virtualserverport/types.go @@ -1,15 +1,7 @@ -package port +package virtualserverport import "github.com/ureuzy/acos-client-go/pkg/axapi/shared" -type ListBody struct { - ListObjects `json:"port-list"` -} - -type Body struct { - Object `json:"port"` -} - // Object Docs: https://documentation.a10networks.com/ACOS/414x/ACOS_4_1_4-P1/html/axapiv3/slb_virtual_server_port.html#port-attributes type Object struct { shared.AxaBase `json:",inline"`