@@ -67,69 +67,67 @@ type CloudProjectDatabaseResponse struct {
67
67
Description string `json:"description"`
68
68
Endpoints []CloudProjectDatabaseEndpoint `json:"endpoints"`
69
69
Flavor string `json:"flavor"`
70
- Id string `json:"id"`
70
+ ID string `json:"id"`
71
71
IPRestrictions []CloudProjectDatabaseIPRestrictionResponse `json:"ipRestrictions"`
72
72
MaintenanceTime string `json:"maintenanceTime"`
73
- NetworkId string `json:"networkId"`
73
+ NetworkID string `json:"networkId"`
74
74
NetworkType string `json:"networkType"`
75
75
Plan string `json:"plan"`
76
76
NodeNumber int `json:"nodeNumber"`
77
77
Region string `json:"region"`
78
- RestApi bool `json:"restApi"`
78
+ RestAPI bool `json:"restApi"`
79
+ SchemaRegistry bool `json:"schemaRegistry"`
79
80
Status string `json:"status"`
80
- SubnetId string `json:"subnetId"`
81
+ SubnetID string `json:"subnetId"`
81
82
Version string `json:"version"`
82
83
Disk CloudProjectDatabaseDisk `json:"disk"`
83
84
AdvancedConfiguration map [string ]string `json:"advancedConfiguration"`
84
85
}
85
86
86
- func (s * CloudProjectDatabaseResponse ) String () string {
87
- return fmt .Sprintf ("%s(%s): %s" , s .Description , s .Id , s .Status )
88
- }
89
-
90
- func (v CloudProjectDatabaseResponse ) ToMap () map [string ]interface {} {
87
+ func (r CloudProjectDatabaseResponse ) toMap () map [string ]interface {} {
91
88
obj := make (map [string ]interface {})
92
- obj ["backup_regions" ] = v .Backups .Regions
93
- obj ["backup_time" ] = v .Backups .Time
94
- obj ["created_at" ] = v .CreatedAt
95
- obj ["description" ] = v .Description
96
- obj ["id" ] = v . Id
89
+ obj ["backup_regions" ] = r .Backups .Regions
90
+ obj ["backup_time" ] = r .Backups .Time
91
+ obj ["created_at" ] = r .CreatedAt
92
+ obj ["description" ] = r .Description
93
+ obj ["id" ] = r . ID
97
94
98
95
var ipRests []map [string ]interface {}
99
- for _ , ir := range v .IPRestrictions {
96
+ for _ , ir := range r .IPRestrictions {
100
97
ipRests = append (ipRests , ir .toMap ())
101
98
}
102
99
obj ["ip_restrictions" ] = ipRests
103
100
104
101
var endpoints []map [string ]interface {}
105
- for _ , e := range v .Endpoints {
102
+ for _ , e := range r .Endpoints {
106
103
endpoints = append (endpoints , e .ToMap ())
107
104
}
108
105
obj ["endpoints" ] = endpoints
109
106
110
- obj ["flavor" ] = v .Flavor
111
- obj ["kafka_rest_api" ] = v .RestApi
112
- obj ["maintenance_time" ] = v .MaintenanceTime
113
- obj ["network_type" ] = v .NetworkType
107
+ obj ["flavor" ] = r .Flavor
108
+ obj ["kafka_rest_api" ] = r .RestAPI
109
+ obj ["kafka_schema_registry" ] = r .SchemaRegistry
110
+ obj ["maintenance_time" ] = r .MaintenanceTime
111
+ obj ["network_type" ] = r .NetworkType
114
112
115
113
var nodes []map [string ]interface {}
116
- for i := 0 ; i < v .NodeNumber ; i ++ {
114
+ for i := 0 ; i < r .NodeNumber ; i ++ {
117
115
node := CloudProjectDatabaseNodes {
118
- Region : v .Region ,
119
- NetworkId : v . NetworkId ,
120
- SubnetId : v . SubnetId ,
116
+ Region : r .Region ,
117
+ NetworkId : r . NetworkID ,
118
+ SubnetId : r . SubnetID ,
121
119
}
122
120
nodes = append (nodes , node .ToMap ())
123
121
}
124
122
obj ["nodes" ] = nodes
125
123
126
- obj ["opensearch_acls_enabled" ] = v .AclsEnabled
127
- obj ["plan" ] = v .Plan
128
- obj ["status" ] = v .Status
129
- obj ["version" ] = v .Version
130
- obj ["disk_size" ] = v .Disk .Size
131
- obj ["disk_type" ] = v .Disk .Type
132
- obj ["advanced_configuration" ] = v .AdvancedConfiguration
124
+ obj ["opensearch_acls_enabled" ] = r .AclsEnabled
125
+ obj ["plan" ] = r .Plan
126
+ obj ["status" ] = r .Status
127
+ obj ["version" ] = r .Version
128
+ obj ["disk_size" ] = r .Disk .Size
129
+ obj ["disk_type" ] = r .Disk .Type
130
+ obj ["advanced_configuration" ] = r .AdvancedConfiguration
133
131
134
132
return obj
135
133
}
@@ -185,7 +183,7 @@ func (v CloudProjectDatabaseNodes) ToMap() map[string]interface{} {
185
183
}
186
184
187
185
type CloudProjectDatabaseCreateOpts struct {
188
- Backups CloudProjectDatabaseBackups `json:"backups,omitempty"`
186
+ Backups * CloudProjectDatabaseBackups `json:"backups,omitempty"`
189
187
Description string `json:"description,omitempty"`
190
188
Disk CloudProjectDatabaseDisk `json:"disk,omitempty"`
191
189
IPRestrictions []CloudProjectDatabaseIPRestriction `json:"ipRestrictions,omitempty"`
@@ -212,7 +210,7 @@ type CloudProjectDatabaseNodesPattern struct {
212
210
Region string `json:"region"`
213
211
}
214
212
215
- func (opts * CloudProjectDatabaseCreateOpts ) FromResource (d * schema.ResourceData ) (* CloudProjectDatabaseCreateOpts , error ) {
213
+ func (opts * CloudProjectDatabaseCreateOpts ) fromResource (d * schema.ResourceData ) (* CloudProjectDatabaseCreateOpts , error ) {
216
214
opts .Description = d .Get ("description" ).(string )
217
215
opts .Plan = d .Get ("plan" ).(string )
218
216
@@ -251,33 +249,39 @@ func (opts *CloudProjectDatabaseCreateOpts) FromResource(d *schema.ResourceData)
251
249
if err != nil {
252
250
return nil , err
253
251
}
252
+ time := d .Get ("backup_time" ).(string )
254
253
255
- opts .Backups = CloudProjectDatabaseBackups {
256
- Regions : regions ,
257
- Time : d .Get ("backup_time" ).(string ),
254
+ if len (regions ) != 0 || time != "" {
255
+ opts .Backups = & CloudProjectDatabaseBackups {
256
+ Regions : regions ,
257
+ Time : time ,
258
+ }
258
259
}
260
+
259
261
return opts , nil
260
262
}
261
263
262
264
type CloudProjectDatabaseUpdateOpts struct {
263
265
AclsEnabled bool `json:"aclsEnabled,omitempty"`
264
- Backups CloudProjectDatabaseBackups `json:"backups,omitempty"`
266
+ Backups * CloudProjectDatabaseBackups `json:"backups,omitempty"`
265
267
Description string `json:"description,omitempty"`
266
268
Disk CloudProjectDatabaseDisk `json:"disk,omitempty"`
267
269
Flavor string `json:"flavor,omitempty"`
268
270
IPRestrictions []CloudProjectDatabaseIPRestriction `json:"ipRestrictions,omitempty"`
269
271
Plan string `json:"plan,omitempty"`
270
- RestApi bool `json:"restApi,omitempty"`
272
+ RestAPI bool `json:"restApi,omitempty"`
273
+ SchemaRegistry bool `json:"schemaRegistry,omitempty"`
271
274
Version string `json:"version,omitempty"`
272
275
}
273
276
274
- func (opts * CloudProjectDatabaseUpdateOpts ) FromResource (d * schema.ResourceData ) (* CloudProjectDatabaseUpdateOpts , error ) {
277
+ func (opts * CloudProjectDatabaseUpdateOpts ) fromResource (d * schema.ResourceData ) (* CloudProjectDatabaseUpdateOpts , error ) {
275
278
engine := d .Get ("engine" ).(string )
276
279
if engine == "opensearch" {
277
280
opts .AclsEnabled = d .Get ("opensearch_acls_enabled" ).(bool )
278
281
}
279
282
if engine == "kafka" {
280
- opts .RestApi = d .Get ("kafka_rest_api" ).(bool )
283
+ opts .RestAPI = d .Get ("kafka_rest_api" ).(bool )
284
+ opts .SchemaRegistry = d .Get ("kafka_schema_registry" ).(bool )
281
285
}
282
286
283
287
opts .Description = d .Get ("description" ).(string )
@@ -301,10 +305,13 @@ func (opts *CloudProjectDatabaseUpdateOpts) FromResource(d *schema.ResourceData)
301
305
if err != nil {
302
306
return nil , err
303
307
}
308
+ time := d .Get ("backup_time" ).(string )
304
309
305
- opts .Backups = CloudProjectDatabaseBackups {
306
- Regions : regions ,
307
- Time : d .Get ("backup_time" ).(string ),
310
+ if engine != "kafka" && (len (regions ) != 0 || time != "" ) {
311
+ opts .Backups = & CloudProjectDatabaseBackups {
312
+ Regions : regions ,
313
+ Time : time ,
314
+ }
308
315
}
309
316
310
317
return opts , nil
0 commit comments