forked from atlassian/go-vtm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpool.go
163 lines (150 loc) · 6.24 KB
/
pool.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
package stingray
import (
"encoding/json"
"net/http"
)
// A Pool is a Stingray pool.
type Pool struct {
jsonResource `json:"-"`
PoolProperties `json:"properties"`
}
type PoolProperties struct {
AutoScaling struct {
AddNodeDelayTime *int `json:"addnode_delaytime,omitempty"`
CloudCredentials *string `json:"cloud_credentials,omitempty"`
Cluster *string `json:"cluster,omitempty"`
DataCenter *string `json:"data_center,omitempty"`
DataStore *string `json:"data_store,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
External *bool `json:"external,omitempty"`
Hysteresis *int `json:"hysteresis,omitempty"`
ImageID *string `json:"imageid,omitempty"`
IPsToUse *string `json:"ips_to_use,omitempty"`
LastNodeIdleTime *int `json:"last_node_idle_time,omitempty"`
MaxNodes *int `json:"max_nodes,omitempty"`
MinNodes *int `json:"min_nodes,omitempty"`
Name *string `json:"name,omitempty"`
Port *int `json:"port,omitempty"`
Refractory *int `json:"refractory,omitempty"`
ResponseTime *int `json:"response_time,omitempty"`
ScaleDownLevel *int `json:"scale_down_level,omitempty"`
ScaleUpLevel *int `json:"scale_up_level,omitempty"`
SecurityGroupIDs *[]string `json:"securitygroupids,omitempty"`
SizeID *string `json:"size_id,omitempty"`
SubnetIDs *[]string `json:"subnetids,omitempty"`
} `json:"auto_scaling"`
Basic struct {
BandwidthClass *string `json:"bandwidth_class,omitempty"`
FailurePool *string `json:"failure_pool,omitempty"`
MaxConnectionAttempts *int `json:"max_connection_attempts,omitempty"`
MaxIdleConnectionsPerNode *int `json:"max_idle_connections_pernode,omitempty"`
MaxTimedOutConnectionAttempts *int `json:"max_timed_out_connection_attempts,omitempty"`
Monitors *[]string `json:"monitors,omitempty"`
NodeCloseWithRST *bool `json:"node_close_with_rst,omitempty"`
NodeConnectionAttempts *int `json:"node_connection_attempts,omitempty"`
NodeDeleteBehavior *string `json:"node_delete_behavior,omitempty"`
NodeDrainToDeleteTimeout *int `json:"node_drain_to_delete_timeout,omitempty"`
NodesTable []Node `json:"nodes_table"`
PassiveMonitoring *bool `json:"passive_monitoring,omitempty"`
PersistenceClass *string `json:"persistence_class,omitempty"`
Note *string `json:"note,omitempty"`
Transparent *bool `json:"transparent,omitempty"`
} `json:"basic"`
Connection struct {
MaxConnectTime *int `json:"max_connect_time,omitempty"`
MaxConnectionsPerNode *int `json:"max_connections_per_node,omitempty"`
MaxQueueSize *int `json:"max_queue_size,omitempty"`
MaxReplyTime *int `json:"max_reply_time,omitempty"`
QueueTimeout *int `json:"queue_timeout,omitempty"`
} `json:"connection"`
DNSAutoscale struct {
Enabled *bool `json:"enabled,omitempty"`
Hostnames *[]string `json:"hostnames,omitempty"`
Port *int `json:"port,omitempty"`
} `json:"dns_autoscale"`
FTP struct {
SupportRFC2428 *bool `json:"support_rfc_2428,omitempty"`
} `json:"ftp"`
HTTP struct {
Keepalive *bool `json:"keepalive,omitempty"`
KeepaliveNonIdempotent *bool `json:"keepalive_non_idempotent,omitempty"`
} `json:"http"`
KerberosProtocolTransition struct {
Principal *string `json:"principal,omitempty"`
Target *string `json:"target,omitempty"`
} `json:"kerberos_protocol_transition"`
LoadBalancing struct {
Algorithm *string `json:"algorithm,omitempty"`
PriorityEnabled *bool `json:"priority_enabled,omitempty"`
PriorityNodes *int `json:"priority_nodes,omitempty"`
} `json:"load_balancing"`
Node struct {
CloseOnDeath *bool `json:"close_on_death,omitempty"`
RetryFailTime *int `json:"retry_fail_time,omitempty"`
} `json:"node"`
SMTP struct {
SendStartTLS *bool `json:"send_starttls,omitempty"`
} `json:"smtp"`
SSL struct {
ClientAuth *bool `json:"client_auth,omitempty"`
CommonNameMatch *[]string `json:"common_name_match,omitempty"`
EllipticCurves *[]string `json:"elliptic_curves,omitempty"`
Enable *bool `json:"enable,omitempty"`
Enhance *bool `json:"enhance,omitempty"`
SendCloseAlerts *bool `json:"send_close_alerts,omitempty"`
ServerName *bool `json:"server_name,omitempty"`
SignatureAlgorithms *string `json:"signature_algorithms,omitempty"`
SSLCiphers *string `json:"ssl_ciphers,omitempty"`
SSLSupportSSL2 *string `json:"ssl_support_ssl2,omitempty"`
SSLSupportSSL3 *string `json:"ssl_support_ssl3,omitempty"`
SSLSupportTLS1 *string `json:"ssl_support_tls1,omitempty"`
SSLSupportTLS11 *string `json:"ssl_support_tls1_1,omitempty"`
SSLSupportTLS12 *string `json:"ssl_support_tls1_2,omitempty"`
StrictVerify *bool `json:"strict_verify,omitempty"`
} `json:"ssl"`
TCP struct {
Nagle *bool `json:"nagle,omitempty"`
} `json:"tcp"`
UDP struct {
AcceptFrom *string `json:"accept_from,omitempty"`
AcceptFromMask *string `json:"accept_from_mask,omitempty"`
} `json:"udp"`
}
type Node struct {
Node *string `json:"node,omitempty"`
Priority *int `json:"priority,omitempty"`
State *string `json:"state,omitempty"`
Weight *int `json:"weight,omitempty"`
}
func (r *Pool) endpoint() string {
return "pools"
}
//String will return back the json as a string
func (r *Pool) String() string {
b := r.Bytes()
return string(b)
}
//Bytes will return back just the bytes
func (r *Pool) Bytes() []byte {
b, _ := jsonMarshal(r)
return b
}
func (r *Pool) decode(data []byte) error {
return json.Unmarshal(data, &r)
}
func NewPool(name string) *Pool {
r := new(Pool)
r.setName(name)
return r
}
func (c *Client) GetPool(name string) (*Pool, *http.Response, error) {
r := NewPool(name)
resp, err := c.Get(r)
if err != nil {
return nil, resp, err
}
return r, resp, nil
}
func (c *Client) ListPools() ([]string, *http.Response, error) {
return c.List(&Pool{})
}