metabase

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DatabaseRoleViewer = "schemas:all"
	DatabaseRoleEditor = "native:write"
)
View Source
const (
	ResourceTypeDatabase   = "database"
	ResourceTypeCollection = "collection"
)

Variables

View Source
var (
	ErrInvalidCredentials            = errors.New("invalid credentials type")
	ErrInvalidPermissionConfig       = errors.New("invalid permission config type")
	ErrUnableToEncryptNilCredentials = errors.New("unable to encrypt nil credentials")
	ErrUnableToDecryptNilCredentials = errors.New("unable to decrypt nil credentials")
	ErrUserNotFound                  = errors.New("metabase user not found")
	ErrInvalidRole                   = errors.New("invalid role")
	ErrInvalidResourceType           = errors.New("invalid resource type")
	ErrPermissionNotFound            = errors.New("permission not found")
)

Functions

func NewClient

func NewClient(config *ClientConfig) (*client, error)

func NewProvider

func NewProvider(typeName string, crypto domain.Crypto) *provider

Types

type ClientConfig

type ClientConfig struct {
	Host       string `validate:"required,url" mapstructure:"host"`
	Username   string `validate:"required" mapstructure:"username"`
	Password   string `validate:"required" mapstructure:"password"`
	HTTPClient HTTPClient
}

type Collection

type Collection struct {
	ID        interface{} `json:"id"`
	Name      string      `json:"name"`
	Slug      string      `json:"slug"`
	Location  string      `json:"location,omitempty"`
	Namespace string      `json:"namespace,omitempty"`
}

func (*Collection) FromDomain

func (c *Collection) FromDomain(r *domain.Resource) error

func (*Collection) ToDomain

func (c *Collection) ToDomain() *domain.Resource

type Config

type Config struct {
	ProviderConfig *domain.ProviderConfig
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(pc *domain.ProviderConfig, crypto domain.Crypto) *Config

func (*Config) EncryptCredentials

func (c *Config) EncryptCredentials() error

func (*Config) ParseAndValidate

func (c *Config) ParseAndValidate() error

type Credentials

type Credentials struct {
	Host     string `json:"host" mapstructure:"host" validate:"required"`
	Username string `json:"username" mapstructure:"username" validate:"required"`
	Password string `json:"password" mapstructure:"password" validate:"required"`
}

func (*Credentials) Decrypt

func (c *Credentials) Decrypt(decryptor domain.Decryptor) error

func (*Credentials) Encrypt

func (c *Credentials) Encrypt(encryptor domain.Encryptor) error

type Database

type Database struct {
	ID                       int    `json:"id"`
	Name                     string `json:"name"`
	CacheFieldValuesSchedule string `json:"cache_field_values_schedule"`
	Timezone                 string `json:"timezone"`
	AutoRunQueries           bool   `json:"auto_run_queries"`
	MetadataSyncSchedule     string `json:"metadata_sync_schedule"`
	Engine                   string `json:"engine"`
	NativePermissions        string `json:"native_permissions"`
}

func (*Database) FromDomain

func (d *Database) FromDomain(r *domain.Resource) error

func (*Database) ToDomain

func (d *Database) ToDomain() *domain.Resource

type HTTPClient

type HTTPClient interface {
	Do(*http.Request) (*http.Response, error)
}

type MetabaseClient

type MetabaseClient interface {
	GetDatabases() ([]*Database, error)
	GetCollections() ([]*Collection, error)
	GrantDatabaseAccess(resource *Database, user, role string) error
	RevokeDatabaseAccess(resource *Database, user, role string) error
	GrantCollectionAccess(resource *Collection, user, role string) error
	RevokeCollectionAccess(resource *Collection, user, role string) error
}

type PermissionConfig added in v0.2.0

type PermissionConfig struct {
	Name string `json:"name" mapstructure:"name" validate:"required"`
}

type SessionRequest

type SessionRequest struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type SessionResponse

type SessionResponse struct {
	ID string `json:"id"`
}

Jump to

Keyboard shortcuts

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