Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit 14f43da

Browse files
committed
Add Machinelearning Cleanup
1 parent 5002410 commit 14f43da

4 files changed

+240
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package resources
2+
3+
import (
4+
"github.com/aws/aws-sdk-go/aws"
5+
"github.com/aws/aws-sdk-go/aws/session"
6+
"github.com/aws/aws-sdk-go/service/machinelearning"
7+
)
8+
9+
type MachineLearningBranchPrediction struct {
10+
svc *machinelearning.MachineLearning
11+
ID *string
12+
}
13+
14+
func init() {
15+
register("MachineLearningBranchPrediction", ListMachineLearningBranchPredictions)
16+
}
17+
18+
func ListMachineLearningBranchPredictions(sess *session.Session) ([]Resource, error) {
19+
svc := machinelearning.New(sess)
20+
resources := []Resource{}
21+
22+
params := &machinelearning.DescribeBatchPredictionsInput{
23+
Limit: aws.Int64(100),
24+
}
25+
26+
for {
27+
output, err := svc.DescribeBatchPredictions(params)
28+
if err != nil {
29+
return nil, err
30+
}
31+
32+
for _, result := range output.Results {
33+
resources = append(resources, &MachineLearningBranchPrediction{
34+
svc: svc,
35+
ID: result.BatchPredictionId,
36+
})
37+
}
38+
39+
if output.NextToken == nil {
40+
break
41+
}
42+
43+
params.NextToken = output.NextToken
44+
}
45+
46+
return resources, nil
47+
}
48+
49+
func (f *MachineLearningBranchPrediction) Remove() error {
50+
51+
_, err := f.svc.DeleteBatchPrediction(&machinelearning.DeleteBatchPredictionInput{
52+
BatchPredictionId: f.ID,
53+
})
54+
55+
return err
56+
}
57+
58+
func (f *MachineLearningBranchPrediction) String() string {
59+
return *f.ID
60+
}
+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package resources
2+
3+
import (
4+
"github.com/aws/aws-sdk-go/aws"
5+
"github.com/aws/aws-sdk-go/aws/session"
6+
"github.com/aws/aws-sdk-go/service/machinelearning"
7+
)
8+
9+
type MachineLearningDataSource struct {
10+
svc *machinelearning.MachineLearning
11+
ID *string
12+
}
13+
14+
func init() {
15+
register("MachineLearningDataSource", ListMachineLearningDataSources)
16+
}
17+
18+
func ListMachineLearningDataSources(sess *session.Session) ([]Resource, error) {
19+
svc := machinelearning.New(sess)
20+
resources := []Resource{}
21+
22+
params := &machinelearning.DescribeDataSourcesInput{
23+
Limit: aws.Int64(100),
24+
}
25+
26+
for {
27+
output, err := svc.DescribeDataSources(params)
28+
if err != nil {
29+
return nil, err
30+
}
31+
32+
for _, result := range output.Results {
33+
resources = append(resources, &MachineLearningDataSource{
34+
svc: svc,
35+
ID: result.DataSourceId,
36+
})
37+
}
38+
39+
if output.NextToken == nil {
40+
break
41+
}
42+
43+
params.NextToken = output.NextToken
44+
}
45+
46+
return resources, nil
47+
}
48+
49+
func (f *MachineLearningDataSource) Remove() error {
50+
51+
_, err := f.svc.DeleteDataSource(&machinelearning.DeleteDataSourceInput{
52+
DataSourceId: f.ID,
53+
})
54+
55+
return err
56+
}
57+
58+
func (f *MachineLearningDataSource) String() string {
59+
return *f.ID
60+
}
+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package resources
2+
3+
import (
4+
"github.com/aws/aws-sdk-go/aws"
5+
"github.com/aws/aws-sdk-go/aws/session"
6+
"github.com/aws/aws-sdk-go/service/machinelearning"
7+
)
8+
9+
type MachineLearningEvaluation struct {
10+
svc *machinelearning.MachineLearning
11+
ID *string
12+
}
13+
14+
func init() {
15+
register("MachineLearningEvaluation", ListMachineLearningEvaluations)
16+
}
17+
18+
func ListMachineLearningEvaluations(sess *session.Session) ([]Resource, error) {
19+
svc := machinelearning.New(sess)
20+
resources := []Resource{}
21+
22+
params := &machinelearning.DescribeEvaluationsInput{
23+
Limit: aws.Int64(100),
24+
}
25+
26+
for {
27+
output, err := svc.DescribeEvaluations(params)
28+
if err != nil {
29+
return nil, err
30+
}
31+
32+
for _, result := range output.Results {
33+
resources = append(resources, &MachineLearningEvaluation{
34+
svc: svc,
35+
ID: result.EvaluationId,
36+
})
37+
}
38+
39+
if output.NextToken == nil {
40+
break
41+
}
42+
43+
params.NextToken = output.NextToken
44+
}
45+
46+
return resources, nil
47+
}
48+
49+
func (f *MachineLearningEvaluation) Remove() error {
50+
51+
_, err := f.svc.DeleteEvaluation(&machinelearning.DeleteEvaluationInput{
52+
EvaluationId: f.ID,
53+
})
54+
55+
return err
56+
}
57+
58+
func (f *MachineLearningEvaluation) String() string {
59+
return *f.ID
60+
}

resources/machinelearning-mlmodels.go

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package resources
2+
3+
import (
4+
"github.com/aws/aws-sdk-go/aws"
5+
"github.com/aws/aws-sdk-go/aws/session"
6+
"github.com/aws/aws-sdk-go/service/machinelearning"
7+
)
8+
9+
type MachineLearningMLModel struct {
10+
svc *machinelearning.MachineLearning
11+
ID *string
12+
}
13+
14+
func init() {
15+
register("MachineLearningMLModel", ListMachineLearningMLModels)
16+
}
17+
18+
func ListMachineLearningMLModels(sess *session.Session) ([]Resource, error) {
19+
svc := machinelearning.New(sess)
20+
resources := []Resource{}
21+
22+
params := &machinelearning.DescribeMLModelsInput{
23+
Limit: aws.Int64(100),
24+
}
25+
26+
for {
27+
output, err := svc.DescribeMLModels(params)
28+
if err != nil {
29+
return nil, err
30+
}
31+
32+
for _, result := range output.Results {
33+
resources = append(resources, &MachineLearningMLModel{
34+
svc: svc,
35+
ID: result.MLModelId,
36+
})
37+
}
38+
39+
if output.NextToken == nil {
40+
break
41+
}
42+
43+
params.NextToken = output.NextToken
44+
}
45+
46+
return resources, nil
47+
}
48+
49+
func (f *MachineLearningMLModel) Remove() error {
50+
51+
_, err := f.svc.DeleteMLModel(&machinelearning.DeleteMLModelInput{
52+
MLModelId: f.ID,
53+
})
54+
55+
return err
56+
}
57+
58+
func (f *MachineLearningMLModel) String() string {
59+
return *f.ID
60+
}

0 commit comments

Comments
 (0)