|
| 1 | +package resources |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/aws/aws-sdk-go/aws/session" |
| 5 | + "github.com/aws/aws-sdk-go/service/codegurureviewer" |
| 6 | + "github.com/rebuy-de/aws-nuke/v2/pkg/types" |
| 7 | +) |
| 8 | + |
| 9 | +type CodeGuruReviewerRepositoryAssociation struct { |
| 10 | + svc *codegurureviewer.CodeGuruReviewer |
| 11 | + AssociationArn *string |
| 12 | + AssociationId *string |
| 13 | + Name *string |
| 14 | + Owner *string |
| 15 | + ProviderType *string |
| 16 | +} |
| 17 | + |
| 18 | +func init() { |
| 19 | + register("CodeGuruReviewerRepositoryAssociation", ListCodeGuruReviewerRepositoryAssociations, |
| 20 | + mapCloudControl("AWS::CodeGuruReviewer::RepositoryAssociation")) |
| 21 | +} |
| 22 | + |
| 23 | +func ListCodeGuruReviewerRepositoryAssociations(sess *session.Session) ([]Resource, error) { |
| 24 | + svc := codegurureviewer.New(sess) |
| 25 | + resources := []Resource{} |
| 26 | + |
| 27 | + params := &codegurureviewer.ListRepositoryAssociationsInput{} |
| 28 | + |
| 29 | + for { |
| 30 | + resp, err := svc.ListRepositoryAssociations(params) |
| 31 | + if err != nil { |
| 32 | + return nil, err |
| 33 | + } |
| 34 | + |
| 35 | + for _, association := range resp.RepositoryAssociationSummaries { |
| 36 | + resources = append(resources, &CodeGuruReviewerRepositoryAssociation{ |
| 37 | + svc: svc, |
| 38 | + AssociationArn: association.AssociationArn, |
| 39 | + AssociationId: association.AssociationId, |
| 40 | + Name: association.Name, |
| 41 | + Owner: association.Owner, |
| 42 | + ProviderType: association.ProviderType, |
| 43 | + }) |
| 44 | + } |
| 45 | + |
| 46 | + if resp.NextToken == nil { |
| 47 | + break |
| 48 | + } |
| 49 | + |
| 50 | + params.NextToken = resp.NextToken |
| 51 | + } |
| 52 | + |
| 53 | + return resources, nil |
| 54 | +} |
| 55 | + |
| 56 | +func (f *CodeGuruReviewerRepositoryAssociation) Remove() error { |
| 57 | + _, err := f.svc.DisassociateRepository(&codegurureviewer.DisassociateRepositoryInput{ |
| 58 | + AssociationArn: f.AssociationArn, |
| 59 | + }) |
| 60 | + return err |
| 61 | +} |
| 62 | + |
| 63 | +func (f *CodeGuruReviewerRepositoryAssociation) Properties() types.Properties { |
| 64 | + properties := types.NewProperties() |
| 65 | + properties. |
| 66 | + Set("AssociationArn", f.AssociationArn) |
| 67 | + properties.Set("AssociationId", f.AssociationId) |
| 68 | + properties.Set("Name", f.Name) |
| 69 | + properties.Set("Owner", f.Owner) |
| 70 | + properties.Set("ProviderType", f.ProviderType) |
| 71 | + return properties |
| 72 | +} |
0 commit comments