metabase

package
v0.1.18 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2023 License: MIT Imports: 21 Imported by: 2

README

Go API client for metabase

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

  • API version: 1.0.0
  • Package version: 1.0.0
  • Build package: org.openapitools.codegen.languages.GoClientCodegen

Installation

Install the following dependencies:

go get github.com/stretchr/testify/assert
go get golang.org/x/oauth2
go get golang.org/x/net/context
go get github.com/antihax/optional

Put the package under your project folder and add the following in import:

import "./metabase"

Documentation for API Endpoints

All URIs are relative to http://example.com/api

Class Method HTTP request Description
DatabaseApi ListDatabases Get /api/database List Databases
DatasetApi QueryDatabase Post /api/dataset Execute a query

Documentation For Models

Documentation For Authorization

Endpoints do not require authorization.

Author

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ContextOAuth2 takes an oauth2.TokenSource as authentication for the request.
	ContextOAuth2 = contextKey("token")

	// ContextBasicAuth takes BasicAuth as authentication for the request.
	ContextBasicAuth = contextKey("basic")

	// ContextAccessToken takes a string oauth2 access token as authentication for the request.
	ContextAccessToken = contextKey("accesstoken")

	// ContextAPIKey takes an APIKey as authentication for the request
	ContextAPIKey = contextKey("apikey")
)

Functions

func CacheExpires

func CacheExpires(r *http.Response) time.Time

CacheExpires helper function to determine remaining time before repeating a request.

Types

type APIClient

type APIClient struct {
	DatabaseApi *DatabaseApiService

	DatasetApi *DatasetApiService
	// contains filtered or unexported fields
}

APIClient manages communication with the Metabase API v1.0.0 In most cases there should be only one, shared, APIClient.

func NewAPIClient

func NewAPIClient(cfg *Configuration) *APIClient

NewAPIClient creates a new API client. Requires a userAgent string describing your application. optionally a custom http.Client to allow for advanced features such as caching.

func (*APIClient) ChangeBasePath

func (c *APIClient) ChangeBasePath(path string)

Change base path to allow switching to mocks

func (*APIClient) HTTPClient

func (apiClient *APIClient) HTTPClient() *http.Client

type APIKey

type APIKey struct {
	Key    string
	Prefix string
}

APIKey provides API key based authentication to a request passed via context using ContextAPIKey

type APIResponse

type APIResponse struct {
	*http.Response `json:"-"`
	Message        string `json:"message,omitempty"`
	// Operation is the name of the OpenAPI operation.
	Operation string `json:"operation,omitempty"`
	// RequestURL is the request URL. This value is always available, even if the
	// embedded *http.Response is nil.
	RequestURL string `json:"url,omitempty"`
	// Method is the HTTP method used for the request.  This value is always
	// available, even if the embedded *http.Response is nil.
	Method string `json:"method,omitempty"`
	// Payload holds the contents of the response body (which may be nil or empty).
	// This is provided here as the raw response.Body() reader will have already
	// been drained.
	Payload []byte `json:"-"`
}

func NewAPIResponse

func NewAPIResponse(r *http.Response) *APIResponse

func NewAPIResponseWithError

func NewAPIResponseWithError(errorMessage string) *APIResponse

type BasicAuth

type BasicAuth struct {
	UserName string `json:"userName,omitempty"`
	Password string `json:"password,omitempty"`
}

BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth

type Configuration

type Configuration struct {
	BasePath      string            `json:"basePath,omitempty"`
	Host          string            `json:"host,omitempty"`
	Scheme        string            `json:"scheme,omitempty"`
	DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
	UserAgent     string            `json:"userAgent,omitempty"`
	HTTPClient    *http.Client
}

func NewConfiguration

func NewConfiguration() *Configuration

func (*Configuration) AddDefaultHeader

func (c *Configuration) AddDefaultHeader(key string, value string)

type Database

type Database struct {
	Id                       int64    `json:"id"`
	Name                     string   `json:"name,omitempty"`
	Description              string   `json:"description,omitempty"`
	Features                 []string `json:"features,omitempty"`
	IsFullSync               bool     `json:"is_full_sync,omitempty"`
	IsSample                 bool     `json:"is_sample,omitempty"`
	CacheFieldValuesSchedule string   `json:"cache_field_values_schedule,omitempty"`
	MetadataSyncSchedule     string   `json:"metadata_sync_schedule,omitempty"`
	// type unknown
	Caveats           string    `json:"caveats,omitempty"`
	Engine            string    `json:"engine,omitempty"`
	CreatedAt         time.Time `json:"created_at,omitempty"`
	UpdatedAt         time.Time `json:"updated_at,omitempty"`
	NativePermissions string    `json:"native_permissions,omitempty"`
	// type unknown
	PointsOfInterest string          `json:"points_of_interest,omitempty"`
	Details          DatabaseDetails `json:"details,omitempty"`
	Tables           []DatabaseTable `json:"tables,omitempty"`
}

type DatabaseApiService

type DatabaseApiService service

func (*DatabaseApiService) ListDatabases

func (a *DatabaseApiService) ListDatabases(ctx context.Context, localVarOptionals *ListDatabasesOpts) ([]Database, *http.Response, error)

type DatabaseDetails

type DatabaseDetails struct {
	Host                     string `json:"host,omitempty"`
	Port                     int32  `json:"port,omitempty"`
	Dbname                   string `json:"dbname,omitempty"`
	AuthMech                 int32  `json:"authMech,omitempty"`
	User                     string `json:"user,omitempty"`
	Password                 string `json:"password,omitempty"`
	ConnProperties           string `json:"connProperties,omitempty"`
	LetUserControlScheduling bool   `json:"let-user-control-scheduling,omitempty"`
}

type DatabaseTable

type DatabaseTable struct {
	Description string `json:"description,omitempty"`
	// unknown type
	EntityType string `json:"entity_type,omitempty"`
	Schema     string `json:"schema,omitempty"`
	// unknown type
	RawTableId           string `json:"raw_table_id,omitempty"`
	ShowInGettingStarted bool   `json:"show_in_getting_started,omitempty"`
	Name                 string `json:"name,omitempty"`
	// unknown type
	Caveats   string    `json:"caveats,omitempty"`
	Rows      int64     `json:"rows,omitempty"`
	UpdatedAt time.Time `json:"updated_at,omitempty"`
	// unknown type
	EntityName string `json:"entity_name,omitempty"`
	Active     bool   `json:"active,omitempty"`
	Id         int64  `json:"id,omitempty"`
	DbId       int64  `json:"db_id,omitempty"`
	// unknown type
	VisibilityType string    `json:"visibility_type,omitempty"`
	DisplayName    string    `json:"display_name,omitempty"`
	CreatedAt      time.Time `json:"created_at,omitempty"`
	// unknown type
	PointsOfInterest string `json:"points_of_interest,omitempty"`
}

type DatasetApiService

type DatasetApiService service

func (*DatasetApiService) QueryDatabase

func (a *DatasetApiService) QueryDatabase(ctx context.Context, datasetQueryJsonQuery DatasetQueryJsonQuery) (DatasetQueryResults, *http.Response, error)

DatasetApiService Execute a query Execute a query and retrieve the results in the usual format.

  • @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param datasetQueryJsonQuery

@return DatasetQueryResults

type DatasetQueryConstraints

type DatasetQueryConstraints struct {
	MaxResults         int64 `json:"max-results,omitempty"`
	MaxResultsBareRows int64 `json:"max-results-bare-rows,omitempty"`
}

type DatasetQueryDsl

type DatasetQueryDsl struct {
	SourceTable int64               `json:"source_table,omitempty"`
	Limit       int64               `json:"limit,omitempty"`
	Page        DatasetQueryDslPage `json:"page,omitempty"`
}

Dataset query request and response object

type DatasetQueryDslPage

type DatasetQueryDslPage struct {
	Page  int64 `json:"page,omitempty"`
	Items int64 `json:"items,omitempty"`
}

type DatasetQueryJsonQuery

type DatasetQueryJsonQuery struct {
	Database    int64                   `json:"database,omitempty"`
	Type        string                  `json:"type,omitempty"`
	Native      DatasetQueryNative      `json:"native,omitempty"`
	Query       DatasetQueryDsl         `json:"query,omitempty"`
	Constraints DatasetQueryConstraints `json:"constraints,omitempty"`
}

type DatasetQueryNative

type DatasetQueryNative struct {
	Query string `json:"query,omitempty"`
}

type DatasetQueryOpts

type DatasetQueryOpts struct {
	Description string `json:"description,omitempty"`
	// unknown type
	EntityType map[string]interface{} `json:"entity_type,omitempty"`
}

type DatasetQueryResults

type DatasetQueryResults struct {
	StartedAt time.Time             `json:"started_at,omitempty"`
	JsonQuery DatasetQueryJsonQuery `json:"json_query,omitempty"`
	// type unknown
	AverageExecutionTime string                  `json:"average_execution_time,omitempty"`
	Status               string                  `json:"status,omitempty"`
	Context              string                  `json:"context,omitempty"`
	RowCount             int64                   `json:"row_count,omitempty"`
	RunningTime          int64                   `json:"running_time,omitempty"`
	Data                 DatasetQueryResultsData `json:"data,omitempty"`
}

type DatasetQueryResultsCol

type DatasetQueryResultsCol struct {
	Description string `json:"description,omitempty"`
	TableId     int64  `json:"table_id,omitempty"`
	SchemaName  string `json:"schema_name,omitempty"`
	SpecialType string `json:"special_type,omitempty"`
	Name        string `json:"name,omitempty"`
	Source      string `json:"source,omitempty"`
	// unknown type
	RemappedFrom string `json:"remapped_from,omitempty"`
	// can be '{\"target_table_id\":517}'
	ExtraInfo map[string]interface{} `json:"extra_info,omitempty"`
	// unknown type
	FkFieldId string `json:"fk_field_id,omitempty"`
	// unknown type
	RemappedTo     string                            `json:"remapped_to,omitempty"`
	Id             int64                             `json:"id,omitempty"`
	VisibilityType string                            `json:"visibility_type,omitempty"`
	Target         DatasetQueryResultsColTarget      `json:"target,omitempty"`
	DisplayName    string                            `json:"display_name,omitempty"`
	Fingerprint    DatasetQueryResultsColFingerprint `json:"fingerprint,omitempty"`
	BaseType       string                            `json:"base_type,omitempty"`
}

type DatasetQueryResultsColFingerprint

type DatasetQueryResultsColFingerprint struct {
	Global DatasetQueryResultsColFingerprintGlobal `json:"global,omitempty"`
	// map[string]DatasetQueryResultsColFingerprintType results in map[string]interface{}
	Type map[string]interface{} `json:"type,omitempty"`
}

type DatasetQueryResultsColFingerprintGlobal

type DatasetQueryResultsColFingerprintGlobal struct {
	DistinctCount int64 `json:"distinct-count,omitempty"`
}

type DatasetQueryResultsColFingerprintType

type DatasetQueryResultsColFingerprintType struct {
	PercentJson   float64 `json:"percent-json,omitempty"`
	PercentUrl    float64 `json:"percent-url,omitempty"`
	PercentEmail  float64 `json:"percent-email,omitempty"`
	AverageLength float64 `json:"average-length,omitempty"`
}

type DatasetQueryResultsColTarget

type DatasetQueryResultsColTarget struct {
	Id             int64  `json:"id,omitempty"`
	Name           string `json:"name,omitempty"`
	DisplayName    string `json:"display_name,omitempty"`
	TableId        int64  `json:"table_id,omitempty"`
	Description    string `json:"description,omitempty"`
	BaseType       string `json:"base_type,omitempty"`
	SpecialType    string `json:"special_type,omitempty"`
	VisibilityType string `json:"visibility_type,omitempty"`
}

type DatasetQueryResultsData

type DatasetQueryResultsData struct {
	Columns         []string                      `json:"columns,omitempty"`
	Rows            [][]interface{}               `json:"rows,omitempty"`
	NativeForm      DatasetQueryResultsNativeForm `json:"native_form,omitempty"`
	Cols            []DatasetQueryResultsCol      `json:"cols,omitempty"`
	ResultsMetadata DatasetQueryResultsMetadata   `json:"results_metadata,omitempty"`
	RowsTruncated   int64                         `json:"rows_truncated,omitempty"`
}

type DatasetQueryResultsMetadata

type DatasetQueryResultsMetadata struct {
	Checksum string                              `json:"checksum,omitempty"`
	Columns  []DatasetQueryResultsMetadataColumn `json:"columns,omitempty"`
}

type DatasetQueryResultsMetadataColumn

type DatasetQueryResultsMetadataColumn struct {
	BaseType    string `json:"base_type,omitempty"`
	DisplayName string `json:"display_name,omitempty"`
	Name        string `json:"name,omitempty"`
	SpecialType string `json:"special_type,omitempty"`
}

type DatasetQueryResultsNativeForm

type DatasetQueryResultsNativeForm struct {
	Query string `json:"query,omitempty"`
	// unknown type
	Params string `json:"params,omitempty"`
}

type GenericOpenAPIError

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

GenericOpenAPIError Provides access to the body, error and model on returned errors.

func (GenericOpenAPIError) Body

func (e GenericOpenAPIError) Body() []byte

Body returns the raw bytes of the response

func (GenericOpenAPIError) Error

func (e GenericOpenAPIError) Error() string

Error returns non-empty string if there was an error.

func (GenericOpenAPIError) Model

func (e GenericOpenAPIError) Model() interface{}

Model returns the unpacked model of the error

type ListDatabasesOpts

type ListDatabasesOpts struct {
	IncludeTables optional.Bool
	IncludeCards  optional.Bool
}

Jump to

Keyboard shortcuts

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