-
Notifications
You must be signed in to change notification settings - Fork 20
/
monitor_postgresql.go
81 lines (70 loc) · 2.73 KB
/
monitor_postgresql.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
// Copyright e-Xpert Solutions SA. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package ltm
import "github.com/e-XpertSolutions/f5-rest-client/f5"
type MonitorPostgreSQLConfigList struct {
Items []MonitorPostgreSQLConfig `json:"items,omitempty"`
Kind string `json:"kind,omitempty"`
SelfLink string `json:"selflink,omitempty"`
}
type MonitorPostgreSQLConfig struct {
AppService string `json:"appService,omitempty"`
Count string `json:"count,omitempty"`
Database string `json:"database,omitempty"`
Debug string `json:"debug,omitempty"`
DefaultsFrom string `json:"defaultsFrom,omitempty"`
Description string `json:"description,omitempty"`
Destination string `json:"destination,omitempty"`
FullPath string `json:"fullPath,omitempty"`
Generation int `json:"generation,omitempty"`
Interval int `json:"interval,omitempty"`
Kind string `json:"kind,omitempty"`
ManualResume string `json:"manualResume,omitempty"`
Name string `json:"name,omitempty"`
Partition string `json:"partition,omitempty"`
Recv string `json:"recv,omitempty"`
RecvColumn string `json:"recvColumn,omitempty"`
RecvRow string `json:"recvRow,omitempty"`
SelfLink string `json:"selfLink,omitempty"`
Send string `json:"send,omitempty"`
TimeUntilUp int `json:"timeUntilUp,omitempty"`
Timeout int `json:"timeout,omitempty"`
UpInterval int `json:"upInterval,omitempty"`
}
const MonitorPostgreSQLEndpoint = "/monitor/postgresql"
type MonitorPostgreSQLResource struct {
c *f5.Client
}
func (r *MonitorPostgreSQLResource) ListAll() (*MonitorPostgreSQLConfigList, error) {
var list MonitorPostgreSQLConfigList
if err := r.c.ReadQuery(BasePath+MonitorPostgreSQLEndpoint, &list); err != nil {
return nil, err
}
return &list, nil
}
func (r *MonitorPostgreSQLResource) Get(id string) (*MonitorPostgreSQLConfig, error) {
var item MonitorPostgreSQLConfig
if err := r.c.ReadQuery(BasePath+MonitorPostgreSQLEndpoint+"/"+id, &item); err != nil {
return nil, err
}
return &item, nil
}
func (r *MonitorPostgreSQLResource) Create(item MonitorPostgreSQLConfig) error {
if err := r.c.ModQuery("POST", BasePath+MonitorPostgreSQLEndpoint, item); err != nil {
return err
}
return nil
}
func (r *MonitorPostgreSQLResource) Edit(id string, item MonitorPostgreSQLConfig) error {
if err := r.c.ModQuery("PUT", BasePath+MonitorPostgreSQLEndpoint+"/"+id, item); err != nil {
return err
}
return nil
}
func (r *MonitorPostgreSQLResource) Delete(id string) error {
if err := r.c.ModQuery("DELETE", BasePath+MonitorPostgreSQLEndpoint+"/"+id, nil); err != nil {
return err
}
return nil
}