Skip to content

Commit

Permalink
added sub resource operators, separated types
Browse files Browse the repository at this point in the history
  • Loading branch information
m-terra committed Sep 28, 2022
1 parent 1f8dfe3 commit 9189fc4
Show file tree
Hide file tree
Showing 16 changed files with 376 additions and 323 deletions.
1 change: 1 addition & 0 deletions pkg/axapi/activepartition/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
)

// Docs: https://acos.docs.a10networks.com/axapi/521p2/axapiv3/active_partition.html
// URI: /axapi/v3/active-partition

type operator struct {
utils.HTTPClient
Expand Down
1 change: 1 addition & 0 deletions pkg/axapi/gslb/policy/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
)

// Docs: https://acos.docs.a10networks.com/axapi/521p2/axapiv3/gslb_policy.html
// URI: /axapi/v3/gslb/policy/{name}

func New(c utils.HTTPClient, basePath string) rest.Operator[Body, ListBody] {
const path = "policy"
Expand Down
26 changes: 26 additions & 0 deletions pkg/axapi/gslb/serviceip/port/port.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package port

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/gslb_service_ip_port.html
// URI: /axapi/v3/gslb/service-ip/{node-name}/port/{port-num}+{port-proto}

func New(c utils.HTTPClient, basePath string) rest.Operator[Body, ListBody] {
const path = "service-ip/%s/port"
return rest.Rest[Body, ListBody](c, fmt.Sprintf("%s/%s", basePath, path))
}

type ListBody struct {
ListObjects `json:"port-list"`
}

type Body struct {
Port `json:"port"`
}

type ListObjects []Port
18 changes: 18 additions & 0 deletions pkg/axapi/gslb/serviceip/port/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package port

import "github.com/ureuzy/acos-client-go/pkg/axapi/shared"

// Object Docs: https://acos.docs.a10networks.com/axapi/521p2/axapiv3/gslb_service_ip.html#service-ip-attributes

type Port struct {
shared.AxaBase `json:",inline"`
PortNum int `json:"port-num,omitempty"`
PortProto string `json:"port-proto,omitempty"`
Action string `json:"action,omitempty"` //"enum":["enable", "disable"]
HealthCheck string `json:"health-check,omitempty"`
HealthCheckFollowPort int `json:"health-check-follow-port,omitempty"`
FollowPortProtocol string `json:"follow-port-protocol,omitempty"`
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","active","current"]
}
32 changes: 1 addition & 31 deletions pkg/axapi/gslb/serviceip/serviceip.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package serviceip
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/gslb_service_ip.html#
// URI: /axapi/v3/gslb/service-ip/{node-name}

func New(c utils.HTTPClient, basePath string) rest.Operator[Body, ListBody] {
const path = "service-ip"
Expand All @@ -24,33 +24,3 @@ type Body struct {
}

type ListObjects []Object

// Object Docs: https://acos.docs.a10networks.com/axapi/521p2/axapiv3/gslb_service_ip.html#service-ip-attributes

type Object struct {
shared.AxaBase `json:",inline"`
NodeName string `json:"node-name,omitempty"`
IPv6Address string `json:"ipv6-address,omitempty"`
IPAddress string `json:"ip-address,omitempty"`
Action string `json:"action,omitempty"` //"enum":["enable", "disable"]
ExternalIP string `json:"external-ip,omitempty"`
IPv6 string `json:"ipv6,omitempty"`
HealthCheck string `json:"health-check,omitempty"`
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 `json:"port-list,omitempty"`
}

type Port struct {
shared.AxaBase `json:",inline"`
PortNum int `json:"port-num,omitempty"`
PortProto string `json:"port-proto,omitempty"`
Action string `json:"action,omitempty"` //"enum":["enable", "disable"]
HealthCheck string `json:"health-check,omitempty"`
HealthCheckFollowPort int `json:"health-check-follow-port,omitempty"`
FollowPortProtocol string `json:"follow-port-protocol,omitempty"`
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","active","current"]
}
23 changes: 23 additions & 0 deletions pkg/axapi/gslb/serviceip/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package serviceip

import (
"github.com/ureuzy/acos-client-go/pkg/axapi/gslb/serviceip/port"
"github.com/ureuzy/acos-client-go/pkg/axapi/shared"
)

// Object Docs: https://acos.docs.a10networks.com/axapi/521p2/axapiv3/gslb_service_ip.html#service-ip-attributes

type Object struct {
shared.AxaBase `json:",inline"`
NodeName string `json:"node-name,omitempty"`
IPv6Address string `json:"ipv6-address,omitempty"`
IPAddress string `json:"ip-address,omitempty"`
Action string `json:"action,omitempty"` //"enum":["enable", "disable"]
ExternalIP string `json:"external-ip,omitempty"`
IPv6 string `json:"ipv6,omitempty"`
HealthCheck string `json:"health-check,omitempty"`
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"`
}
10 changes: 4 additions & 6 deletions pkg/axapi/gslb/site/ipserver/ipserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ package ipserver
import (
"fmt"

"github.com/ureuzy/acos-client-go/pkg/axapi/gslb/site"
"github.com/ureuzy/acos-client-go/pkg/rest"
"github.com/ureuzy/acos-client-go/utils"
)

// Docs: https://acos.docs.a10networks.com/axapi/521p2/axapiv3/gslb_zone_service.html

// /axapi/v3/gslb/site/{site-name}/ip-server/{ip-server-name}
// Docs: https://acos.docs.a10networks.com/axapi/521p2/axapiv3/gslb_site_ip_server.html
// URI: /axapi/v3/gslb/site/{site-name}/ip-server/{ip-server-name}

func New(c utils.HTTPClient, basePath string) rest.Operator[Body, ListBody] {
const path = "site/%s/ip-server"
Expand All @@ -22,7 +20,7 @@ type ListBody struct {
}

type Body struct {
site.IPServer `json:"ip-server"`
IPServer `json:"ip-server"`
}

type ListObjects []site.IPServer
type ListObjects []IPServer
8 changes: 8 additions & 0 deletions pkg/axapi/gslb/site/ipserver/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package ipserver

import "github.com/ureuzy/acos-client-go/pkg/axapi/shared"

type IPServer struct {
shared.AxaBase `json:",inline"`
IPServerName string `json:"ip-server-name,omitempty"`
}
1 change: 1 addition & 0 deletions pkg/axapi/gslb/site/site.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
)

// Docs: https://acos.docs.a10networks.com/axapi/521p2/axapiv3/gslb_site.html
// URI: /axapi/v3/gslb/site/{site-name}

func New(c utils.HTTPClient, basePath string) rest.Operator[Body, ListBody] {
const path = "site"
Expand Down
42 changes: 20 additions & 22 deletions pkg/axapi/gslb/site/types.go
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
package site

import "github.com/ureuzy/acos-client-go/pkg/axapi/shared"
import (
"github.com/ureuzy/acos-client-go/pkg/axapi/gslb/site/ipserver"
"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 `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 IPServer struct {
shared.AxaBase `json:",inline"`
IPServerName string `json:"ip-server-name,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 []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"`
}

type ActiveRdt struct {
Expand Down
8 changes: 3 additions & 5 deletions pkg/axapi/gslb/zone/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ package service
import (
"fmt"

"github.com/ureuzy/acos-client-go/pkg/axapi/gslb/zone"
"github.com/ureuzy/acos-client-go/pkg/rest"
"github.com/ureuzy/acos-client-go/utils"
)

// Docs: https://acos.docs.a10networks.com/axapi/521p2/axapiv3/gslb_zone_service.html

// /axapi/v3/gslb/zone/{name}/service/{service-port}+{service-name}
// URI: /axapi/v3/gslb/zone/{name}/service/{service-port}+{service-name}

func New(c utils.HTTPClient, basePath string) rest.Operator[Body, ListBody] {
const path = "zone/%s/service"
Expand All @@ -22,7 +20,7 @@ type ListBody struct {
}

type Body struct {
zone.Service `json:"service"`
Service `json:"service"`
}

type ListObjects []zone.Service
type ListObjects []Service
114 changes: 114 additions & 0 deletions pkg/axapi/gslb/zone/service/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
package service

import (
"github.com/ureuzy/acos-client-go/pkg/axapi/shared"
)

type Service struct {
shared.AxaBase `json:",inline"`
ServicePort int `json:"service-port,omitempty"`
ServiceName string `json:"service-name,omitempty"`
Action string `json:"action,omitempty"` // "enum":[ "drop", "forward", "ignore", "reject"]
ForwardType string `json:"forward-type,omitempty"` // "enum":[ "both", "query", "response"]
Disable shared.Boolean `json:"disable,omitempty"`
HealthCheckGateway string `json:"health-check-gateway,omitempty"` //"enum":[ "enable", "disable"]
HealthCheckPort []HealthCheckPort `json:"health-check-port,omitempty"`
Policy string `json:"policy,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"]
DNSARecord DNSARecord `json:"dns-a-record,omitempty"`
DNSCNAMERecordList []DNSCnameRecord `json:"dns-cname-record-list,omitempty"`
DNSMXRecordList []DNSMXRecord `json:"dns-mx-record-list,omitempty"`
DNSNSRecordList []DNSMXRecord `json:"dns-ns-record-list,omitempty"`
DNSPtrRecordList []TodoRecord `json:"dns-ptr-record-list,omitempty"`
DNSSrvRecordList []TodoRecord `json:"dns-srv-record-list,omitempty"`
DNSNaptrRecordList []TodoRecord `json:"dns-naptr-record-list,omitempty"`
DNSTxtRecordList []TodoRecord `json:"dns-txt-record-list,omitempty"`
DNSRecordList []TodoRecord `json:"dns-record-list,omitempty"`
GeoLocationList []TodoRecord `json:"geo-location-list,omitempty"`
}

type DNSSOARecord struct {
SOAName string `json:"soa-name,omitempty"`
Mail string `json:"mail,omitempty"`
Expire int `json:"expire,omitempty"`
Refresh int `json:"refresh,omitempty"`
Retry int `json:"retry,omitempty"`
Serial int `json:"serial,omitempty"`
SOATTL int `json:"soa-ttl,omitempty"`
External string `json:"external,omitempty"`
ExMail string `json:"ex-mail,omitempty"`
ExEpire int `json:"ex-expire,omitempty"`
ExRefresh int `json:"ex-refresh,omitempty"`
ExRetry int `json:"ex-retry,omitempty"`
ExSerial int `json:"ex-serial,omitempty"`
ExSoaTTL int `json:"ex-soa-ttl,omitempty"`
}

type DNSMXRecord struct {
shared.AxaBase `json:",inline"`
}

type DNSNSRecord struct {
shared.AxaBase `json:",inline"`
}

type TodoRecord struct {
// TODO
}

type HealthCheckPort struct {
HealthCheckPort int `json:"health-check-port,omitempty"`
}

type DNSARecord struct {
DNSARecordSrvList []DNSARecordSrv `json:"dns-a-record-srv-list,omitempty"`
DNSARecordIPv4List []DNSARecordIPv4 `json:"dns-a-record-ipv4-list,omitempty"`
DNSARecordIPv6List []DNSARecordIPv6 `json:"dns-a-record-ipv6-list,omitempty"`
}

type DNSCnameRecord struct {
AliasName string `json:"alias-name,omitempty"`
AdminPreference shared.Boolean `json:"admin-preference,omitempty"`
Weight int `json:"weight,omitempty"`
AsBackup shared.Boolean `json:"as-backup,omitempty"`
SamplingEnable []shared.SamplingEnable `json:"sampling-enable,omitempty"` // "enum":[ "all", "cname-hits"]
}

type DNSARecordSrv struct {
shared.AxaBase
SvrName string `json:"svrname,omitempty"`
NoResp shared.Boolean `json:"no-resp,omitempty"`
AsBackup shared.Boolean `json:"as-backup,omitempty"`
Weight int `json:"weight,omitempty"`
TTL int `json:"ttl,omitempty"`
AsReplace shared.Boolean `json:"as-replace,omitempty"`
Disable shared.Boolean `json:"disable,omitempty"`
Static shared.Boolean `json:"static,omitempty"`
AdminIP int `json:"admin-ip,omitempty"`
}

type DNSARecordIPv4 struct {
shared.AxaBase
DNSARecordIP string `json:"dns-a-record-ip,omitempty"`
NoResp shared.Boolean `json:"no-resp,omitempty"`
AsBackup shared.Boolean `json:"as-backup,omitempty"`
Weight int `json:"weight,omitempty"`
TTL int `json:"ttl,omitempty"`
AsReplace shared.Boolean `json:"as-replace,omitempty"`
Disable shared.Boolean `json:"disable,omitempty"`
Static shared.Boolean `json:"static,omitempty"`
AdminIP int `json:"admin-ip,omitempty"`
}

type DNSARecordIPv6 struct {
shared.AxaBase
DNSARecordIP string `json:"dns-a-record-ipv6,omitempty"`
NoResp shared.Boolean `json:"no-resp,omitempty"`
AsBackup shared.Boolean `json:"as-backup,omitempty"`
Weight int `json:"weight,omitempty"`
TTL int `json:"ttl,omitempty"`
AsReplace shared.Boolean `json:"as-replace,omitempty"`
Disable shared.Boolean `json:"disable,omitempty"`
Static shared.Boolean `json:"static,omitempty"`
AdminIP int `json:"admin-ip,omitempty"`
}
Loading

0 comments on commit 9189fc4

Please sign in to comment.