Skip to content

Commit 3475931

Browse files
committed
DBAAS-7710 adding support for autoscaling
1 parent 5ee89f1 commit 3475931

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

databases.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const (
4949
databaseKafkaSchemaRegistrySubjectPath = databaseBasePath + "/%s/schema-registry/%s"
5050
databaseKafkaSchemaRegistryConfigPath = databaseBasePath + "/%s/schema-registry/config"
5151
databaseKafkaSchemaRegistrySubjectConfigPath = databaseBasePath + "/%s/schema-registry/config/%s"
52+
databaseStorageAutoscalePath = databaseBasePath + "/%s/autoscale"
5253
)
5354

5455
// SQL Mode constants allow for MySQL-specific SQL flavor configuration.
@@ -129,6 +130,7 @@ type DatabasesService interface {
129130
Resize(context.Context, string, *DatabaseResizeRequest) (*Response, error)
130131
Migrate(context.Context, string, *DatabaseMigrateRequest) (*Response, error)
131132
UpdateMaintenance(context.Context, string, *DatabaseUpdateMaintenanceRequest) (*Response, error)
133+
UpdateStorageAutoscale(context.Context, string, *DatabaseStorageAutoscale) (*Response, error)
132134
InstallUpdate(context.Context, string) (*Response, error)
133135
ListBackups(context.Context, string, *ListOptions) ([]DatabaseBackup, *Response, error)
134136
GetUser(context.Context, string, string) (*DatabaseUser, *Response, error)
@@ -236,6 +238,7 @@ type Database struct {
236238
Tags []string `json:"tags,omitempty"`
237239
ProjectID string `json:"project_id,omitempty"`
238240
StorageSizeMib uint64 `json:"storage_size_mib,omitempty"`
241+
StorageAutoscale *DatabaseStorageAutoscale `json:"storage_autoscale,omitempty"`
239242
MetricsEndpoints []*ServiceAddress `json:"metrics_endpoints,omitempty"`
240243
}
241244

@@ -320,6 +323,13 @@ type DatabaseBackup struct {
320323
SizeGigabytes float64 `json:"size_gigabytes,omitempty"`
321324
}
322325

326+
// DatabaseStorageAutoscale represents the storage autoscaling configuration for a database cluster
327+
type DatabaseStorageAutoscale struct {
328+
Enabled bool `json:"enabled"`
329+
ThresholdPercent *int `json:"threshold_percent,omitempty"`
330+
IncrementGib *uint64 `json:"increment_gib,omitempty"`
331+
}
332+
323333
// DatabaseBackupRestore contains information needed to restore a backup.
324334
type DatabaseBackupRestore struct {
325335
DatabaseName string `json:"database_name,omitempty"`
@@ -346,6 +356,7 @@ type DatabaseCreateRequest struct {
346356
BackupRestore *DatabaseBackupRestore `json:"backup_restore,omitempty"`
347357
ProjectID string `json:"project_id"`
348358
StorageSizeMib uint64 `json:"storage_size_mib,omitempty"`
359+
StorageAutoscale *DatabaseStorageAutoscale `json:"storage_autoscale,omitempty"`
349360
Rules []*DatabaseCreateFirewallRule `json:"rules"`
350361
}
351362

@@ -1206,6 +1217,20 @@ func (svc *DatabasesServiceOp) UpdateMaintenance(ctx context.Context, databaseID
12061217
return resp, nil
12071218
}
12081219

1220+
// UpdateStorageAutoscale updates the storage autoscaling configuration on a cluster
1221+
func (svc *DatabasesServiceOp) UpdateStorageAutoscale(ctx context.Context, databaseID string, autoscale *DatabaseStorageAutoscale) (*Response, error) {
1222+
path := fmt.Sprintf(databaseStorageAutoscalePath, databaseID)
1223+
req, err := svc.client.NewRequest(ctx, http.MethodPut, path, autoscale)
1224+
if err != nil {
1225+
return nil, err
1226+
}
1227+
resp, err := svc.client.Do(ctx, req, nil)
1228+
if err != nil {
1229+
return resp, err
1230+
}
1231+
return resp, nil
1232+
}
1233+
12091234
// InstallUpdate starts installation of updates
12101235
func (svc *DatabasesServiceOp) InstallUpdate(ctx context.Context, databaseID string) (*Response, error) {
12111236
path := fmt.Sprintf(databaseUpdateInstallationPath, databaseID)

0 commit comments

Comments
 (0)