-
Notifications
You must be signed in to change notification settings - Fork 708
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
970888e
commit 3fe7ac3
Showing
3 changed files
with
210 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,72 @@ | ||
package resources | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/aws/session" | ||
"github.com/aws/aws-sdk-go/service/lexmodelbuildingservice" | ||
"github.com/rebuy-de/aws-nuke/pkg/types" | ||
) | ||
|
||
type LexBot struct { | ||
svc *lexmodelbuildingservice.LexModelBuildingService | ||
name *string | ||
status *string | ||
} | ||
|
||
func init() { | ||
register("LexBot", ListLexBots) | ||
} | ||
|
||
func ListLexBots(sess *session.Session) ([]Resource, error) { | ||
svc := lexmodelbuildingservice.New(sess) | ||
resources := []Resource{} | ||
|
||
params := &lexmodelbuildingservice.GetBotsInput{ | ||
MaxResults: aws.Int64(10), | ||
} | ||
|
||
for { | ||
output, err := svc.GetBots(params) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
for _, bot := range output.Bots { | ||
resources = append(resources, &LexBot{ | ||
svc: svc, | ||
name: bot.Name, | ||
status: bot.Status, | ||
}) | ||
} | ||
|
||
if output.NextToken == nil { | ||
break | ||
} | ||
|
||
params.NextToken = output.NextToken | ||
} | ||
|
||
return resources, nil | ||
} | ||
|
||
func (f *LexBot) Remove() error { | ||
|
||
_, err := f.svc.DeleteBot(&lexmodelbuildingservice.DeleteBotInput{ | ||
Name: f.name, | ||
}) | ||
|
||
return err | ||
} | ||
|
||
func (f *LexBot) String() string { | ||
return *f.name | ||
} | ||
|
||
func (f *LexBot) Properties() types.Properties { | ||
properties := types.NewProperties() | ||
|
||
properties. | ||
Set("Name", f.name). | ||
Set("Status", f.status) | ||
return properties | ||
} |
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,69 @@ | ||
package resources | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/aws/session" | ||
"github.com/aws/aws-sdk-go/service/lexmodelbuildingservice" | ||
"github.com/rebuy-de/aws-nuke/pkg/types" | ||
) | ||
|
||
type LexIntent struct { | ||
svc *lexmodelbuildingservice.LexModelBuildingService | ||
name *string | ||
} | ||
|
||
func init() { | ||
register("LexIntent", ListLexIntents) | ||
} | ||
|
||
func ListLexIntents(sess *session.Session) ([]Resource, error) { | ||
svc := lexmodelbuildingservice.New(sess) | ||
resources := []Resource{} | ||
|
||
params := &lexmodelbuildingservice.GetIntentsInput{ | ||
MaxResults: aws.Int64(20), | ||
} | ||
|
||
for { | ||
output, err := svc.GetIntents(params) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
for _, bot := range output.Intents { | ||
resources = append(resources, &LexIntent{ | ||
svc: svc, | ||
name: bot.Name, | ||
}) | ||
} | ||
|
||
if output.NextToken == nil { | ||
break | ||
} | ||
|
||
params.NextToken = output.NextToken | ||
} | ||
|
||
return resources, nil | ||
} | ||
|
||
func (f *LexIntent) Remove() error { | ||
|
||
_, err := f.svc.DeleteIntent(&lexmodelbuildingservice.DeleteIntentInput{ | ||
Name: f.name, | ||
}) | ||
|
||
return err | ||
} | ||
|
||
func (f *LexIntent) String() string { | ||
return *f.name | ||
} | ||
|
||
func (f *LexIntent) Properties() types.Properties { | ||
properties := types.NewProperties() | ||
|
||
properties. | ||
Set("Name", f.name) | ||
return properties | ||
} |
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,69 @@ | ||
package resources | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/aws/session" | ||
"github.com/aws/aws-sdk-go/service/lexmodelbuildingservice" | ||
"github.com/rebuy-de/aws-nuke/pkg/types" | ||
) | ||
|
||
type LexSlotType struct { | ||
svc *lexmodelbuildingservice.LexModelBuildingService | ||
name *string | ||
} | ||
|
||
func init() { | ||
register("LexSlotType", ListLexSlotTypes) | ||
} | ||
|
||
func ListLexSlotTypes(sess *session.Session) ([]Resource, error) { | ||
svc := lexmodelbuildingservice.New(sess) | ||
resources := []Resource{} | ||
|
||
params := &lexmodelbuildingservice.GetSlotTypesInput{ | ||
MaxResults: aws.Int64(20), | ||
} | ||
|
||
for { | ||
output, err := svc.GetSlotTypes(params) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
for _, bot := range output.SlotTypes { | ||
resources = append(resources, &LexSlotType{ | ||
svc: svc, | ||
name: bot.Name, | ||
}) | ||
} | ||
|
||
if output.NextToken == nil { | ||
break | ||
} | ||
|
||
params.NextToken = output.NextToken | ||
} | ||
|
||
return resources, nil | ||
} | ||
|
||
func (f *LexSlotType) Remove() error { | ||
|
||
_, err := f.svc.DeleteSlotType(&lexmodelbuildingservice.DeleteSlotTypeInput{ | ||
Name: f.name, | ||
}) | ||
|
||
return err | ||
} | ||
|
||
func (f *LexSlotType) String() string { | ||
return *f.name | ||
} | ||
|
||
func (f *LexSlotType) Properties() types.Properties { | ||
properties := types.NewProperties() | ||
|
||
properties. | ||
Set("Name", f.name) | ||
return properties | ||
} |