diff --git a/examples/go-bigip_example.go b/examples/go-bigip_example.go index 0f497cd..9b2411e 100644 --- a/examples/go-bigip_example.go +++ b/examples/go-bigip_example.go @@ -45,7 +45,7 @@ func main() { f5.AddPoolMember("ssl_443_pool", "ssl-web-server-2:443") // Create a monitor, and assign it to a pool. - f5.CreateMonitor("web_http_monitor", "http", 5, 16, "GET /\r\n", "200 OK") + f5.CreateMonitor("web_http_monitor", "http", 5, 16, "GET /\r\n", "200 OK", "http") f5.AddMonitorToPool("web_http_monitor", "web_farm_80_pool") // Create a virtual server, with the above pool. The third field is the subnet diff --git a/ltm.go b/ltm.go index d52dace..f0ad5c9 100644 --- a/ltm.go +++ b/ltm.go @@ -130,6 +130,205 @@ type ClientSSLProfile struct { UncleanShutdown string `json:"uncleanShutdown,omitempty"` } +// TcpProfiles contains a list of every tcp profile on the BIG-IP system. +type TcpProfiles struct { + TcpProfiles []TcpProfile `json:"items"` +} + +type TcpProfile struct { + Abc string `json:"abc,omitempty"` + AckOnPush string `json:"ackOnPush,omitempty"` + AppService string `json:"appService,omitempty"` + AutoProxyBufferSize string `json:"autoProxyBufferSize,omitempty"` + AutoReceiveWindowSize string `json:"autoReceiveWindowSize,omitempty"` + AutoSendBufferSize string `json:"autoSendBufferSize,omitempty"` + CloseWaitTimeout int `json:"closeWaitTimeout,omitempty"` + CmetricsCache string `json:"cmetricsCache,omitempty"` + CmetricsCacheTimeout int `json:"cmetricsCacheTimeout,omitempty"` + CongestionControl string `json:"congestionControl,omitempty"` + DefaultsFrom string `json:"defaultsFrom,omitempty"` + DeferredAccept string `json:"deferredAccept,omitempty"` + DelayWindowControl string `json:"delayWindowControl,omitempty"` + DelayedAcks string `json:"delayedAcks,omitempty"` + Description string `json:"description,omitempty"` + Dsack string `json:"dsack,omitempty"` + EarlyRetransmit string `json:"earlyRetransmit,omitempty"` + Ecn string `json:"ecn,omitempty"` + EnhancedLossRecovery string `json:"enhancedLossRecovery,omitempty"` + FastOpen string `json:"fastOpen,omitempty"` + FastOpenCookieExpiration int `json:"fastOpenCookieExpiration,omitempty"` + FinWait_2Timeout int `json:"finWait_2Timeout,omitempty"` + FinWaitTimeout int `json:"finWaitTimeout,omitempty"` + HardwareSynCookie string `json:"hardwareSynCookie,omitempty"` + IdleTimeout int `json:"idleTimeout,omitempty"` + InitCwnd int `json:"initCwnd,omitempty"` + InitRwnd int `json:"initRwnd,omitempty"` + IpDfMode string `json:"ipDfMode,omitempty"` + IpTosToClient string `json:"ipTosToClient,omitempty"` + IpTtlMode string `json:"ipTtlMode,omitempty"` + IpTtlV4 int `json:"ipTtlV4,omitempty"` + IpTtlV6 int `json:"ipTtlV6,omitempty"` + KeepAliveInterval int `json:"keepAliveInterval,omitempty"` + LimitedTransmit string `json:"limitedTransmit,omitempty"` + LinkQosToClient string `json:"linkQosToClient,omitempty"` + MaxRetrans int `json:"maxRetrans,omitempty"` + MaxSegmentSize int `json:"maxSegmentSize,omitempty"` + Md5Signature string `json:"md5Signature,omitempty"` + Md5SignaturePassphrase string `json:"md5SignaturePassphrase,omitempty"` + MinimumRto int `json:"minimumRto,omitempty"` + Mptcp string `json:"mptcp,omitempty"` + MptcpCsum string `json:"mptcpCsum,omitempty"` + MptcpCsumVerify string `json:"mptcpCsumVerify,omitempty"` + MptcpDebug string `json:"mptcpDebug,omitempty"` + MptcpFallback string `json:"mptcpFallback,omitempty"` + MptcpFastjoin string `json:"mptcpFastjoin,omitempty"` + MptcpIdleTimeout int `json:"mptcpIdleTimeout,omitempty"` + MptcpJoinMax int `json:"mptcpJoinMax,omitempty"` + MptcpMakeafterbreak string `json:"mptcpMakeafterbreak,omitempty"` + MptcpNojoindssack string `json:"mptcpNojoindssack,omitempty"` + MptcpRtomax int `json:"mptcpRtomax,omitempty"` + MptcpRxmitmin int `json:"mptcpRxmitmin,omitempty"` + MptcpSubflowmax int `json:"mptcpSubflowmax,omitempty"` + MptcpTimeout int `json:"mptcpTimeout,omitempty"` + Nagle string `json:"nagle,omitempty"` + Name string `json:"name,omitempty"` + TmPartition string `json:"tmPartition,omitempty"` + PktLossIgnoreBurst int `json:"pktLossIgnoreBurst,omitempty"` + PktLossIgnoreRate int `json:"pktLossIgnoreRate,omitempty"` + ProxyBufferHigh int `json:"proxyBufferHigh,omitempty"` + ProxyBufferLow int `json:"proxyBufferLow,omitempty"` + ProxyMss string `json:"proxyMss,omitempty"` + ProxyOptions string `json:"proxyOptions,omitempty"` + RatePace string `json:"ratePace,omitempty"` + RatePaceMaxRate int `json:"ratePaceMaxRate,omitempty"` + ReceiveWindowSize int `json:"receiveWindowSize,omitempty"` + ResetOnTimeout string `json:"resetOnTimeout,omitempty"` + RexmtThresh int `json:"rexmtThresh,omitempty"` + SelectiveAcks string `json:"selectiveAcks,omitempty"` + SelectiveNack string `json:"selectiveNack,omitempty"` + SendBufferSize int `json:"sendBufferSize,omitempty"` + SlowStart string `json:"slowStart,omitempty"` + SynCookieEnable string `json:"synCookieEnable,omitempty"` + SynCookieWhitelist string `json:"synCookieWhitelist,omitempty"` + SynMaxRetrans int `json:"synMaxRetrans,omitempty"` + SynRtoBase int `json:"synRtoBase,omitempty"` + TailLossProbe string `json:"tailLossProbe,omitempty"` + TcpOptions string `json:"tcpOptions,omitempty"` + TimeWaitRecycle string `json:"timeWaitRecycle,omitempty"` + TimeWaitTimeout string `json:"timeWaitTimeout,omitempty"` + Timestamps string `json:"timestamps,omitempty"` + VerifiedAccept string `json:"verifiedAccept,omitempty"` +} + +// UdpProfiles contains a list of every tcp profile on the BIG-IP system. +type UdpProfiles struct { + UdpProfiles []UdpProfile `json:"items"` +} + +type UdpProfile struct { + AllowNoPayload string `json:"allowNoPayload,omitempty"` + AppService string `json:"appService,omitempty"` + BufferMaxBytes int `json:"bufferMaxBytes,omitempty"` + BufferMaxPackets int `json:"bufferMaxPackets,omitempty"` + DatagramLoadBalancing string `json:"datagramLoadBalancing,omitempty"` + DefaultsFrom string `json:"defaultsFrom,omitempty"` + Description string `json:"description,omitempty"` + IdleTimeout string `json:"idleTimeout,omitempty"` + IpDfMode string `json:"ipDfMode,omitempty"` + IpTosToClient string `json:"ipTosToClient,omitempty"` + IpTtlMode string `json:"ipTtlMode,omitempty"` + IpTtlV4 int `json:"ipTtlV4,omitempty"` + IpTtlV6 int `json:"ipTtlV6,omitempty"` + LinkQosToClient string `json:"linkQosToClient,omitempty"` + Name string `json:"name,omitempty"` + NoChecksum string `json:"noChecksum,omitempty"` + TmPartition string `json:"tmPartition,omitempty"` + ProxyMss string `json:"proxyMss,omitempty"` +} + +type HttpProfiles struct { + HttpProfiles []HttpProfile `json:"items"` +} + +type HttpProfile struct { + AcceptXff string `json:"acceptXff,omitempty"` + AppService string `json:"appService,omitempty"` + BasicAuthRealm string `json:"basicAuthRealm,omitempty"` + DefaultsFrom string `json:"defaultsFrom,omitempty"` + Description string `json:"description,omitempty"` + EncryptCookieSecret string `json:"encryptCookieSecret,omitempty"` + EncryptCookies string `json:"encryptCookies,omitempty"` + FallbackHost string `json:"fallbackHost,omitempty"` + FallbackStatusCodes string `json:"fallbackStatusCodes,omitempty"` + HeaderErase string `json:"headerErase,omitempty"` + HeaderInsert string `json:"headerInsert,omitempty"` + InsertXforwardedFor string `json:"insertXforwardedFor,omitempty"` + LwsSeparator string `json:"lwsSeparator,omitempty"` + LwsWidth int `json:"lwsWidth,omitempty"` + Name string `json:"name,omitempty"` + OneconnectTransformations string `json:"oneconnectTransformations,omitempty"` + TmPartition string `json:"tmPartition,omitempty"` + ProxyType string `json:"proxyType,omitempty"` + RedirectRewrite string `json:"redirectRewrite,omitempty"` + RequestChunking string `json:"requestChunking,omitempty"` + ResponseChunking string `json:"responseChunking,omitempty"` + ResponseHeadersPermitted string `json:"responseHeadersPermitted,omitempty"` + ServerAgentName string `json:"serverAgentName,omitempty"` + ViaHostName string `json:"viaHostName,omitempty"` + ViaRequest string `json:"viaRequest,omitempty"` + ViaResponse string `json:"viaResponse,omitempty"` + XffAlternativeNames string `json:"xffAlternativeNames,omitempty"` +} + +type OneconnectProfiles struct { + OneconnectProfiles []OneconnectProfile `json:"items"` +} + +type OneconnectProfile struct { + AppService string `json:"appService,omitempty"` + DefaultsFrom string `json:"defaultsFrom,omitempty"` + Description string `json:"description,omitempty"` + IdleTimeoutOverride string `json:"idleTimeoutOverride,omitempty"` + LimitType string `json:"limitType,omitempty"` + MaxAge int `json:"maxAge,omitempty"` + MaxReuse int `json:"maxReuse,omitempty"` + MaxSize int `json:"maxSize,omitempty"` + Name string `json:"name,omitempty"` + TmPartition string `json:"tmPartition,omitempty"` + SharePools string `json:"sharePools,omitempty"` + SourceMask string `json:"sourceMask,omitempty"` +} + +type HttpCompressionProfiles struct { + HttpCompressionProfiles []HttpCompressionProfile `json:"items"` +} + +type HttpCompressionProfile struct { + AllowHttp_10 string `json:"allowHttp_10,omitempty"` + AppService string `json:"appService,omitempty"` + BrowserWorkarounds string `json:"browserWorkarounds,omitempty"` + BufferSize int `json:"bufferSize,omitempty"` + ContentTypeExclude []string `json:"contentTypeExclude,omitempty"` + ContentTypeInclude []string `json:"contentTypeInclude,omitempty"` + CpuSaver string `json:"cpuSaver,omitempty"` + CpuSaverHigh int `json:"cpuSaverHigh,omitempty"` + CpuSaverLow int `json:"cpuSaverLow,omitempty"` + DefaultsFrom string `json:"defaultsFrom,omitempty"` + Description string `json:"description,omitempty"` + GzipLevel int `json:"gzipLevel,omitempty"` + GzipMemoryLevel int `json:"gzipMemoryLevel,omitempty"` + GzipWindowSize int `json:"gzipWindowSize,omitempty"` + KeepAcceptEncoding string `json:"keepAcceptEncoding,omitempty"` + MethodPrefer string `json:"methodPrefer,omitempty"` + MinSize int `json:"minSize,omitempty"` + Name string `json:"name,omitempty"` + TmPartition string `json:"tmPartition,omitempty"` + Selective string `json:"selective,omitempty"` + UriExclude []string `json:"uriExclude,omitempty"` + UriInclude []string `json:"uriInclude,omitempty"` + VaryHeader string `json:"varyHeader,omitempty"` +} + // Nodes contains a list of every node on the BIG-IP system. type Nodes struct { Nodes []Node `json:"items"` @@ -338,6 +537,7 @@ type VirtualServer struct { CMPEnabled string `json:"cmpEnabled,omitempty"` ConnectionLimit int `json:"connectionLimit,omitempty"` Destination string `json:"destination,omitempty"` + Description string `json:"description,omitempty"` Enabled bool `json:"enabled,omitempty"` GTMScore int `json:"gtmScore,omitempty"` IPProtocol string `json:"ipProtocol,omitempty"` @@ -766,12 +966,16 @@ type Monitor struct { FullPath string Generation int ParentMonitor string + Database string Description string Destination string Interval int IPDSCP int ManualResume bool + MonitorType string Password string + ReceiveColumn string + ReceiveRow string ReceiveString string ReceiveDisable string Reverse bool @@ -784,17 +988,21 @@ type Monitor struct { } type monitorDTO struct { - Name string `json:"name,omitempty"` - Partition string `json:"partition,omitempty"` - FullPath string `json:"fullPath,omitempty"` - Generation int `json:"generation,omitempty"` - ParentMonitor string `json:"defaultsFrom,omitempty"` - Description string `json:"description,omitempty"` - Destination string `json:"destination,omitempty"` - Interval int `json:"interval,omitempty"` - IPDSCP int `json:"ipDscp,omitempty"` - ManualResume string `json:"manualResume,omitempty" bool:"enabled"` + Name string `json:"name,omitempty"` + Partition string `json:"partition,omitempty"` + FullPath string `json:"fullPath,omitempty"` + Generation int `json:"generation,omitempty"` + ParentMonitor string `json:"defaultsFrom,omitempty"` + Database string `json:"database,omitempty"` + Description string `json:"description,omitempty"` + Destination string `json:"destination,omitempty"` + Interval int `json:"interval,omitempty"` + IPDSCP int `json:"ipDscp,omitempty"` + ManualResume string `json:"manualResume,omitempty" bool:"enabled"` + // MonitorType string `json:"monitorType,omitempty"` Password string `json:"password,omitempty"` + ReceiveColumn string `json:"recvColumn,omitempty"` + ReceiveRow string `json:"recvRow,omitempty"` ReceiveString string `json:"recv,omitempty"` ReceiveDisable string `json:"recvDisable,omitempty"` Reverse string `json:"reverse,omitempty" bool:"enabled"` @@ -1267,6 +1475,7 @@ const ( uriHttp2 = "http2" uriSnat = "snat" uriSnatpool = "snatpool" + uriUdp = "udp" ) var cidr = map[string]string{ @@ -1459,6 +1668,256 @@ func (b *BigIP) ModifyClientSSLProfile(name string, config *ClientSSLProfile) er return b.put(config, uriLtm, uriProfile, uriClientSSL, name) } +// TcpProfiles returns a list of Tcp profiles +func (b *BigIP) TcpProfiles() (*TcpProfiles, error) { + var tcpProfiles TcpProfiles + err, _ := b.getForEntity(&tcpProfiles, uriLtm, uriProfile, uriTcp) + if err != nil { + return nil, err + } + + return &tcpProfiles, nil +} + +func (b *BigIP) GetTcpProfile(name string) (*TcpProfile, error) { + var tcpProfile TcpProfile + err, ok := b.getForEntity(&tcpProfile, uriLtm, uriProfile, uriTcp, name) + if err != nil { + return nil, err + } + + if !ok { + return nil, nil + } + + return &tcpProfile, nil +} + +// CreateTcpProfile creates a new tcp profile on the BIG-IP system. +func (b *BigIP) CreateTcpProfile(name string, parent string) error { + config := &TcpProfile{ + Name: name, + DefaultsFrom: parent, + } + + return b.post(config, uriLtm, uriProfile, uriTcp) +} + +func (b *BigIP) AddTcpProfile(config *TcpProfile) error { + return b.post(config, uriLtm, uriProfile, uriTcp) +} + +// DeleteTcpProfile removes a tcp profile. +func (b *BigIP) DeleteTcpProfile(name string) error { + return b.delete(uriLtm, uriProfile, uriTcp, name) +} + +// ModifyTcpProfile allows you to change any attribute of a tcp profile. +// Fields that can be modified are referenced in the TcpProfile struct. +func (b *BigIP) ModifyTcpProfile(name string, config *TcpProfile) error { + return b.put(config, uriLtm, uriProfile, uriTcp, name) +} + +// UdpProfiles returns a list of Udp profiles +func (b *BigIP) UdpProfiles() (*UdpProfiles, error) { + var udpProfiles UdpProfiles + err, _ := b.getForEntity(&udpProfiles, uriLtm, uriProfile, uriUdp) + if err != nil { + return nil, err + } + + return &udpProfiles, nil +} + +func (b *BigIP) GetUdpProfile(name string) (*UdpProfile, error) { + var udpProfile UdpProfile + err, ok := b.getForEntity(&udpProfile, uriLtm, uriProfile, uriUdp, name) + if err != nil { + return nil, err + } + + if !ok { + return nil, nil + } + + return &udpProfile, nil +} + +// CreateUdpProfile creates a new udp profile on the BIG-IP system. +func (b *BigIP) CreateUdpProfile(name string, parent string) error { + config := &UdpProfile{ + Name: name, + DefaultsFrom: parent, + } + + return b.post(config, uriLtm, uriProfile, uriUdp) +} + +func (b *BigIP) AddUdpProfile(config *UdpProfile) error { + return b.post(config, uriLtm, uriProfile, uriUdp) +} + +// DeleteUdpProfile removes a udp profile. +func (b *BigIP) DeleteUdpProfile(name string) error { + return b.delete(uriLtm, uriProfile, uriUdp, name) +} + +// ModifyUdpProfile allows you to change any attribute of a udp profile. +// Fields that can be modified are referenced in the UdpProfile struct. +func (b *BigIP) ModifyUdpProfile(name string, config *UdpProfile) error { + return b.put(config, uriLtm, uriProfile, uriUdp, name) +} + +// HttpProfiles returns a list of HTTP profiles +func (b *BigIP) HttpProfiles() (*HttpProfiles, error) { + var httpProfiles HttpProfiles + err, _ := b.getForEntity(&httpProfiles, uriLtm, uriProfile, uriHttp) + if err != nil { + return nil, err + } + + return &httpProfiles, nil +} + +func (b *BigIP) GetHttpProfile(name string) (*HttpProfile, error) { + var httpProfile HttpProfile + err, ok := b.getForEntity(&httpProfile, uriLtm, uriProfile, uriHttp, name) + if err != nil { + return nil, err + } + + if !ok { + return nil, nil + } + + return &httpProfile, nil +} + +// CreateHttpProfile creates a new http profile on the BIG-IP system. +func (b *BigIP) CreateHttpProfile(name string, parent string) error { + config := &HttpProfile{ + Name: name, + DefaultsFrom: parent, + } + + return b.post(config, uriLtm, uriProfile, uriHttp) +} + +func (b *BigIP) AddHttpProfile(config *HttpProfile) error { + return b.post(config, uriLtm, uriProfile, uriHttp) +} + +// DeleteHttpProfile removes a http profile. +func (b *BigIP) DeleteHttpProfile(name string) error { + return b.delete(uriLtm, uriProfile, uriHttp, name) +} + +// ModifyHttpProfile allows you to change any attribute of a http profile. +// Fields that can be modified are referenced in the HttpProfile struct. +func (b *BigIP) ModifyHttpProfile(name string, config *HttpProfile) error { + return b.put(config, uriLtm, uriProfile, uriHttp, name) +} + +// OneconnectProfiles returns a list of HTTP profiles +func (b *BigIP) OneconnectProfiles() (*OneconnectProfiles, error) { + var oneconnectProfiles OneconnectProfiles + err, _ := b.getForEntity(&oneconnectProfiles, uriLtm, uriProfile, uriOneconnect) + if err != nil { + return nil, err + } + + return &oneconnectProfiles, nil +} + +func (b *BigIP) GetOneconnectProfile(name string) (*OneconnectProfile, error) { + var oneconnectProfile OneconnectProfile + err, ok := b.getForEntity(&oneconnectProfile, uriLtm, uriProfile, uriOneconnect, name) + if err != nil { + return nil, err + } + + if !ok { + return nil, nil + } + + return &oneconnectProfile, nil +} + +// CreateOneconnectProfile creates a new http profile on the BIG-IP system. +func (b *BigIP) CreateOneconnectProfile(name string, parent string) error { + config := &OneconnectProfile{ + Name: name, + DefaultsFrom: parent, + } + + return b.post(config, uriLtm, uriProfile, uriOneconnect) +} + +func (b *BigIP) AddOneconnectProfile(config *OneconnectProfile) error { + return b.post(config, uriLtm, uriProfile, uriOneconnect) +} + +// DeleteOneconnectProfile removes a http profile. +func (b *BigIP) DeleteOneconnectProfile(name string) error { + return b.delete(uriLtm, uriProfile, uriOneconnect, name) +} + +// ModifyOneconnectProfile allows you to change any attribute of a http profile. +// Fields that can be modified are referenced in the OneconnectProfile struct. +func (b *BigIP) ModifyOneconnectProfile(name string, config *OneconnectProfile) error { + return b.put(config, uriLtm, uriProfile, uriOneconnect, name) +} + +// HttpCompressionProfiles returns a list of HTTP profiles +func (b *BigIP) HttpCompressionProfiles() (*HttpCompressionProfiles, error) { + var httpCompressionProfiles HttpCompressionProfiles + err, _ := b.getForEntity(&httpCompressionProfiles, uriLtm, uriProfile, uriHttpcompress) + if err != nil { + return nil, err + } + + return &httpCompressionProfiles, nil +} + +func (b *BigIP) GetHttpCompressionProfile(name string) (*HttpCompressionProfile, error) { + var httpCompressionProfile HttpCompressionProfile + err, ok := b.getForEntity(&httpCompressionProfile, uriLtm, uriProfile, uriHttpcompress, name) + if err != nil { + return nil, err + } + + if !ok { + return nil, nil + } + + return &httpCompressionProfile, nil +} + +// CreateHttpCompressionProfile creates a new http profile on the BIG-IP system. +func (b *BigIP) CreateHttpCompressionProfile(name string, parent string) error { + config := &HttpCompressionProfile{ + Name: name, + DefaultsFrom: parent, + } + + return b.post(config, uriLtm, uriProfile, uriHttpcompress) +} + +func (b *BigIP) AddHttpCompressionProfile(config *HttpCompressionProfile) error { + return b.post(config, uriLtm, uriProfile, uriHttpcompress) +} + +// DeleteHttpCompressionProfile removes a http profile. +func (b *BigIP) DeleteHttpCompressionProfile(name string) error { + return b.delete(uriLtm, uriProfile, uriHttpcompress, name) +} + +// ModifyHttpCompressionProfile allows you to change any attribute of a http profile. +// Fields that can be modified are referenced in the HttpCompressionProfile struct. +func (b *BigIP) ModifyHttpCompressionProfile(name string, config *HttpCompressionProfile) error { + return b.put(config, uriLtm, uriProfile, uriHttpcompress, name) +} + // Nodes returns a list of nodes. func (b *BigIP) Nodes() (*Nodes, error) { var nodes Nodes @@ -1536,6 +1995,31 @@ func (b *BigIP) InternalDataGroups() (*DataGroups, error) { return &dataGroups, nil } +func (b *BigIP) GetInternalDataGroup(name string) (*DataGroup, error) { + var dataGroup DataGroup + err, ok := b.getForEntity(&dataGroup, uriLtm, uriDatagroup, uriInternal, name) + + if err != nil { + return nil, err + } + + if !ok { + return nil, nil + } + + return &dataGroup, nil +} + +// Create an internal data group; dataype must bee one of "ip", "string", or "integer" +func (b *BigIP) CreateInternalDataGroup(name string, datatype string) error { + config := &DataGroup{ + Name: name, + Type: datatype, + } + + return b.post(config, uriLtm, uriDatagroup, uriInternal) +} + func (b *BigIP) AddInternalDataGroup(config *DataGroup) error { return b.post(config, uriLtm, uriDatagroup, uriInternal) } @@ -1843,10 +2327,20 @@ func (b *BigIP) DeleteVirtualAddress(vaddr string) error { return b.delete(uriLtm, uriVirtualAddress, vaddr) } -// Monitors returns a list of all HTTP, HTTPS, Gateway ICMP, ICMP, and TCP monitors. +// Monitors returns a list of all HTTP, HTTPS, Gateway ICMP, ICMP, and Tcp monitors. func (b *BigIP) Monitors() ([]Monitor, error) { var monitors []Monitor - monitorUris := []string{"http", "https", "icmp", "gateway-icmp", "tcp"} + monitorUris := []string{ + "gateway-icmp", + "http", + "https", + "icmp", + "inband", + "mysql", + "postgresql", + "tcp", + "udp", + } for _, name := range monitorUris { var m Monitors @@ -1855,6 +2349,7 @@ func (b *BigIP) Monitors() ([]Monitor, error) { return nil, err } for _, monitor := range m.Monitors { + monitor.MonitorType = name monitors = append(monitors, monitor) } } @@ -1862,9 +2357,9 @@ func (b *BigIP) Monitors() ([]Monitor, error) { return monitors, nil } -// CreateMonitor adds a new monitor to the BIG-IP system. must be one of "http", "https", -// "icmp", "gateway icmp", or "tcp". -func (b *BigIP) CreateMonitor(name, parent string, interval, timeout int, send, receive string) error { +// CreateMonitor adds a new monitor to the BIG-IP system. must be one of "http", "https", +// "icmp", "gateway icmp", "inband", "postgresql", "mysql", "udp" or "tcp". +func (b *BigIP) CreateMonitor(name, parent string, interval, timeout int, send, receive, monitorType string) error { config := &Monitor{ Name: name, ParentMonitor: parent, @@ -1874,16 +2369,16 @@ func (b *BigIP) CreateMonitor(name, parent string, interval, timeout int, send, ReceiveString: receive, } - return b.AddMonitor(config) + return b.AddMonitor(config, monitorType) } // Create a monitor by supplying a config -func (b *BigIP) AddMonitor(config *Monitor) error { +func (b *BigIP) AddMonitor(config *Monitor, monitorType string) error { if strings.Contains(config.ParentMonitor, "gateway") { config.ParentMonitor = "gateway_icmp" } - return b.post(config, uriLtm, uriMonitor, config.ParentMonitor) + return b.post(config, uriLtm, uriMonitor, monitorType) } // GetVirtualServer retrieves a monitor by name. Returns nil if the monitor does not exist @@ -1906,15 +2401,15 @@ func (b *BigIP) DeleteMonitor(name, parent string) error { return b.delete(uriLtm, uriMonitor, parent, name) } -// ModifyMonitor allows you to change any attribute of a monitor. must be -// one of "http", "https", "icmp", "gateway icmp", or "tcp". Fields that -// can be modified are referenced in the Monitor struct. -func (b *BigIP) ModifyMonitor(name, parent string, config *Monitor) error { +// ModifyMonitor allows you to change any attribute of a monitor. must +// be one of "http", "https", "icmp", "inband", "gateway icmp", "postgresql", "mysql", "udp" or "tcp". +// Fields that can be modified are referenced in the Monitor struct. +func (b *BigIP) ModifyMonitor(name, monitorType string, config *Monitor) error { if strings.Contains(config.ParentMonitor, "gateway") { config.ParentMonitor = "gateway_icmp" } - return b.put(config, uriLtm, uriMonitor, parent, name) + return b.put(config, uriLtm, uriMonitor, monitorType, name) } // AddMonitorToPool assigns the monitor, to the given . diff --git a/ltm_test.go b/ltm_test.go index b70ed75..208ad9f 100644 --- a/ltm_test.go +++ b/ltm_test.go @@ -792,7 +792,7 @@ func (s *LTMTestSuite) TestCreateMonitor() { ReceiveString: "200 OK", } - s.Client.CreateMonitor(config.Name, config.ParentMonitor, config.Interval, config.Timeout, config.SendString, config.ReceiveString) + s.Client.CreateMonitor(config.Name, config.ParentMonitor, config.Interval, config.Timeout, config.SendString, config.ReceiveString, "http") assert.Equal(s.T(), "POST", s.LastRequest.Method) assert.Equal(s.T(), fmt.Sprintf("/mgmt/tm/%s/%s/%s", uriLtm, uriMonitor, config.ParentMonitor), s.LastRequest.URL.Path) @@ -809,7 +809,7 @@ func (s *LTMTestSuite) TestCreateMonitorSpecialCharacters() { ReceiveString: "Response &<>", } - s.Client.CreateMonitor(config.Name, config.ParentMonitor, config.Interval, config.Timeout, config.SendString, config.ReceiveString) + s.Client.CreateMonitor(config.Name, config.ParentMonitor, config.Interval, config.Timeout, config.SendString, config.ReceiveString, "http") assert.Equal(s.T(), "POST", s.LastRequest.Method) assert.Equal(s.T(), fmt.Sprintf("/mgmt/tm/%s/%s/%s", uriLtm, uriMonitor, config.ParentMonitor), s.LastRequest.URL.Path) @@ -828,7 +828,7 @@ func (s *LTMTestSuite) TestAddMonitor() { Password: "monitoring", } - s.Client.AddMonitor(config) + s.Client.AddMonitor(config, "http") assert.Equal(s.T(), "POST", s.LastRequest.Method) assert.Equal(s.T(), fmt.Sprintf("/mgmt/tm/%s/%s/%s", uriLtm, uriMonitor, config.ParentMonitor), s.LastRequest.URL.Path)