Skip to content

Commit

Permalink
feat(resource-explorer2-index): add properties
Browse files Browse the repository at this point in the history
  • Loading branch information
ekristen committed Dec 23, 2024
1 parent e457ef3 commit aa8a6ff
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions resources/resource-explorer2-index.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ package resources

import (
"context"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/resourceexplorer2"
"github.com/ekristen/aws-nuke/v3/pkg/nuke"

"github.com/ekristen/libnuke/pkg/registry"
"github.com/ekristen/libnuke/pkg/resource"
"github.com/ekristen/libnuke/pkg/types"

"github.com/ekristen/aws-nuke/v3/pkg/nuke"
)

const ResourceExplorer2IndexResource = "ResourceExplorer2Index"
Expand All @@ -22,11 +26,6 @@ func init() {

type ResourceExplorer2IndexLister struct{}

type ResourceExplorer2Index struct {
svc *resourceexplorer2.ResourceExplorer2
indexArn *string
}

func (l *ResourceExplorer2IndexLister) List(_ context.Context, o interface{}) ([]resource.Resource, error) {
opts := o.(*nuke.ListerOpts)
svc := resourceexplorer2.New(opts.Session)
Expand All @@ -45,8 +44,9 @@ func (l *ResourceExplorer2IndexLister) List(_ context.Context, o interface{}) ([

for _, index := range output.Indexes {
resources = append(resources, &ResourceExplorer2Index{
svc: svc,
indexArn: index.Arn,
svc: svc,
ARN: index.Arn,
Type: index.Type,
})
}

Expand All @@ -60,14 +60,24 @@ func (l *ResourceExplorer2IndexLister) List(_ context.Context, o interface{}) ([
return resources, nil
}

type ResourceExplorer2Index struct {
svc *resourceexplorer2.ResourceExplorer2
ARN *string
Type *string
}

func (r *ResourceExplorer2Index) Remove(_ context.Context) error {
_, err := r.svc.DeleteIndex(&resourceexplorer2.DeleteIndexInput{
Arn: r.indexArn,
Arn: r.ARN,
})

return err
}

func (r *ResourceExplorer2Index) String() string {
return *r.indexArn
return *r.ARN
}

func (r *ResourceExplorer2Index) Properties() types.Properties {
return types.NewPropertiesFromStruct(r)
}

0 comments on commit aa8a6ff

Please sign in to comment.