This repository has been archived by the owner on Oct 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 727
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
63d0495
commit 06920a0
Showing
7 changed files
with
489 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,87 @@ | ||
package resources | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws/session" | ||
"github.com/aws/aws-sdk-go/service/comprehend" | ||
"github.com/rebuy-de/aws-nuke/pkg/types" | ||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
func init() { | ||
register("ComprehendDocumentClassifier", ListComprehendDocumentClassifiers) | ||
} | ||
|
||
func ListComprehendDocumentClassifiers(sess *session.Session) ([]Resource, error) { | ||
svc := comprehend.New(sess) | ||
|
||
params := &comprehend.ListDocumentClassifiersInput{} | ||
resources := make([]Resource, 0) | ||
|
||
for { | ||
resp, err := svc.ListDocumentClassifiers(params) | ||
if err != nil { | ||
return nil, err | ||
} | ||
for _, documentClassifier := range resp.DocumentClassifierPropertiesList { | ||
resources = append(resources, &ComprehendDocumentClassifier{ | ||
svc: svc, | ||
documentClassifier: documentClassifier, | ||
}) | ||
} | ||
|
||
if resp.NextToken == nil { | ||
break | ||
} | ||
|
||
params.NextToken = resp.NextToken | ||
} | ||
|
||
return resources, nil | ||
} | ||
|
||
type ComprehendDocumentClassifier struct { | ||
svc *comprehend.Comprehend | ||
documentClassifier *comprehend.DocumentClassifierProperties | ||
} | ||
|
||
func (ce *ComprehendDocumentClassifier) Remove() error { | ||
switch *ce.documentClassifier.Status { | ||
case "IN_ERROR": | ||
fallthrough | ||
case "TRAINED": | ||
{ | ||
logrus.Infof("ComprehendDocumentClassifier deleteDocumentClassifier arn=%s status=%s", *ce.documentClassifier.DocumentClassifierArn, *ce.documentClassifier.Status) | ||
_, err := ce.svc.DeleteDocumentClassifier(&comprehend.DeleteDocumentClassifierInput{ | ||
DocumentClassifierArn: ce.documentClassifier.DocumentClassifierArn, | ||
}) | ||
return err | ||
} | ||
case "SUBMITTED": | ||
fallthrough | ||
case "TRAINING": | ||
{ | ||
logrus.Infof("ComprehendDocumentClassifier stopTrainingDocumentClassifier arn=%s status=%s", *ce.documentClassifier.DocumentClassifierArn, *ce.documentClassifier.Status) | ||
_, err := ce.svc.StopTrainingDocumentClassifier(&comprehend.StopTrainingDocumentClassifierInput{ | ||
DocumentClassifierArn: ce.documentClassifier.DocumentClassifierArn, | ||
}) | ||
return err | ||
} | ||
default: | ||
{ | ||
logrus.Infof("ComprehendDocumentClassifier already deleting arn=%s status=%s", *ce.documentClassifier.DocumentClassifierArn, *ce.documentClassifier.Status) | ||
return nil | ||
} | ||
} | ||
} | ||
|
||
func (ce *ComprehendDocumentClassifier) Properties() types.Properties { | ||
properties := types.NewProperties() | ||
properties.Set("LanguageCode", ce.documentClassifier.LanguageCode) | ||
properties.Set("DocumentClassifierArn", ce.documentClassifier.DocumentClassifierArn) | ||
|
||
return properties | ||
} | ||
|
||
func (ce *ComprehendDocumentClassifier) String() string { | ||
return *ce.documentClassifier.DocumentClassifierArn | ||
} |
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,63 @@ | ||
package resources | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws/session" | ||
"github.com/aws/aws-sdk-go/service/comprehend" | ||
"github.com/rebuy-de/aws-nuke/pkg/types" | ||
) | ||
|
||
func init() { | ||
register("ComprehendDominantLanguageDetectionJob", ListComprehendDominantLanguageDetectionJobs) | ||
} | ||
|
||
func ListComprehendDominantLanguageDetectionJobs(sess *session.Session) ([]Resource, error) { | ||
svc := comprehend.New(sess) | ||
|
||
params := &comprehend.ListDominantLanguageDetectionJobsInput{} | ||
resources := make([]Resource, 0) | ||
|
||
for { | ||
resp, err := svc.ListDominantLanguageDetectionJobs(params) | ||
if err != nil { | ||
return nil, err | ||
} | ||
for _, dominantLanguageDetectionJob := range resp.DominantLanguageDetectionJobPropertiesList { | ||
resources = append(resources, &ComprehendDominantLanguageDetectionJob{ | ||
svc: svc, | ||
dominantLanguageDetectionJob: dominantLanguageDetectionJob, | ||
}) | ||
} | ||
|
||
if resp.NextToken == nil { | ||
break | ||
} | ||
|
||
params.NextToken = resp.NextToken | ||
} | ||
|
||
return resources, nil | ||
} | ||
|
||
type ComprehendDominantLanguageDetectionJob struct { | ||
svc *comprehend.Comprehend | ||
dominantLanguageDetectionJob *comprehend.DominantLanguageDetectionJobProperties | ||
} | ||
|
||
func (ce *ComprehendDominantLanguageDetectionJob) Remove() error { | ||
_, err := ce.svc.StopDominantLanguageDetectionJob(&comprehend.StopDominantLanguageDetectionJobInput{ | ||
JobId: ce.dominantLanguageDetectionJob.JobId, | ||
}) | ||
return err | ||
} | ||
|
||
func (ce *ComprehendDominantLanguageDetectionJob) Properties() types.Properties { | ||
properties := types.NewProperties() | ||
properties.Set("JobName", ce.dominantLanguageDetectionJob.JobName) | ||
properties.Set("JobId", ce.dominantLanguageDetectionJob.JobId) | ||
|
||
return properties | ||
} | ||
|
||
func (ce *ComprehendDominantLanguageDetectionJob) String() string { | ||
return *ce.dominantLanguageDetectionJob.JobName | ||
} |
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,63 @@ | ||
package resources | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws/session" | ||
"github.com/aws/aws-sdk-go/service/comprehend" | ||
"github.com/rebuy-de/aws-nuke/pkg/types" | ||
) | ||
|
||
func init() { | ||
register("ComprehendEndpoint", ListComprehendEndpoints) | ||
} | ||
|
||
func ListComprehendEndpoints(sess *session.Session) ([]Resource, error) { | ||
svc := comprehend.New(sess) | ||
|
||
params := &comprehend.ListEndpointsInput{} | ||
resources := make([]Resource, 0) | ||
|
||
for { | ||
resp, err := svc.ListEndpoints(params) | ||
if err != nil { | ||
return nil, err | ||
} | ||
for _, endpoint := range resp.EndpointPropertiesList { | ||
resources = append(resources, &ComprehendEndpoint{ | ||
svc: svc, | ||
endpoint: endpoint, | ||
}) | ||
} | ||
|
||
if resp.NextToken == nil { | ||
break | ||
} | ||
|
||
params.NextToken = resp.NextToken | ||
} | ||
|
||
return resources, nil | ||
} | ||
|
||
type ComprehendEndpoint struct { | ||
svc *comprehend.Comprehend | ||
endpoint *comprehend.EndpointProperties | ||
} | ||
|
||
func (ce *ComprehendEndpoint) Remove() error { | ||
_, err := ce.svc.DeleteEndpoint(&comprehend.DeleteEndpointInput{ | ||
EndpointArn: ce.endpoint.EndpointArn, | ||
}) | ||
return err | ||
} | ||
|
||
func (ce *ComprehendEndpoint) Properties() types.Properties { | ||
properties := types.NewProperties() | ||
properties.Set("EndpointArn", ce.endpoint.EndpointArn) | ||
properties.Set("ModelArn", ce.endpoint.ModelArn) | ||
|
||
return properties | ||
} | ||
|
||
func (ce *ComprehendEndpoint) String() string { | ||
return *ce.endpoint.EndpointArn | ||
} |
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,63 @@ | ||
package resources | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws/session" | ||
"github.com/aws/aws-sdk-go/service/comprehend" | ||
"github.com/rebuy-de/aws-nuke/pkg/types" | ||
) | ||
|
||
func init() { | ||
register("ComprehendEntitiesDetectionJob", ListComprehendEntitiesDetectionJobs) | ||
} | ||
|
||
func ListComprehendEntitiesDetectionJobs(sess *session.Session) ([]Resource, error) { | ||
svc := comprehend.New(sess) | ||
|
||
params := &comprehend.ListEntitiesDetectionJobsInput{} | ||
resources := make([]Resource, 0) | ||
|
||
for { | ||
resp, err := svc.ListEntitiesDetectionJobs(params) | ||
if err != nil { | ||
return nil, err | ||
} | ||
for _, entitiesDetectionJob := range resp.EntitiesDetectionJobPropertiesList { | ||
resources = append(resources, &ComprehendEntitiesDetectionJob{ | ||
svc: svc, | ||
entitiesDetectionJob: entitiesDetectionJob, | ||
}) | ||
} | ||
|
||
if resp.NextToken == nil { | ||
break | ||
} | ||
|
||
params.NextToken = resp.NextToken | ||
} | ||
|
||
return resources, nil | ||
} | ||
|
||
type ComprehendEntitiesDetectionJob struct { | ||
svc *comprehend.Comprehend | ||
entitiesDetectionJob *comprehend.EntitiesDetectionJobProperties | ||
} | ||
|
||
func (ce *ComprehendEntitiesDetectionJob) Remove() error { | ||
_, err := ce.svc.StopEntitiesDetectionJob(&comprehend.StopEntitiesDetectionJobInput{ | ||
JobId: ce.entitiesDetectionJob.JobId, | ||
}) | ||
return err | ||
} | ||
|
||
func (ce *ComprehendEntitiesDetectionJob) Properties() types.Properties { | ||
properties := types.NewProperties() | ||
properties.Set("JobName", ce.entitiesDetectionJob.JobName) | ||
properties.Set("JobId", ce.entitiesDetectionJob.JobId) | ||
|
||
return properties | ||
} | ||
|
||
func (ce *ComprehendEntitiesDetectionJob) String() string { | ||
return *ce.entitiesDetectionJob.JobName | ||
} |
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,87 @@ | ||
package resources | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws/session" | ||
"github.com/aws/aws-sdk-go/service/comprehend" | ||
"github.com/rebuy-de/aws-nuke/pkg/types" | ||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
func init() { | ||
register("ComprehendEntityRecognizer", ListComprehendEntityRecognizers) | ||
} | ||
|
||
func ListComprehendEntityRecognizers(sess *session.Session) ([]Resource, error) { | ||
svc := comprehend.New(sess) | ||
|
||
params := &comprehend.ListEntityRecognizersInput{} | ||
resources := make([]Resource, 0) | ||
|
||
for { | ||
resp, err := svc.ListEntityRecognizers(params) | ||
if err != nil { | ||
return nil, err | ||
} | ||
for _, entityRecognizer := range resp.EntityRecognizerPropertiesList { | ||
resources = append(resources, &ComprehendEntityRecognizer{ | ||
svc: svc, | ||
entityRecognizer: entityRecognizer, | ||
}) | ||
} | ||
|
||
if resp.NextToken == nil { | ||
break | ||
} | ||
|
||
params.NextToken = resp.NextToken | ||
} | ||
|
||
return resources, nil | ||
} | ||
|
||
type ComprehendEntityRecognizer struct { | ||
svc *comprehend.Comprehend | ||
entityRecognizer *comprehend.EntityRecognizerProperties | ||
} | ||
|
||
func (ce *ComprehendEntityRecognizer) Remove() error { | ||
switch *ce.entityRecognizer.Status { | ||
case "IN_ERROR": | ||
fallthrough | ||
case "TRAINED": | ||
{ | ||
logrus.Infof("ComprehendEntityRecognizer deleteEntityRecognizer arn=%s status=%s", *ce.entityRecognizer.EntityRecognizerArn, *ce.entityRecognizer.Status) | ||
_, err := ce.svc.DeleteEntityRecognizer(&comprehend.DeleteEntityRecognizerInput{ | ||
EntityRecognizerArn: ce.entityRecognizer.EntityRecognizerArn, | ||
}) | ||
return err | ||
} | ||
case "SUBMITTED": | ||
fallthrough | ||
case "TRAINING": | ||
{ | ||
logrus.Infof("ComprehendEntityRecognizer stopTrainingEntityRecognizer arn=%s status=%s", *ce.entityRecognizer.EntityRecognizerArn, *ce.entityRecognizer.Status) | ||
_, err := ce.svc.StopTrainingEntityRecognizer(&comprehend.StopTrainingEntityRecognizerInput{ | ||
EntityRecognizerArn: ce.entityRecognizer.EntityRecognizerArn, | ||
}) | ||
return err | ||
} | ||
default: | ||
{ | ||
logrus.Infof("ComprehendEntityRecognizer already deleting arn=%s status=%s", *ce.entityRecognizer.EntityRecognizerArn, *ce.entityRecognizer.Status) | ||
return nil | ||
} | ||
} | ||
} | ||
|
||
func (ce *ComprehendEntityRecognizer) Properties() types.Properties { | ||
properties := types.NewProperties() | ||
properties.Set("LanguageCode", ce.entityRecognizer.LanguageCode) | ||
properties.Set("EntityRecognizerArn", ce.entityRecognizer.EntityRecognizerArn) | ||
|
||
return properties | ||
} | ||
|
||
func (ce *ComprehendEntityRecognizer) String() string { | ||
return *ce.entityRecognizer.EntityRecognizerArn | ||
} |
Oops, something went wrong.