From aa8a6ffdec287f996b5a4dc7c12d1d3a24fb2865 Mon Sep 17 00:00:00 2001 From: Erik Kristensen Date: Mon, 23 Dec 2024 12:17:15 -0700 Subject: [PATCH] feat(resource-explorer2-index): add properties --- resources/resource-explorer2-index.go | 30 ++++++++++++++++++--------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/resources/resource-explorer2-index.go b/resources/resource-explorer2-index.go index 03cb03e3..06a5ea4c 100644 --- a/resources/resource-explorer2-index.go +++ b/resources/resource-explorer2-index.go @@ -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" @@ -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) @@ -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, }) } @@ -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) }