diff --git a/plugins/providers/bigquery/config.go b/plugins/providers/bigquery/config.go index ab77d6cb6..057d4890e 100644 --- a/plugins/providers/bigquery/config.go +++ b/plugins/providers/bigquery/config.go @@ -14,10 +14,33 @@ import ( ) const ( + // legacy roles DatasetRoleReader = "READER" DatasetRoleWriter = "WRITER" DatasetRoleOwner = "OWNER" + // new roles + BigQueryRoleAdmin = "roles/bigquery.admin" + BigQueryRoleUser = "roles/bigquery.user" + + BigQueryConnectionAdmin = "roles/bigquery.connectionAdmin" + BigQueryConnectionUser = "roles/bigquery.connectionUser" + + BigQueryRoleDataEditor = "roles/bigquery.dataEditor" + BigQueryRoleDataOwner = "roles/bigquery.dataOwner" + BigQueryRoleDataViewer = "roles/bigquery.dataViewer" + + BigQueryFilteredDataViewer = "roles/bigquery.filteredDataViewer" + BigQueryRoleJobUser = "roles/bigquery.jobUser" + BigQueryRoleMetaViewer = "roles/bigquery.metadataViewer" + + BigQueryReadSessionUser = "roles/bigquery.readSessionUser" + BigQueryResourceAdmin = "roles/bigquery.resourceAdmin" + BigQueryResourceEditor = "roles/bigquery.resourceEditor" + BigQueryResourceViewer = "roles/bigquery.resourceViewer" + + BigQueryMaskedReader = "roles/bigquerydatapolicy.maskedReader" + AccountTypeUser = "user" AccountTypeServiceAccount = "serviceAccount" ) diff --git a/plugins/providers/bigquery/provider.go b/plugins/providers/bigquery/provider.go index 3280842f1..496f96036 100644 --- a/plugins/providers/bigquery/provider.go +++ b/plugins/providers/bigquery/provider.go @@ -108,6 +108,21 @@ func (p *Provider) GetDefaultRoles(ctx context.Context, name string, resourceTyp DatasetRoleOwner, DatasetRoleWriter, DatasetRoleReader, + BigQueryRoleAdmin, + BigQueryRoleUser, + BigQueryRoleDataOwner, + BigQueryRoleDataEditor, + BigQueryRoleDataViewer, + BigQueryConnectionAdmin, + BigQueryConnectionUser, + BigQueryFilteredDataViewer, + BigQueryRoleJobUser, + BigQueryRoleMetaViewer, + BigQueryReadSessionUser, + BigQueryResourceAdmin, + BigQueryResourceEditor, + BigQueryResourceViewer, + BigQueryMaskedReader, }, nil } diff --git a/plugins/providers/grafana/provider.go b/plugins/providers/grafana/provider.go index c1aaf3f92..8b74cf880 100644 --- a/plugins/providers/grafana/provider.go +++ b/plugins/providers/grafana/provider.go @@ -31,7 +31,15 @@ func (p *provider) GetType() string { // GetDefaultRoles returns a list of roles supported by the provider func (p *provider) GetDefaultRoles(ctx context.Context, name string, resourceType string) ([]string, error) { - return []string{}, nil + if resourceType == ResourceTypeDashboard || resourceType == "" { + return []string{ + DashboardRoleAdmin, + DashboardRoleEditor, + DashboardRoleViewer, + }, nil + } + + return nil, ErrInvalidResourceType } func (p *provider) CreateConfig(pc *domain.ProviderConfig) error { diff --git a/plugins/providers/metabase/provider.go b/plugins/providers/metabase/provider.go index 64b90bb02..ac34d05ce 100644 --- a/plugins/providers/metabase/provider.go +++ b/plugins/providers/metabase/provider.go @@ -35,7 +35,32 @@ func (p *provider) GetType() string { // GetDefaultRoles returns a list of roles supported by the provider func (p *provider) GetDefaultRoles(ctx context.Context, name string, resourceType string) ([]string, error) { - return []string{}, nil + databaseRoles := []string{ + DatabaseRoleViewer, + DatabaseRoleEditor, + } + collectionRoles := []string{ + CollectionRoleViewer, + CollectionRoleCurate, + } + tableRoles := []string{ + TableRoleViewer, + } + allRoles := append(databaseRoles, collectionRoles...) + allRoles = append(allRoles, tableRoles...) + + switch resourceType { + case ResourceTypeDatabase: + return databaseRoles, nil + case ResourceTypeCollection: + return collectionRoles, nil + case ResourceTypeTable: + return tableRoles, nil + case "": + return allRoles, nil + default: + return nil, ErrInvalidResourceType + } } func (p *provider) CreateConfig(pc *domain.ProviderConfig) error {