8
8
"github.com/rackspace/gophercloud/pagination"
9
9
)
10
10
11
+ // List will list all of the available configurations.
11
12
func List (client * gophercloud.ServiceClient ) pagination.Pager {
12
13
pageFn := func (r pagination.PageResult ) pagination.Page {
13
14
return ConfigPage {pagination .SinglePageBase (r )}
@@ -16,15 +17,22 @@ func List(client *gophercloud.ServiceClient) pagination.Pager {
16
17
return pagination .NewPager (client , baseURL (client ), pageFn )
17
18
}
18
19
20
+ // CreateOptsBuilder is a top-level interface which renders a JSON map.
19
21
type CreateOptsBuilder interface {
20
22
ToConfigCreateMap () (map [string ]interface {}, error )
21
23
}
22
24
25
+ // DatastoreOpts is the primary options struct for creating and modifying
26
+ // how configuration resources are associated with datastores.
23
27
type DatastoreOpts struct {
24
- Type string
28
+ // [OPTIONAL] The type of datastore. Defaults to "MySQL".
29
+ Type string
30
+
31
+ // [OPTIONAL] The specific version of a datastore. Defaults to "5.6".
25
32
Version string
26
33
}
27
34
35
+ // ToMap renders a JSON map for a datastore setting.
28
36
func (opts DatastoreOpts ) ToMap () (map [string ]string , error ) {
29
37
datastore := map [string ]string {}
30
38
@@ -39,13 +47,24 @@ func (opts DatastoreOpts) ToMap() (map[string]string, error) {
39
47
return datastore , nil
40
48
}
41
49
50
+ // CreateOpts is the struct responsible for configuring new configurations.
42
51
type CreateOpts struct {
43
- Datastore * DatastoreOpts
52
+ // [REQUIRED] The configuration group name
53
+ Name string
54
+
55
+ // [REQUIRED] A map of user-defined configuration settings that will define
56
+ // how each associated datastore works. Each key/value pair is specific to a
57
+ // datastore type.
58
+ Values map [string ]interface {}
59
+
60
+ // [OPTIONAL] Associates the configuration group with a particular datastore.
61
+ Datastore * DatastoreOpts
62
+
63
+ // [OPTIONAL] A human-readable explanation for the group.
44
64
Description string
45
- Name string
46
- Values map [string ]interface {}
47
65
}
48
66
67
+ // ToConfigCreateMap casts a CreateOpts struct into a JSON map.
49
68
func (opts CreateOpts ) ToConfigCreateMap () (map [string ]interface {}, error ) {
50
69
if opts .Name == "" {
51
70
return nil , errors .New ("Name is a required field" )
@@ -74,6 +93,7 @@ func (opts CreateOpts) ToConfigCreateMap() (map[string]interface{}, error) {
74
93
return map [string ]interface {}{"configuration" : config }, nil
75
94
}
76
95
96
+ // Create will create a new configuration group.
77
97
func Create (client * gophercloud.ServiceClient , opts CreateOptsBuilder ) CreateResult {
78
98
var res CreateResult
79
99
@@ -92,6 +112,7 @@ func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) CreateRes
92
112
return res
93
113
}
94
114
115
+ // Get will retrieve the details for a specified configuration group.
95
116
func Get (client * gophercloud.ServiceClient , configID string ) GetResult {
96
117
var res GetResult
97
118
@@ -103,17 +124,30 @@ func Get(client *gophercloud.ServiceClient, configID string) GetResult {
103
124
return res
104
125
}
105
126
127
+ // UpdateOptsBuilder is the top-level interface for casting update options into
128
+ // JSON maps.
106
129
type UpdateOptsBuilder interface {
107
130
ToConfigUpdateMap () (map [string ]interface {}, error )
108
131
}
109
132
133
+ // UpdateOpts is the struct responsible for modifying existing configurations.
110
134
type UpdateOpts struct {
111
- Datastore * DatastoreOpts
135
+ // [OPTIONAL] The configuration group name
136
+ Name string
137
+
138
+ // [OPTIONAL] A map of user-defined configuration settings that will define
139
+ // how each associated datastore works. Each key/value pair is specific to a
140
+ // datastore type.
141
+ Values map [string ]interface {}
142
+
143
+ // [OPTIONAL] Associates the configuration group with a particular datastore.
144
+ Datastore * DatastoreOpts
145
+
146
+ // [OPTIONAL] A human-readable explanation for the group.
112
147
Description string
113
- Name string
114
- Values map [string ]interface {}
115
148
}
116
149
150
+ // ToConfigUpdateMap will cast an UpdateOpts struct into a JSON map.
117
151
func (opts UpdateOpts ) ToConfigUpdateMap () (map [string ]interface {}, error ) {
118
152
config := map [string ]interface {}{}
119
153
@@ -140,6 +174,9 @@ func (opts UpdateOpts) ToConfigUpdateMap() (map[string]interface{}, error) {
140
174
return map [string ]interface {}{"configuration" : config }, nil
141
175
}
142
176
177
+ // Update will modify an existing configuration group by performing a merge
178
+ // between new and existing values. If the key already exists, the new value
179
+ // will overwrite. All other keys will remain unaffected.
143
180
func Update (client * gophercloud.ServiceClient , configID string , opts UpdateOptsBuilder ) UpdateResult {
144
181
var res UpdateResult
145
182
@@ -158,6 +195,9 @@ func Update(client *gophercloud.ServiceClient, configID string, opts UpdateOptsB
158
195
return res
159
196
}
160
197
198
+ // Replace will modify an existing configuration group by overwriting the
199
+ // entire parameter group with the new values provided. Any existing keys not
200
+ // included in UpdateOptsBuilder will be deleted.
161
201
func Replace (client * gophercloud.ServiceClient , configID string , opts UpdateOptsBuilder ) ReplaceResult {
162
202
var res ReplaceResult
163
203
@@ -176,6 +216,7 @@ func Replace(client *gophercloud.ServiceClient, configID string, opts UpdateOpts
176
216
return res
177
217
}
178
218
219
+ // Delete will permanently delete a configuration group.
179
220
func Delete (client * gophercloud.ServiceClient , configID string ) DeleteResult {
180
221
var res DeleteResult
181
222
@@ -186,20 +227,32 @@ func Delete(client *gophercloud.ServiceClient, configID string) DeleteResult {
186
227
return res
187
228
}
188
229
230
+ // ListInstances will list all the instances associated with a particular
231
+ // configuration group.
189
232
func ListInstances (client * gophercloud.ServiceClient , configID string ) pagination.Pager {
190
233
pageFn := func (r pagination.PageResult ) pagination.Page {
191
234
return instances.InstancePage {pagination.LinkedPageBase {PageResult : r }}
192
235
}
193
236
return pagination .NewPager (client , instancesURL (client , configID ), pageFn )
194
237
}
195
238
239
+ // ListDatastoreParams will list all the available and supported parameters
240
+ // that can be used for a particular datastore ID and a particular version.
241
+ // For example, if you are wondering how you can configure a MySQL 5.6 instance,
242
+ // you can use this operation (you will need to retrieve the MySQL datastore ID
243
+ // by using the datastores API).
196
244
func ListDatastoreParams (client * gophercloud.ServiceClient , datastoreID , versionID string ) pagination.Pager {
197
245
pageFn := func (r pagination.PageResult ) pagination.Page {
198
246
return ParamPage {pagination .SinglePageBase (r )}
199
247
}
200
248
return pagination .NewPager (client , listDSParamsURL (client , datastoreID , versionID ), pageFn )
201
249
}
202
250
251
+ // GetDatastoreParam will retrieve information about a specific configuration
252
+ // parameter. For example, you can use this operation to understand more about
253
+ // "innodb_file_per_table" configuration param for MySQL datastores. You will
254
+ // need the param's ID first, which can be attained by using the ListDatastoreParams
255
+ // operation.
203
256
func GetDatastoreParam (client * gophercloud.ServiceClient , datastoreID , versionID , paramID string ) ParamResult {
204
257
var res ParamResult
205
258
@@ -211,13 +264,17 @@ func GetDatastoreParam(client *gophercloud.ServiceClient, datastoreID, versionID
211
264
return res
212
265
}
213
266
267
+ // ListGlobalParams is similar to ListDatastoreParams but does not require a
268
+ // DatastoreID.
214
269
func ListGlobalParams (client * gophercloud.ServiceClient , versionID string ) pagination.Pager {
215
270
pageFn := func (r pagination.PageResult ) pagination.Page {
216
271
return ParamPage {pagination .SinglePageBase (r )}
217
272
}
218
273
return pagination .NewPager (client , listGlobalParamsURL (client , versionID ), pageFn )
219
274
}
220
275
276
+ // GetGlobalParam is similar to GetDatastoreParam but does not require a
277
+ // DatastoreID.
221
278
func GetGlobalParam (client * gophercloud.ServiceClient , versionID , paramID string ) ParamResult {
222
279
var res ParamResult
223
280
0 commit comments