|
| 1 | +package resources |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/aws/aws-sdk-go/aws/session" |
| 5 | + "github.com/aws/aws-sdk-go/service/polly" |
| 6 | + "github.com/rebuy-de/aws-nuke/v2/pkg/types" |
| 7 | +) |
| 8 | + |
| 9 | +type PollyLexicon struct { |
| 10 | + svc *polly.Polly |
| 11 | + name *string |
| 12 | + attributes *polly.LexiconAttributes |
| 13 | +} |
| 14 | + |
| 15 | +func init() { |
| 16 | + register("PollyLexicons", ListPollyLexicons) |
| 17 | +} |
| 18 | + |
| 19 | +func ListPollyLexicons(sess *session.Session) ([]Resource, error) { |
| 20 | + svc := polly.New(sess) |
| 21 | + resources := []Resource{} |
| 22 | + |
| 23 | + listLexiconsInput := &polly.ListLexiconsInput{} |
| 24 | + |
| 25 | + listOutput, err := svc.ListLexicons(listLexiconsInput) |
| 26 | + if err != nil { |
| 27 | + return nil, err |
| 28 | + } |
| 29 | + for _, lexicon := range listOutput.Lexicons { |
| 30 | + resources = append(resources, &PollyLexicon{ |
| 31 | + svc: svc, |
| 32 | + name: lexicon.Name, |
| 33 | + attributes: lexicon.Attributes, |
| 34 | + }) |
| 35 | + } |
| 36 | + return resources, nil |
| 37 | +} |
| 38 | + |
| 39 | +func (lexicon *PollyLexicon) Remove() error { |
| 40 | + deleteInput := &polly.DeleteLexiconInput{ |
| 41 | + Name: lexicon.name, |
| 42 | + } |
| 43 | + _, err := lexicon.svc.DeleteLexicon(deleteInput) |
| 44 | + return err |
| 45 | +} |
| 46 | + |
| 47 | +func (lexicon *PollyLexicon) Properties() types.Properties { |
| 48 | + properties := types.NewProperties() |
| 49 | + properties.Set("Name", lexicon.name) |
| 50 | + properties.Set("Alphabet", lexicon.attributes.Alphabet) |
| 51 | + properties.Set("LanguageCode", lexicon.attributes.LanguageCode) |
| 52 | + properties.Set("LastModified", lexicon.attributes.LastModified) |
| 53 | + properties.Set("LexemesCount", lexicon.attributes.LexemesCount) |
| 54 | + properties.Set("LexiconArn", lexicon.attributes.LexiconArn) |
| 55 | + properties.Set("Size", lexicon.attributes.Size) |
| 56 | + return properties |
| 57 | +} |
0 commit comments