This repository has been archived by the owner on Oct 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 724
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add RedshiftScheduledAction resource (#1047)
* Add RedshiftScheduledAction resource --------- Co-authored-by: Björn Häuser <[email protected]>
- Loading branch information
1 parent
e641116
commit 150eb13
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package resources | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws/session" | ||
"github.com/aws/aws-sdk-go/service/redshift" | ||
"github.com/rebuy-de/aws-nuke/v2/pkg/types" | ||
) | ||
|
||
type RedshiftScheduledAction struct { | ||
svc *redshift.Redshift | ||
scheduledActionName *string | ||
} | ||
|
||
func init() { | ||
register("RedshiftScheduledAction", ListRedshiftScheduledActions) | ||
} | ||
|
||
func ListRedshiftScheduledActions(sess *session.Session) ([]Resource, error) { | ||
svc := redshift.New(sess) | ||
resources := []Resource{} | ||
|
||
params := &redshift.DescribeScheduledActionsInput{} | ||
|
||
for { | ||
resp, err := svc.DescribeScheduledActions(params) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
for _, item := range resp.ScheduledActions { | ||
resources = append(resources, &RedshiftScheduledAction{ | ||
svc: svc, | ||
scheduledActionName: item.ScheduledActionName, | ||
}) | ||
} | ||
|
||
if resp.Marker == nil { | ||
break | ||
} | ||
|
||
params.Marker = resp.Marker | ||
} | ||
|
||
return resources, nil | ||
} | ||
|
||
func (f *RedshiftScheduledAction) Remove() error { | ||
|
||
_, err := f.svc.DeleteScheduledAction(&redshift.DeleteScheduledActionInput{ | ||
ScheduledActionName: f.scheduledActionName, | ||
}) | ||
|
||
return err | ||
} | ||
|
||
func (f *RedshiftScheduledAction) Properties() types.Properties { | ||
properties := types.NewProperties() | ||
properties.Set("scheduledActionName", f.scheduledActionName) | ||
return properties | ||
} |