client

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxPageSize = 100
	MinPageSize = 10
)
View Source
const (
	UserType = "user"
	RoleType = "role"
)
View Source
const ColumnType = "column"
View Source
const DatabaseType = "database"
View Source
const RoutineType = "routine"
View Source
const ServerType = "server"
View Source
const TableType = "table"

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func New

func New(ctx context.Context, dsn string) (*Client, error)

func (*Client) GetServerInfo

func (c *Client) GetServerInfo(ctx context.Context) (*ServerModel, error)

func (*Client) GetUser

func (c *Client) GetUser(ctx context.Context, user string, host string) (*User, error)

GetUser returns a single user@host row and its perms Grants required:

GRANT SELECT (Host, User, Select_priv, Insert_priv, Update_priv,  Delete_priv, Create_priv, Drop_priv, Reload_priv,
			  References_priv, Index_priv, Alter_priv, Show_db_priv, Super_priv, Create_tmp_table_priv, Lock_tables_priv,
			  Execute_priv, Repl_slave_priv, Repl_client_priv, Create_view_priv, Show_view_priv, Create_routine_priv,
			  Alter_routine_priv, Create_user_priv, Event_priv, Trigger_priv, Create_tablespace_priv, Create_role_priv,
			  Drop_role_priv, File_priv,, Grant_priv, authentication_string) ON mysql.user TO user@host;

func (*Client) IsVersion8

func (c *Client) IsVersion8() bool

func (*Client) ListColumnGrants

func (c *Client) ListColumnGrants(ctx context.Context, user string, host string) ([]*ColumnGrant, error)

ListColumnGrants returns a single user@host row and its perms Grants required:

GRANT SELECT (Host, User, Db, Column_name, Column_priv, Table_name) ON mysql.columns_priv TO user@host;

func (*Client) ListColumns

func (c *Client) ListColumns(ctx context.Context, parentResourceID *v2.ResourceId, pager *Pager) ([]*ColumnModel, string, error)

ListColumns scans the server for all columns associated with the parent table.

func (*Client) ListDatabaseGrants

func (c *Client) ListDatabaseGrants(ctx context.Context, user string, host string) ([]*DatabaseGrant, error)

ListDatabaseGrants returns a single user@host row and its perms Grants required:

GRANT SELECT (Host, User, Db, Select_priv, Insert_priv, Update_priv,  Delete_priv, Create_priv, Drop_priv,
			  Grant_priv, References_priv, Index_priv, Alter_priv, Create_tmp_table_priv, Lock_tables_priv,
			  Execute_priv, Create_view_priv, Show_view_priv, Create_routine_priv,
			  Alter_routine_priv, Event_priv, Trigger_priv) ON mysql.db TO user@host;

func (*Client) ListDatabases

func (c *Client) ListDatabases(ctx context.Context, pager *Pager) ([]*DbModel, string, error)

ListDatabases scans and returns all the databases.

func (*Client) ListGlobalGrants

func (c *Client) ListGlobalGrants(ctx context.Context, user string, host string) ([]*GlobalGrant, error)

ListGlobalGrants returns the set of grants from the mysql.global_grants Required MySQL grant for connector:

GRANT SELECT (USER, HOST, PRIV, WITH_GRANT_OPTION) ON mysql.global_grants TO user@host;

func (*Client) ListProxyGrants

func (c *Client) ListProxyGrants(ctx context.Context, user string, host string) ([]*ProxyGrant, error)

ListProxyGrants returns a single user@host row and its perms Grants required:

GRANT SELECT (Host, User, Db, Column_name, Column_priv, Table_name) ON mysql.columns_priv TO user@host;

func (*Client) ListRoleGrants

func (c *Client) ListRoleGrants(ctx context.Context, user string, host string) ([]*RoleGrant, error)

ListRoleGrants returns a single user@host row and its role edges Grants required:

GRANT SELECT (FROM_HOST, FROM_USER, TO_HOST, TO_USER, WITH_ADMIN_OPTION) ON mysql.role_edges TO user@host;

func (*Client) ListRoutines

func (c *Client) ListRoutines(ctx context.Context, parentResourceID *v2.ResourceId, pager *Pager) ([]*RoutineModel, string, error)

ListRoutines scans and returns all the routines associated with the parent database.

func (*Client) ListTableGrants

func (c *Client) ListTableGrants(ctx context.Context, user string, host string) ([]*TableGrant, error)

ListTableGrants returns a single user@host row and its perms Grants required:

GRANT SELECT (Host, User, Db, Table_priv, Table_name) ON mysql.tables_priv TO user@host;

func (*Client) ListTables

func (c *Client) ListTables(ctx context.Context, parentResourceID *v2.ResourceId, pager *Pager) ([]*TableModel, string, error)

ListTables scans and returns all the tables for the parent database.

func (*Client) ListUsers

func (c *Client) ListUsers(ctx context.Context, userType string, pager *Pager, collapseUsers bool) ([]*User, string, error)

ListUsers queries the server and fetches all the users for the given page.

func (*Client) ValidateConnection

func (c *Client) ValidateConnection(ctx context.Context) error

type ColumnGrant

type ColumnGrant struct {
	Id       string `db:"-"`
	User     string `db:"User"`
	Host     string `db:"Host"`
	Database string `db:"Db"`
	Table    string `db:"Table_name"`
	Column   string `db:"Column_name"`
	Privs    string `db:"Column_priv"`
}

func (*ColumnGrant) GetPrivs

func (u *ColumnGrant) GetPrivs(ctx context.Context) map[string]struct{}

GetPrivs parses the columns grant data from mysql.

func (*ColumnGrant) TableID

func (u *ColumnGrant) TableID() string

type ColumnModel

type ColumnModel struct {
	ID       string `db:"-"`
	Name     string `db:"COLUMN_NAME"`
	Database string `db:"TABLE_SCHEMA"`
	Table    string `db:"TABLE_NAME"`
}

type DatabaseGrant

type DatabaseGrant struct {
	Id       string `db:"-"`
	User     string `db:"User"`
	Host     string `db:"Host"`
	Database string `db:"Db"`
	Privs    string `db:"privs"`
}

func (*DatabaseGrant) GetPrivs

func (u *DatabaseGrant) GetPrivs(ctx context.Context) map[string]struct{}

type DbModel

type DbModel struct {
	ID   string `db:"-"`
	Name string `db:"SCHEMA_NAME"`
}

type GlobalGrant

type GlobalGrant struct {
	User      string `db:"USER"`
	Host      string `db:"HOST"`
	Priv      string `db:"PRIV"`
	WithGrant string `db:"WITH_GRANT_OPTION"`
}

type Pager

type Pager struct {
	Token string
	Size  int
}

func (*Pager) Parse

func (p *Pager) Parse() (int, int, error)

Parse returns the offset and page size.

type ProxyGrant

type ProxyGrant struct {
	Id          string `db:"-"`
	User        string `db:"User"`
	Host        string `db:"Host"`
	ProxiedHost string `db:"Proxied_host"`
	ProxiedUser string `db:"Proxied_user"`
	WithGrant   int    `db:"With_grant"`
}

type RoleGrant

type RoleGrant struct {
	Id        string `db:"-"`
	FromHost  string `db:"FROM_HOST"`
	FromUser  string `db:"FROM_USER"`
	ToHost    string `db:"TO_HOST"`
	ToUser    string `db:"TO_USER"`
	WithGrant string `db:"WITH_ADMIN_OPTION"`
}

type RoutineModel

type RoutineModel struct {
	ID       string `db:"-"`
	Name     string `db:"SPECIFIC_NAME"`
	Database string `db:"ROUTINE_SCHEMA"`
	Type     string `db:"ROUTINE_TYPE"`
}

type ServerModel

type ServerModel struct {
	ID      string `db:"-"`
	Name    string `db:"hostname"`
	Version string `db:"version"`
}

type TableGrant

type TableGrant struct {
	Id       string `db:"-"`
	User     string `db:"User"`
	Host     string `db:"Host"`
	Database string `db:"Db"`
	Table    string `db:"Table_name"`
	Privs    string `db:"Table_priv"`
}

func (*TableGrant) GetPrivs

func (u *TableGrant) GetPrivs(ctx context.Context) map[string]struct{}

type TableModel

type TableModel struct {
	ID       string `db:"-"`
	Name     string `db:"TABLE_NAME"`
	Database string `db:"TABLE_SCHEMA"`
	Type     string `db:"TABLE_TYPE"`
}

type User

type User struct {
	UserType string `db:"user_type"`
	Host     string `db:"Host"`
	User     string `db:"User"`
	Privs    string `db:"privs"`
}

func (*User) GetID

func (u *User) GetID() string

func (*User) GetPrivs

func (u *User) GetPrivs(ctx context.Context) map[string]struct{}

Jump to

Keyboard shortcuts

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