Documentation ¶
Index ¶
- Constants
- Variables
- func AuthRequest(authURL, username, password string, tlsSkipVerify bool) (*http.Response, error)
- func BuildURL(server, urlpath string) string
- func NewClientEnv(opts *ConfigEnvOpts) (*http.Client, *AuthResponse, *Config, error)
- func NewClientSessionID(sessionID string, allowInsecure bool) *http.Client
- func RetrieveQuestions(cu ClientUtil, q2s QuestionsToSlug, dir string) (map[string][]byte, error)
- type AuthResponse
- func NewClient(cfg Config) (*http.Client, *AuthResponse, error)
- func NewClientPassword(baseURL, username, password string, allowInsecure bool) (*http.Client, *AuthResponse, error)
- func NewClientPasswordWithSessionID(baseURL, username, password, sessionID string, allowInsecure bool) (*http.Client, *AuthResponse, error)
- type ClientUtil
- func (cu *ClientUtil) BuildMetabaseCardAPI(cardID int, format string) string
- func (cu *ClientUtil) GetCurrentUser() (User, *http.Response, error)
- func (cu *ClientUtil) GetQuestionData(cardID int) ([]byte, error)
- func (cu *ClientUtil) GetSCIMUser() (scim.User, error)
- func (cu *ClientUtil) GetStoreQuestionData(cardID int, filename string, perm os.FileMode) ([]byte, error)
- type Config
- type ConfigEnvOpts
- type QuestionsToSlug
- type User
Constants ¶
View Source
const ( HeaderMetabaseSession = "X-Metabase-Session" RelPathAPIDatabase = "api/database" RelPathAPISession = "api/session" RelPathAPIUserCurrent = "api/user/current" // Example environment variables EnvMetabaseBaseURL = "METABASE_BASE_URL" EnvMetabaseUsername = "METABASE_USERNAME" EnvMetabasePassword = "METABASE_PASSWORD" // #nosec G101 EnvMetabaseSessionID = "METABASE_SESSION_ID" EnvMetabaseTLSSkipVerify = "METABASE_TLS_SKIP_VERIFY" // #nosec G101 )
View Source
const (
CurrentUserURLPath = "/api/user/current"
)
Variables ¶
View Source
var (
TLSInsecureSkipVerify = false
)
Functions ¶
func AuthRequest ¶
AuthRequest creates an authentiation request that returns a id that is used in Metabase API requests. It follows the following curl command: curl -v -H "Content-Type: application/json" -d '{"username":"myusername","password":"mypassword"}' -XPOST 'http://example.com/api/session'
func NewClientEnv ¶
func NewClientEnv(opts *ConfigEnvOpts) (*http.Client, *AuthResponse, *Config, error)
func NewClientSessionID ¶ added in v0.13.0
func RetrieveQuestions ¶
func RetrieveQuestions(cu ClientUtil, q2s QuestionsToSlug, dir string) (map[string][]byte, error)
Types ¶
type AuthResponse ¶
type AuthResponse struct {
ID string `json:"id,omitempty"`
}
func NewClientPassword ¶
func NewClientPassword(baseURL, username, password string, allowInsecure bool) (*http.Client, *AuthResponse, error)
NewClient returns a *http.Client that will add the Metabase Session header to each request.
func NewClientPasswordWithSessionID ¶ added in v0.13.0
func NewClientPasswordWithSessionID(baseURL, username, password, sessionID string, allowInsecure bool) (*http.Client, *AuthResponse, error)
NewClientPasswordWithSessionId returns a *http.Client first attempting to use the supplied `sessionId` with a fallback to `username` and `password`.
type ClientUtil ¶
func NewClientUtil ¶
func NewClientUtil(baseURL, username, password string, tlsSkipVerify bool) (*ClientUtil, error)
func (*ClientUtil) BuildMetabaseCardAPI ¶
func (cu *ClientUtil) BuildMetabaseCardAPI(cardID int, format string) string
func (*ClientUtil) GetCurrentUser ¶
func (cu *ClientUtil) GetCurrentUser() (User, *http.Response, error)
func (*ClientUtil) GetQuestionData ¶
func (cu *ClientUtil) GetQuestionData(cardID int) ([]byte, error)
func (*ClientUtil) GetSCIMUser ¶
func (cu *ClientUtil) GetSCIMUser() (scim.User, error)
func (*ClientUtil) GetStoreQuestionData ¶
type Config ¶
type Config struct { BaseURL string SessionID string Username string Password string TLSSkipVerify bool }
Config is a basic struct to hold API access information for Metabase.
type ConfigEnvOpts ¶
type ConfigEnvOpts struct { EnvPaths []string EnvPathsLoad bool EnvMetabaseBaseURL string EnvMetabaseSessionID string EnvMetabaseUsername string EnvMetabasePassword string // #nosec G101 EnvMetabaseTLSSkipVerify string }
func (*ConfigEnvOpts) Config ¶
func (opts *ConfigEnvOpts) Config() Config
func (*ConfigEnvOpts) Defaultify ¶
func (opts *ConfigEnvOpts) Defaultify()
func (*ConfigEnvOpts) LoadEnv ¶
func (opts *ConfigEnvOpts) LoadEnv() error
type QuestionsToSlug ¶
type User ¶
type User struct { Email string `json:"email,omitempty"` LdapAuth bool `json:"ldap_auth,omitempty"` FirstName string `json:"first_name,omitempty"` LastLogin time.Time `json:"last_login,omitempty"` IsActive bool `json:"is_active,omitempty"` IsQbnewb bool `json:"is_qbnewb,omitempty"` IsSuperuser bool `json:"is_superuser,omitempty"` ID int `json:"id,omitempty"` LastName string `json:"last_name,omitempty"` DateJoined time.Time `json:"date_joined,omitempty"` CommonName string `json:"common_name,omitempty"` GoogleAuth bool `json:"google_auth,omitempty"` }
Click to show internal directories.
Click to hide internal directories.