Skip to content

Commit

Permalink
Forcibly serializing empty alert/globalalert lists when updating data…
Browse files Browse the repository at this point in the history
…bases
  • Loading branch information
JohnSharpe committed Oct 25, 2023
1 parent 4b6c94b commit 3922bd3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
11 changes: 8 additions & 3 deletions service/databases/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,14 @@ type UpdateDatabase struct {
SourceIP []*string `json:"sourceIp,omitempty"`
ClientSSLCertificate *string `json:"clientSslCertificate,omitempty"`
Password *string `json:"password,omitempty"`
Alerts []*UpdateAlert `json:"alerts,omitempty"`
EnableTls *bool `json:"enableTls,omitempty"`
RemoteBackup *DatabaseBackupConfig `json:"remoteBackup,omitempty"`

// It's important to use a pointer here, because the terraform user may want to send an empty list.
// In that case, the developer must pass a (pointer to a) non-nil, zero-length slice
// If the developer really wants to omit this value, passing a nil slice value would work
Alerts *[]*UpdateAlert `json:"alerts,omitempty"`

EnableTls *bool `json:"enableTls,omitempty"`
RemoteBackup *DatabaseBackupConfig `json:"remoteBackup,omitempty"`
}

func (o UpdateDatabase) String() string {
Expand Down
28 changes: 15 additions & 13 deletions service/databases/model_active_active.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,19 @@ func (o LocalThroughput) String() string {
}

type UpdateActiveActiveDatabase struct {
DryRun *bool `json:"dryRun,omitempty"`
MemoryLimitInGB *float64 `json:"memoryLimitInGb,omitempty"`
SupportOSSClusterAPI *bool `json:"supportOSSClusterApi,omitempty"`
UseExternalEndpointForOSSClusterAPI *bool `json:"useExternalEndpointForOSSClusterApi,omitempty"`
ClientSSLCertificate *string `json:"clientSslCertificate,omitempty"`
EnableTls *bool `json:"enableTls,omitempty"`
GlobalDataPersistence *string `json:"globalDataPersistence,omitempty"`
GlobalPassword *string `json:"globalPassword,omitempty"`
GlobalSourceIP []*string `json:"globalSourceIp,omitempty"`
GlobalAlerts []*UpdateAlert `json:"globalAlerts,omitempty"`
Regions []*LocalRegionProperties `json:"regions,omitempty"`
DataEvictionPolicy *string `json:"dataEvictionPolicy,omitempty"`
DryRun *bool `json:"dryRun,omitempty"`
MemoryLimitInGB *float64 `json:"memoryLimitInGb,omitempty"`
SupportOSSClusterAPI *bool `json:"supportOSSClusterApi,omitempty"`
UseExternalEndpointForOSSClusterAPI *bool `json:"useExternalEndpointForOSSClusterApi,omitempty"`
ClientSSLCertificate *string `json:"clientSslCertificate,omitempty"`
EnableTls *bool `json:"enableTls,omitempty"`
GlobalDataPersistence *string `json:"globalDataPersistence,omitempty"`
GlobalPassword *string `json:"globalPassword,omitempty"`
GlobalSourceIP []*string `json:"globalSourceIp,omitempty"`
// Using a pointer to allow empty slices to be serialised/sent
GlobalAlerts *[]*UpdateAlert `json:"globalAlerts,omitempty"`
Regions []*LocalRegionProperties `json:"regions,omitempty"`
DataEvictionPolicy *string `json:"dataEvictionPolicy,omitempty"`
}

func (o UpdateActiveActiveDatabase) String() string {
Expand All @@ -113,7 +114,8 @@ type LocalRegionProperties struct {
DataPersistence *string `json:"dataPersistence,omitempty"`
Password *string `json:"password,omitempty"`
SourceIP []*string `json:"sourceIp,omitempty"`
Alerts []*UpdateAlert `json:"alerts,omitempty"`
// Using a pointer to allow empty slices to be serialised/sent
Alerts *[]*UpdateAlert `json:"alerts,omitempty"`
}

func (o LocalRegionProperties) String() string {
Expand Down

0 comments on commit 3922bd3

Please sign in to comment.