forked from rebuy-de/aws-nuke
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding rekognition project and dataset support.
Rekogniton datasets don't have list functions directly available. Info has been parsed from the DescribeProjects call.
- Loading branch information
1 parent
91e2670
commit a90dcf2
Showing
2 changed files
with
122 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,62 @@ | ||
package resources | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/aws/session" | ||
"github.com/aws/aws-sdk-go/service/rekognition" | ||
) | ||
|
||
type RekognitionDataset struct { | ||
svc *rekognition.Rekognition | ||
arn *string | ||
} | ||
|
||
func init() { | ||
register("RekognitionDataset", ListRekognitionDatasets) | ||
} | ||
|
||
func ListRekognitionDatasets(sess *session.Session) ([]Resource, error) { | ||
svc := rekognition.New(sess) | ||
resources := []Resource{} | ||
|
||
params := &rekognition.DescribeProjectsInput{ | ||
MaxResults: aws.Int64(100), | ||
} | ||
|
||
for { | ||
output, err := svc.DescribeProjects(params) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
for _, project := range output.ProjectDescriptions { | ||
for _, dataset := range project.Datasets { | ||
resources = append(resources, &RekognitionDataset{ | ||
svc: svc, | ||
arn: dataset.DatasetArn, | ||
}) | ||
} | ||
} | ||
|
||
if output.NextToken == nil { | ||
break | ||
} | ||
|
||
params.NextToken = output.NextToken | ||
} | ||
|
||
return resources, nil | ||
} | ||
|
||
func (f *RekognitionDataset) Remove() error { | ||
|
||
_, err := f.svc.DeleteDataset(&rekognition.DeleteDatasetInput{ | ||
DatasetArn: f.arn, | ||
}) | ||
|
||
return err | ||
} | ||
|
||
func (f *RekognitionDataset) String() string { | ||
return *f.arn | ||
} |
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,60 @@ | ||
package resources | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/aws/session" | ||
"github.com/aws/aws-sdk-go/service/rekognition" | ||
) | ||
|
||
type RekognitionProject struct { | ||
svc *rekognition.Rekognition | ||
arn *string | ||
} | ||
|
||
func init() { | ||
register("RekognitionProject", ListRekognitionProjects) | ||
} | ||
|
||
func ListRekognitionProjects(sess *session.Session) ([]Resource, error) { | ||
svc := rekognition.New(sess) | ||
resources := []Resource{} | ||
|
||
params := &rekognition.DescribeProjectsInput{ | ||
MaxResults: aws.Int64(100), | ||
} | ||
|
||
for { | ||
output, err := svc.DescribeProjects(params) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
for _, project := range output.ProjectDescriptions { | ||
resources = append(resources, &RekognitionProject{ | ||
svc: svc, | ||
arn: project.ProjectArn, | ||
}) | ||
} | ||
|
||
if output.NextToken == nil { | ||
break | ||
} | ||
|
||
params.NextToken = output.NextToken | ||
} | ||
|
||
return resources, nil | ||
} | ||
|
||
func (f *RekognitionProject) Remove() error { | ||
|
||
_, err := f.svc.DeleteProject(&rekognition.DeleteProjectInput{ | ||
ProjectArn: f.arn, | ||
}) | ||
|
||
return err | ||
} | ||
|
||
func (f *RekognitionProject) String() string { | ||
return *f.arn | ||
} |