|
| 1 | +package resources |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/aws/aws-sdk-go/aws" |
| 5 | + "github.com/aws/aws-sdk-go/aws/session" |
| 6 | + "github.com/aws/aws-sdk-go/service/databasemigrationservice" |
| 7 | +) |
| 8 | + |
| 9 | +type DatabaseMigrationServiceEventSubscription struct { |
| 10 | + svc *databasemigrationservice.DatabaseMigrationService |
| 11 | + subscriptionName *string |
| 12 | +} |
| 13 | + |
| 14 | +func init() { |
| 15 | + register("DatabaseMigrationServiceEventSubscription", ListDatabaseMigrationServiceEventSubscriptions) |
| 16 | +} |
| 17 | + |
| 18 | +func ListDatabaseMigrationServiceEventSubscriptions(sess *session.Session) ([]Resource, error) { |
| 19 | + svc := databasemigrationservice.New(sess) |
| 20 | + resources := []Resource{} |
| 21 | + |
| 22 | + params := &databasemigrationservice.DescribeEventSubscriptionsInput{ |
| 23 | + MaxRecords: aws.Int64(100), |
| 24 | + } |
| 25 | + |
| 26 | + for { |
| 27 | + output, err := svc.DescribeEventSubscriptions(params) |
| 28 | + if err != nil { |
| 29 | + return nil, err |
| 30 | + } |
| 31 | + |
| 32 | + for _, eventSubscription := range output.EventSubscriptionsList { |
| 33 | + resources = append(resources, &DatabaseMigrationServiceEventSubscription{ |
| 34 | + svc: svc, |
| 35 | + subscriptionName: eventSubscription.CustSubscriptionId, |
| 36 | + }) |
| 37 | + } |
| 38 | + |
| 39 | + if output.Marker == nil { |
| 40 | + break |
| 41 | + } |
| 42 | + |
| 43 | + params.Marker = output.Marker |
| 44 | + } |
| 45 | + |
| 46 | + return resources, nil |
| 47 | +} |
| 48 | + |
| 49 | +func (f *DatabaseMigrationServiceEventSubscription) Remove() error { |
| 50 | + |
| 51 | + _, err := f.svc.DeleteEventSubscription(&databasemigrationservice.DeleteEventSubscriptionInput{ |
| 52 | + SubscriptionName: f.subscriptionName, |
| 53 | + }) |
| 54 | + |
| 55 | + return err |
| 56 | +} |
| 57 | + |
| 58 | +func (f *DatabaseMigrationServiceEventSubscription) String() string { |
| 59 | + return *f.subscriptionName |
| 60 | +} |
0 commit comments