Skip to content
This repository was archived by the owner on Aug 1, 2023. It is now read-only.

Commit b0d267b

Browse files
author
Jamie Hannaford
committed
Finish DB docs for Rackspace
1 parent 9793d94 commit b0d267b

File tree

19 files changed

+251
-12
lines changed

19 files changed

+251
-12
lines changed

rackspace/db/v1/backups/doc.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1+
// Package backups provides information and interaction with the backup API
2+
// resource in the Rackspace Database service.
3+
//
4+
// A backup is a copy of a database instance that can be used to restore it to
5+
// some defined point in history.
16
package backups

rackspace/db/v1/backups/requests.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,25 @@ import (
77
"github.com/rackspace/gophercloud/pagination"
88
)
99

10+
// CreateOptsBuilder is the top-level interface for creating JSON maps.
1011
type CreateOptsBuilder interface {
1112
ToBackupCreateMap() (map[string]interface{}, error)
1213
}
1314

15+
// CreateOpts is responsible for configuring newly provisioned backups.
1416
type CreateOpts struct {
17+
// [REQUIRED] The name of the backup. The only restriction is the name must
18+
// be less than 64 characters long.
1519
Name string
1620

21+
// [REQUIRED] The ID of the instance being backed up.
1722
InstanceID string
1823

24+
// [OPTIONAL] A human-readable explanation of the backup.
1925
Description string
2026
}
2127

28+
// ToBackupCreateMap will create a JSON map for the Create operation.
2229
func (opts CreateOpts) ToBackupCreateMap() (map[string]interface{}, error) {
2330
if opts.Name == "" {
2431
return nil, errors.New("Name is a required field")
@@ -39,6 +46,17 @@ func (opts CreateOpts) ToBackupCreateMap() (map[string]interface{}, error) {
3946
return map[string]interface{}{"backup": backup}, nil
4047
}
4148

49+
// Create asynchronously creates a new backup for a specified database instance.
50+
// During the backup process, write access on MyISAM databases will be
51+
// temporarily disabled; innoDB databases will be unaffected. During this time,
52+
// you will not be able to add or delete databases or users; nor delete, stop
53+
// or reboot the instance itself. Only one backup is permitted at once.
54+
//
55+
// Backups are not deleted when database instances are deleted; you must
56+
// manually delete any backups created using Delete(). Backups are saved to your
57+
// Cloud Files account in a new container called z_CLOUDDB_BACKUPS. It is
58+
// strongly recommended you do not alter this container or its contents; usual
59+
// storage costs apply.
4260
func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) CreateResult {
4361
var res CreateResult
4462

@@ -57,14 +75,18 @@ func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) CreateRes
5775
return res
5876
}
5977

78+
// ListOptsBuilder is the top-level interface for creating query strings.
6079
type ListOptsBuilder interface {
6180
ToBackupListQuery() (string, error)
6281
}
6382

83+
// ListOpts allows you to refine a list search by certain parameters.
6484
type ListOpts struct {
85+
// The type of datastore by which to filter.
6586
Datastore string `q:"datastore"`
6687
}
6788

89+
// ToBackupListQuery converts a ListOpts struct into a query string.
6890
func (opts ListOpts) ToBackupListQuery() (string, error) {
6991
q, err := gophercloud.BuildQueryString(opts)
7092
if err != nil {
@@ -73,6 +95,7 @@ func (opts ListOpts) ToBackupListQuery() (string, error) {
7395
return q.String(), nil
7496
}
7597

98+
// List will list all the saved backups for all database instances.
7699
func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager {
77100
url := baseURL(client)
78101

@@ -91,6 +114,7 @@ func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pa
91114
return pagination.NewPager(client, url, pageFn)
92115
}
93116

117+
// Get will retrieve details for a particular backup based on its unique ID.
94118
func Get(client *gophercloud.ServiceClient, id string) GetResult {
95119
var res GetResult
96120

@@ -102,6 +126,7 @@ func Get(client *gophercloud.ServiceClient, id string) GetResult {
102126
return res
103127
}
104128

129+
// Delete will permanently delete a backup.
105130
func Delete(client *gophercloud.ServiceClient, id string) DeleteResult {
106131
var res DeleteResult
107132

rackspace/db/v1/backups/results.go

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@ import (
77
"github.com/rackspace/gophercloud/rackspace/db/v1/datastores"
88
)
99

10+
// Status represents the various states a Backup can be in.
11+
type Status string
12+
13+
// Enum types for the status.
14+
const (
15+
StatusNew Status = "NEW"
16+
StatusBuilding Status = "BUILDING"
17+
StatusCompleted Status = "COMPLETED"
18+
StatusFailed Status = "FAILED"
19+
StatusDeleteFailed Status = "DELETE_FAILED"
20+
)
21+
22+
// Backup represents a Backup API resource.
1023
type Backup struct {
1124
Description string
1225
ID string
@@ -15,24 +28,32 @@ type Backup struct {
1528
Name string
1629
ParentID string `json:"parent_id" mapstructure:"parent_id"`
1730
Size float64
18-
Status string
31+
Status Status
1932
Created string
2033
Updated string
2134
Datastore datastores.DatastorePartial
2235
}
2336

37+
// CreateResult represents the result of a create operation.
2438
type CreateResult struct {
2539
commonResult
2640
}
2741

42+
// GetResult represents the result of a get operation.
2843
type GetResult struct {
2944
commonResult
3045
}
3146

47+
// DeleteResult represents the result of a delete operation.
48+
type DeleteResult struct {
49+
gophercloud.ErrResult
50+
}
51+
3252
type commonResult struct {
3353
gophercloud.Result
3454
}
3555

56+
// Extract will retrieve a Backup struct from an operation's result.
3657
func (r commonResult) Extract() (*Backup, error) {
3758
if r.Err != nil {
3859
return nil, r.Err
@@ -46,10 +67,7 @@ func (r commonResult) Extract() (*Backup, error) {
4667
return &response.Backup, err
4768
}
4869

49-
type DeleteResult struct {
50-
gophercloud.ErrResult
51-
}
52-
70+
// BackupPage represents a page of backups.
5371
type BackupPage struct {
5472
pagination.SinglePageBase
5573
}
@@ -63,6 +81,7 @@ func (r BackupPage) IsEmpty() (bool, error) {
6381
return len(is) == 0, nil
6482
}
6583

84+
// ExtractBackups will retrieve a slice of Backup structs from a paginated collection.
6685
func ExtractBackups(page pagination.Page) ([]Backup, error) {
6786
casted := page.(BackupPage).Body
6887

rackspace/db/v1/configurations/doc.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1+
// Package configurations provides information and interaction with the
2+
// configuration API resource in the Rackspace Database service.
3+
//
4+
// A configuration group is a collection of key/value pairs which define how a
5+
// particular database operates. These key/value pairs are specific to each
6+
// datastore type and serve like settings. Some directives are capable of being
7+
// applied dynamically, while other directives require a server restart to take
8+
// effect. The configuration group can be applied to an instance at creation or
9+
// applied to an existing instance to modify the behavior of the running
10+
// datastore on the instance.
111
package configurations

rackspace/db/v1/configurations/requests.go

Lines changed: 64 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/rackspace/gophercloud/pagination"
99
)
1010

11+
// List will list all of the available configurations.
1112
func List(client *gophercloud.ServiceClient) pagination.Pager {
1213
pageFn := func(r pagination.PageResult) pagination.Page {
1314
return ConfigPage{pagination.SinglePageBase(r)}
@@ -16,15 +17,22 @@ func List(client *gophercloud.ServiceClient) pagination.Pager {
1617
return pagination.NewPager(client, baseURL(client), pageFn)
1718
}
1819

20+
// CreateOptsBuilder is a top-level interface which renders a JSON map.
1921
type CreateOptsBuilder interface {
2022
ToConfigCreateMap() (map[string]interface{}, error)
2123
}
2224

25+
// DatastoreOpts is the primary options struct for creating and modifying
26+
// how configuration resources are associated with datastores.
2327
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".
2532
Version string
2633
}
2734

35+
// ToMap renders a JSON map for a datastore setting.
2836
func (opts DatastoreOpts) ToMap() (map[string]string, error) {
2937
datastore := map[string]string{}
3038

@@ -39,13 +47,24 @@ func (opts DatastoreOpts) ToMap() (map[string]string, error) {
3947
return datastore, nil
4048
}
4149

50+
// CreateOpts is the struct responsible for configuring new configurations.
4251
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.
4464
Description string
45-
Name string
46-
Values map[string]interface{}
4765
}
4866

67+
// ToConfigCreateMap casts a CreateOpts struct into a JSON map.
4968
func (opts CreateOpts) ToConfigCreateMap() (map[string]interface{}, error) {
5069
if opts.Name == "" {
5170
return nil, errors.New("Name is a required field")
@@ -74,6 +93,7 @@ func (opts CreateOpts) ToConfigCreateMap() (map[string]interface{}, error) {
7493
return map[string]interface{}{"configuration": config}, nil
7594
}
7695

96+
// Create will create a new configuration group.
7797
func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) CreateResult {
7898
var res CreateResult
7999

@@ -92,6 +112,7 @@ func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) CreateRes
92112
return res
93113
}
94114

115+
// Get will retrieve the details for a specified configuration group.
95116
func Get(client *gophercloud.ServiceClient, configID string) GetResult {
96117
var res GetResult
97118

@@ -103,17 +124,30 @@ func Get(client *gophercloud.ServiceClient, configID string) GetResult {
103124
return res
104125
}
105126

127+
// UpdateOptsBuilder is the top-level interface for casting update options into
128+
// JSON maps.
106129
type UpdateOptsBuilder interface {
107130
ToConfigUpdateMap() (map[string]interface{}, error)
108131
}
109132

133+
// UpdateOpts is the struct responsible for modifying existing configurations.
110134
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.
112147
Description string
113-
Name string
114-
Values map[string]interface{}
115148
}
116149

150+
// ToConfigUpdateMap will cast an UpdateOpts struct into a JSON map.
117151
func (opts UpdateOpts) ToConfigUpdateMap() (map[string]interface{}, error) {
118152
config := map[string]interface{}{}
119153

@@ -140,6 +174,9 @@ func (opts UpdateOpts) ToConfigUpdateMap() (map[string]interface{}, error) {
140174
return map[string]interface{}{"configuration": config}, nil
141175
}
142176

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.
143180
func Update(client *gophercloud.ServiceClient, configID string, opts UpdateOptsBuilder) UpdateResult {
144181
var res UpdateResult
145182

@@ -158,6 +195,9 @@ func Update(client *gophercloud.ServiceClient, configID string, opts UpdateOptsB
158195
return res
159196
}
160197

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.
161201
func Replace(client *gophercloud.ServiceClient, configID string, opts UpdateOptsBuilder) ReplaceResult {
162202
var res ReplaceResult
163203

@@ -176,6 +216,7 @@ func Replace(client *gophercloud.ServiceClient, configID string, opts UpdateOpts
176216
return res
177217
}
178218

219+
// Delete will permanently delete a configuration group.
179220
func Delete(client *gophercloud.ServiceClient, configID string) DeleteResult {
180221
var res DeleteResult
181222

@@ -186,20 +227,32 @@ func Delete(client *gophercloud.ServiceClient, configID string) DeleteResult {
186227
return res
187228
}
188229

230+
// ListInstances will list all the instances associated with a particular
231+
// configuration group.
189232
func ListInstances(client *gophercloud.ServiceClient, configID string) pagination.Pager {
190233
pageFn := func(r pagination.PageResult) pagination.Page {
191234
return instances.InstancePage{pagination.LinkedPageBase{PageResult: r}}
192235
}
193236
return pagination.NewPager(client, instancesURL(client, configID), pageFn)
194237
}
195238

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).
196244
func ListDatastoreParams(client *gophercloud.ServiceClient, datastoreID, versionID string) pagination.Pager {
197245
pageFn := func(r pagination.PageResult) pagination.Page {
198246
return ParamPage{pagination.SinglePageBase(r)}
199247
}
200248
return pagination.NewPager(client, listDSParamsURL(client, datastoreID, versionID), pageFn)
201249
}
202250

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.
203256
func GetDatastoreParam(client *gophercloud.ServiceClient, datastoreID, versionID, paramID string) ParamResult {
204257
var res ParamResult
205258

@@ -211,13 +264,17 @@ func GetDatastoreParam(client *gophercloud.ServiceClient, datastoreID, versionID
211264
return res
212265
}
213266

267+
// ListGlobalParams is similar to ListDatastoreParams but does not require a
268+
// DatastoreID.
214269
func ListGlobalParams(client *gophercloud.ServiceClient, versionID string) pagination.Pager {
215270
pageFn := func(r pagination.PageResult) pagination.Page {
216271
return ParamPage{pagination.SinglePageBase(r)}
217272
}
218273
return pagination.NewPager(client, listGlobalParamsURL(client, versionID), pageFn)
219274
}
220275

276+
// GetGlobalParam is similar to GetDatastoreParam but does not require a
277+
// DatastoreID.
221278
func GetGlobalParam(client *gophercloud.ServiceClient, versionID, paramID string) ParamResult {
222279
var res ParamResult
223280

0 commit comments

Comments
 (0)