Skip to content

Commit

Permalink
Merge pull request #54 from HewlettPackard/PROFILE-POOL
Browse files Browse the repository at this point in the history
updated models for profile and pool
  • Loading branch information
gandharvas authored Aug 5, 2022
2 parents 629a8da + b0e2593 commit 5e7b03d
Show file tree
Hide file tree
Showing 3 changed files with 161 additions and 79 deletions.
17 changes: 17 additions & 0 deletions pkg/client/load_balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,3 +526,20 @@ func (lb *LoadBalancerAPIService) GetSpecificLBVirtualServer(

return LBVSResp, err
}

func (lb *LoadBalancerAPIService) GetLBVirtualServerSSLCerts(
ctx context.Context,
) (models.GetSSLCertificates, error) {
LBCertResp := models.GetSSLCertificates{}
LBCertInput := &api{
method: "GET",
path: consts.LBSSLCertificatesPath,
client: lb.Client,
jsonParser: func(body []byte) error {
return json.Unmarshal(body, &LBCertResp)
},
}
err := LBCertInput.do(ctx, nil, nil)

return LBCertResp, err
}
3 changes: 2 additions & 1 deletion pkg/common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ const (
RouterBgpNeighborPath = "bgp-neighbors"
NetworkEdgeClusterPath = "edge-clusters"
// Whoami Path
WhoamiPath = "whoami"
WhoamiPath = "whoami"
LBSSLCertificatesPath = "certificates"

// headers
ContentType = "application/json"
Expand Down
220 changes: 142 additions & 78 deletions pkg/models/load_balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,15 @@ type CreateLBMonitorReq struct {
FallCount int `json:"fallCount"`
DataLength int `json:"dataLength"`
MaxFail int `json:"maxRetry"`
TfHttpConfig *CreateHttpMonitorConfig `json:"-" tf:"http_monitor,sub"`
TfHttpsConfig *CreateHttpsMonitorConfig `json:"-" tf:"https_monitor,sub"`
TfHTTPConfig *CreateHTTPMonitorConfig `json:"-" tf:"http_monitor,sub"`
TfHTTPSConfig *CreateHTTPSMonitorConfig `json:"-" tf:"https_monitor,sub"`
TfIcmpConfig *CreateIcmpMonitorConfig `json:"-" tf:"icmp_monitor,sub"`
TfPassiveConfig *CreatePassiveMonitorConfig `json:"-" tf:"passive_monitor,sub"`
TfTcpConfig *CreateTcpMonitorConfig `json:"-" tf:"tcp_monitor,sub"`
TfUdpConfig *CreateUdpMonitorConfig `json:"-" tf:"udp_monitor,sub"`
TfTCPConfig *CreateTCPMonitorConfig `json:"-" tf:"tcp_monitor,sub"`
TfUDPConfig *CreateUDPMonitorConfig `json:"-" tf:"udp_monitor,sub"`
}

type CreateHttpMonitorConfig struct {
type CreateHTTPMonitorConfig struct {
Timeout int `json:"-" tf:"timeout"`
Interval int `json:"-" tf:"interval"`
RequestVersion string `json:"-" tf:"request_version"`
Expand All @@ -183,7 +183,7 @@ type CreateHttpMonitorConfig struct {
FallCount int `json:"-" tf:"fall_count"`
}

type CreateHttpsMonitorConfig struct {
type CreateHTTPSMonitorConfig struct {
Timeout int `json:"-" tf:"timeout"`
Interval int `json:"-" tf:"interval"`
RequestVersion string `json:"-" tf:"request_version"`
Expand Down Expand Up @@ -211,7 +211,7 @@ type CreatePassiveMonitorConfig struct {
MaxFail int `json:"-" tf:"max_fail"`
}

type CreateTcpMonitorConfig struct {
type CreateTCPMonitorConfig struct {
FallCount int `json:"-" tf:"fall_count"`
Interval int `json:"-" tf:"interval"`
AliasPort int `json:"-" tf:"monitor_port"`
Expand All @@ -221,7 +221,7 @@ type CreateTcpMonitorConfig struct {
ResponseData string `json:"-" tf:"response_data"`
}

type CreateUdpMonitorConfig struct {
type CreateUDPMonitorConfig struct {
FallCount int `json:"-" tf:"fall_count"`
Interval int `json:"-" tf:"interval"`
AliasPort int `json:"-" tf:"monitor_port"`
Expand Down Expand Up @@ -287,16 +287,29 @@ type CreateLBProfileReq struct {
LbID int `json:"-" tf:"lb_id"`
Name string `json:"name" tf:"name"`
Description string `json:"description" tf:"description"`
ServiceType string `json:"serviceType" tf:"service_type"`
TfHttpConfig *CreateHttpProfileConfig `json:"-" tf:"http_profile,sub"`
TfTcpConfig *CreateTcpProfileConfig `json:"-" tf:"tcp_profile,sub"`
TfUdpConfig *CreateUdpProfileConfig `json:"-" tf:"udp_profile,sub"`
ServiceType string `json:"serviceType"`
ProfileType string `json:"" tf:"profile_type"`
TfHTTPConfig *CreateHTTPProfileConfig `json:"-" tf:"http_profile,sub"`
TfTCPConfig *CreateTCPProfileConfig `json:"-" tf:"tcp_profile,sub"`
TfUDPConfig *CreateUDPProfileConfig `json:"-" tf:"udp_profile,sub"`
TfCookieConfig *CreateCookieProfileConfig `json:"-" tf:"cookie_profile,sub"`
TfGenericConfig *CreateGenericProfileConfig `json:"-" tf:"generic_profile,sub"`
TfSourceConfig *CreateSourceProfileConfig `json:"-" tf:"sourceip_profile,sub"`
TfClientConfig *CreateClientProfileConfig `json:"-" tf:"client_profile,sub"`
TfServerConfig *CreateServerProfileConfig `json:"-" tf:"server_profile,sub"`
ProfileConfig LBProfile `json:"config" tf:"config,sub"`
ProfileConfig *LBProfile `json:"config" tf:"config,sub"`
}

type CreateHTTPProfileConfig struct {
ServiceType string `json:"-" tf:"service_type"`
HTTPIdleTimeout int `json:"-" tf:"http_idle_timeout"`
HTTPSRedirect string `json:"-" tf:"redirection"`
RequestHeaderSize int `json:"-" tf:"request_header_size"`
ResponseHeaderSize int `json:"-" tf:"response_header_size"`
NtlmAuthentication bool `json:"-" tf:"ntlm_authentication"`
RequestBodySize string `json:"-" tf:"request_body_size"`
ResponseTimeout int `json:"-" tf:"response_timeout"`
XForwardedFor string `json:"-" tf:"x_forwarded_for"`
}

type LBProfile struct {
Expand All @@ -308,7 +321,7 @@ type LBProfile struct {
HaFlowMirroring bool `json:"haFlowMirroring"`
RequestHeaderSize int `json:"requestHeaderSize"`
ResponseHeaderSize int `json:"responseHeaderSize"`
HTTPsRedirect string `json:"httpsRedirect"`
HTTPSRedirect string `json:"httpsRedirect"`
XForwardedFor string `json:"xForwardedFor"`
RequestBodySize string `json:"requestBodySize"`
ResponseTimeout int `json:"responseTimeout"`
Expand All @@ -335,35 +348,36 @@ type LBProfile struct {
}

type CreateClientProfileConfig struct {
ServiceType string `json:"-" tf:"service_type"`
SSLSuite string `json:"-" tf:"ssl_suite"`
SessionCache bool `json:"-" tf:"session_cache"`
ProfileType string `json:"-" tf:"profile_type"`
SessionCacheEntryTimeout int `json:"-" tf:"session_cache_entry_timeout"`
PreferServerCipher bool `json:"-" tf:"prefer_server_cipher"`
}

type CreateServerProfileConfig struct {
ServiceType string `json:"-" tf:"service_type"`
SSLSuite string `json:"-" tf:"ssl_suite"`
SessionCache bool `json:"-" tf:"session_cache"`
ProfileType string `json:"-" tf:"profile_type"`
}

type CreateSourceProfileConfig struct {
ServiceType string `json:"-" tf:"service_type"`
HaPersistenceMirroring bool `json:"-" tf:"ha_persistence_mirroring"`
PersistenceEntryTimeout int `json:"-" tf:"persistence_entry_timeout"`
PurgeEntries bool `json:"-" tf:"purge_entries_when_full"`
ProfileType string `json:"-" tf:"profile_type"`
SharePersistence bool `json:"-" tf:"share_persistence"`
}

type CreateGenericProfileConfig struct {
ProfileType string `json:"-" tf:"profile_type"`
ServiceType string `json:"-" tf:"service_type"`
HaPersistenceMirroring bool `json:"-" tf:"ha_persistence_mirroring"`
PersistenceEntryTimeout int `json:"-" tf:"persistence_entry_timeout"`
SharePersistence bool `json:"-" tf:"share_persistence"`
}

type CreateCookieProfileConfig struct {
ServiceType string `json:"-" tf:"service_type"`
CookieName string `json:"-" tf:"cookie_name"`
CookieFallback bool `json:"-" tf:"cookie_fallback"`
CookieGarbling bool `json:"-" tf:"cookie_garbling"`
Expand All @@ -373,40 +387,28 @@ type CreateCookieProfileConfig struct {
CookiePath string `json:"-" tf:"cookie_path"`
MaxIdleTime int `json:"-" tf:"max_idle_time"`
MaxCookieAge int `json:"-" tf:"max_cookie_age"`
ProfileType string `json:"-" tf:"profile_type"`
SharePersistence bool `json:"-" tf:"share_persistence"`
MaxCookieLife int `json:"-" tf:"max_cookie_life"`
}

type CreateHttpProfileConfig struct {
HTTPIdleTimeout int `json:"-" tf:"http_idle_timeout"`
HTTPsRedirect string `json:"-" tf:"redirection"`
ProfileType string `json:"-" tf:"profile_type"`
RequestHeaderSize int `json:"-" tf:"request_header_size"`
ResponseHeaderSize int `json:"-" tf:"response_header_size"`
NtlmAuthentication bool `json:"-" tf:"ntlm_authentication"`
RequestBodySize string `json:"-" tf:"request_body_size"`
ResponseTimeout int `json:"-" tf:"response_timeout"`
XForwardedFor string `json:"-" tf:"x_forwarded_for"`
}

type CreateTcpProfileConfig struct {
type CreateTCPProfileConfig struct {
ServiceType string `json:"-" tf:"service_type"`
ConnectionCloseTimeout int `json:"-" tf:"connection_close_timeout"`
FastTCPIdleTimeout int `json:"-" tf:"fast_tcp_idle_timeout"`
HaFlowMirroring bool `json:"-" tf:"ha_flow_mirroring"`
ProfileType string `json:"-" tf:"profile_type"`
}

type CreateUdpProfileConfig struct {
type CreateUDPProfileConfig struct {
ServiceType string `json:"-" tf:"service_type"`
FastUDPIdleTimeout int `json:"-" tf:"fast_udp_idle_timeout"`
ProfileType string `json:"-" tf:"profile_type"`
HaFlowMirroring bool `json:"-" tf:"ha_flow_mirroring"`
}

type Tags struct {
Tag string `json:"tag" tf:"tag"`
Scope string `json:"scope" tf:"scope"`
}

type PoolTags struct {
Tag string `json:"name" tf:"tag"`
Scope string `json:"value" tf:"scope"`
Expand Down Expand Up @@ -459,22 +461,21 @@ type GetLBProfile struct {
}

type GetLBProfilesResp struct {
ID int `json:"id" tf:"id,computed"`
LbID int `json:"-" tf:"lb_id,computed"`
Name string `json:"name"`
Category string `json:"category"`
ServiceType string `json:"serviceType"`
ServiceTypeDisplay string `json:"serviceTypeDisplay"`
Visibility string `json:"visibility"`
Description string `json:"description"`
InternalID string `json:"internalId"`
ExternalID string `json:"externalId"`
Enabled bool `json:"enabled"`
InsertXforwardedFor bool `json:"insertXforwardedFor"`
Editable bool `json:"editable"`
DateCreated string `json:"dateCreated"`
LastUpdated string `json:"lastUpdated"`
LBProfileConfig LBprofileConfig `json:"config"`
ID int `json:"id" tf:"id,computed"`
LbID int `json:"-" tf:"lb_id,computed"`
Name string `json:"name"`
Category string `json:"category"`
ServiceType string `json:"serviceType"`
ServiceTypeDisplay string `json:"serviceTypeDisplay"`
Visibility string `json:"visibility"`
Description string `json:"description"`
InternalID string `json:"internalId"`
ExternalID string `json:"externalId"`
Enabled bool `json:"enabled"`
InsertXforwardedFor bool `json:"insertXforwardedFor"`
Editable bool `json:"editable"`
DateCreated string `json:"dateCreated"`
LastUpdated string `json:"lastUpdated"`
}

type LBprofileConfig struct {
Expand Down Expand Up @@ -591,20 +592,20 @@ type CreateLBPoolReq struct {
}

type PoolConfig struct {
SnatTranslationType string `json:"snatTranslationType" tf:"snat_translation_type"`
PassiveMonitorPath int `json:"passiveMonitorPath" tf:"passive_monitor_path"`
ActiveMonitorPaths int `json:"activeMonitorPaths" tf:"active_monitor_paths"`
TCPMultiplexing bool `json:"tcpMultiplexing" tf:"tcp_multiplexing"`
TCPMultiplexingNumber int `json:"tcpMultiplexingNumber" tf:"tcp_multiplexing_number"`
SnatIPAddress string `json:"snatIpAddress" tf:"snat_ip_address"`
MemberGroup MemberGroup `json:"memberGroup" tf:"member_group"`
SnatTranslationType string `json:"snatTranslationType" tf:"snat_translation_type"`
PassiveMonitorPath int `json:"passiveMonitorPath" tf:"passive_monitor_path"`
ActiveMonitorPaths int `json:"activeMonitorPaths" tf:"active_monitor_paths"`
TCPMultiplexing bool `json:"tcpMultiplexing" tf:"tcp_multiplexing"`
TCPMultiplexingNumber int `json:"tcpMultiplexingNumber" tf:"tcp_multiplexing_number"`
SnatIPAddress string `json:"snatIpAddress" tf:"snat_ip_address"`
MemberGroup *MemberGroup `json:"memberGroup" tf:"member_group,sub"`
}

type MemberGroup struct {
Group string `json:"group" tf:"group"`
MaxIpListSize int `json:"maxIpListSize" tf:"max_ip_list_size"`
Group string `json:"path" tf:"group"`
MaxIPListSize int `json:"MaxIPListSize" tf:"max_ip_list_size"`
IPRevisionFilter string `json:"ipRevisionFilter" tf:"ip_revision_filter"`
Port int `json:"port"`
Port int `json:"port" tf:"port"`
}

// Create LB Pool Resp
Expand Down Expand Up @@ -716,26 +717,67 @@ type CreateLBVirtualServers struct {
}

type CreateLBVirtualServersReq struct {
ID int `json:"id" tf:"id,computed"`
LbID int `json:"-" tf:"lb_id"`
Description string `json:"description" tf:"description"`
VipName string `json:"vipName" tf:"name"`
VipAddress string `json:"vipAddress" tf:"vip_address"`
VipProtocol string `json:"vipProtocol" tf:"type"`
VipPort string `json:"vipPort" tf:"vip_port"`
Pool int `json:"pool" tf:"pool"`
VipHostName string `json:"vipHostName" tf:"vip_host_name"`
SSLServerCert int `json:"sslServerCert" tf:"ssl_server_cert"`
SSLCert int `json:"sslCert" tf:"ssl_client_cert"`
VirtualServerConfig *VirtualServerConfig `json:"config" tf:"config,sub"`
ID int `json:"id" tf:"id,computed"`
LbID int `json:"-" tf:"lb_id"`
Description string `json:"description" tf:"description"`
VipName string `json:"vipName" tf:"name"`
VipAddress string `json:"vipAddress" tf:"vip_address"`
Pool int `json:"pool" tf:"pool"`
VipPort string `json:"vipPort" tf:"vip_port"`
VipHostName string `json:"vipHostname" tf:"vip_host_name"`

VipProtocol string `json:"vipProtocol" tf:"type"`
TCPApplicationProfileConfig *TCPApplicationProfileConfig `json:"-" tf:"tcp_application_profile,sub"`
UDPApplicationProfileConfig *UDPApplicationProfileConfig `json:"-" tf:"udp_application_profile,sub"`
HTTPApplicationProfileConfig *HTTPApplicationProfileConfig `json:"-" tf:"http_application_profile,sub"`

Persistence string `json:"-" tf:"persistence"`
CookiePersistenceProfileConfig *CookiePersistenceProfileConfig `json:"-" tf:"cookie_persistence_profile,sub"`
SourceipPersistenceProfileConfig *SourceipPersistenceProfileConfig `json:"-" tf:"sourceip_persistence_profile,sub"`

SSLServerCert int `json:"sslServerCert" tf:"ssl_server_cert"`
SSLServerConfig *SSLServerConfig `json:"-" tf:"ssl_server_config,sub"`

SSLCert int `json:"sslCert" tf:"ssl_client_cert"`
SSLClientConfig *SSLClientConfig `json:"-" tf:"ssl_client_config,sub"`

VirtualServerConfig VirtualServerConfig `json:"config" tf:"config,sub"`
}

type TCPApplicationProfileConfig struct {
ApplicationProfile int `json:"-" tf:"application_profile"`
}

type UDPApplicationProfileConfig struct {
ApplicationProfile int `json:"-" tf:"application_profile"`
}

type HTTPApplicationProfileConfig struct {
ApplicationProfile int `json:"-" tf:"application_profile"`
}

type CookiePersistenceProfileConfig struct {
PersistenceProfile int `json:"-" tf:"persistence_profile"`
}

type SourceipPersistenceProfileConfig struct {
PersistenceProfile int `json:"-" tf:"persistence_profile"`
}

type SSLClientConfig struct {
SSLClientProfile int `json:"-" tf:"ssl_client_profile"`
}

type SSLServerConfig struct {
SSLServerProfile int `json:"-" tf:"ssl_server_profile"`
}

type VirtualServerConfig struct {
Persistence string `json:"persistence" tf:"persistence"`
PersistenceProfile int `json:"persistenceProfile" tf:"persistence_profile"`
ApplicationProfile int `json:"applicationProfile" tf:"application_profile"`
SSLClientProfile int `json:"sslClientProfile" tf:"ssl_client_profile"`
SSLServerProfile int `json:"sslServerProfile" tf:"ssl_server_profile"`
Persistence string `json:"persistence"`
PersistenceProfile int `json:"persistenceProfile"`
ApplicationProfile int `json:"applicationProfile"`
SSLClientProfile int `json:"sslClientProfile"`
SSLServerProfile int `json:"sslServerProfile"`
}

// CREATE LB Virtual Server Resp
Expand Down Expand Up @@ -861,3 +903,25 @@ type GetSpecificLBVirtualServersResp struct {
SSLCert SSLCert `json:"sslCert"`
SSLServerCert SSLServerCert `json:"sslServerCert"`
}

type GetMemeberGroupForPool struct {
MemeberGroup []MemeberGroups `json:"groups"`
}

type MemeberGroups struct {
ID int `json:"id" tf:"id,computed"`
Name string `json:"name"`
Description interface{} `json:"description"`
InternalID string `json:"internalId"`
ExternalID string `json:"externalId" tf:"external_id,computed"`
}

type GetSSLCertificates struct {
Certificates []Certificates `json:"certificates"`
}

type Certificates struct {
ID int `json:"id" tf:"id,computed"`
Name string `json:"name"`
Description string `json:"description"`
}

0 comments on commit 5e7b03d

Please sign in to comment.