client

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAuthFailed = errors.New("auth failed; check ARCHERY_USERNAME / ARCHERY_PASSWORD")

Functions

This section is empty.

Types

type Client

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

func New

func New(cfg *config.Config, opts ...Option) (*Client, error)

func (*Client) Endpoint

func (c *Client) Endpoint() string

Endpoint exposes the configured base URL (for diagnostics).

func (*Client) Instance

func (c *Client) Instance() string

Instance exposes the configured instance name (for diagnostics).

func (*Client) InstanceResource

func (c *Client) InstanceResource(rt ResourceType, db, schema, table string) ([]string, error)

InstanceResource lists databases / schemas / tables / columns. db/schema/table are passed only when meaningful for the resource type.

func (*Client) Login

func (c *Client) Login() error

Login establishes an authenticated session with Archery.

hhyo/Archery's login form is JS-driven: the page POSTs to /authenticate/ (not /login/) over AJAX with username + password. We mirror that:

  1. GET /login/ — primes the csrftoken cookie (the page itself sets it).
  2. POST /authenticate/ with X-CSRFToken header + form (username, password). Response is {"status": 0, "msg": "ok", "data": null} on success and the server sets a sessionid cookie.

func (*Client) Query

func (c *Client) Query(db, schema, sql string, limit int) (*QueryResult, error)

Query runs SELECT against (db, schema). limit corresponds to archery's limit_num (server appends LIMIT internally).

type Option

type Option func(*Client)

func WithCookiePath

func WithCookiePath(p string) Option

func WithVerbose

func WithVerbose(w io.Writer) Option

type QueryResult

type QueryResult struct {
	FullSQL      string   `json:"full_sql"`
	IsExecute    bool     `json:"is_execute"`
	IsMasked     bool     `json:"is_masked"`
	QueryTime    float64  `json:"query_time"`
	MaskRuleHit  bool     `json:"mask_rule_hit"`
	Warning      *string  `json:"warning"`
	Error        *string  `json:"error"`
	IsCritical   bool     `json:"is_critical"`
	Rows         [][]any  `json:"rows"`
	ColumnList   []string `json:"column_list"`
	ColumnType   []string `json:"column_type"`
	AffectedRows int      `json:"affected_rows"`
}

QueryResult mirrors the data block of /query/ responses.

type ResourceType

type ResourceType string

ResourceType is the kind of metadata to list via /instance/instance_resource/.

const (
	ResDatabase ResourceType = "database"
	ResSchema   ResourceType = "schema"
	ResTable    ResourceType = "table"
	ResColumn   ResourceType = "column"
)

type ServerError

type ServerError struct {
	Status int    `json:"status"`
	Msg    string `json:"msg"`
}

ServerError is returned when archery responds with status != 0.

func (*ServerError) Error

func (e *ServerError) Error() string

Jump to

Keyboard shortcuts

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