-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #324 from ekristen/rebuy-1023
feat(resource): implements gamelift and pinpoint
- Loading branch information
Showing
11 changed files
with
11,689 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
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" | ||
) | ||
|
||
const GameLiftBuildResource = "GameLiftBuild" | ||
|
||
func init() { | ||
registry.Register(®istry.Registration{ | ||
Name: GameLiftBuildResource, | ||
Scope: nuke.Account, | ||
Lister: &GameLiftBuildLister{}, | ||
}) | ||
} | ||
|
||
type GameLiftBuildLister struct{} | ||
|
||
func (l *GameLiftBuildLister) List(_ context.Context, o interface{}) ([]resource.Resource, error) { | ||
opts := o.(*nuke.ListerOpts) | ||
var resources []resource.Resource | ||
|
||
svc := gamelift.New(opts.Session) | ||
|
||
params := &gamelift.ListBuildsInput{} | ||
|
||
for { | ||
resp, err := svc.ListBuilds(params) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
for _, build := range resp.Builds { | ||
resources = append(resources, &GameLiftBuild{ | ||
svc: svc, | ||
BuildID: build.BuildId, | ||
Name: build.Name, | ||
Status: build.Status, | ||
Version: build.Version, | ||
CreationDate: build.CreationTime, | ||
}) | ||
} | ||
|
||
if resp.NextToken == nil { | ||
break | ||
} | ||
|
||
params.NextToken = resp.NextToken | ||
} | ||
|
||
return resources, nil | ||
} | ||
|
||
type GameLiftBuild struct { | ||
svc *gamelift.GameLift | ||
BuildID *string | ||
Name *string | ||
Status *string | ||
Version *string | ||
CreationDate *time.Time | ||
} | ||
|
||
func (r *GameLiftBuild) Remove(_ context.Context) error { | ||
params := &gamelift.DeleteBuildInput{ | ||
BuildId: r.BuildID, | ||
} | ||
|
||
_, err := r.svc.DeleteBuild(params) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (r *GameLiftBuild) Properties() types.Properties { | ||
return types.NewPropertiesFromStruct(r) | ||
} | ||
|
||
func (r *GameLiftBuild) String() string { | ||
return *r.BuildID | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package resources | ||
|
||
import ( | ||
"context" | ||
|
||
"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" | ||
) | ||
|
||
const GameLiftFleetResource = "GameLiftFleet" | ||
|
||
func init() { | ||
registry.Register(®istry.Registration{ | ||
Name: GameLiftFleetResource, | ||
Scope: nuke.Account, | ||
Lister: &GameLiftFleetLister{}, | ||
}) | ||
} | ||
|
||
type GameLiftFleetLister struct{} | ||
|
||
func (l *GameLiftFleetLister) List(_ context.Context, o interface{}) ([]resource.Resource, error) { | ||
opts := o.(*nuke.ListerOpts) | ||
var resources []resource.Resource | ||
|
||
svc := gamelift.New(opts.Session) | ||
|
||
params := &gamelift.ListFleetsInput{} | ||
|
||
for { | ||
resp, err := svc.ListFleets(params) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
for _, fleetID := range resp.FleetIds { | ||
fleet := &GameLiftFleet{ | ||
svc: svc, | ||
FleetID: fleetID, | ||
} | ||
resources = append(resources, fleet) | ||
} | ||
|
||
if resp.NextToken == nil { | ||
break | ||
} | ||
|
||
params.NextToken = resp.NextToken | ||
} | ||
|
||
return resources, nil | ||
} | ||
|
||
type GameLiftFleet struct { | ||
svc *gamelift.GameLift | ||
FleetID *string | ||
} | ||
|
||
func (r *GameLiftFleet) Remove(_ context.Context) error { | ||
params := &gamelift.DeleteFleetInput{ | ||
FleetId: r.FleetID, | ||
} | ||
|
||
_, err := r.svc.DeleteFleet(params) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (r *GameLiftFleet) String() string { | ||
return *r.FleetID | ||
} | ||
|
||
func (r *GameLiftFleet) Properties() types.Properties { | ||
return types.NewPropertiesFromStruct(r) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
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" | ||
) | ||
|
||
const GameLiftMatchmakingConfigurationResource = "GameLiftMatchmakingConfiguration" | ||
|
||
func init() { | ||
registry.Register(®istry.Registration{ | ||
Name: GameLiftMatchmakingConfigurationResource, | ||
Scope: nuke.Account, | ||
Lister: &GameLiftMatchmakingConfigurationLister{}, | ||
}) | ||
} | ||
|
||
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) | ||
|
||
params := &gamelift.DescribeMatchmakingConfigurationsInput{} | ||
|
||
for { | ||
resp, err := svc.DescribeMatchmakingConfigurations(params) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
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 resources, nil | ||
} | ||
|
||
type GameLiftMatchmakingConfiguration struct { | ||
svc *gamelift.GameLift | ||
Name *string | ||
CreationTime *time.Time | ||
} | ||
|
||
func (r *GameLiftMatchmakingConfiguration) Remove(_ context.Context) error { | ||
params := &gamelift.DeleteMatchmakingConfigurationInput{ | ||
Name: r.Name, | ||
} | ||
|
||
_, err := r.svc.DeleteMatchmakingConfiguration(params) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (r *GameLiftMatchmakingConfiguration) Properties() types.Properties { | ||
return types.NewPropertiesFromStruct(r) | ||
} | ||
|
||
func (r *GameLiftMatchmakingConfiguration) String() string { | ||
return *r.Name | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package resources | ||
|
||
import ( | ||
"context" | ||
|
||
"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" | ||
) | ||
|
||
const GameLiftMatchmakingRuleSetResource = "GameLiftMatchmakingRuleSet" | ||
|
||
func init() { | ||
registry.Register(®istry.Registration{ | ||
Name: GameLiftMatchmakingRuleSetResource, | ||
Scope: nuke.Account, | ||
Lister: &GameLiftMatchmakingRuleSetLister{}, | ||
}) | ||
} | ||
|
||
type GameLiftMatchmakingRuleSetLister struct{} | ||
|
||
func (l *GameLiftMatchmakingRuleSetLister) List(_ context.Context, o interface{}) ([]resource.Resource, error) { | ||
opts := o.(*nuke.ListerOpts) | ||
var resources []resource.Resource | ||
|
||
svc := gamelift.New(opts.Session) | ||
|
||
params := &gamelift.DescribeMatchmakingRuleSetsInput{} | ||
|
||
for { | ||
resp, err := svc.DescribeMatchmakingRuleSets(params) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
for _, ruleSet := range resp.RuleSets { | ||
q := &GameLiftMatchmakingRuleSet{ | ||
svc: svc, | ||
Name: ruleSet.RuleSetName, | ||
} | ||
resources = append(resources, q) | ||
} | ||
|
||
if resp.NextToken == nil { | ||
break | ||
} | ||
|
||
params.NextToken = resp.NextToken | ||
} | ||
|
||
return resources, nil | ||
} | ||
|
||
type GameLiftMatchmakingRuleSet struct { | ||
svc *gamelift.GameLift | ||
Name *string | ||
} | ||
|
||
func (r *GameLiftMatchmakingRuleSet) Remove(_ context.Context) error { | ||
params := &gamelift.DeleteMatchmakingRuleSetInput{ | ||
Name: r.Name, | ||
} | ||
|
||
_, err := r.svc.DeleteMatchmakingRuleSet(params) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (r *GameLiftMatchmakingRuleSet) Properties() types.Properties { | ||
return types.NewPropertiesFromStruct(r) | ||
} | ||
|
||
func (r *GameLiftMatchmakingRuleSet) String() string { | ||
return *r.Name | ||
} |
Oops, something went wrong.