snowflake

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthTypeHeaderKey   = "X-Snowflake-Authorization-Token-Type"
	AuthTypeHeaderValue = "KEYPAIR_JWT"
)

Variables

This section is empty.

Functions

func Contains

func Contains[T comparable](ts []T, val T) bool

func ParsePrivateKey added in v0.0.6

func ParsePrivateKey(key []byte) (any, error)

func ReadPrivateKey

func ReadPrivateKey(path string) (any, error)

Types

type AccountRole

type AccountRole struct {
	Name string
}

func (*AccountRole) GetColumnName

func (ar *AccountRole) GetColumnName(fieldName string) string

type AccountRoleGrantee

type AccountRoleGrantee struct {
	RoleName    string
	GranteeName string
	GranteeType string
}

type Client

type Client struct {
	uhttp.BaseHttpClient
	JWTConfig

	AccountUrl       string
	StatementsApiUrl *url.URL
}

func New

func New(accountUrl string, jwtConfig JWTConfig, httpClient *http.Client) (*Client, error)

func (*Client) GetAccountRole

func (c *Client) GetAccountRole(ctx context.Context, roleName string) (*AccountRole, *http.Response, error)

func (*Client) GetDatabase

func (c *Client) GetDatabase(ctx context.Context, name string) (*Database, *http.Response, error)

func (*Client) GetStatementResponse

func (c *Client) GetStatementResponse(ctx context.Context, statementHandle string) (*http.Request, error)

func (*Client) GetUser

func (c *Client) GetUser(ctx context.Context, username string) (*User, *http.Response, error)

func (*Client) GrantAccountRole

func (c *Client) GrantAccountRole(ctx context.Context, roleName, userName string) (*http.Response, error)

func (*Client) ListAccountRoleGrantees

func (c *Client) ListAccountRoleGrantees(ctx context.Context, roleName string, offset, limit int) ([]AccountRoleGrantee, *http.Response, error)

func (*Client) ListAccountRoles

func (c *Client) ListAccountRoles(ctx context.Context, offset, limit int) ([]AccountRole, *http.Response, error)

func (*Client) ListDatabases

func (c *Client) ListDatabases(ctx context.Context, offset, limit int) ([]Database, *http.Response, error)

func (*Client) ListUsers

func (c *Client) ListUsers(ctx context.Context, offset, limit int) ([]User, *http.Response, error)

func (*Client) PostStatementRequest

func (c *Client) PostStatementRequest(ctx context.Context, queries []string) (*http.Request, error)

func (*Client) RevokeAccountRole

func (c *Client) RevokeAccountRole(ctx context.Context, roleName, userName string) (*http.Response, error)

type Database

type Database struct {
	Name  string
	Owner string
}

func (*Database) GetColumnName

func (d *Database) GetColumnName(fieldName string) string

type GetUserRawResponse

type GetUserRawResponse struct {
	StatementsApiResponseBase
	Data [][]string `json:"data"`
}

func (*GetUserRawResponse) GetUser

func (r *GetUserRawResponse) GetUser() (*User, error)

func (*GetUserRawResponse) GetValueByColumnName

func (r *GetUserRawResponse) GetValueByColumnName(columnName string) (string, bool)

type GrantAccountRoleResponse

type GrantAccountRoleResponse struct {
	StatementsApiResponseBase
}

type JWTConfig

type JWTConfig struct {
	AccountIdentifier string
	UserIdentifier    string
	PrivateKeyValue   any
	// contains filtered or unexported fields
}

func (*JWTConfig) GenerateBearerToken

func (c *JWTConfig) GenerateBearerToken() (string, error)

type ListAccountRoleGranteesRawResponse

type ListAccountRoleGranteesRawResponse struct {
	StatementsApiResponseBase
	Data [][]string `json:"data"`
}

func (*ListAccountRoleGranteesRawResponse) GetAccountRoleGrantees

func (r *ListAccountRoleGranteesRawResponse) GetAccountRoleGrantees() []AccountRoleGrantee

type ListAccountRolesRawResponse

type ListAccountRolesRawResponse struct {
	StatementsApiResponseBase
}

func (*ListAccountRolesRawResponse) GetAccountRoles

func (r *ListAccountRolesRawResponse) GetAccountRoles() ([]AccountRole, error)

type ListDatabasesRawResponse

type ListDatabasesRawResponse struct {
	StatementsApiResponseBase
}

func (*ListDatabasesRawResponse) GetDatabases

func (r *ListDatabasesRawResponse) GetDatabases() ([]Database, error)

type ListUsersRawResponse

type ListUsersRawResponse struct {
	StatementsApiResponseBase
}

func (*ListUsersRawResponse) GetUsers

func (r *ListUsersRawResponse) GetUsers() ([]User, error)

type Parsable

type Parsable interface {
	GetColumnName(fieldName string) string
}

type QueryParameter

type QueryParameter struct {
	Type  string `json:"type"`
	Value string `json:"value"`
}

type ResultSetMetadata

type ResultSetMetadata struct {
	NumRows  int       `json:"numRows"`
	RowTypes []RowType `json:"rowType"`
}

func (*ResultSetMetadata) FindRowTypeByName

func (m *ResultSetMetadata) FindRowTypeByName(name string) (bool, int, *RowType)

func (*ResultSetMetadata) GetBoolValueFromRow

func (m *ResultSetMetadata) GetBoolValueFromRow(row []string, key string) (bool, error)

func (*ResultSetMetadata) GetStringValueFromRow

func (m *ResultSetMetadata) GetStringValueFromRow(row []string, key string) (string, error)

func (*ResultSetMetadata) GetTimeValueFromRow added in v0.0.7

func (m *ResultSetMetadata) GetTimeValueFromRow(row []string, key string) (time.Time, error)

func (*ResultSetMetadata) ParseRow

func (m *ResultSetMetadata) ParseRow(s Parsable, row []string) error

type RowType

type RowType struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

type StatementsApiRequestBody

type StatementsApiRequestBody struct {
	Statement  string                      `json:"statement"`
	Parameters StatementsRequestParameters `json:"parameters"`
}

type StatementsApiResponseBase

type StatementsApiResponseBase struct {
	ResultSetMetadata ResultSetMetadata `json:"resultSetMetadata"`
	Code              string            `json:"code"`
	StatementHandle   string            `json:"statementHandle"`
	StatementHandles  []string          `json:"statementHandles"`
	Message           string            `json:"message"`
	Data              [][]string        `json:"data"`
}

type StatementsRequestParameters

type StatementsRequestParameters struct {
	StatementsCount int `json:"MULTI_STATEMENT_COUNT"`
}

type User

type User struct {
	Username         string
	Login            string
	DisplayName      string
	FirstName        string
	LastName         string
	Email            string
	Disabled         bool
	Locked           bool
	DefaultRole      string
	HasRSAPublicKey  bool
	HasPassword      bool
	LastSuccessLogin time.Time
	Type             string
	HasMfa           bool
	Comment          string
}

func (*User) GetColumnName

func (u *User) GetColumnName(fieldName string) string

Jump to

Keyboard shortcuts

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