redash

package
v0.4.3-0...-04f28d4 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package redash is a simple redash client library

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Config *Config
}

Client contains an active Redash API client

func NewClient

func NewClient(config *Config) (*Client, error)

NewClient returns a *Client from a valid *Config

func (*Client) CreateDataSource

func (c *Client) CreateDataSource(dataSourcePayload *DataSource) (*DataSource, error)

CreateDataSource creates a new DataSource

func (*Client) CreateGroup

func (c *Client) CreateGroup(groupPayload *GroupCreatePayload) (*Group, error)

CreateGroup creates a new Redash group

func (*Client) CreateUser

func (c *Client) CreateUser(userCreatePayload *UserCreatePayload) (*User, error)

CreateUser creates a new Redash user

func (*Client) DeleteDataSource

func (c *Client) DeleteDataSource(id int) error

DeleteDataSource deletes a specific DataSource

func (*Client) DeleteGroup

func (c *Client) DeleteGroup(id int) error

DeleteGroup deletes a Redash group

func (*Client) DisableUser

func (c *Client) DisableUser(id int) error

DisableUser disables an active user.

func (*Client) GetDataSource

func (c *Client) GetDataSource(id int) (*DataSource, error)

GetDataSource gets a specific DataSource

func (*Client) GetDataSourceTypes

func (c *Client) GetDataSourceTypes() ([]DataSourceType, error)

GetDataSourceTypes gets all available types with configuration details

func (*Client) GetDataSources

func (c *Client) GetDataSources() (*[]DataSource, error)

GetDataSources gets an array of all DataSources available

func (*Client) GetGroup

func (c *Client) GetGroup(id int) (*Group, error)

GetGroup returns an individual Redash group

func (*Client) GetGroups

func (c *Client) GetGroups() (*[]Group, error)

GetGroups returns a list of Redash groups

func (*Client) GetUser

func (c *Client) GetUser(id int) (*User, error)

GetUser gets a specific User

func (*Client) GetUserByEmail

func (c *Client) GetUserByEmail(email string) (*User, error)

GetUserByEmail returns a single user from their email address

func (*Client) GetUsers

func (c *Client) GetUsers(pageSize int) (*UserList, error)

GetUsers returns a paginated list of users

func (*Client) GroupAddDataSource

func (c *Client) GroupAddDataSource(groupID int, dataSourceID int) error

GroupAddDataSource adds a Data Source to a Redash group

func (*Client) GroupAddUser

func (c *Client) GroupAddUser(groupID int, userID int) error

GroupAddUser adds a user to a Redash group

func (*Client) GroupRemoveDataSource

func (c *Client) GroupRemoveDataSource(groupID int, dataSourceID int) error

GroupRemoveDataSource removes a Data Source from a Redash group

func (*Client) GroupRemoveUser

func (c *Client) GroupRemoveUser(groupID int, userID int) error

GroupRemoveUser removes a user from a Redash group

func (*Client) IsStrict

func (c *Client) IsStrict() bool

IsStrict returns true if StrictMode is set. This currently causes data_source creates/updates to fail if extraneous properties are present in the payload.

func (*Client) SanitizeDataSourceOptions

func (c *Client) SanitizeDataSourceOptions(dataSource *DataSource) (*DataSource, error)

SanitizeDataSourceOptions checks the validity of the options field in a DataSource.Option against Redash's API and cleans up when possible

func (*Client) SearchUsers

func (c *Client) SearchUsers(term string) (*UserList, error)

SearchUsers finds a list of users matching a string (searches `name` and `email` fields)

func (*Client) UpdateDataSource

func (c *Client) UpdateDataSource(id int, dataSourcePayload *DataSource) (*DataSource, error)

UpdateDataSource Updates an existing DataSource

func (*Client) UpdateGroup

func (c *Client) UpdateGroup(id int, group *Group) (*Group, error)

UpdateGroup updates an existing Redash group

func (*Client) UpdateUser

func (c *Client) UpdateUser(id int, userUpdatePayload *UserUpdatePayload) (*User, error)

UpdateUser updates an existing Redash user

type Config

type Config struct {
	RedashURI  string
	APIKey     string
	StrictMode bool
}

Config holds the necessary setup vars

type DataSource

type DataSource struct {
	ID                 int                    `json:"id,omitempty"`
	Name               string                 `json:"name,omitempty"`
	ScheduledQueueName string                 `json:"scheduled_queue_name,omitempty"`
	QueueName          string                 `json:"queue_name,omitempty"`
	Options            map[string]interface{} `json:"options,omitempty"`
	Paused             int                    `json:"paused,omitempty"`
	PauseReason        string                 `json:"pause_reason,omitempty"`
	Type               string                 `json:"type,omitempty"`
	Syntax             string                 `json:"syntax,omitempty"`
	Groups             map[int]bool           `json:"groups,omitempty"`
}

DataSource struct

type DataSourceType

type DataSourceType struct {
	Type                string `json:"type"`
	Name                string `json:"name,omitempty"`
	ConfigurationSchema struct {
		Secret     []string                               `json:"secret,omitempty"`
		Required   []string                               `json:"required,omitempty"`
		Type       string                                 `json:"type,omitempty"`
		Order      []string                               `json:"order,omitempty"`
		Properties map[string]DataSourceTypePropertyField `json:"properties,omitempty"`
	} `json:"configuration_schema,omitempty"`
}

DataSourceType struct

type DataSourceTypePropertyField

type DataSourceTypePropertyField struct {
	Type    string
	Title   string
	Default interface{}
}

DataSourceTypePropertyField struct

type Group

type Group struct {
	CreatedAt   time.Time `json:"created_at,omitempty"`
	Permissions []string  `json:"permissions,omitempty"`
	Type        string    `json:"type,omitempty"`
	ID          int       `json:"id,omitempty"`
	Name        string    `json:"name,omitempty"`
}

Group struct

type GroupCreatePayload

type GroupCreatePayload struct {
	Name string `json:"name"`
}

GroupCreatePayload struct

type GroupDataSource

type GroupDataSource struct {
	DataSourceID int `json:"data_source_id"`
}

GroupDataSource struct

type GroupUser

type GroupUser struct {
	MemberID int `json:"user_id"`
}

GroupUser struct

type User

type User struct {
	AuthType            string      `json:"auth_type,omitempty"`
	IsDisabled          bool        `json:"is_disabled,omitempty"`
	UpdatedAt           time.Time   `json:"updated_at,omitempty"`
	ProfileImageURL     string      `json:"profile_image_url,omitempty"`
	IsInvitationPending bool        `json:"is_invitation_pending,omitempty"`
	Groups              []int       `json:"groups,omitempty"`
	ID                  int         `json:"id,omitempty"`
	Name                string      `json:"name,omitempty"`
	CreatedAt           time.Time   `json:"created_at,omitempty"`
	DisabledAt          interface{} `json:"disabled_at,omitempty"`
	IsEmailVerified     bool        `json:"is_email_verified,omitempty"`
	ActiveAt            time.Time   `json:"active_at,omitempty"`
	Email               string      `json:"email,omitempty"`
}

User representation

type UserCreatePayload

type UserCreatePayload struct {
	Name  string `json:"name"`
	Email string `json:"email"`
}

UserCreatePayload struct for mutating users.

type UserList

type UserList struct {
	Count    int `json:"count"`
	Page     int `json:"page"`
	PageSize int `json:"page_size"`
	Results  []struct {
		AuthType            string    `json:"auth_type,omitempty"`
		IsDisabled          bool      `json:"is_disabled,omitempty"`
		UpdatedAt           time.Time `json:"updated_at,omitempty"`
		ProfileImageURL     string    `json:"profile_image_url,omitempty"`
		IsInvitationPending bool      `json:"is_invitation_pending,omitempty"`
		Groups              []struct {
			ID   int    `json:"id,omitempty"`
			Name string `json:"name,omitempty"`
		} `json:"groups,omitempty"`
		ID              int         `json:"id,omitempty"`
		Name            string      `json:"name,omitempty"`
		CreatedAt       time.Time   `json:"created_at,omitempty"`
		DisabledAt      interface{} `json:"disabled_at,omitempty"`
		IsEmailVerified bool        `json:"is_email_verified,omitempty"`
		ActiveAt        time.Time   `json:"active_at,omitempty"`
		Email           string      `json:"email,omitempty"`
	} `json:"results,omitempty"`
}

UserList struct

type UserUpdatePayload

type UserUpdatePayload struct {
	Name   string `json:"name"`
	Email  string `json:"email"`
	Groups []int  `json:"group_ids"`
}

UserUpdatePayload struct for mutating users.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳