Skip to content

Commit

Permalink
Add Transcribe support (#13)
Browse files Browse the repository at this point in the history
* Add TranscribeCallAnalyticsCategory resource

* Add TranscribeCallAnalyticsJob resource

* Add TranscribeLanguageModel resource

* Add TranscribeMedicalTranscriptionJob resource

* Add TranscribeMedicalVocabulary resource

* Add TranscribeTranscriptionJob resource

* Add TranscribeVocabulary resource

* Add TranscribeVocabularyFilter resource

* go fmt formatting fixes
  • Loading branch information
danarbaugh authored Sep 6, 2023
1 parent 5fca9fc commit 08cd574
Show file tree
Hide file tree
Showing 8 changed files with 678 additions and 0 deletions.
77 changes: 77 additions & 0 deletions resources/transcribe-call-analytics-categories.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/session"
"github.com/aws/aws-sdk-go/service/transcribeservice"
"github.com/rebuy-de/aws-nuke/v2/pkg/types"
)

type TranscribeCallAnalyticsCategory struct {
svc *transcribeservice.TranscribeService
name *string
inputType *string
createTime *time.Time
lastUpdateTime *time.Time
}

func init() {
register("TranscribeCallAnalyticsCategory", ListTranscribeCallAnalyticsCategories)
}

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

for {
listCallAnalyticsCategoriesInput := &transcribeservice.ListCallAnalyticsCategoriesInput{
NextToken: nextToken,
}

listOutput, err := svc.ListCallAnalyticsCategories(listCallAnalyticsCategoriesInput)
if err != nil {
return nil, err
}
for _, category := range listOutput.Categories {
resources = append(resources, &TranscribeCallAnalyticsCategory{
svc: svc,
name: category.CategoryName,
inputType: category.InputType,
createTime: category.CreateTime,
lastUpdateTime: category.LastUpdateTime,
})
}

// 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 (category *TranscribeCallAnalyticsCategory) Remove() error {
deleteInput := &transcribeservice.DeleteCallAnalyticsCategoryInput{
CategoryName: category.name,
}
_, err := category.svc.DeleteCallAnalyticsCategory(deleteInput)
return err
}

func (category *TranscribeCallAnalyticsCategory) Properties() types.Properties {
properties := types.NewProperties()
properties.Set("Name", category.name)
properties.Set("InputType", category.inputType)
if category.createTime != nil {
properties.Set("CreateTime", category.createTime.Format(time.RFC3339))
}
if category.lastUpdateTime != nil {
properties.Set("LastUpdateTime", category.lastUpdateTime.Format(time.RFC3339))
}
return properties
}
90 changes: 90 additions & 0 deletions resources/transcribe-call-analytics-jobs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
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 TranscribeCallAnalyticsJob struct {
svc *transcribeservice.TranscribeService
name *string
status *string
completionTime *time.Time
creationTime *time.Time
failureReason *string
languageCode *string
startTime *time.Time
}

func init() {
register("TranscribeCallAnalyticsJob", ListTranscribeCallAnalyticsJobs)
}

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

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

listOutput, err := svc.ListCallAnalyticsJobs(listCallAnalyticsJobsInput)
if err != nil {
return nil, err
}
for _, job := range listOutput.CallAnalyticsJobSummaries {
resources = append(resources, &TranscribeCallAnalyticsJob{
svc: svc,
name: job.CallAnalyticsJobName,
status: job.CallAnalyticsJobStatus,
completionTime: job.CompletionTime,
creationTime: job.CreationTime,
failureReason: job.FailureReason,
languageCode: job.LanguageCode,
startTime: job.StartTime,
})
}

// 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 (job *TranscribeCallAnalyticsJob) Remove() error {
deleteInput := &transcribeservice.DeleteCallAnalyticsJobInput{
CallAnalyticsJobName: job.name,
}
_, err := job.svc.DeleteCallAnalyticsJob(deleteInput)
return err
}

func (job *TranscribeCallAnalyticsJob) Properties() types.Properties {
properties := types.NewProperties()
properties.Set("Name", job.name)
properties.Set("Status", job.status)
if job.completionTime != nil {
properties.Set("CompletionTime", job.completionTime.Format(time.RFC3339))
}
if job.creationTime != nil {
properties.Set("CreationTime", job.creationTime.Format(time.RFC3339))
}
properties.Set("FailureReason", job.failureReason)
properties.Set("LanguageCode", job.languageCode)
if job.startTime != nil {
properties.Set("StartTime", job.startTime.Format(time.RFC3339))
}
return properties
}
91 changes: 91 additions & 0 deletions resources/transcribe-language-models.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
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 TranscribeLanguageModel struct {
svc *transcribeservice.TranscribeService
name *string
baseModelName *string
createTime *time.Time
failureReason *string
languageCode *string
lastModifiedTime *time.Time
modelStatus *string
upgradeAvailability *bool
}

func init() {
register("TranscribeLanguageModel", ListTranscribeLanguageModels)
}

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

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

listOutput, err := svc.ListLanguageModels(listLanguageModelsInput)
if err != nil {
return nil, err
}
for _, model := range listOutput.Models {
resources = append(resources, &TranscribeLanguageModel{
svc: svc,
name: model.ModelName,
baseModelName: model.BaseModelName,
createTime: model.CreateTime,
failureReason: model.FailureReason,
languageCode: model.LanguageCode,
lastModifiedTime: model.LastModifiedTime,
modelStatus: model.ModelStatus,
upgradeAvailability: model.UpgradeAvailability,
})
}

// 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 (model *TranscribeLanguageModel) Remove() error {
deleteInput := &transcribeservice.DeleteLanguageModelInput{
ModelName: model.name,
}
_, err := model.svc.DeleteLanguageModel(deleteInput)
return err
}

func (model *TranscribeLanguageModel) Properties() types.Properties {
properties := types.NewProperties()
properties.Set("Name", model.name)
properties.Set("BaseModelName", model.baseModelName)
if model.createTime != nil {
properties.Set("CreateTime", model.createTime.Format(time.RFC3339))
}
properties.Set("FailureReason", model.failureReason)
properties.Set("LanguageCode", model.languageCode)
if model.lastModifiedTime != nil {
properties.Set("LastModifiedTime", model.lastModifiedTime.Format(time.RFC3339))
}
properties.Set("ModelStatus", model.modelStatus)
properties.Set("UpgradeAvailability", model.upgradeAvailability)
return properties
}
102 changes: 102 additions & 0 deletions resources/transcribe-medical-transcription-jobs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
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 TranscribeMedicalTranscriptionJob struct {
svc *transcribeservice.TranscribeService
name *string
status *string
completionTime *time.Time
contentIdentificationType *string
creationTime *time.Time
failureReason *string
languageCode *string
outputLocationType *string
specialty *string
startTime *time.Time
inputType *string
}

func init() {
register("TranscribeMedicalTranscriptionJob", ListTranscribeMedicalTranscriptionJobs)
}

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

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

listOutput, err := svc.ListMedicalTranscriptionJobs(listMedicalTranscriptionJobsInput)
if err != nil {
return nil, err
}
for _, job := range listOutput.MedicalTranscriptionJobSummaries {
resources = append(resources, &TranscribeMedicalTranscriptionJob{
svc: svc,
name: job.MedicalTranscriptionJobName,
status: job.TranscriptionJobStatus,
completionTime: job.CompletionTime,
contentIdentificationType: job.ContentIdentificationType,
creationTime: job.CreationTime,
failureReason: job.FailureReason,
languageCode: job.LanguageCode,
outputLocationType: job.OutputLocationType,
specialty: job.Specialty,
startTime: job.StartTime,
inputType: job.Type,
})
}

// 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 (job *TranscribeMedicalTranscriptionJob) Remove() error {
deleteInput := &transcribeservice.DeleteMedicalTranscriptionJobInput{
MedicalTranscriptionJobName: job.name,
}
_, err := job.svc.DeleteMedicalTranscriptionJob(deleteInput)
return err
}

func (job *TranscribeMedicalTranscriptionJob) Properties() types.Properties {
properties := types.NewProperties()
properties.Set("Name", job.name)
properties.Set("Status", job.status)
if job.completionTime != nil {
properties.Set("CompletionTime", job.completionTime.Format(time.RFC3339))
}
properties.Set("ContentIdentificationType", job.contentIdentificationType)
if job.creationTime != nil {
properties.Set("CreationTime", job.creationTime.Format(time.RFC3339))
}
properties.Set("FailureReason", job.failureReason)
properties.Set("LanguageCode", job.languageCode)
properties.Set("OutputLocationType", job.outputLocationType)
properties.Set("Specialty", job.specialty)
if job.startTime != nil {
properties.Set("StartTime", job.startTime.Format(time.RFC3339))
}
properties.Set("InputType", job.inputType)
return properties
}
Loading

0 comments on commit 08cd574

Please sign in to comment.