snowflake

package
v0.21.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SfAccount                           = "sf-account"
	SfUser                              = "sf-user"
	SfPassword                          = "sf-password"
	SfRole                              = "sf-role"
	SfExcludedDatabases                 = "sf-excluded-databases"
	SfExcludedSchemas                   = "sf-excluded-schemas"
	SfExternalIdentityStoreOwners       = "sf-external-identity-store-owners"
	SfStandardEdition                   = "sf-standard-edition"
	SfLinkToExternalIdentityStoreGroups = "sf-link-to-external-identity-store-groups"
)
View Source
const ConnectionStringIdentifier = "Raito_CLI"
View Source
const SfLimit = 10000

Variables

View Source
var AcceptedTypes = map[string]struct{}{"ACCOUNT": {}, "WAREHOUSE": {}, "DATABASE": {}, "SCHEMA": {}, "TABLE": {}, "VIEW": {}, "COLUMN": {}, "SHARED-DATABASE": {}}
View Source
var PermissionMap = map[string]PermissionTarget{
	"READ":  {/* contains filtered or unexported fields */},
	"WRITE": {/* contains filtered or unexported fields */},
}
View Source
var RolesNotinternalizable = []string{"ORGADMIN", "ACCOUNTADMIN", "SECURITYADMIN", "USERADMIN", "SYSADMIN", "PUBLIC"}

Functions

func CheckSFLimitExceeded

func CheckSFLimitExceeded(query string, size int) error

func ConnectToSnowflake

func ConnectToSnowflake(params map[string]string, role string) (*sql.DB, string, error)

func GetQueryDbEntitiesColumnNames added in v0.11.0

func GetQueryDbEntitiesColumnNames(tag string, includeTag string) []string

func QuerySnowflake

func QuerySnowflake(conn *sql.DB, query string) (*sql.Rows, error)

Types

type AccessSyncer

type AccessSyncer struct {
	// contains filtered or unexported fields
}

func NewDataAccessSyncer added in v0.10.8

func NewDataAccessSyncer() *AccessSyncer

func (*AccessSyncer) SyncAccessAsCodeToTarget added in v0.10.8

func (s *AccessSyncer) SyncAccessAsCodeToTarget(ctx context.Context, access map[string]*importer.AccessProvider, prefix string, configMap *config.ConfigMap) error

func (*AccessSyncer) SyncAccessProvidersFromTarget added in v0.10.8

func (s *AccessSyncer) SyncAccessProvidersFromTarget(ctx context.Context, accessProviderHandler wrappers.AccessProviderHandler, configMap *config.ConfigMap) error

func (*AccessSyncer) SyncAccessProvidersToTarget added in v0.10.8

func (s *AccessSyncer) SyncAccessProvidersToTarget(ctx context.Context, rolesToRemove []string, accessProviders map[string]*importer.AccessProvider, feedbackHandler wrappers.AccessProviderFeedbackHandler, configMap *config.ConfigMap) error

type DataSourceSyncer

type DataSourceSyncer struct {
	// contains filtered or unexported fields
}

func NewDataSourceSyncer added in v0.10.7

func NewDataSourceSyncer() *DataSourceSyncer

func (*DataSourceSyncer) GetDataSourceMetaData added in v0.12.0

func (s *DataSourceSyncer) GetDataSourceMetaData(ctx context.Context) (*ds.MetaData, error)

func (*DataSourceSyncer) SyncDataSource

func (s *DataSourceSyncer) SyncDataSource(ctx context.Context, dataSourceHandler wrappers.DataSourceObjectHandler, configParams *config.ConfigMap) error

type DataUsageSyncer

type DataUsageSyncer struct {
	// contains filtered or unexported fields
}

func NewDataUsageSyncer

func NewDataUsageSyncer() *DataUsageSyncer

func (*DataUsageSyncer) SyncDataUsage

func (s *DataUsageSyncer) SyncDataUsage(ctx context.Context, fileCreator wrappers.DataUsageStatementHandler, configParams *config.ConfigMap) error

type DbEntity added in v0.11.0

type DbEntity struct {
	Name    string  `db:"name"`
	Comment *string `db:"comment"`
}

Data Source

type Grant

type Grant struct {
	Permissions string
	On          string
}

type GrantOfRole added in v0.11.0

type GrantOfRole struct {
	GrantedTo   string `db:"granted_to"`
	GranteeName string `db:"grantee_name"`
}

type GrantToRole added in v0.11.0

type GrantToRole struct {
	Privilege string `db:"privilege"`
	GrantedOn string `db:"granted_on"`
	Name      string `db:"name"`
}

type IdentityStoreSyncer

type IdentityStoreSyncer struct {
	// contains filtered or unexported fields
}

func NewIdentityStoreSyncer added in v0.10.6

func NewIdentityStoreSyncer() *IdentityStoreSyncer

func (*IdentityStoreSyncer) GetIdentityStoreMetaData added in v0.12.0

func (s *IdentityStoreSyncer) GetIdentityStoreMetaData(_ context.Context) (*is.MetaData, error)

func (*IdentityStoreSyncer) SyncIdentityStore

func (s *IdentityStoreSyncer) SyncIdentityStore(ctx context.Context, identityHandler wrappers.IdentityStoreIdentityHandler, configMap *config.ConfigMap) error

type NullString

type NullString sql.NullString

Implementation of Scanner interface for NullString

func (*NullString) Scan

func (nullString *NullString) Scan(value interface{}) error

type PermissionTarget

type PermissionTarget struct {
	// contains filtered or unexported fields
}

PermissionTarget is used as value for the PermissionMap to map a Raito permission to a list of snowflake permissions and a string to use in the role name to represent the permission

type QueryDbEntities

type QueryDbEntities struct {
	ExternalId            string     `db:"QUERY_ID" useColumnName:"true"`
	Status                string     `db:"EXECUTION_STATUS" useColumnName:"true"`
	Query                 string     `db:"QUERY_TEXT" useColumnName:"true"`
	ErrorMessage          NullString `db:"ERROR_MESSAGE" useColumnName:"true"`
	DatabaseName          NullString `db:"DATABASE_NAME" useColumnName:"true"`
	SchemaName            NullString `db:"SCHEMA_NAME" useColumnName:"true"`
	User                  string     `db:"USER_NAME" useColumnName:"true"`
	Role                  string     `db:"ROLE_NAME" useColumnName:"true"`
	StartTime             string     `db:"START_TIME" useColumnName:"true"`
	EndTime               string     `db:"END_TIME" useColumnName:"true"`
	BytesTranferred       int        `db:"OUTBOUND_DATA_TRANSFER_BYTES" useColumnName:"true"`
	RowsReturned          int        `db:"EXTERNAL_FUNCTION_TOTAL_SENT_ROWS" useColumnName:"true"`
	CloudCreditsUsed      float32    `db:"CREDITS_USED_CLOUD_SERVICES" useColumnName:"true"`
	AccessId              NullString `db:"QID"`
	DirectObjectsAccessed *string    `db:"DIRECT_OBJECTS_ACCESSED"`
	BaseObjectsAccessed   *string    `db:"BASE_OBJECTS_ACCESSED"`
	ObjectsModified       *string    `db:"OBJECTS_MODIFIED"`
}

Data Usage

func (QueryDbEntities) String

func (entity QueryDbEntities) String() string

type RoleEntity added in v0.11.0

type RoleEntity struct {
	Name            string `db:"name"`
	AssignedToUsers int    `db:"assigned_to_users"`
	GrantedToRoles  int    `db:"granted_to_roles"`
	GrantedRoles    int    `db:"granted_roles"`
	Owner           string `db:"owner"`
}

Data Access

type SnowflakeRepository

type SnowflakeRepository struct {
	// contains filtered or unexported fields
}

func NewSnowflakeRepository

func NewSnowflakeRepository(params map[string]string, role string) (*SnowflakeRepository, error)

func (*SnowflakeRepository) BatchingInformation

func (repo *SnowflakeRepository) BatchingInformation(startDate *time.Time, historyTable string) (*string, *string, int, error)

func (*SnowflakeRepository) CheckAccessHistoryAvailability added in v0.10.6

func (repo *SnowflakeRepository) CheckAccessHistoryAvailability(historyTable string) (bool, error)

func (*SnowflakeRepository) Close

func (repo *SnowflakeRepository) Close() error

func (*SnowflakeRepository) CommentIfExists added in v0.10.8

func (repo *SnowflakeRepository) CommentIfExists(comment, objectType, objectName string) error

func (*SnowflakeRepository) CreateRole added in v0.10.8

func (repo *SnowflakeRepository) CreateRole(roleName string) error

func (*SnowflakeRepository) DataUsage

func (repo *SnowflakeRepository) DataUsage(columns []string, limit int, offset int, historyTable string, minTime, maxTime *string, accessHistoryAvailable bool) ([]QueryDbEntities, error)

func (*SnowflakeRepository) DescribePolicy added in v0.10.8

func (repo *SnowflakeRepository) DescribePolicy(policyType, dbName, schema, policyName string) ([]describePolicyEntity, error)

func (*SnowflakeRepository) DropRole added in v0.10.8

func (repo *SnowflakeRepository) DropRole(roleName string) error

func (*SnowflakeRepository) ExecuteGrant added in v0.10.8

func (repo *SnowflakeRepository) ExecuteGrant(perm, on, role string) error

func (*SnowflakeRepository) ExecuteRevoke added in v0.10.8

func (repo *SnowflakeRepository) ExecuteRevoke(perm, on, role string) error

func (*SnowflakeRepository) GetColumnsInTable added in v0.10.7

func (repo *SnowflakeRepository) GetColumnsInTable(sfObject *common.SnowflakeObject) ([]DbEntity, error)

func (*SnowflakeRepository) GetDataBases added in v0.10.7

func (repo *SnowflakeRepository) GetDataBases() ([]DbEntity, error)

func (*SnowflakeRepository) GetGrantsOfRole added in v0.10.8

func (repo *SnowflakeRepository) GetGrantsOfRole(roleName string) ([]GrantOfRole, error)

func (*SnowflakeRepository) GetGrantsToRole added in v0.10.8

func (repo *SnowflakeRepository) GetGrantsToRole(roleName string) ([]GrantToRole, error)

func (*SnowflakeRepository) GetPolicies added in v0.10.8

func (repo *SnowflakeRepository) GetPolicies(policy string) ([]policyEntity, error)

func (*SnowflakeRepository) GetPolicyReferences added in v0.10.8

func (repo *SnowflakeRepository) GetPolicyReferences(dbName, schema, policyName string) ([]policyReferenceEntity, error)

func (*SnowflakeRepository) GetRoles added in v0.10.8

func (repo *SnowflakeRepository) GetRoles() ([]RoleEntity, error)

func (*SnowflakeRepository) GetRolesWithPrefix added in v0.10.8

func (repo *SnowflakeRepository) GetRolesWithPrefix(prefix string) ([]RoleEntity, error)

func (*SnowflakeRepository) GetSchemasInDatabase added in v0.14.1

func (repo *SnowflakeRepository) GetSchemasInDatabase(databaseName string) ([]DbEntity, error)

func (*SnowflakeRepository) GetShares added in v0.10.7

func (repo *SnowflakeRepository) GetShares() ([]DbEntity, error)

func (*SnowflakeRepository) GetSnowFlakeAccountName added in v0.10.7

func (repo *SnowflakeRepository) GetSnowFlakeAccountName() (string, error)

func (*SnowflakeRepository) GetTablesInSchema added in v0.10.7

func (repo *SnowflakeRepository) GetTablesInSchema(sfObject *common.SnowflakeObject) ([]DbEntity, error)

func (*SnowflakeRepository) GetUsers added in v0.10.6

func (repo *SnowflakeRepository) GetUsers() ([]UserEntity, error)

func (*SnowflakeRepository) GetViewsInSchema added in v0.10.7

func (repo *SnowflakeRepository) GetViewsInSchema(sfObject *common.SnowflakeObject) ([]DbEntity, error)

func (*SnowflakeRepository) GetWarehouses added in v0.10.7

func (repo *SnowflakeRepository) GetWarehouses() ([]DbEntity, error)

func (*SnowflakeRepository) GrantRolesToRole added in v0.10.8

func (repo *SnowflakeRepository) GrantRolesToRole(ctx context.Context, role string, roles ...string) error

func (*SnowflakeRepository) GrantUsersToRole added in v0.10.8

func (repo *SnowflakeRepository) GrantUsersToRole(ctx context.Context, role string, users ...string) error

func (*SnowflakeRepository) RevokeRolesFromRole added in v0.10.8

func (repo *SnowflakeRepository) RevokeRolesFromRole(ctx context.Context, role string, roles ...string) error

func (*SnowflakeRepository) RevokeUsersFromRole added in v0.10.8

func (repo *SnowflakeRepository) RevokeUsersFromRole(ctx context.Context, role string, users ...string) error

func (*SnowflakeRepository) TotalQueryTime

func (repo *SnowflakeRepository) TotalQueryTime() time.Duration

type UserEntity added in v0.11.0

type UserEntity struct {
	Name        string `db:"name"`
	LoginName   string `db:"login_name"`
	DisplayName string `db:"display_name"`
	Email       string `db:"email"`
	Owner       string `db:"owner"`
}

Identity Store

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL