sdk

package
v0.64.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoQuotes     quoteType = "no_quotes"
	DoubleQuotes quoteType = "double_quotes"
	SingleQuotes quoteType = "single_quotes"
)

Variables

View Source
var (
	// go-snowflake errors.
	ErrObjectNotExistOrAuthorized = errors.New("object does not exist or not authorized")
	ErrAccountIsEmpty             = errors.New("account is empty")
)

Functions

func Bool

func Bool(b bool) *bool

Bool returns a pointer to the given bool.

func DefaultConfig

func DefaultConfig() *gosnowflake.Config

func EnvConfig

func EnvConfig() *gosnowflake.Config

func Int

func Int(i int) *int

Int returns a pointer to the given int.

func IsValidDataType

func IsValidDataType(v string) bool

func MergeConfig

func MergeConfig(baseConfig *gosnowflake.Config, mergeConfig *gosnowflake.Config) *gosnowflake.Config

func ProfileConfig

func ProfileConfig(profile string) (*gosnowflake.Config, error)

func String

func String(s string) *string

String returns a pointer to the given string.

Types

type AccountObjectIdentifier

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

func NewAccountObjectIdentifier

func NewAccountObjectIdentifier(name string) AccountObjectIdentifier

func (AccountObjectIdentifier) FullyQualifiedName

func (i AccountObjectIdentifier) FullyQualifiedName() string

func (AccountObjectIdentifier) Name

type Client

type Client struct {
	ContextFunctions ContextFunctions
	MaskingPolicies  MaskingPolicies
	PasswordPolicies PasswordPolicies
	Sessions         Sessions
	SystemFunctions  SystemFunctions
	Warehouses       Warehouses
	// contains filtered or unexported fields
}

func NewClient

func NewClient(cfg *gosnowflake.Config) (*Client, error)

func NewClientFromDB

func NewClientFromDB(db *sql.DB) *Client

func NewDefaultClient

func NewDefaultClient() (*Client, error)

func (*Client) Close

func (c *Client) Close() error

func (*Client) Ping

func (c *Client) Ping() error

func (*Client) SetDryRun

func (c *Client) SetDryRun(dryRun bool)

type ContextFunctions

type ContextFunctions interface {
	// Session functions.
	CurrentSession(ctx context.Context) (string, error)

	// Session Object functions.
	CurrentDatabase(ctx context.Context) (string, error)
	CurrentSchema(ctx context.Context) (string, error)
	CurrentWarehouse(ctx context.Context) (string, error)
}

type DataType

type DataType string
const (
	DataTypeNumber       DataType = "NUMBER"
	DataTypeFloat        DataType = "FLOAT"
	DataTypeVARCHAR      DataType = "VARCHAR"
	DataTypeBinary       DataType = "BINARY"
	DataTypeBoolean      DataType = "BOOLEAN"
	DataTypeDate         DataType = "DATE"
	DataTypeTime         DataType = "TIME"
	DataTypeTimestampLTZ DataType = "TIMESTAMP_LTZ"
	DataTypeTimestampNTZ DataType = "TIMESTAMP_NTZ"
	DataTypeTimestampTZ  DataType = "TIMESTAMP_TZ"
	DataTypeVariant      DataType = "VARIANT"
	DataTypeObject       DataType = "OBJECT"
	DataTypeArray        DataType = "ARRAY"
	DataTypeGeography    DataType = "GEOGRAPHY"
	DataTypeGeometry     DataType = "GEOMETRY"

	// DataTypeUnknown is used for testing purposes only.
	DataTypeUnknown DataType = "UNKNOWN"
)

func DataTypeFromString

func DataTypeFromString(s string) DataType

type Database

type Database struct {
	Name string
}

func (*Database) ID

type DatabaseCreateOptions

type DatabaseCreateOptions struct{}

placeholder for the real implementation.

type In

type In struct {
	Account  *bool                   `ddl:"keyword" db:"ACCOUNT"`
	Database AccountObjectIdentifier `ddl:"identifier" db:"DATABASE"`
	Schema   SchemaIdentifier        `ddl:"identifier" db:"SCHEMA"`
}

type IntProperty

type IntProperty struct {
	Value        int
	DefaultValue int
	Description  string
}

type Like

type Like struct {
	Pattern *string `ddl:"keyword,single_quotes"`
}

type MaskingPolicies

type MaskingPolicies interface {
	// Create creates a new masking policy.
	Create(ctx context.Context, id SchemaObjectIdentifier, signature []TableColumnSignature, returns DataType, expression string, opts *MaskingPolicyCreateOptions) error
	// Alter modifies an existing masking policy.
	Alter(ctx context.Context, id SchemaObjectIdentifier, opts *MaskingPolicyAlterOptions) error
	// Drop removes a masking policy.
	Drop(ctx context.Context, id SchemaObjectIdentifier) error
	// Show returns a list of masking policies.
	Show(ctx context.Context, opts *MaskingPolicyShowOptions) ([]*MaskingPolicy, error)
	// Describe returns the details of a masking policy.
	Describe(ctx context.Context, id SchemaObjectIdentifier) (*MaskingPolicyDetails, error)
}

MaskingPolicies describes all the masking policy related methods that the Snowflake API supports.

type MaskingPolicy

type MaskingPolicy struct {
	CreatedOn           time.Time
	Name                string
	DatabaseName        string
	SchemaName          string
	Kind                string
	Owner               string
	Comment             string
	ExemptOtherPolicies bool
}

MaskingPolicys is a user friendly result for a CREATE MASKING POLICY query.

func (*MaskingPolicy) ID

type MaskingPolicyAlterOptions

type MaskingPolicyAlterOptions struct {
	IfExists *bool `ddl:"keyword" db:"IF EXISTS"`

	NewName SchemaObjectIdentifier `ddl:"identifier" db:"RENAME TO"`
	Set     *MaskingPolicySet      `ddl:"keyword" db:"SET"`
	Unset   *MaskingPolicyUnset    `ddl:"keyword" db:"UNSET"`
	// contains filtered or unexported fields
}

type MaskingPolicyCreateOptions

type MaskingPolicyCreateOptions struct {
	OrReplace *bool `ddl:"keyword" db:"OR REPLACE"`

	IfNotExists *bool `ddl:"keyword" db:"IF NOT EXISTS"`

	// optional
	Comment             *string `ddl:"parameter,single_quotes" db:"COMMENT"`
	ExemptOtherPolicies *bool   `ddl:"parameter" db:"EXEMPT_OTHER_POLICIES"`
	// contains filtered or unexported fields
}

type MaskingPolicyDetails

type MaskingPolicyDetails struct {
	Name       string
	Signature  []TableColumnSignature
	ReturnType DataType
	Body       string
}

type MaskingPolicyDropOptions

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

type MaskingPolicySet

type MaskingPolicySet struct {
	Body    *string          `ddl:"command" db:"BODY ->"`
	Tag     []TagAssociation `ddl:"list,no_parentheses" db:"TAG"`
	Comment *string          `ddl:"parameter,single_quotes" db:"COMMENT"`
}

type MaskingPolicyShowOptions

type MaskingPolicyShowOptions struct {
	Like  *Like `ddl:"keyword" db:"LIKE"`
	In    *In   `ddl:"keyword" db:"IN"`
	Limit *int  `ddl:"command,no_quotes" db:"LIMIT"`
	// contains filtered or unexported fields
}

MaskingPolicyShowOptions represents the options for listing masking policies.

type MaskingPolicyUnset

type MaskingPolicyUnset struct {
	Tag     []ObjectIdentifier `ddl:"list,no_parentheses" db:"TAG"`
	Comment *bool              `ddl:"keyword" db:"COMMENT"`
}

type ObjectIdentifier

type ObjectIdentifier interface {
	Name() string
	FullyQualifiedName() string
}

type ObjectType

type ObjectType string

ObjectType is the type of object.

const (
	ObjectTypeMaskingPolicy  ObjectType = "MASKING POLICY"
	ObjectTypePasswordPolicy ObjectType = "PASSWORD POLICY"
)

func (ObjectType) String

func (o ObjectType) String() string

type PasswordPolicies

type PasswordPolicies interface {
	// Create creates a new password policy.
	Create(ctx context.Context, id SchemaObjectIdentifier, opts *PasswordPolicyCreateOptions) error
	// Alter modifies an existing password policy.
	Alter(ctx context.Context, id SchemaObjectIdentifier, opts *PasswordPolicyAlterOptions) error
	// Drop removes a password policy.
	Drop(ctx context.Context, id SchemaObjectIdentifier, opts *PasswordPolicyDropOptions) error
	// Show returns a list of password policies.
	Show(ctx context.Context, opts *PasswordPolicyShowOptions) ([]*PasswordPolicy, error)
	// Describe returns the details of a password policy.
	Describe(ctx context.Context, id SchemaObjectIdentifier) (*PasswordPolicyDetails, error)
}

PasswordPolicies describes all the password policy related methods that the Snowflake API supports.

type PasswordPolicy

type PasswordPolicy struct {
	CreatedOn    time.Time
	Name         string
	DatabaseName string
	SchemaName   string
	Kind         string
	Owner        string
	Comment      string
}

PasswordPolicys is a user friendly result for a CREATE PASSWORD POLICY query.

func (*PasswordPolicy) ID

type PasswordPolicyAlterOptions

type PasswordPolicyAlterOptions struct {
	IfExists *bool `ddl:"keyword" db:"IF EXISTS"`

	NewName SchemaObjectIdentifier `ddl:"identifier" db:"RENAME TO"`
	Set     *PasswordPolicySet     `ddl:"keyword" db:"SET"`
	Unset   *PasswordPolicyUnset   `ddl:"keyword" db:"UNSET"`
	// contains filtered or unexported fields
}

type PasswordPolicyCreateOptions

type PasswordPolicyCreateOptions struct {
	OrReplace *bool `ddl:"keyword" db:"OR REPLACE"`

	IfNotExists *bool `ddl:"keyword" db:"IF NOT EXISTS"`

	PasswordMinLength         *int `ddl:"parameter" db:"PASSWORD_MIN_LENGTH"`
	PasswordMaxLength         *int `ddl:"parameter" db:"PASSWORD_MAX_LENGTH"`
	PasswordMinUpperCaseChars *int `ddl:"parameter" db:"PASSWORD_MIN_UPPER_CASE_CHARS"`
	PasswordMinLowerCaseChars *int `ddl:"parameter" db:"PASSWORD_MIN_LOWER_CASE_CHARS"`
	PasswordMinNumericChars   *int `ddl:"parameter" db:"PASSWORD_MIN_NUMERIC_CHARS"`
	PasswordMinSpecialChars   *int `ddl:"parameter" db:"PASSWORD_MIN_SPECIAL_CHARS"`
	PasswordMaxAgeDays        *int `ddl:"parameter" db:"PASSWORD_MAX_AGE_DAYS"`
	PasswordMaxRetries        *int `ddl:"parameter" db:"PASSWORD_MAX_RETRIES"`
	PasswordLockoutTimeMins   *int `ddl:"parameter" db:"PASSWORD_LOCKOUT_TIME_MINS"`

	Comment *string `ddl:"parameter,single_quotes" db:"COMMENT"`
	// contains filtered or unexported fields
}

type PasswordPolicyDetails

type PasswordPolicyDetails struct {
	Name                      *StringProperty
	Owner                     *StringProperty
	Comment                   *StringProperty
	PasswordMinLength         *IntProperty
	PasswordMaxLength         *IntProperty
	PasswordMinUpperCaseChars *IntProperty
	PasswordMinLowerCaseChars *IntProperty
	PasswordMinNumericChars   *IntProperty
	PasswordMinSpecialChars   *IntProperty
	PasswordMaxAgeDays        *IntProperty
	PasswordMaxRetries        *IntProperty
	PasswordLockoutTimeMins   *IntProperty
}

type PasswordPolicyDropOptions

type PasswordPolicyDropOptions struct {
	IfExists *bool `ddl:"keyword" db:"IF EXISTS"`
	// contains filtered or unexported fields
}

type PasswordPolicySet

type PasswordPolicySet struct {
	PasswordMinLength         *int    `ddl:"parameter" db:"PASSWORD_MIN_LENGTH"`
	PasswordMaxLength         *int    `ddl:"parameter" db:"PASSWORD_MAX_LENGTH"`
	PasswordMinUpperCaseChars *int    `ddl:"parameter" db:"PASSWORD_MIN_UPPER_CASE_CHARS"`
	PasswordMinLowerCaseChars *int    `ddl:"parameter" db:"PASSWORD_MIN_LOWER_CASE_CHARS"`
	PasswordMinNumericChars   *int    `ddl:"parameter" db:"PASSWORD_MIN_NUMERIC_CHARS"`
	PasswordMinSpecialChars   *int    `ddl:"parameter" db:"PASSWORD_MIN_SPECIAL_CHARS"`
	PasswordMaxAgeDays        *int    `ddl:"parameter" db:"PASSWORD_MAX_AGE_DAYS"`
	PasswordMaxRetries        *int    `ddl:"parameter" db:"PASSWORD_MAX_RETRIES"`
	PasswordLockoutTimeMins   *int    `ddl:"parameter" db:"PASSWORD_LOCKOUT_TIME_MINS"`
	Comment                   *string `ddl:"parameter,single_quotes" db:"COMMENT"`
}

type PasswordPolicyShowOptions

type PasswordPolicyShowOptions struct {
	Like  *Like `ddl:"keyword" db:"LIKE"`
	In    *In   `ddl:"keyword" db:"IN"`
	Limit *int  `ddl:"command,no_quotes" db:"LIMIT"`
	// contains filtered or unexported fields
}

PasswordPolicyShowOptions represents the options for listing password policies.

type PasswordPolicyUnset

type PasswordPolicyUnset struct {
	PasswordMinLength         *bool `ddl:"keyword" db:"PASSWORD_MIN_LENGTH"`
	PasswordMaxLength         *bool `ddl:"keyword" db:"PASSWORD_MAX_LENGTH"`
	PasswordMinUpperCaseChars *bool `ddl:"keyword" db:"PASSWORD_MIN_UPPER_CASE_CHARS"`
	PasswordMinLowerCaseChars *bool `ddl:"keyword" db:"PASSWORD_MIN_LOWER_CASE_CHARS"`
	PasswordMinNumericChars   *bool `ddl:"keyword" db:"PASSWORD_MIN_NUMERIC_CHARS"`
	PasswordMinSpecialChars   *bool `ddl:"keyword" db:"PASSWORD_MIN_SPECIAL_CHARS"`
	PasswordMaxAgeDays        *bool `ddl:"keyword" db:"PASSWORD_MAX_AGE_DAYS"`
	PasswordMaxRetries        *bool `ddl:"keyword" db:"PASSWORD_MAX_RETRIES"`
	PasswordLockoutTimeMins   *bool `ddl:"keyword" db:"PASSWORD_LOCKOUT_TIME_MINS"`
	Comment                   *bool `ddl:"keyword" db:"COMMENT"`
}

type Schema

type Schema struct {
	DatabaseName string
	Name         string
}

placeholder for the real implementation.

func (*Schema) ID

func (v *Schema) ID() SchemaIdentifier

type SchemaIdentifier

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

func NewSchemaIdentifier

func NewSchemaIdentifier(databaseName, schemaName string) SchemaIdentifier

func NewSchemaIdentifierFromFullyQualifiedName

func NewSchemaIdentifierFromFullyQualifiedName(fullyQualifiedName string) SchemaIdentifier

func (SchemaIdentifier) DatabaseName

func (i SchemaIdentifier) DatabaseName() string

func (SchemaIdentifier) FullyQualifiedName

func (i SchemaIdentifier) FullyQualifiedName() string

func (SchemaIdentifier) Name

func (i SchemaIdentifier) Name() string

type SchemaObjectIdentifier

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

func NewSchemaObjectIdentifier

func NewSchemaObjectIdentifier(databaseName, schemaName, name string) SchemaObjectIdentifier

func NewSchemaObjectIdentifierFromFullyQualifiedName

func NewSchemaObjectIdentifierFromFullyQualifiedName(fullyQualifiedName string) SchemaObjectIdentifier

func (SchemaObjectIdentifier) DatabaseName

func (i SchemaObjectIdentifier) DatabaseName() string

func (SchemaObjectIdentifier) FullyQualifiedName

func (i SchemaObjectIdentifier) FullyQualifiedName() string

func (SchemaObjectIdentifier) Name

func (i SchemaObjectIdentifier) Name() string

func (SchemaObjectIdentifier) SchemaName

func (i SchemaObjectIdentifier) SchemaName() string

type Sessions

type Sessions interface {
	// Context functions.
	UseWarehouse(ctx context.Context, warehouse AccountObjectIdentifier) error
	UseDatabase(ctx context.Context, database AccountObjectIdentifier) error
	UseSchema(ctx context.Context, schema SchemaIdentifier) error
}

type StringProperty

type StringProperty struct {
	Value        string
	DefaultValue string
	Description  string
}

type SystemFunctions

type SystemFunctions interface {
	GetTag(ctx context.Context, tagID ObjectIdentifier, objectID ObjectIdentifier, typ ObjectType) (string, error)
}

type TableColumnIdentifier

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

func NewTableColumnIdentifier

func NewTableColumnIdentifier(databaseName, schemaName, tableName, columnName string) TableColumnIdentifier

func NewTableColumnIdentifierFromFullyQualifiedName

func NewTableColumnIdentifierFromFullyQualifiedName(fullyQualifiedName string) TableColumnIdentifier

func (TableColumnIdentifier) DatabaseName

func (i TableColumnIdentifier) DatabaseName() string

func (TableColumnIdentifier) FullyQualifiedName

func (i TableColumnIdentifier) FullyQualifiedName() string

func (TableColumnIdentifier) Name

func (i TableColumnIdentifier) Name() string

func (TableColumnIdentifier) SchemaName

func (i TableColumnIdentifier) SchemaName() string

func (TableColumnIdentifier) TableName

func (i TableColumnIdentifier) TableName() string

type TableColumnSignature

type TableColumnSignature struct {
	Name string   `ddl:"keyword,double_quotes"`
	Type DataType `ddl:"keyword"`
}

type Tag

type Tag struct {
	DatabaseName string
	SchemaName   string
	Name         string
}

func (*Tag) ID

func (v *Tag) ID() SchemaObjectIdentifier

type TagAssociation

type TagAssociation struct {
	Name ObjectIdentifier `ddl:"identifier"`

	Value string `ddl:"keyword,single_quotes"`
	// contains filtered or unexported fields
}

type TagCreateOptions

type TagCreateOptions struct{}

placeholder for the real implementation.

type Warehouse

type Warehouse struct {
	Name string
}

func (*Warehouse) ID

type WarehouseAlterOptions

type WarehouseAlterOptions struct{}

placeholder for the real implementation.

type WarehouseCreateOptions

type WarehouseCreateOptions struct{}

placeholder for the real implementation.

type WarehouseDetails

type WarehouseDetails struct {
	Name string
}

type WarehouseDropOptions

type WarehouseDropOptions struct{}

placeholder for the real implementation.

type WarehouseShowOptions

type WarehouseShowOptions struct{}

placeholder for the real implementation.

type Warehouses

type Warehouses interface {
	// Create creates a warehouse.
	Create(ctx context.Context, id AccountObjectIdentifier, opts *WarehouseCreateOptions) error
	// Alter modifies an existing warehouse
	Alter(ctx context.Context, id AccountObjectIdentifier, opts *WarehouseAlterOptions) error
	// Drop removes a warehouse.
	Drop(ctx context.Context, id AccountObjectIdentifier, opts *WarehouseDropOptions) error
	// Show returns a list of warehouses.
	Show(ctx context.Context, opts *WarehouseShowOptions) ([]*Warehouse, error)
	// Describe returns the details of a warehouse.
	Describe(ctx context.Context, id AccountObjectIdentifier) (*WarehouseDetails, error)
}

Jump to

Keyboard shortcuts

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