Skip to content

Commit db76315

Browse files
ParthaImisraved
andauthored
Add tables aws_quicksight_user, aws_quicksight_namespace, aws_quicksight_group, aws_quicksight_data_source, aws_quicksight_data_set, aws_quicksight_vpc_connection and aws_quicksight_account_settings Closes #2457 (#2467)
Co-authored-by: Ved misra <47312748+misraved@users.noreply.github.com>
1 parent b92675f commit db76315

18 files changed

Lines changed: 2624 additions & 3 deletions

aws/plugin.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,13 @@ func Plugin(ctx context.Context) *plugin.Plugin {
409409
"aws_pipes_pipe": tableAwsPipes(ctx),
410410
"aws_pricing_product": tableAwsPricingProduct(ctx),
411411
"aws_pricing_service_attribute": tableAwsPricingServiceAttribute(ctx),
412+
"aws_quicksight_account_setting": tableAwsQuickSightAccountSetting(ctx),
413+
"aws_quicksight_data_set": tableAwsQuickSightDataset(ctx),
414+
"aws_quicksight_data_source": tableAwsQuickSightDatasource(ctx),
415+
"aws_quicksight_group": tableAwsQuickSightGroup(ctx),
416+
"aws_quicksight_namespace": tableAwsQuickSightNamespace(ctx),
417+
"aws_quicksight_user": tableAwsQuickSightUser(ctx),
418+
"aws_quicksight_vpc_connection": tableAwsQuickSightVpcConnection(ctx),
412419
"aws_ram_principal_association": tableAwsRAMPrincipalAssociation(ctx),
413420
"aws_ram_resource_association": tableAwsRAMResourceAssociation(ctx),
414421
"aws_rds_db_cluster": tableAwsRDSDBCluster(ctx),

aws/service.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ import (
107107
"github.com/aws/aws-sdk-go-v2/service/pinpoint"
108108
"github.com/aws/aws-sdk-go-v2/service/pipes"
109109
"github.com/aws/aws-sdk-go-v2/service/pricing"
110+
"github.com/aws/aws-sdk-go-v2/service/quicksight"
110111
"github.com/aws/aws-sdk-go-v2/service/ram"
111112
"github.com/aws/aws-sdk-go-v2/service/rds"
112113
"github.com/aws/aws-sdk-go-v2/service/redshift"
@@ -1187,6 +1188,15 @@ func PricingClient(ctx context.Context, d *plugin.QueryData) (*pricing.Client, e
11871188
return pricing.NewFromConfig(*cfg), nil
11881189
}
11891190

1191+
// QuickSightClient returns the client for the Amazon QuickSight service
1192+
func QuickSightClient(ctx context.Context, d *plugin.QueryData) (*quicksight.Client, error) {
1193+
cfg, err := getClientForQueryRegion(ctx, d)
1194+
if err != nil {
1195+
return nil, err
1196+
}
1197+
return quicksight.NewFromConfig(*cfg), nil
1198+
}
1199+
11901200
func RAMClient(ctx context.Context, d *plugin.QueryData) (*ram.Client, error) {
11911201
cfg, err := getClientForQueryRegion(ctx, d)
11921202
if err != nil {
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
package aws
2+
3+
import (
4+
"context"
5+
6+
"github.com/aws/aws-sdk-go-v2/aws"
7+
"github.com/aws/aws-sdk-go-v2/service/quicksight"
8+
9+
"github.com/turbot/steampipe-plugin-sdk/v5/grpc/proto"
10+
"github.com/turbot/steampipe-plugin-sdk/v5/plugin"
11+
"github.com/turbot/steampipe-plugin-sdk/v5/plugin/transform"
12+
)
13+
14+
//// TABLE DEFINITION
15+
16+
func tableAwsQuickSightAccountSetting(_ context.Context) *plugin.Table {
17+
return &plugin.Table{
18+
Name: "aws_quicksight_account_setting",
19+
Description: "AWS QuickSight Account Setting",
20+
List: &plugin.ListConfig{
21+
Hydrate: listAwsQuickSightAccountSettings,
22+
IgnoreConfig: &plugin.IgnoreConfig{
23+
ShouldIgnoreErrorFunc: shouldIgnoreErrors([]string{"ResourceNotFoundException"}),
24+
},
25+
KeyColumns: []*plugin.KeyColumn{
26+
{Name: "region", Require: plugin.Required},
27+
{Name: "quicksight_account_id", Require: plugin.Optional},
28+
},
29+
Tags: map[string]string{"service": "quicksight", "action": "DescribeAccountSettings"},
30+
},
31+
GetMatrixItemFunc: SupportedRegionMatrix(AWS_QUICKSIGHT_SERVICE_ID),
32+
Columns: awsRegionalColumns([]*plugin.Column{
33+
{
34+
Name: "account_name",
35+
Description: "The account name displayed for the account.",
36+
Type: proto.ColumnType_STRING,
37+
Transform: transform.FromField("AccountSettings.AccountName"),
38+
},
39+
// As we have already a column "account_id" as a common column for all the tables, we have renamed the column to "quicksight_account_id"
40+
{
41+
Name: "quicksight_account_id",
42+
Description: "The ID for the Amazon Web Services account that contains the settings that you want to list.",
43+
Type: proto.ColumnType_STRING,
44+
Transform: transform.FromQual("quicksight_account_id"),
45+
},
46+
{
47+
Name: "edition",
48+
Description: "The edition of Amazon QuickSight that you're currently subscribed to: Enterprise edition or Standard edition.",
49+
Type: proto.ColumnType_STRING,
50+
Transform: transform.FromField("AccountSettings.Edition"),
51+
},
52+
{
53+
Name: "default_namespace",
54+
Description: "The default namespace for this AWS account.",
55+
Type: proto.ColumnType_STRING,
56+
Transform: transform.FromField("AccountSettings.DefaultNamespace"),
57+
},
58+
{
59+
Name: "notification_email",
60+
Description: "The email address that QuickSight uses to send notifications.",
61+
Type: proto.ColumnType_STRING,
62+
Transform: transform.FromField("AccountSettings.NotificationEmail"),
63+
},
64+
{
65+
Name: "termination_protection_enabled",
66+
Description: "A boolean value that indicates whether termination protection is enabled.",
67+
Type: proto.ColumnType_BOOL,
68+
Transform: transform.FromField("AccountSettings.TerminationProtectionEnabled"),
69+
},
70+
{
71+
Name: "public_sharing_enabled",
72+
Description: "A boolean value that indicates whether public sharing is enabled.",
73+
Type: proto.ColumnType_BOOL,
74+
Transform: transform.FromField("AccountSettings.PublicSharingEnabled"),
75+
},
76+
77+
// Standard columns
78+
{
79+
Name: "title",
80+
Description: resourceInterfaceDescription("title"),
81+
Type: proto.ColumnType_STRING,
82+
Transform: transform.FromField("AccountSettings.AccountName"),
83+
},
84+
}),
85+
}
86+
}
87+
88+
//// LIST FUNCTION
89+
90+
func listAwsQuickSightAccountSettings(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) {
91+
// Create client
92+
svc, err := QuickSightClient(ctx, d)
93+
if err != nil {
94+
plugin.Logger(ctx).Error("aws_quicksight_account_setting.listAwsQuickSightAccountSettings", "connection_error", err)
95+
return nil, err
96+
}
97+
98+
accountId := d.EqualsQuals["quicksight_account_id"].GetStringValue()
99+
// Get AWS Account ID
100+
commonData, err := getCommonColumns(ctx, d, h)
101+
if err != nil {
102+
return nil, err
103+
}
104+
commonColumnData := commonData.(*awsCommonColumnData)
105+
106+
if accountId == "" {
107+
accountId = commonColumnData.AccountId
108+
}
109+
110+
// Build the params
111+
params := &quicksight.DescribeAccountSettingsInput{
112+
AwsAccountId: aws.String(accountId),
113+
}
114+
115+
// Get call
116+
data, err := svc.DescribeAccountSettings(ctx, params)
117+
if err != nil {
118+
plugin.Logger(ctx).Error("aws_quicksight_account_setting.listAwsQuickSightAccountSettings", "api_error", err)
119+
return nil, err
120+
}
121+
122+
d.StreamListItem(ctx, data)
123+
124+
return nil, nil
125+
}

0 commit comments

Comments
 (0)