-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.go
198 lines (166 loc) · 7.62 KB
/
types.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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
package sys11dbaassdk
import "time"
// requests
type CreatePostgreSQLRequest struct {
Organization string `json:"-"`
Project string `json:"-"`
ServiceConfig *PSQLServiceConfigRequest `json:"service_config,omitempty"`
ApplicationConfig *PSQLApplicationConfigRequest `json:"application_config,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Verbose bool `json:"-"`
}
type GetPostgreSQLRequest struct {
Organization string `json:"-"`
Project string `json:"-"`
UUID string `json:"-"`
Verbose bool `json:"-"`
}
type GetPostgreSQLsRequest struct {
Organization string `json:"-"`
Project string `json:"-"`
Verbose bool `json:"-"`
}
type DeletePostgreSQLRequest struct {
Organization string `json:"-"`
Project string `json:"-"`
UUID string `json:"-"`
Verbose bool `json:"-"`
}
type UpdatePostgreSQLRequest struct {
Organization string `json:"-"`
Project string `json:"-"`
ServiceConfig *PSQLServiceConfigUpdateRequest `json:"service_config,omitempty"`
ApplicationConfig *PSQLApplicationConfigUpdateRequest `json:"application_config,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
UUID string `json:"-"`
Verbose bool `json:"-"`
}
// responses
type CreatePostgreSQLResponse struct {
ServiceConfig *PSQLServiceConfigResponse `json:"service_config,omitempty"`
ApplicationConfig *PSQLApplicationConfigResponse `json:"application_config,omitempty"`
Status string `json:"status,omitempty"`
Phase string `json:"phase,omitempty"`
ResourceStatus string `json:"resource_status,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
UUID string `json:"uuid,omitempty"`
CreatedBy string `json:"created_by,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
LastModifiedBy string `json:"last_modified_by,omitempty"`
LastModifiedAt string `json:"last_modified_at,omitempty"`
}
type GetPostgreSQLResponse struct {
ServiceConfig *PSQLServiceConfigResponse `json:"service_config,omitempty"`
ApplicationConfig *PSQLApplicationConfigResponse `json:"application_config,omitempty"`
Status string `json:"status,omitempty"`
Phase string `json:"phase,omitempty"`
ResourceStatus string `json:"resource_status,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
UUID string `json:"uuid,omitempty"`
CreatedBy string `json:"created_by,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
LastModifiedBy string `json:"last_modified_by,omitempty"`
LastModifiedAt string `json:"last_modified_at,omitempty"`
}
type GetPostgreSQLsResponse []*GetPostgreSQLResponse
type DeletePostgreSQLResponse struct {
}
type UpdatePostgreSQLResponse struct {
}
// data structs
type PSQLServiceConfigRequest struct {
Disksize *int `json:"disksize,omitempty"`
MaintenanceWindow *MaintenanceWindow `json:"maintenance_window,omitempty"`
RemoteIPs []string `json:"remote_ips,omitempty"`
Type string `json:"type,omitempty"`
Flavor string `json:"flavor,omitempty"`
Region string `json:"region,omitempty"`
}
type PSQLServiceConfigUpdateRequest struct {
Disksize *int `json:"disksize,omitempty"`
MaintenanceWindow *MaintenanceWindow `json:"maintenance_window,omitempty"`
RemoteIPs []string `json:"remote_ips,omitempty"`
Type string `json:"type,omitempty"`
Flavor string `json:"flavor,omitempty"`
}
type PSQLServiceConfigResponse struct {
Disksize *int `json:"disksize,omitempty"`
MaintenanceWindow *MaintenanceWindow `json:"maintenance_window,omitempty"`
RemoteIPs []string `json:"remote_ips,omitempty"`
Type string `json:"type,omitempty"`
Flavor string `json:"flavor,omitempty"`
Region string `json:"region,omitempty"`
}
type PSQLApplicationConfigRequest struct {
Type string `json:"type,omitempty"`
Password string `json:"password,omitempty"`
Instances *int `json:"instances,omitempty"`
Version string `json:"version,omitempty"`
ScheduledBackups *PSQLScheduledBackups `json:"scheduled_backups,omitempty"`
Recovery *PSQLRecovery `json:"recovery,omitempty"`
}
type PSQLApplicationConfigUpdateRequest struct {
Password string `json:"password,omitempty"`
Instances *int `json:"instances,omitempty"`
Version string `json:"version,omitempty"`
ScheduledBackups *PSQLScheduledBackups `json:"scheduled_backups,omitempty"`
}
type PSQLApplicationConfigResponse struct {
Type string `json:"type,omitempty"`
Password string `json:"password,omitempty"`
Instances *int `json:"instances,omitempty"`
Version string `json:"version,omitempty"`
Hostname string `json:"hostname,omitempty"`
IPAddress string `json:"ip_address,omitempty"`
ScheduledBackups *PSQLScheduledBackups `json:"scheduled_backups,omitempty"`
Recovery *PSQLRecovery `json:"recovery,omitempty"`
}
type PSQLScheduledBackups struct {
Schedule *PSQLScheduledBackupsSchedule `json:"schedule,omitempty"`
Retention *int `json:"retention,omitempty"`
}
type PSQLScheduledBackupsSchedule struct {
Hour *int `json:"hour,omitempty"`
Minute *int `json:"minute,omitempty"`
}
type MaintenanceWindow struct {
DayOfWeek *int `json:"day_of_week,omitempty"`
StartHour *int `json:"start_hour,omitempty"`
StartMinute *int `json:"start_minute,omitempty"`
}
type PSQLRecovery struct {
Source string `json:"source,omitempty"`
Exclusive bool `json:"exclusive,omitempty"`
TargetName string `json:"targetName,omitempty"`
TargetLSN string `json:"targetLSN,omitempty"`
TargetXID string `json:"targetXID,omitempty"`
TargetTime *time.Time `json:"targetTime,omitempty"`
}
// pointer
func StrPtr(s string) *string {
sPtr := s
return &sPtr
}
func IntPtr(i int) *int {
iPtr := i
return &iPtr
}
func Int64ToIntPtr(i int64) *int {
iPtr := int(i)
return &iPtr
}
func TimePtr(t time.Time) *time.Time {
tPtr := t
return &tPtr
}
// consts
const (
SERVICE_TYPE_DB = "database"
APP_TYPE_PSQL = "postgresql"
STATE_NOT_READY = "ClusterIsNotReady"
STATE_READY = "ClusterIsReady"
)