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

Add Machinelearning Cleanup #132

Merged
merged 1 commit into from
Mar 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions resources/machinelearning-batchpredictions.go
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/machinelearning"
)

type MachineLearningBranchPrediction struct {
svc *machinelearning.MachineLearning
ID *string
}

func init() {
register("MachineLearningBranchPrediction", ListMachineLearningBranchPredictions)
}

func ListMachineLearningBranchPredictions(sess *session.Session) ([]Resource, error) {
svc := machinelearning.New(sess)
resources := []Resource{}

params := &machinelearning.DescribeBatchPredictionsInput{
Limit: aws.Int64(100),
}

for {
output, err := svc.DescribeBatchPredictions(params)
if err != nil {
return nil, err
}

for _, result := range output.Results {
resources = append(resources, &MachineLearningBranchPrediction{
svc: svc,
ID: result.BatchPredictionId,
})
}

if output.NextToken == nil {
break
}

params.NextToken = output.NextToken
}

return resources, nil
}

func (f *MachineLearningBranchPrediction) Remove() error {

_, err := f.svc.DeleteBatchPrediction(&machinelearning.DeleteBatchPredictionInput{
BatchPredictionId: f.ID,
})

return err
}

func (f *MachineLearningBranchPrediction) String() string {
return *f.ID
}
60 changes: 60 additions & 0 deletions resources/machinelearning-datasources.go
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/machinelearning"
)

type MachineLearningDataSource struct {
svc *machinelearning.MachineLearning
ID *string
}

func init() {
register("MachineLearningDataSource", ListMachineLearningDataSources)
}

func ListMachineLearningDataSources(sess *session.Session) ([]Resource, error) {
svc := machinelearning.New(sess)
resources := []Resource{}

params := &machinelearning.DescribeDataSourcesInput{
Limit: aws.Int64(100),
}

for {
output, err := svc.DescribeDataSources(params)
if err != nil {
return nil, err
}

for _, result := range output.Results {
resources = append(resources, &MachineLearningDataSource{
svc: svc,
ID: result.DataSourceId,
})
}

if output.NextToken == nil {
break
}

params.NextToken = output.NextToken
}

return resources, nil
}

func (f *MachineLearningDataSource) Remove() error {

_, err := f.svc.DeleteDataSource(&machinelearning.DeleteDataSourceInput{
DataSourceId: f.ID,
})

return err
}

func (f *MachineLearningDataSource) String() string {
return *f.ID
}
60 changes: 60 additions & 0 deletions resources/machinelearning-evaluations.go
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/machinelearning"
)

type MachineLearningEvaluation struct {
svc *machinelearning.MachineLearning
ID *string
}

func init() {
register("MachineLearningEvaluation", ListMachineLearningEvaluations)
}

func ListMachineLearningEvaluations(sess *session.Session) ([]Resource, error) {
svc := machinelearning.New(sess)
resources := []Resource{}

params := &machinelearning.DescribeEvaluationsInput{
Limit: aws.Int64(100),
}

for {
output, err := svc.DescribeEvaluations(params)
if err != nil {
return nil, err
}

for _, result := range output.Results {
resources = append(resources, &MachineLearningEvaluation{
svc: svc,
ID: result.EvaluationId,
})
}

if output.NextToken == nil {
break
}

params.NextToken = output.NextToken
}

return resources, nil
}

func (f *MachineLearningEvaluation) Remove() error {

_, err := f.svc.DeleteEvaluation(&machinelearning.DeleteEvaluationInput{
EvaluationId: f.ID,
})

return err
}

func (f *MachineLearningEvaluation) String() string {
return *f.ID
}
60 changes: 60 additions & 0 deletions resources/machinelearning-mlmodels.go
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/machinelearning"
)

type MachineLearningMLModel struct {
svc *machinelearning.MachineLearning
ID *string
}

func init() {
register("MachineLearningMLModel", ListMachineLearningMLModels)
}

func ListMachineLearningMLModels(sess *session.Session) ([]Resource, error) {
svc := machinelearning.New(sess)
resources := []Resource{}

params := &machinelearning.DescribeMLModelsInput{
Limit: aws.Int64(100),
}

for {
output, err := svc.DescribeMLModels(params)
if err != nil {
return nil, err
}

for _, result := range output.Results {
resources = append(resources, &MachineLearningMLModel{
svc: svc,
ID: result.MLModelId,
})
}

if output.NextToken == nil {
break
}

params.NextToken = output.NextToken
}

return resources, nil
}

func (f *MachineLearningMLModel) Remove() error {

_, err := f.svc.DeleteMLModel(&machinelearning.DeleteMLModelInput{
MLModelId: f.ID,
})

return err
}

func (f *MachineLearningMLModel) String() string {
return *f.ID
}