Skip to content

Commit 08cd574

Browse files
authored
Add Transcribe support (#13)
* 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
1 parent 5fca9fc commit 08cd574

8 files changed

+678
-0
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package resources
2+
3+
import (
4+
"time"
5+
6+
"github.com/aws/aws-sdk-go/aws/session"
7+
"github.com/aws/aws-sdk-go/service/transcribeservice"
8+
"github.com/rebuy-de/aws-nuke/v2/pkg/types"
9+
)
10+
11+
type TranscribeCallAnalyticsCategory struct {
12+
svc *transcribeservice.TranscribeService
13+
name *string
14+
inputType *string
15+
createTime *time.Time
16+
lastUpdateTime *time.Time
17+
}
18+
19+
func init() {
20+
register("TranscribeCallAnalyticsCategory", ListTranscribeCallAnalyticsCategories)
21+
}
22+
23+
func ListTranscribeCallAnalyticsCategories(sess *session.Session) ([]Resource, error) {
24+
svc := transcribeservice.New(sess)
25+
resources := []Resource{}
26+
var nextToken *string
27+
28+
for {
29+
listCallAnalyticsCategoriesInput := &transcribeservice.ListCallAnalyticsCategoriesInput{
30+
NextToken: nextToken,
31+
}
32+
33+
listOutput, err := svc.ListCallAnalyticsCategories(listCallAnalyticsCategoriesInput)
34+
if err != nil {
35+
return nil, err
36+
}
37+
for _, category := range listOutput.Categories {
38+
resources = append(resources, &TranscribeCallAnalyticsCategory{
39+
svc: svc,
40+
name: category.CategoryName,
41+
inputType: category.InputType,
42+
createTime: category.CreateTime,
43+
lastUpdateTime: category.LastUpdateTime,
44+
})
45+
}
46+
47+
// Check if there are more results
48+
if listOutput.NextToken == nil {
49+
break // No more results, exit the loop
50+
}
51+
52+
// Set the nextToken for the next iteration
53+
nextToken = listOutput.NextToken
54+
}
55+
return resources, nil
56+
}
57+
58+
func (category *TranscribeCallAnalyticsCategory) Remove() error {
59+
deleteInput := &transcribeservice.DeleteCallAnalyticsCategoryInput{
60+
CategoryName: category.name,
61+
}
62+
_, err := category.svc.DeleteCallAnalyticsCategory(deleteInput)
63+
return err
64+
}
65+
66+
func (category *TranscribeCallAnalyticsCategory) Properties() types.Properties {
67+
properties := types.NewProperties()
68+
properties.Set("Name", category.name)
69+
properties.Set("InputType", category.inputType)
70+
if category.createTime != nil {
71+
properties.Set("CreateTime", category.createTime.Format(time.RFC3339))
72+
}
73+
if category.lastUpdateTime != nil {
74+
properties.Set("LastUpdateTime", category.lastUpdateTime.Format(time.RFC3339))
75+
}
76+
return properties
77+
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
package resources
2+
3+
import (
4+
"time"
5+
6+
"github.com/aws/aws-sdk-go/aws"
7+
"github.com/aws/aws-sdk-go/aws/session"
8+
"github.com/aws/aws-sdk-go/service/transcribeservice"
9+
"github.com/rebuy-de/aws-nuke/v2/pkg/types"
10+
)
11+
12+
type TranscribeCallAnalyticsJob struct {
13+
svc *transcribeservice.TranscribeService
14+
name *string
15+
status *string
16+
completionTime *time.Time
17+
creationTime *time.Time
18+
failureReason *string
19+
languageCode *string
20+
startTime *time.Time
21+
}
22+
23+
func init() {
24+
register("TranscribeCallAnalyticsJob", ListTranscribeCallAnalyticsJobs)
25+
}
26+
27+
func ListTranscribeCallAnalyticsJobs(sess *session.Session) ([]Resource, error) {
28+
svc := transcribeservice.New(sess)
29+
resources := []Resource{}
30+
var nextToken *string
31+
32+
for {
33+
listCallAnalyticsJobsInput := &transcribeservice.ListCallAnalyticsJobsInput{
34+
MaxResults: aws.Int64(100),
35+
NextToken: nextToken,
36+
}
37+
38+
listOutput, err := svc.ListCallAnalyticsJobs(listCallAnalyticsJobsInput)
39+
if err != nil {
40+
return nil, err
41+
}
42+
for _, job := range listOutput.CallAnalyticsJobSummaries {
43+
resources = append(resources, &TranscribeCallAnalyticsJob{
44+
svc: svc,
45+
name: job.CallAnalyticsJobName,
46+
status: job.CallAnalyticsJobStatus,
47+
completionTime: job.CompletionTime,
48+
creationTime: job.CreationTime,
49+
failureReason: job.FailureReason,
50+
languageCode: job.LanguageCode,
51+
startTime: job.StartTime,
52+
})
53+
}
54+
55+
// Check if there are more results
56+
if listOutput.NextToken == nil {
57+
break // No more results, exit the loop
58+
}
59+
60+
// Set the nextToken for the next iteration
61+
nextToken = listOutput.NextToken
62+
}
63+
return resources, nil
64+
}
65+
66+
func (job *TranscribeCallAnalyticsJob) Remove() error {
67+
deleteInput := &transcribeservice.DeleteCallAnalyticsJobInput{
68+
CallAnalyticsJobName: job.name,
69+
}
70+
_, err := job.svc.DeleteCallAnalyticsJob(deleteInput)
71+
return err
72+
}
73+
74+
func (job *TranscribeCallAnalyticsJob) Properties() types.Properties {
75+
properties := types.NewProperties()
76+
properties.Set("Name", job.name)
77+
properties.Set("Status", job.status)
78+
if job.completionTime != nil {
79+
properties.Set("CompletionTime", job.completionTime.Format(time.RFC3339))
80+
}
81+
if job.creationTime != nil {
82+
properties.Set("CreationTime", job.creationTime.Format(time.RFC3339))
83+
}
84+
properties.Set("FailureReason", job.failureReason)
85+
properties.Set("LanguageCode", job.languageCode)
86+
if job.startTime != nil {
87+
properties.Set("StartTime", job.startTime.Format(time.RFC3339))
88+
}
89+
return properties
90+
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
package resources
2+
3+
import (
4+
"time"
5+
6+
"github.com/aws/aws-sdk-go/aws"
7+
"github.com/aws/aws-sdk-go/aws/session"
8+
"github.com/aws/aws-sdk-go/service/transcribeservice"
9+
"github.com/rebuy-de/aws-nuke/v2/pkg/types"
10+
)
11+
12+
type TranscribeLanguageModel struct {
13+
svc *transcribeservice.TranscribeService
14+
name *string
15+
baseModelName *string
16+
createTime *time.Time
17+
failureReason *string
18+
languageCode *string
19+
lastModifiedTime *time.Time
20+
modelStatus *string
21+
upgradeAvailability *bool
22+
}
23+
24+
func init() {
25+
register("TranscribeLanguageModel", ListTranscribeLanguageModels)
26+
}
27+
28+
func ListTranscribeLanguageModels(sess *session.Session) ([]Resource, error) {
29+
svc := transcribeservice.New(sess)
30+
resources := []Resource{}
31+
var nextToken *string
32+
33+
for {
34+
listLanguageModelsInput := &transcribeservice.ListLanguageModelsInput{
35+
MaxResults: aws.Int64(100),
36+
NextToken: nextToken,
37+
}
38+
39+
listOutput, err := svc.ListLanguageModels(listLanguageModelsInput)
40+
if err != nil {
41+
return nil, err
42+
}
43+
for _, model := range listOutput.Models {
44+
resources = append(resources, &TranscribeLanguageModel{
45+
svc: svc,
46+
name: model.ModelName,
47+
baseModelName: model.BaseModelName,
48+
createTime: model.CreateTime,
49+
failureReason: model.FailureReason,
50+
languageCode: model.LanguageCode,
51+
lastModifiedTime: model.LastModifiedTime,
52+
modelStatus: model.ModelStatus,
53+
upgradeAvailability: model.UpgradeAvailability,
54+
})
55+
}
56+
57+
// Check if there are more results
58+
if listOutput.NextToken == nil {
59+
break // No more results, exit the loop
60+
}
61+
62+
// Set the nextToken for the next iteration
63+
nextToken = listOutput.NextToken
64+
}
65+
return resources, nil
66+
}
67+
68+
func (model *TranscribeLanguageModel) Remove() error {
69+
deleteInput := &transcribeservice.DeleteLanguageModelInput{
70+
ModelName: model.name,
71+
}
72+
_, err := model.svc.DeleteLanguageModel(deleteInput)
73+
return err
74+
}
75+
76+
func (model *TranscribeLanguageModel) Properties() types.Properties {
77+
properties := types.NewProperties()
78+
properties.Set("Name", model.name)
79+
properties.Set("BaseModelName", model.baseModelName)
80+
if model.createTime != nil {
81+
properties.Set("CreateTime", model.createTime.Format(time.RFC3339))
82+
}
83+
properties.Set("FailureReason", model.failureReason)
84+
properties.Set("LanguageCode", model.languageCode)
85+
if model.lastModifiedTime != nil {
86+
properties.Set("LastModifiedTime", model.lastModifiedTime.Format(time.RFC3339))
87+
}
88+
properties.Set("ModelStatus", model.modelStatus)
89+
properties.Set("UpgradeAvailability", model.upgradeAvailability)
90+
return properties
91+
}
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
package resources
2+
3+
import (
4+
"time"
5+
6+
"github.com/aws/aws-sdk-go/aws"
7+
"github.com/aws/aws-sdk-go/aws/session"
8+
"github.com/aws/aws-sdk-go/service/transcribeservice"
9+
"github.com/rebuy-de/aws-nuke/v2/pkg/types"
10+
)
11+
12+
type TranscribeMedicalTranscriptionJob struct {
13+
svc *transcribeservice.TranscribeService
14+
name *string
15+
status *string
16+
completionTime *time.Time
17+
contentIdentificationType *string
18+
creationTime *time.Time
19+
failureReason *string
20+
languageCode *string
21+
outputLocationType *string
22+
specialty *string
23+
startTime *time.Time
24+
inputType *string
25+
}
26+
27+
func init() {
28+
register("TranscribeMedicalTranscriptionJob", ListTranscribeMedicalTranscriptionJobs)
29+
}
30+
31+
func ListTranscribeMedicalTranscriptionJobs(sess *session.Session) ([]Resource, error) {
32+
svc := transcribeservice.New(sess)
33+
resources := []Resource{}
34+
var nextToken *string
35+
36+
for {
37+
listMedicalTranscriptionJobsInput := &transcribeservice.ListMedicalTranscriptionJobsInput{
38+
MaxResults: aws.Int64(100),
39+
NextToken: nextToken,
40+
}
41+
42+
listOutput, err := svc.ListMedicalTranscriptionJobs(listMedicalTranscriptionJobsInput)
43+
if err != nil {
44+
return nil, err
45+
}
46+
for _, job := range listOutput.MedicalTranscriptionJobSummaries {
47+
resources = append(resources, &TranscribeMedicalTranscriptionJob{
48+
svc: svc,
49+
name: job.MedicalTranscriptionJobName,
50+
status: job.TranscriptionJobStatus,
51+
completionTime: job.CompletionTime,
52+
contentIdentificationType: job.ContentIdentificationType,
53+
creationTime: job.CreationTime,
54+
failureReason: job.FailureReason,
55+
languageCode: job.LanguageCode,
56+
outputLocationType: job.OutputLocationType,
57+
specialty: job.Specialty,
58+
startTime: job.StartTime,
59+
inputType: job.Type,
60+
})
61+
}
62+
63+
// Check if there are more results
64+
if listOutput.NextToken == nil {
65+
break // No more results, exit the loop
66+
}
67+
68+
// Set the nextToken for the next iteration
69+
nextToken = listOutput.NextToken
70+
}
71+
return resources, nil
72+
}
73+
74+
func (job *TranscribeMedicalTranscriptionJob) Remove() error {
75+
deleteInput := &transcribeservice.DeleteMedicalTranscriptionJobInput{
76+
MedicalTranscriptionJobName: job.name,
77+
}
78+
_, err := job.svc.DeleteMedicalTranscriptionJob(deleteInput)
79+
return err
80+
}
81+
82+
func (job *TranscribeMedicalTranscriptionJob) Properties() types.Properties {
83+
properties := types.NewProperties()
84+
properties.Set("Name", job.name)
85+
properties.Set("Status", job.status)
86+
if job.completionTime != nil {
87+
properties.Set("CompletionTime", job.completionTime.Format(time.RFC3339))
88+
}
89+
properties.Set("ContentIdentificationType", job.contentIdentificationType)
90+
if job.creationTime != nil {
91+
properties.Set("CreationTime", job.creationTime.Format(time.RFC3339))
92+
}
93+
properties.Set("FailureReason", job.failureReason)
94+
properties.Set("LanguageCode", job.languageCode)
95+
properties.Set("OutputLocationType", job.outputLocationType)
96+
properties.Set("Specialty", job.specialty)
97+
if job.startTime != nil {
98+
properties.Set("StartTime", job.startTime.Format(time.RFC3339))
99+
}
100+
properties.Set("InputType", job.inputType)
101+
return properties
102+
}

0 commit comments

Comments
 (0)