forked from mitchellh/goamz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rds.go
823 lines (624 loc) · 20.6 KB
/
rds.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
// The rds package provides types and functions for interaction with the AWS
// Relational Database service (rds)
package rds
import (
"encoding/xml"
"net/http"
"net/url"
"strconv"
"time"
"github.com/mitchellh/goamz/aws"
)
// The Rds type encapsulates operations operations with the Rds endpoint.
type Rds struct {
aws.Auth
aws.Region
httpClient *http.Client
}
const APIVersion = "2013-09-09"
// New creates a new Rds instance.
func New(auth aws.Auth, region aws.Region) *Rds {
return NewWithClient(auth, region, aws.RetryingClient)
}
func NewWithClient(auth aws.Auth, region aws.Region, httpClient *http.Client) *Rds {
return &Rds{auth, region, httpClient}
}
func (rds *Rds) query(params map[string]string, resp interface{}) error {
params["Version"] = APIVersion
params["Timestamp"] = time.Now().In(time.UTC).Format(time.RFC3339)
endpoint, err := url.Parse(rds.Region.RdsEndpoint)
if err != nil {
return err
}
sign(rds.Auth, "GET", "/", params, endpoint.Host)
endpoint.RawQuery = multimap(params).Encode()
r, err := rds.httpClient.Get(endpoint.String())
if err != nil {
return err
}
defer r.Body.Close()
if r.StatusCode > 200 {
return buildError(r)
}
decoder := xml.NewDecoder(r.Body)
decodedBody := decoder.Decode(resp)
return decodedBody
}
func buildError(r *http.Response) error {
var (
err Error
errors xmlErrors
)
xml.NewDecoder(r.Body).Decode(&errors)
if len(errors.Errors) > 0 {
err = errors.Errors[0]
}
err.StatusCode = r.StatusCode
if err.Message == "" {
err.Message = r.Status
}
return &err
}
func multimap(p map[string]string) url.Values {
q := make(url.Values, len(p))
for k, v := range p {
q[k] = []string{v}
}
return q
}
func makeParams(action string) map[string]string {
params := make(map[string]string)
params["Action"] = action
return params
}
// ----------------------------------------------------------------------------
// Rds objects
type DBInstance struct {
Address string `xml:"Endpoint>Address"`
AllocatedStorage int `xml:"AllocatedStorage"`
AvailabilityZone string `xml:"AvailabilityZone"`
BackupRetentionPeriod int `xml:"BackupRetentionPeriod"`
DBInstanceClass string `xml:"DBInstanceClass"`
DBInstanceIdentifier string `xml:"DBInstanceIdentifier"`
DBInstanceStatus string `xml:"DBInstanceStatus"`
DBName string `xml:"DBName"`
Engine string `xml:"Engine"`
EngineVersion string `xml:"EngineVersion"`
MasterUsername string `xml:"MasterUsername"`
MultiAZ bool `xml:"MultiAZ"`
Port int `xml:"Endpoint>Port"`
PreferredBackupWindow string `xml:"PreferredBackupWindow"`
PreferredMaintenanceWindow string `xml:"PreferredMaintenanceWindow"`
VpcSecurityGroupIds []string `xml:"VpcSecurityGroups>VpcSecurityGroupMembership>VpcSecurityGroupId"`
DBSecurityGroupNames []string `xml:"DBSecurityGroups>DBSecurityGroup>DBSecurityGroupName"`
DBSubnetGroup DBSubnetGroup `xml:"DBSubnetGroup"`
DBParameterGroupName string `xml:"DBParameterGroups>DBParameterGroup>DBParameterGroupName"`
}
type DBSecurityGroup struct {
Description string `xml:"DBSecurityGroupDescription"`
Name string `xml:"DBSecurityGroupName"`
EC2SecurityGroupNames []string `xml:"EC2SecurityGroups>EC2SecurityGroup>EC2SecurityGroupName"`
EC2SecurityGroupIds []string `xml:"EC2SecurityGroups>EC2SecurityGroup>EC2SecurityGroupId"`
EC2SecurityGroupOwnerIds []string `xml:"EC2SecurityGroups>EC2SecurityGroup>EC2SecurityGroupOwnerId"`
EC2SecurityGroupStatuses []string `xml:"EC2SecurityGroups>EC2SecurityGroup>Status"`
CidrIps []string `xml:"IPRanges>IPRange>CIDRIP"`
CidrStatuses []string `xml:"IPRanges>IPRange>Status"`
}
type DBSubnetGroup struct {
Description string `xml:"DBSubnetGroupDescription"`
Name string `xml:"DBSubnetGroupName"`
Status string `xml:"SubnetGroupStatus"`
SubnetIds []string `xml:"Subnets>Subnet>SubnetIdentifier"`
VpcId string `xml:"VpcId"`
}
type DBSnapshot struct {
AllocatedStorage int `xml:"AllocatedStorage"`
AvailabilityZone string `xml:"AvailabilityZone"`
DBInstanceIdentifier string `xml:"DBInstanceIdentifier"`
DBSnapshotIdentifier string `xml:"DBSnapshotIdentifier"`
Engine string `xml:"Engine"`
EngineVersion string `xml:"EngineVersion"`
InstanceCreateTime string `xml:"InstanceCreateTime"`
Iops int `xml:"Iops"`
LicenseModel string `xml:"LicenseModel"`
MasterUsername string `xml:"MasterUsername"`
OptionGroupName string `xml:"OptionGroupName"`
PercentProgress int `xml:"PercentProgress"`
Port int `xml:"Port"`
SnapshotCreateTime string `xml:"SnapshotCreateTime"`
SnapshotType string `xml:"SnapshotType"`
SourceRegion string `xml:"SourceRegion"`
Status string `xml:"Status"`
VpcId string `xml:"VpcId"`
}
type DBParameterGroup struct {
DBParameterGroupFamily string `xml:"DBParameterGroupFamily"`
DBParameterGroupName string `xml:"DBParameterGroupName"`
Description string `xml:"Description"`
}
type Parameter struct {
ApplyMethod string `xml:"ApplyMethod"`
ParameterName string `xml:"ParameterName"`
ParameterValue string `xml:"ParameterValue"`
}
// ----------------------------------------------------------------------------
// Create
// The CreateDBInstance request parameters
type CreateDBInstance struct {
AllocatedStorage int
AvailabilityZone string
BackupRetentionPeriod int
DBInstanceClass string
DBInstanceIdentifier string
DBName string
DBSubnetGroupName string
Engine string
EngineVersion string
Iops int
MasterUsername string
MasterUserPassword string
MultiAZ bool
Port int
PreferredBackupWindow string // hh24:mi-hh24:mi
PreferredMaintenanceWindow string // ddd:hh24:mi-ddd:hh24:mi
PubliclyAccessible bool
VpcSecurityGroupIds []string
DBSecurityGroupNames []string
DBParameterGroupName string
SetAllocatedStorage bool
SetBackupRetentionPeriod bool
SetIops bool
SetPort bool
}
func (rds *Rds) CreateDBInstance(options *CreateDBInstance) (resp *SimpleResp, err error) {
params := makeParams("CreateDBInstance")
if options.SetAllocatedStorage {
params["AllocatedStorage"] = strconv.Itoa(options.AllocatedStorage)
}
if options.SetBackupRetentionPeriod {
params["BackupRetentionPeriod"] = strconv.Itoa(options.BackupRetentionPeriod)
}
if options.SetIops {
params["Iops"] = strconv.Itoa(options.Iops)
}
if options.SetPort {
params["Port"] = strconv.Itoa(options.Port)
}
if options.AvailabilityZone != "" {
params["AvailabilityZone"] = options.AvailabilityZone
}
if options.DBInstanceClass != "" {
params["DBInstanceClass"] = options.DBInstanceClass
}
if options.DBInstanceIdentifier != "" {
params["DBInstanceIdentifier"] = options.DBInstanceIdentifier
}
if options.DBName != "" {
params["DBName"] = options.DBName
}
if options.DBSubnetGroupName != "" {
params["DBSubnetGroupName"] = options.DBSubnetGroupName
}
if options.Engine != "" {
params["Engine"] = options.Engine
}
if options.EngineVersion != "" {
params["EngineVersion"] = options.EngineVersion
}
if options.MasterUsername != "" {
params["MasterUsername"] = options.MasterUsername
}
if options.MasterUserPassword != "" {
params["MasterUserPassword"] = options.MasterUserPassword
}
if options.MultiAZ {
params["MultiAZ"] = "true"
}
if options.PreferredBackupWindow != "" {
params["PreferredBackupWindow"] = options.PreferredBackupWindow
}
if options.PreferredMaintenanceWindow != "" {
params["PreferredMaintenanceWindow"] = options.PreferredMaintenanceWindow
}
if options.PubliclyAccessible {
params["PubliclyAccessible"] = "true"
}
for j, group := range options.VpcSecurityGroupIds {
params["VpcSecurityGroupIds.member."+strconv.Itoa(j+1)] = group
}
for j, group := range options.DBSecurityGroupNames {
params["DBSecurityGroups.member."+strconv.Itoa(j+1)] = group
}
if options.DBParameterGroupName != "" {
params["DBParameterGroupName"] = options.DBParameterGroupName
}
resp = &SimpleResp{}
err = rds.query(params, resp)
if err != nil {
resp = nil
}
return
}
// The CreateDBSecurityGroup request parameters
type CreateDBSecurityGroup struct {
DBSecurityGroupName string
DBSecurityGroupDescription string
}
func (rds *Rds) CreateDBSecurityGroup(options *CreateDBSecurityGroup) (resp *SimpleResp, err error) {
params := makeParams("CreateDBSecurityGroup")
params["DBSecurityGroupName"] = options.DBSecurityGroupName
params["DBSecurityGroupDescription"] = options.DBSecurityGroupDescription
resp = &SimpleResp{}
err = rds.query(params, resp)
if err != nil {
resp = nil
}
return
}
// The CreateDBSubnetGroup request parameters
type CreateDBSubnetGroup struct {
DBSubnetGroupName string
DBSubnetGroupDescription string
SubnetIds []string
}
func (rds *Rds) CreateDBSubnetGroup(options *CreateDBSubnetGroup) (resp *SimpleResp, err error) {
params := makeParams("CreateDBSubnetGroup")
params["DBSubnetGroupName"] = options.DBSubnetGroupName
params["DBSubnetGroupDescription"] = options.DBSubnetGroupDescription
for j, group := range options.SubnetIds {
params["SubnetIds.member."+strconv.Itoa(j+1)] = group
}
resp = &SimpleResp{}
err = rds.query(params, resp)
if err != nil {
resp = nil
}
return
}
// The CreateDBSecurityGroup request parameters
type AuthorizeDBSecurityGroupIngress struct {
Cidr string
DBSecurityGroupName string
EC2SecurityGroupId string
EC2SecurityGroupName string
EC2SecurityGroupOwnerId string
}
func (rds *Rds) AuthorizeDBSecurityGroupIngress(options *AuthorizeDBSecurityGroupIngress) (resp *SimpleResp, err error) {
params := makeParams("AuthorizeDBSecurityGroupIngress")
if attr := options.Cidr; attr != "" {
params["CIDRIP"] = attr
}
if attr := options.EC2SecurityGroupId; attr != "" {
params["EC2SecurityGroupId"] = attr
}
if attr := options.EC2SecurityGroupOwnerId; attr != "" {
params["EC2SecurityGroupOwnerId"] = attr
}
if attr := options.EC2SecurityGroupName; attr != "" {
params["EC2SecurityGroupName"] = attr
}
params["DBSecurityGroupName"] = options.DBSecurityGroupName
resp = &SimpleResp{}
err = rds.query(params, resp)
if err != nil {
resp = nil
}
return
}
// The CreateDBParameterGroup request parameters
type CreateDBParameterGroup struct {
DBParameterGroupFamily string
DBParameterGroupName string
Description string
}
func (rds *Rds) CreateDBParameterGroup(options *CreateDBParameterGroup) (resp *SimpleResp, err error) {
params := makeParams("CreateDBParameterGroup")
params["DBParameterGroupFamily"] = options.DBParameterGroupFamily
params["DBParameterGroupName"] = options.DBParameterGroupName
params["Description"] = options.Description
resp = &SimpleResp{}
err = rds.query(params, resp)
if err != nil {
resp = nil
}
return
}
// Describe
// DescribeDBInstances request params
type DescribeDBInstances struct {
DBInstanceIdentifier string
}
type DescribeDBInstancesResp struct {
RequestId string `xml:"ResponseMetadata>RequestId"`
DBInstances []DBInstance `xml:"DescribeDBInstancesResult>DBInstances>DBInstance"`
}
func (rds *Rds) DescribeDBInstances(options *DescribeDBInstances) (resp *DescribeDBInstancesResp, err error) {
params := makeParams("DescribeDBInstances")
params["DBInstanceIdentifier"] = options.DBInstanceIdentifier
resp = &DescribeDBInstancesResp{}
err = rds.query(params, resp)
if err != nil {
resp = nil
}
return
}
// DescribeDBSecurityGroups request params
type DescribeDBSecurityGroups struct {
DBSecurityGroupName string
}
type DescribeDBSecurityGroupsResp struct {
RequestId string `xml:"ResponseMetadata>RequestId"`
DBSecurityGroups []DBSecurityGroup `xml:"DescribeDBSecurityGroupsResult>DBSecurityGroups>DBSecurityGroup"`
}
func (rds *Rds) DescribeDBSecurityGroups(options *DescribeDBSecurityGroups) (resp *DescribeDBSecurityGroupsResp, err error) {
params := makeParams("DescribeDBSecurityGroups")
params["DBSecurityGroupName"] = options.DBSecurityGroupName
resp = &DescribeDBSecurityGroupsResp{}
err = rds.query(params, resp)
if err != nil {
resp = nil
}
return
}
// DescribeDBSubnetGroups request params
type DescribeDBSubnetGroups struct {
DBSubnetGroupName string
}
type DescribeDBSubnetGroupsResp struct {
RequestId string `xml:"ResponseMetadata>RequestId"`
DBSubnetGroups []DBSubnetGroup `xml:"DescribeDBSubnetGroupsResult>DBSubnetGroups>DBSubnetGroup"`
}
func (rds *Rds) DescribeDBSubnetGroups(options *DescribeDBSubnetGroups) (resp *DescribeDBSubnetGroupsResp, err error) {
params := makeParams("DescribeDBSubnetGroups")
params["DBSubnetGroupName"] = options.DBSubnetGroupName
resp = &DescribeDBSubnetGroupsResp{}
err = rds.query(params, resp)
if err != nil {
resp = nil
}
return
}
// DescribeDBSnapshots request params
type DescribeDBSnapshots struct {
DBInstanceIdentifier string
DBSnapshotIdentifier string
SnapshotType string
}
type DescribeDBSnapshotsResp struct {
RequestId string `xml:"ResponseMetadata>RequestId"`
DBSnapshots []DBSnapshot `xml:"DescribeDBSnapshotsResult>DBSnapshots>DBSnapshot"`
}
func (rds *Rds) DescribeDBSnapshots(options *DescribeDBSnapshots) (resp *DescribeDBSnapshotsResp, err error) {
params := makeParams("DescribeDBSnapshots")
if options.DBInstanceIdentifier != "" {
params["DBInstanceIdentifier"] = options.DBInstanceIdentifier
}
if options.DBSnapshotIdentifier != "" {
params["DBSnapshotIdentifier"] = options.DBSnapshotIdentifier
}
if options.SnapshotType != "" {
params["SnapshotType"] = options.SnapshotType
}
resp = &DescribeDBSnapshotsResp{}
err = rds.query(params, resp)
if err != nil {
resp = nil
}
return
}
// DescribeDBParameterGroups request params
type DescribeDBParameterGroups struct {
DBParameterGroupName string
}
type DescribeDBParameterGroupsResp struct {
RequestId string `xml:"ResponseMetadata>RequestId"`
DBParameterGroups []DBParameterGroup `xml:"DescribeDBParameterGroupsResult>DBParameterGroups>DBParameterGroup"`
}
func (rds *Rds) DescribeDBParameterGroups(options *DescribeDBParameterGroups) (resp *DescribeDBParameterGroupsResp, err error) {
params := makeParams("DescribeDBParameterGroups")
params["DBParameterGroupName"] = options.DBParameterGroupName
resp = &DescribeDBParameterGroupsResp{}
err = rds.query(params, resp)
if err != nil {
resp = nil
}
return
}
// DescribeDBParameters request params
type DescribeDBParameters struct {
DBParameterGroupName string
Source string
}
type DescribeDBParametersResp struct {
RequestId string `xml:"ResponseMetadata>RequestId"`
Parameters []Parameter `xml:"DescribeDBParametersResult>Parameters>Parameter"`
}
func (rds *Rds) DescribeDBParameters(options *DescribeDBParameters) (resp *DescribeDBParametersResp, err error) {
params := makeParams("DescribeDBParameters")
params["DBParameterGroupName"] = options.DBParameterGroupName
if attr := options.Source; attr != "" {
params["Source"] = attr
}
resp = &DescribeDBParametersResp{}
err = rds.query(params, resp)
if err != nil {
resp = nil
}
return
}
// DeleteDBInstance request params
type DeleteDBInstance struct {
FinalDBSnapshotIdentifier string
DBInstanceIdentifier string
SkipFinalSnapshot bool
}
func (rds *Rds) DeleteDBInstance(options *DeleteDBInstance) (resp *SimpleResp, err error) {
params := makeParams("DeleteDBInstance")
params["DBInstanceIdentifier"] = options.DBInstanceIdentifier
// If we don't skip the final snapshot, we need to specify a final
// snapshot identifier
if options.SkipFinalSnapshot {
params["SkipFinalSnapshot"] = "true"
} else {
params["FinalDBSnapshotIdentifier"] = options.FinalDBSnapshotIdentifier
}
resp = &SimpleResp{}
err = rds.query(params, resp)
if err != nil {
resp = nil
}
return
}
// DeleteDBSecurityGroup request params
type DeleteDBSecurityGroup struct {
DBSecurityGroupName string
}
func (rds *Rds) DeleteDBSecurityGroup(options *DeleteDBSecurityGroup) (resp *SimpleResp, err error) {
params := makeParams("DeleteDBSecurityGroup")
params["DBSecurityGroupName"] = options.DBSecurityGroupName
resp = &SimpleResp{}
err = rds.query(params, resp)
if err != nil {
resp = nil
}
return
}
// DeleteDBSubnetGroup request params
type DeleteDBSubnetGroup struct {
DBSubnetGroupName string
}
func (rds *Rds) DeleteDBSubnetGroup(options *DeleteDBSubnetGroup) (resp *SimpleResp, err error) {
params := makeParams("DeleteDBSubnetGroup")
params["DBSubnetGroupName"] = options.DBSubnetGroupName
resp = &SimpleResp{}
err = rds.query(params, resp)
if err != nil {
resp = nil
}
return
}
// DeleteDBParameterGroup request params
type DeleteDBParameterGroup struct {
DBParameterGroupName string
}
func (rds *Rds) DeleteDBParameterGroup(options *DeleteDBParameterGroup) (resp *SimpleResp, err error) {
params := makeParams("DeleteDBParameterGroup")
params["DBParameterGroupName"] = options.DBParameterGroupName
resp = &SimpleResp{}
err = rds.query(params, resp)
if err != nil {
resp = nil
}
return
}
type RestoreDBInstanceFromDBSnapshot struct {
DBInstanceIdentifier string
DBSnapshotIdentifier string
AutoMinorVersionUpgrade bool
AvailabilityZone string
DBInstanceClass string
DBName string
DBSubnetGroupName string
Engine string
Iops int
LicenseModel string
MultiAZ bool
OptionGroupName string
Port int
PubliclyAccessible bool
SetIops bool
SetPort bool
}
func (rds *Rds) RestoreDBInstanceFromDBSnapshot(options *RestoreDBInstanceFromDBSnapshot) (resp *SimpleResp, err error) {
params := makeParams("RestoreDBInstanceFromDBSnapshot")
params["DBInstanceIdentifier"] = options.DBInstanceIdentifier
params["DBSnapshotIdentifier"] = options.DBSnapshotIdentifier
if options.AutoMinorVersionUpgrade {
params["AutoMinorVersionUpgrade"] = "true"
}
if options.AvailabilityZone != "" {
params["AvailabilityZone"] = options.AvailabilityZone
}
if options.DBInstanceClass != "" {
params["DBInstanceClass"] = options.DBInstanceClass
}
if options.DBName != "" {
params["DBName"] = options.DBName
}
if options.DBSubnetGroupName != "" {
params["DBSubnetGroupName"] = options.DBSubnetGroupName
}
if options.Engine != "" {
params["Engine"] = options.Engine
}
if options.SetIops {
params["Iops"] = strconv.Itoa(options.Iops)
}
if options.LicenseModel != "" {
params["LicenseModel"] = options.LicenseModel
}
if options.MultiAZ {
params["MultiAZ"] = "true"
}
if options.OptionGroupName != "" {
params["OptionGroupName"] = options.OptionGroupName
}
if options.SetPort {
params["Port"] = strconv.Itoa(options.Port)
}
if options.PubliclyAccessible {
params["PubliclyAccessible"] = "true"
}
resp = &SimpleResp{}
err = rds.query(params, resp)
if err != nil {
resp = nil
}
return
}
// ModifyDBParameterGroup request parameters
type ModifyDBParameterGroup struct {
DBParameterGroupName string
Parameters []Parameter
}
func (rds *Rds) ModifyDBParameterGroup(options *ModifyDBParameterGroup) (resp *SimpleResp, err error) {
params := makeParams("ModifyDBParameterGroup")
params["DBParameterGroupName"] = options.DBParameterGroupName
for j, group := range options.Parameters {
params["Parameters.member."+strconv.Itoa(j+1)+".ApplyMethod"] = group.ApplyMethod
params["Parameters.member."+strconv.Itoa(j+1)+".ParameterName"] = group.ParameterName
params["Parameters.member."+strconv.Itoa(j+1)+".ParameterValue"] = group.ParameterValue
}
resp = &SimpleResp{}
err = rds.query(params, resp)
if err != nil {
resp = nil
}
return
}
// Responses
type SimpleResp struct {
RequestId string `xml:"ResponseMetadata>RequestId"`
}
type xmlErrors struct {
Errors []Error `xml:"Error"`
}
// Error encapsulates an Rds error.
type Error struct {
// HTTP status code of the error.
StatusCode int
// AWS code of the error.
Code string
// Message explaining the error.
Message string
}
func (e *Error) Error() string {
var prefix string
if e.Code != "" {
prefix = e.Code + ": "
}
if prefix == "" && e.StatusCode > 0 {
prefix = strconv.Itoa(e.StatusCode) + ": "
}
return prefix + e.Message
}