Skip to content

Commit

Permalink
feat(resource): add TranscribeMedicalVocabulary resource
Browse files Browse the repository at this point in the history
  • Loading branch information
danarbaugh authored and ekristen committed Oct 2, 2024
1 parent e680d44 commit 9880189
Showing 1 changed file with 77 additions and 0 deletions.
77 changes: 77 additions & 0 deletions resources/transcribe-medical-vocabularies.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package resources

import (
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/transcribeservice"
"github.com/rebuy-de/aws-nuke/v2/pkg/types"
)

type TranscribeMedicalVocabulary struct {
svc *transcribeservice.TranscribeService
name *string
state *string
languageCode *string
lastModifiedTime *time.Time
}

func init() {
register("TranscribeMedicalVocabulary", ListTranscribeMedicalVocabularies)
}

func ListTranscribeMedicalVocabularies(sess *session.Session) ([]Resource, error) {
svc := transcribeservice.New(sess)
resources := []Resource{}
var nextToken *string

for {
listMedicalVocabulariesInput := &transcribeservice.ListMedicalVocabulariesInput{
MaxResults: aws.Int64(100),
NextToken: nextToken,
}

listOutput, err := svc.ListMedicalVocabularies(listMedicalVocabulariesInput)
if err != nil {
return nil, err
}
for _, vocab := range listOutput.Vocabularies {
resources = append(resources, &TranscribeMedicalVocabulary{
svc: svc,
name: vocab.VocabularyName,
state: vocab.VocabularyState,
languageCode: vocab.LanguageCode,
lastModifiedTime: vocab.LastModifiedTime,
})
}

// Check if there are more results
if listOutput.NextToken == nil {
break // No more results, exit the loop
}

// Set the nextToken for the next iteration
nextToken = listOutput.NextToken
}
return resources, nil
}

func (vocab *TranscribeMedicalVocabulary) Remove() error {
deleteInput := &transcribeservice.DeleteMedicalVocabularyInput{
VocabularyName: vocab.name,
}
_, err := vocab.svc.DeleteMedicalVocabulary(deleteInput)
return err
}

func (vocab *TranscribeMedicalVocabulary) Properties() types.Properties {
properties := types.NewProperties()
properties.Set("Name", vocab.name)
properties.Set("State", vocab.state)
properties.Set("LanguageCode", vocab.languageCode)
if vocab.lastModifiedTime != nil {
properties.Set("LastModifiedTime", vocab.lastModifiedTime.Format(time.RFC3339))
}
return properties
}

0 comments on commit 9880189

Please sign in to comment.