Skip to content

Commit

Permalink
refactor(integration): make space for New() funcs
Browse files Browse the repository at this point in the history
This commit is making space to have different integration functions
like:
```go
// NewAwsConfigIntegration for Config
func NewAwsConfigIntegration() {}

// NewAwsCloudTrailIntegration for CloudTrail
func NewAwsCloudTrailIntegration() {}
```

Signed-off-by: Salim Afiune Maya <[email protected]>
  • Loading branch information
afiune committed Mar 20, 2020
1 parent 1aaec6c commit 1da9746
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 32 deletions.
22 changes: 11 additions & 11 deletions api/integrations_aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@

package api

// NewAwsIntegration returns an instance of awsIntegration
// NewAwsConfigIntegration returns an instance of awsConfigIntegration
//
// Basic usage: Initialize a new awsIntegration struct, then
// Basic usage: Initialize a new awsConfigIntegration struct, then
// use the new instance to do CRUD operations
//
// aws, err := api.NewAwsIntegration("foo",
// aws, err := api.NewAwsConfigIntegration("foo",
// api.AwsIntegrationData{
// Credentials: api.AwsIntegrationCreds {
// RoleArn: "arn:aws:XYZ",
Expand All @@ -40,8 +40,8 @@ package api
// return err
// }
//
func NewAwsIntegration(name string, data AwsIntegrationData) awsIntegration {
return awsIntegration{
func NewAwsConfigIntegration(name string, data AwsIntegrationData) awsConfigIntegration {
return awsConfigIntegration{
commonIntegrationData: commonIntegrationData{
Name: name,
Type: AwsCfgIntegration.String(),
Expand All @@ -52,7 +52,7 @@ func NewAwsIntegration(name string, data AwsIntegrationData) awsIntegration {
}

// CreateAwsConfigIntegration creates a single AWS_CFG integration on the Lacework Server
func (c *Client) CreateAwsConfigIntegration(integration awsIntegration) (response awsIntegrationsResponse, err error) {
func (c *Client) CreateAwsConfigIntegration(integration awsConfigIntegration) (response awsIntegrationsResponse, err error) {
err = c.createIntegration(integration, &response)
return
}
Expand All @@ -64,7 +64,7 @@ func (c *Client) GetAwsConfigIntegration(intgGuid string) (response awsIntegrati
}

// UpdateAwsConfigIntegration updates a single AWS_CFG integration on the Lacework Server
func (c *Client) UpdateAwsConfigIntegration(data awsIntegration) (response awsIntegrationsResponse, err error) {
func (c *Client) UpdateAwsConfigIntegration(data awsConfigIntegration) (response awsIntegrationsResponse, err error) {
err = c.updateIntegration(data.IntgGuid, data, &response)
return
}
Expand All @@ -80,12 +80,12 @@ func (c *Client) GetAwsIntegrations() (response awsIntegrationsResponse, err err
}

type awsIntegrationsResponse struct {
Data []awsIntegration `json:"data"`
Ok bool `json:"ok"`
Message string `json:"message"`
Data []awsConfigIntegration `json:"data"`
Ok bool `json:"ok"`
Message string `json:"message"`
}

type awsIntegration struct {
type awsConfigIntegration struct {
commonIntegrationData
Data AwsIntegrationData `json:"DATA"`
}
Expand Down
18 changes: 9 additions & 9 deletions api/integrations_azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@

package api

// NewAzureIntegration returns an instance of azureIntegration
// NewAzureConfigIntegration returns an instance of azureConfigIntegration
//
// Basic usage: Initialize a new azureIntegration struct, then
// Basic usage: Initialize a new azureConfigIntegration struct, then
// use the new instance to do CRUD operations
//
// azure, err := api.NewAzureIntegration("bar",
// azure, err := api.NewAzureConfigIntegration("bar",
// api.AzureIntegrationData{},
// )
// if err != nil {
Expand All @@ -35,8 +35,8 @@ package api
// return err
// }
//
func NewAzureIntegration(name string, data AzureIntegrationData) azureIntegration {
return azureIntegration{
func NewAzureConfigIntegration(name string, data AzureIntegrationData) azureConfigIntegration {
return azureConfigIntegration{
commonIntegrationData: commonIntegrationData{
Name: name,
Type: AzureCfgIntegration.String(),
Expand All @@ -51,12 +51,12 @@ func (c *Client) GetAzureIntegrations() (response azureIntegrationsResponse, err
}

type azureIntegrationsResponse struct {
Data []azureIntegration `json:"data"`
Ok bool `json:"ok"`
Message string `json:"message"`
Data []azureConfigIntegration `json:"data"`
Ok bool `json:"ok"`
Message string `json:"message"`
}

type azureIntegration struct {
type azureConfigIntegration struct {
commonIntegrationData
Data AzureIntegrationData `json:"DATA"`
}
Expand Down
23 changes: 11 additions & 12 deletions api/integrations_gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ func (g gcpResourceLevel) String() string {
return gcpResourceLevels[g]
}

// NewGcpIntegration returns an instance of gcpIntegration
// NewGcpConfigIntegration returns an instance of gcpConfigIntegration
//
// Basic usage: Initialize a new gcpIntegration struct, then
// Basic usage: Initialize a new gcpConfigIntegration struct, then
// use the new instance to do CRUD operations
//
// gcp, err := api.NewGcpIntegration("abc",
// gcp, err := api.NewGcpConfigIntegration("abc",
// api.GcpIntegrationData{
// ID: "1234",
// Credentials: api.GcpCredentials{
Expand All @@ -63,8 +63,8 @@ func (g gcpResourceLevel) String() string {
// return err
// }
//
func NewGcpIntegration(name string, data GcpIntegrationData) gcpIntegration {
return gcpIntegration{
func NewGcpConfigIntegration(name string, data GcpIntegrationData) gcpConfigIntegration {
return gcpConfigIntegration{
commonIntegrationData: commonIntegrationData{
Name: name,
Type: GcpCfgIntegration.String(),
Expand All @@ -75,7 +75,7 @@ func NewGcpIntegration(name string, data GcpIntegrationData) gcpIntegration {
}

// CreateGcpConfigIntegration creates a single GCP_CFG integration on the Lacework Server
func (c *Client) CreateGcpConfigIntegration(data gcpIntegration) (response gcpIntegrationsResponse, err error) {
func (c *Client) CreateGcpConfigIntegration(data gcpConfigIntegration) (response gcpIntegrationsResponse, err error) {
err = c.createIntegration(data, &response)
return
}
Expand All @@ -87,7 +87,7 @@ func (c *Client) GetGcpConfigIntegration(intgGuid string) (response gcpIntegrati
}

// UpdateGcpConfigIntegration updates a single integration on the server
func (c *Client) UpdateGcpConfigIntegration(data gcpIntegration) (response gcpIntegrationsResponse, err error) {
func (c *Client) UpdateGcpConfigIntegration(data gcpConfigIntegration) (response gcpIntegrationsResponse, err error) {
err = c.updateIntegration(data.IntgGuid, data, &response)
return
}
Expand All @@ -103,20 +103,19 @@ func (c *Client) GetGcpIntegrations() (response gcpIntegrationsResponse, err err
}

type gcpIntegrationsResponse struct {
Data []gcpIntegration `json:"data"`
Ok bool `json:"ok"`
Message string `json:"message"`
Data []gcpConfigIntegration `json:"data"`
Ok bool `json:"ok"`
Message string `json:"message"`
}

type gcpIntegration struct {
type gcpConfigIntegration struct {
commonIntegrationData
Data GcpIntegrationData `json:"DATA"`
}

type GcpIntegrationData struct {
ID string `json:"ID"`
IdType string `json:"ID_TYPE"`
IssueGrouping string `json:"ISSUE_GROUPING,omitempty"`
Credentials GcpCredentials `json:"CREDENTIALS"`
SubscriptionName string `json:"SUBSCRIPTION_NAME,omitempty"`
}
Expand Down

0 comments on commit 1da9746

Please sign in to comment.