Skip to content

Commit

Permalink
feat(gamelift-mm-config): add properties and pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
ekristen committed Sep 26, 2024
1 parent 93e7720 commit 14db660
Showing 1 changed file with 31 additions and 13 deletions.
44 changes: 31 additions & 13 deletions resources/gamelift-mm-config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package resources

import (
"context"
"time"

"github.com/aws/aws-sdk-go/service/gamelift"

"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"
)
Expand All @@ -25,29 +27,41 @@ type GameLiftMatchmakingConfigurationLister struct{}

func (l *GameLiftMatchmakingConfigurationLister) List(_ context.Context, o interface{}) ([]resource.Resource, error) {
opts := o.(*nuke.ListerOpts)
var resources []resource.Resource

svc := gamelift.New(opts.Session)

resp, err := svc.DescribeMatchmakingConfigurations(&gamelift.DescribeMatchmakingConfigurationsInput{})
if err != nil {
return nil, err
}
params := &gamelift.DescribeMatchmakingConfigurationsInput{}

configs := make([]resource.Resource, 0)
for _, config := range resp.Configurations {
q := &GameLiftMatchmakingConfiguration{
svc: svc,
Name: config.Name,
for {
resp, err := svc.DescribeMatchmakingConfigurations(params)
if err != nil {
return nil, err
}
configs = append(configs, q)

for _, config := range resp.Configurations {
q := &GameLiftMatchmakingConfiguration{
svc: svc,
Name: config.Name,
CreationTime: config.CreationTime,
}
resources = append(resources, q)
}

if resp.NextToken == nil {
break
}

params.NextToken = resp.NextToken
}

return configs, nil
return resources, nil
}

type GameLiftMatchmakingConfiguration struct {
svc *gamelift.GameLift
Name *string
svc *gamelift.GameLift
Name *string
CreationTime *time.Time
}

func (r *GameLiftMatchmakingConfiguration) Remove(_ context.Context) error {
Expand All @@ -63,6 +77,10 @@ func (r *GameLiftMatchmakingConfiguration) Remove(_ context.Context) error {
return nil
}

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

func (r *GameLiftMatchmakingConfiguration) String() string {
return *r.Name
}

0 comments on commit 14db660

Please sign in to comment.