-
Notifications
You must be signed in to change notification settings - Fork 501
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(aws): Support AWS Account Contacts (#4734)
#### Summary <!-- Explain what problem this PR addresses --> <!--
- Loading branch information
Showing
18 changed files
with
455 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,46 @@ | ||
package recipes | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go-v2/service/account/types" | ||
"github.com/cloudquery/plugin-sdk/codegen" | ||
"github.com/cloudquery/plugin-sdk/schema" | ||
) | ||
|
||
func AccountResources() []*Resource { | ||
resources := []*Resource{ | ||
{ | ||
SubService: "alternate_contacts", | ||
Struct: &types.AlternateContact{}, | ||
Description: "https://docs.aws.amazon.com/accounts/latest/reference/API_AlternateContact.html", | ||
PKColumns: []string{"alternate_contact_type"}, | ||
ExtraColumns: []codegen.ColumnDefinition{ | ||
{ | ||
Name: "account_id", | ||
Type: schema.TypeString, | ||
Resolver: "client.ResolveAWSAccount", | ||
Options: schema.ColumnCreationOptions{PrimaryKey: true}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
SubService: "contacts", | ||
Struct: &types.ContactInformation{}, | ||
Description: "https://docs.aws.amazon.com/accounts/latest/reference/API_ContactInformation.html", | ||
ExtraColumns: []codegen.ColumnDefinition{ | ||
{ | ||
Name: "account_id", | ||
Type: schema.TypeString, | ||
Resolver: "client.ResolveAWSAccount", | ||
Options: schema.ColumnCreationOptions{PrimaryKey: true}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
for _, r := range resources { | ||
r.Service = "account" | ||
r.Multiplex = `client.AccountMultiplex` | ||
|
||
} | ||
return resources | ||
} |
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
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
20 changes: 20 additions & 0 deletions
20
plugins/source/aws/docs/tables/aws_account_alternate_contacts.md
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,20 @@ | ||
# Table: aws_account_alternate_contacts | ||
|
||
https://docs.aws.amazon.com/accounts/latest/reference/API_AlternateContact.html | ||
|
||
The composite primary key for this table is (**account_id**, **alternate_contact_type**). | ||
|
||
|
||
## Columns | ||
| Name | Type | | ||
| ------------- | ------------- | | ||
|_cq_source_name|String| | ||
|_cq_sync_time|Timestamp| | ||
|_cq_id|UUID| | ||
|_cq_parent_id|UUID| | ||
|account_id (PK)|String| | ||
|alternate_contact_type (PK)|String| | ||
|email_address|String| | ||
|name|String| | ||
|phone_number|String| | ||
|title|String| |
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,27 @@ | ||
# Table: aws_account_contacts | ||
|
||
https://docs.aws.amazon.com/accounts/latest/reference/API_ContactInformation.html | ||
|
||
The primary key for this table is **account_id**. | ||
|
||
|
||
## Columns | ||
| Name | Type | | ||
| ------------- | ------------- | | ||
|_cq_source_name|String| | ||
|_cq_sync_time|Timestamp| | ||
|_cq_id|UUID| | ||
|_cq_parent_id|UUID| | ||
|account_id (PK)|String| | ||
|address_line1|String| | ||
|city|String| | ||
|country_code|String| | ||
|full_name|String| | ||
|phone_number|String| | ||
|postal_code|String| | ||
|address_line2|String| | ||
|address_line3|String| | ||
|company_name|String| | ||
|district_or_county|String| | ||
|state_or_region|String| | ||
|website_url|String| |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
55 changes: 55 additions & 0 deletions
55
plugins/source/aws/resources/services/account/alternate_contacts.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
plugins/source/aws/resources/services/account/alternate_contacts_fetch.go
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,26 @@ | ||
package account | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/aws/aws-sdk-go-v2/service/account" | ||
"github.com/aws/aws-sdk-go-v2/service/account/types" | ||
"github.com/cloudquery/cloudquery/plugins/source/aws/client" | ||
"github.com/cloudquery/plugin-sdk/schema" | ||
) | ||
|
||
func fetchAccountAlternateContacts(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { | ||
cl := meta.(*client.Client) | ||
svc := cl.Services().Account | ||
var contactTypes types.AlternateContactType | ||
for _, acType := range contactTypes.Values() { | ||
var input account.GetAlternateContactInput | ||
input.AlternateContactType = acType | ||
output, err := svc.GetAlternateContact(ctx, &input) | ||
if err != nil { | ||
return err | ||
} | ||
res <- output.AlternateContact | ||
} | ||
return nil | ||
} |
35 changes: 35 additions & 0 deletions
35
plugins/source/aws/resources/services/account/alternate_contacts_mock_test.go
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,35 @@ | ||
package account | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/aws/aws-sdk-go-v2/service/account" | ||
"github.com/aws/aws-sdk-go-v2/service/account/types" | ||
"github.com/cloudquery/cloudquery/plugins/source/aws/client" | ||
"github.com/cloudquery/cloudquery/plugins/source/aws/client/mocks" | ||
"github.com/cloudquery/plugin-sdk/faker" | ||
"github.com/golang/mock/gomock" | ||
) | ||
|
||
func buildAlternateContacts(t *testing.T, ctrl *gomock.Controller) client.Services { | ||
mock := mocks.NewMockAccountClient(ctrl) | ||
|
||
var ac types.AlternateContact | ||
if err := faker.FakeObject(&ac); err != nil { | ||
t.Fatal(err) | ||
} | ||
mock.EXPECT().GetAlternateContact( | ||
gomock.Any(), | ||
gomock.Any(), | ||
gomock.Any(), | ||
).Return( | ||
&account.GetAlternateContactOutput{AlternateContact: &ac}, | ||
nil, | ||
).MinTimes(1) | ||
|
||
return client.Services{Account: mock} | ||
} | ||
|
||
func TestAlternateContacts(t *testing.T) { | ||
client.AwsMockTestHelper(t, AlternateContacts(), buildAlternateContacts, client.TestOptions{}) | ||
} |
Oops, something went wrong.