Merge pull request #146 from yunify/lb-cluster

CreateLoadbalancer support cluster mode
This commit is contained in:
roger 2020-01-19 15:42:04 +08:00 committed by GitHub
commit 94e2b0ab3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 51 additions and 6 deletions

View File

@ -347,20 +347,45 @@ func (s *LoadBalancerService) CreateLoadBalancer(i *CreateLoadBalancerInput) (*C
}
type CreateLoadBalancerInput struct {
// ClusterMode's available values: 0, 1
ClusterMode *int `json:"cluster_mode" name:"cluster_mode" default:"0" location:"params"`
EIPs []*string `json:"eips" name:"eips" location:"params"`
HTTPHeaderSize *int `json:"http_header_size" name:"http_header_size" location:"params"`
LoadBalancerName *string `json:"loadbalancer_name" name:"loadbalancer_name" location:"params"`
// LoadBalancerType's available values: 0, 1, 2, 3, 4, 5
LoadBalancerType *int `json:"loadbalancer_type" name:"loadbalancer_type" default:"0" location:"params"`
NodeCount *int `json:"node_count" name:"node_count" location:"params"`
PrivateIP *string `json:"private_ip" name:"private_ip" location:"params"`
ProjectID *string `json:"project_id" name:"project_id" location:"params"`
SecurityGroup *string `json:"security_group" name:"security_group" location:"params"`
VxNet *string `json:"vxnet" name:"vxnet" location:"params"`
LoadBalancerType *int `json:"loadbalancer_type" name:"loadbalancer_type" default:"0" location:"params"`
// Mode's available values: 0, 1
Mode *int `json:"mode" name:"mode" default:"0" location:"params"`
NodeCount *int `json:"node_count" name:"node_count" location:"params"`
PrivateIP *string `json:"private_ip" name:"private_ip" location:"params"`
ProjectID *string `json:"project_id" name:"project_id" location:"params"`
SecurityGroup *string `json:"security_group" name:"security_group" location:"params"`
VxNet *string `json:"vxnet" name:"vxnet" location:"params"`
}
func (v *CreateLoadBalancerInput) Validate() error {
if v.ClusterMode != nil {
clusterModeValidValues := []string{"0", "1"}
clusterModeParameterValue := fmt.Sprint(*v.ClusterMode)
clusterModeIsValid := false
for _, value := range clusterModeValidValues {
if value == clusterModeParameterValue {
clusterModeIsValid = true
}
}
if !clusterModeIsValid {
return errors.ParameterValueNotAllowedError{
ParameterName: "ClusterMode",
ParameterValue: clusterModeParameterValue,
AllowedValues: clusterModeValidValues,
}
}
}
if v.LoadBalancerType != nil {
loadBalancerTypeValidValues := []string{"0", "1", "2", "3", "4", "5"}
loadBalancerTypeParameterValue := fmt.Sprint(*v.LoadBalancerType)
@ -381,6 +406,26 @@ func (v *CreateLoadBalancerInput) Validate() error {
}
}
if v.Mode != nil {
modeValidValues := []string{"0", "1"}
modeParameterValue := fmt.Sprint(*v.Mode)
modeIsValid := false
for _, value := range modeValidValues {
if value == modeParameterValue {
modeIsValid = true
}
}
if !modeIsValid {
return errors.ParameterValueNotAllowedError{
ParameterName: "Mode",
ParameterValue: modeParameterValue,
AllowedValues: modeValidValues,
}
}
}
return nil
}