1313 DatabaseDayOfWeek int
1414 DatabaseMaintenanceFrequency string
1515 DatabaseStatus string
16+ DatabasePlatform string
17+ DatabaseMemberType string
1618)
1719
1820const (
@@ -50,24 +52,45 @@ const (
5052 DatabaseStatusBackingUp DatabaseStatus = "backing_up"
5153)
5254
55+ const (
56+ DatabasePlatformRDBMSLegacy DatabasePlatform = "rdbms-legacy"
57+ DatabasePlatformRDBMSDefault DatabasePlatform = "rdbms-default"
58+ )
59+
60+ const (
61+ DatabaseMemberTypePrimary DatabaseMemberType = "primary"
62+ DatabaseMemberTypeFailover DatabaseMemberType = "failover"
63+ )
64+
5365// A Database is a instance of Linode Managed Databases
5466type Database struct {
55- ID int `json:"id"`
56- Status DatabaseStatus `json:"status"`
57- Label string `json:"label"`
58- Hosts DatabaseHost `json:"hosts"`
59- Region string `json:"region"`
60- Type string `json:"type"`
61- Engine string `json:"engine"`
62- Version string `json:"version"`
63- ClusterSize int `json:"cluster_size"`
64- ReplicationType string `json:"replication_type"`
65- SSLConnection bool `json:"ssl_connection"`
66- Encrypted bool `json:"encrypted"`
67- AllowList []string `json:"allow_list"`
68- InstanceURI string `json:"instance_uri"`
69- Created * time.Time `json:"-"`
70- Updated * time.Time `json:"-"`
67+ ID int `json:"id"`
68+ Status DatabaseStatus `json:"status"`
69+ Label string `json:"label"`
70+ Hosts DatabaseHost `json:"hosts"`
71+ Region string `json:"region"`
72+ Type string `json:"type"`
73+ Engine string `json:"engine"`
74+ Version string `json:"version"`
75+ ClusterSize int `json:"cluster_size"`
76+ Platform DatabasePlatform `json:"platform"`
77+ Fork * DatabaseFork `json:"fork"`
78+
79+ // Members has dynamic keys so it is a map
80+ Members map [string ]DatabaseMemberType `json:"members"`
81+
82+ // Deprecated: ReplicationType is a deprecated property, as it is no longer supported in DBaaS V2.
83+ ReplicationType string `json:"replication_type"`
84+ // Deprecated: SSLConnection is a deprecated property, as it is no longer supported in DBaaS V2.
85+ SSLConnection bool `json:"ssl_connection"`
86+ // Deprecated: Encrypted is a deprecated property, as it is no longer supported in DBaaS V2.
87+ Encrypted bool `json:"encrypted"`
88+
89+ AllowList []string `json:"allow_list"`
90+ InstanceURI string `json:"instance_uri"`
91+ Created * time.Time `json:"-"`
92+ Updated * time.Time `json:"-"`
93+ OldestRestoreTime * time.Time `json:"-"`
7194}
7295
7396// DatabaseHost for Primary/Secondary of Database
@@ -85,11 +108,21 @@ type DatabaseEngine struct {
85108
86109// DatabaseMaintenanceWindow stores information about a MySQL cluster's maintenance window
87110type DatabaseMaintenanceWindow struct {
88- DayOfWeek DatabaseDayOfWeek `json:"day_of_week"`
89- Duration int `json:"duration"`
90- Frequency DatabaseMaintenanceFrequency `json:"frequency"`
91- HourOfDay int `json:"hour_of_day"`
92- WeekOfMonth * int `json:"week_of_month"`
111+ DayOfWeek DatabaseDayOfWeek `json:"day_of_week"`
112+ Duration int `json:"duration"`
113+ Frequency DatabaseMaintenanceFrequency `json:"frequency"`
114+ HourOfDay int `json:"hour_of_day"`
115+
116+ Pending []DatabaseMaintenanceWindowPending `json:"pending,omitempty"`
117+
118+ // Deprecated: WeekOfMonth is a deprecated property, as it is no longer supported in DBaaS V2.
119+ WeekOfMonth * int `json:"week_of_month,omitempty"`
120+ }
121+
122+ type DatabaseMaintenanceWindowPending struct {
123+ Deadline * time.Time `json:"-"`
124+ Description string `json:"description"`
125+ PlannedFor * time.Time `json:"-"`
93126}
94127
95128// DatabaseType is information about the supported Database Types by Linode Managed Databases
@@ -120,13 +153,20 @@ type ClusterPrice struct {
120153 Monthly float32 `json:"monthly"`
121154}
122155
156+ // DatabaseFork describes the source and restore time for the fork for forked DBs
157+ type DatabaseFork struct {
158+ Source int `json:"source"`
159+ RestoreTime * time.Time `json:"-,omitempty"`
160+ }
161+
123162func (d * Database ) UnmarshalJSON (b []byte ) error {
124163 type Mask Database
125164
126165 p := struct {
127166 * Mask
128- Created * parseabletime.ParseableTime `json:"created"`
129- Updated * parseabletime.ParseableTime `json:"updated"`
167+ Created * parseabletime.ParseableTime `json:"created"`
168+ Updated * parseabletime.ParseableTime `json:"updated"`
169+ OldestRestoreTime * parseabletime.ParseableTime `json:"oldest_restore_time"`
130170 }{
131171 Mask : (* Mask )(d ),
132172 }
@@ -137,6 +177,45 @@ func (d *Database) UnmarshalJSON(b []byte) error {
137177
138178 d .Created = (* time .Time )(p .Created )
139179 d .Updated = (* time .Time )(p .Updated )
180+ d .OldestRestoreTime = (* time .Time )(p .OldestRestoreTime )
181+ return nil
182+ }
183+
184+ func (d * DatabaseFork ) UnmarshalJSON (b []byte ) error {
185+ type Mask DatabaseFork
186+
187+ p := struct {
188+ * Mask
189+ RestoreTime * parseabletime.ParseableTime `json:"restore_time"`
190+ }{
191+ Mask : (* Mask )(d ),
192+ }
193+
194+ if err := json .Unmarshal (b , & p ); err != nil {
195+ return err
196+ }
197+
198+ d .RestoreTime = (* time .Time )(p .RestoreTime )
199+ return nil
200+ }
201+
202+ func (d * DatabaseMaintenanceWindowPending ) UnmarshalJSON (b []byte ) error {
203+ type Mask DatabaseMaintenanceWindowPending
204+
205+ p := struct {
206+ * Mask
207+ Deadline * parseabletime.ParseableTime `json:"deadline"`
208+ PlannedFor * parseabletime.ParseableTime `json:"planned_for"`
209+ }{
210+ Mask : (* Mask )(d ),
211+ }
212+
213+ if err := json .Unmarshal (b , & p ); err != nil {
214+ return err
215+ }
216+
217+ d .Deadline = (* time .Time )(p .Deadline )
218+ d .PlannedFor = (* time .Time )(p .PlannedFor )
140219 return nil
141220}
142221
0 commit comments