Documentation ¶
Index ¶
- Constants
- Variables
- func CacheTableSchema(qb *qbclient.Client, tableID string) error
- func Export(qb *qbclient.Client, opts *ExportOptions) error
- func GetOptions(ctx context.Context, logger *cliutil.LeveledLogger, input interface{}, ...)
- func HandleError(ctx context.Context, logger *cliutil.LeveledLogger, message string, err error)
- func Import(qb *qbclient.Client, opts *ImportOptions) (*qbclient.InsertRecordsOutputMetadata, error)
- func NewClient(cmd *cobra.Command, cfg GlobalConfig) (ctx context.Context, logger *cliutil.LeveledLogger, qb *qbclient.Client)
- func NewDumpPlugin(ctx context.Context, logger *cliutil.LeveledLogger, transid string, ...) qbclient.Plugin
- func NewGroupOption(tag map[string]string) cliutil.OptionType
- func NewLogger(cmd *cobra.Command, cfg GlobalConfig) (ctx context.Context, logger *cliutil.LeveledLogger, transid xid.ID)
- func NewLoggerPlugin(ctx context.Context, logger *cliutil.LeveledLogger) qbclient.Plugin
- func NewQueryOption(tag map[string]string) cliutil.OptionType
- func NewRecordOption(tag map[string]string) cliutil.OptionType
- func NewSortOption(tag map[string]string) cliutil.OptionType
- func ParseGroupBy(s string) (groupBy []*qbclient.QueryRecordsInputGroupBy, err error)
- func ParseQuery(q string) string
- func ParseSortBy(s string) (sortBy []*qbclient.QueryRecordsInputSortBy, err error)
- func Prompt(label string, validate qbclient.ValidateStringFn) (s string, err error)
- func Render(ctx context.Context, logger *cliutil.LeveledLogger, cmd *cobra.Command, ...)
- func SetOptionFromArg(cfg *viper.Viper, args []string, idx int, option string)
- func TestsFailedError(format string, a ...interface{}) error
- type DeployFormulaInput
- type DeployFormulaOutput
- type DumpPlugin
- type ExportOptions
- type FieldMap
- type GlobalConfig
- func (c GlobalConfig) ConfigDir() string
- func (c GlobalConfig) DefaultAppID() string
- func (c GlobalConfig) DefaultFieldID() int
- func (c GlobalConfig) DefaultTableID() string
- func (c GlobalConfig) DumpDirectory() string
- func (c GlobalConfig) Format() string
- func (c GlobalConfig) JMESPathFilter() string
- func (c GlobalConfig) LogFile() string
- func (c GlobalConfig) LogLevel() string
- func (c GlobalConfig) Profile() string
- func (c GlobalConfig) Quiet() bool
- func (c *GlobalConfig) ReadInConfig() error
- func (c GlobalConfig) RealmHostname() string
- func (c GlobalConfig) SetDefaultAppID(cfg *viper.Viper)
- func (c GlobalConfig) SetDefaultTableID(cfg *viper.Viper)
- func (c GlobalConfig) SetDefaultTableIDs(cfg *viper.Viper, key string)
- func (c GlobalConfig) UserToken() string
- func (c *GlobalConfig) Validate() error
- type GroupOption
- type ImportOptions
- type LoggerPlugin
- type QueryOption
- type QuickbaseFile
- type QuickbaseFileDeploy
- type QuickbaseFileDeployFormula
- type QuickbaseFileTest
- type QuickbaseFileTestFormula
- type RecordOption
- type SortOption
- type TestFormulaInput
- type TestFormulaOutput
Constants ¶
const ( OptionDumpDirectory = "dump-dir" OptionFormat = "format" OptionJMESPathFilter = "filter" OptionLogFile = "log-file" OptionLogLevel = "log-level" OptionQuiet = "quiet" )
Option* constants contain CLI options.
const ( OptionAppIDDescription = "unique identifier of an app (required)" OptionFieldIDDescription = "unique identifier (fid) of the field (required)" OptionParentTableIDDescription = "unique identifier (dbid) of the parent table (required)" OptionTableIDDescription = "unique identifier (dbid) of the table (required)" OptionQuietDescription = "suppress output written to stdout" )
Option*Description constants contain common option descriptions.
Variables ¶
var (
TestsFailed = qberrors.ErrSafe{Message: "tests failed", StatusCode: http.StatusBadRequest}
)
Functions ¶
func CacheTableSchema ¶ added in v0.2.0
CacheTableSchema caches schema information for a table.
func Export ¶ added in v0.2.0
func Export(qb *qbclient.Client, opts *ExportOptions) error
Export exports data from a Quickbase table into an io.Writer.
func GetOptions ¶
func GetOptions(ctx context.Context, logger *cliutil.LeveledLogger, input interface{}, cfg *viper.Viper)
GetOptions gets options based on the input and validates them.
func HandleError ¶
HandleError handles an error by logging it and returning a non-zero status. We reserve Fatal errors for internal problems.
func Import ¶ added in v0.2.0
func Import(qb *qbclient.Client, opts *ImportOptions) (*qbclient.InsertRecordsOutputMetadata, error)
Import imports data from an io.Reader into a Quickbase table.
func NewClient ¶
func NewClient(cmd *cobra.Command, cfg GlobalConfig) (ctx context.Context, logger *cliutil.LeveledLogger, qb *qbclient.Client)
NewClient returns a new *qbclient.Client.
func NewDumpPlugin ¶
func NewDumpPlugin(ctx context.Context, logger *cliutil.LeveledLogger, transid string, directory string) qbclient.Plugin
NewDumpPlugin returns a DumpPlugin, which implements qbclient.Plugin.
func NewGroupOption ¶
func NewGroupOption(tag map[string]string) cliutil.OptionType
NewGroupOption is a cliutil.OptionTypeFunc that returns a *cliutil.GroupOption.
func NewLogger ¶
func NewLogger(cmd *cobra.Command, cfg GlobalConfig) (ctx context.Context, logger *cliutil.LeveledLogger, transid xid.ID)
NewLogger returns a new *cliutil.LeveledLogger.
func NewLoggerPlugin ¶
NewLoggerPlugin returns a LoggerPlugin, which implements qbclient.Plugin.
func NewQueryOption ¶
func NewQueryOption(tag map[string]string) cliutil.OptionType
NewQueryOption is a cliutil.OptionTypeFunc that returns a *cliutil.QueryOption.
func NewRecordOption ¶
func NewRecordOption(tag map[string]string) cliutil.OptionType
NewRecordOption is a cliutil.OptionTypeFunc that returns a *cliutil.RecordOption.
func NewSortOption ¶
func NewSortOption(tag map[string]string) cliutil.OptionType
NewSortOption is a cliutil.OptionTypeFunc that returns a *cliutil.SortOption.
func ParseGroupBy ¶
func ParseGroupBy(s string) (groupBy []*qbclient.QueryRecordsInputGroupBy, err error)
ParseGroupBy parses the groupBy clause.
func ParseQuery ¶
ParseQuery parses queries. It also detcts and transforms simple queries into Quick Base query syntax.
func ParseSortBy ¶
func ParseSortBy(s string) (sortBy []*qbclient.QueryRecordsInputSortBy, err error)
ParseSortBy parses the sortBy clause.
func Prompt ¶
func Prompt(label string, validate qbclient.ValidateStringFn) (s string, err error)
Prompt prompts a user for input and returns what they typed.
func Render ¶
func Render( ctx context.Context, logger *cliutil.LeveledLogger, cmd *cobra.Command, cfg GlobalConfig, v interface{}, err error, )
Render renders the output in JSON, or writes an error log.
func SetOptionFromArg ¶
SetOptionFromArg sets an option from an argument.
func TestsFailedError ¶ added in v0.2.7
Types ¶
type DeployFormulaInput ¶ added in v0.2.4
type DeployFormulaInput struct {
File string `cliutil:"option=file default=quickbase.yml"`
}
type DeployFormulaOutput ¶ added in v0.2.4
type DeployFormulaOutput struct { Deployed map[string][]int `json:"deployed"` Errors map[string]map[int]string `json:"errors"` }
func DeployFormula ¶ added in v0.2.4
func DeployFormula(qb *qbclient.Client, in *DeployFormulaInput) (out *DeployFormulaOutput, err error)
type DumpPlugin ¶
type DumpPlugin struct {
// contains filtered or unexported fields
}
DumpPlugin implements qbclient.Plugin and dumps requests and responses to files in a directory.
func (DumpPlugin) PostResponse ¶
func (p DumpPlugin) PostResponse(resp *http.Response)
PostResponse implements qbclient.Plugin.PostResponse.
func (DumpPlugin) PreRequest ¶
func (p DumpPlugin) PreRequest(req *http.Request)
PreRequest implements qbclient.Plugin.PreRequest.
type ExportOptions ¶ added in v0.2.0
type ExportOptions struct { TableID string `validate:"required" cliutil:"option=table-id"` Filepath string `cliutil:"option=file usage='file the data is exported to'"` BatchSize int `cliutil:"option=batch-size default=10000"` Delay int `cliutil:"option=delay"` }
ExportOptions are the options read through the command line.
type FieldMap ¶ added in v0.2.0
type FieldMap map[int]*qbclient.ListFieldsOutputField
FieldMap is a map of field IDs to field definitions.
func GetCachedTableSchema ¶ added in v0.2.0
GetCachedTableSchema returns schema information for a table.
TODO Caching beyond in-memory caching?
type GlobalConfig ¶
type GlobalConfig struct {
// contains filtered or unexported fields
}
GlobalConfig contains configuration common to all commands.
func NewGlobalConfig ¶
func NewGlobalConfig(cmd *cobra.Command, cfg *viper.Viper) GlobalConfig
NewGlobalConfig returns a GlobalConfig.
func (GlobalConfig) ConfigDir ¶
func (c GlobalConfig) ConfigDir() string
ConfigDir returns the configuration directory.
func (GlobalConfig) DefaultAppID ¶
func (c GlobalConfig) DefaultAppID() string
DefaultAppID returns the default app ID.
func (GlobalConfig) DefaultFieldID ¶
func (c GlobalConfig) DefaultFieldID() int
DefaultFieldID returns the default field ID.
func (GlobalConfig) DefaultTableID ¶
func (c GlobalConfig) DefaultTableID() string
DefaultTableID returns the default table ID.
func (GlobalConfig) DumpDirectory ¶
func (c GlobalConfig) DumpDirectory() string
DumpDirectory returns the configured dump file directory.
func (GlobalConfig) Format ¶ added in v0.1.4
func (c GlobalConfig) Format() string
Format returns the configured output format, e.g., table. No config == JSON.
func (GlobalConfig) JMESPathFilter ¶
func (c GlobalConfig) JMESPathFilter() string
JMESPathFilter returns the JMESPath filter.
func (GlobalConfig) LogFile ¶
func (c GlobalConfig) LogFile() string
LogFile returns the configured log file.
func (GlobalConfig) LogLevel ¶
func (c GlobalConfig) LogLevel() string
LogLevel returns the configured log level.
func (GlobalConfig) Profile ¶
func (c GlobalConfig) Profile() string
Profile returns the configured profile.
func (GlobalConfig) Quiet ¶
func (c GlobalConfig) Quiet() bool
Quiet returns whehter to suppress output written to stdout.
func (*GlobalConfig) ReadInConfig ¶
func (c *GlobalConfig) ReadInConfig() error
ReadInConfig reads in the config file.
func (GlobalConfig) RealmHostname ¶
func (c GlobalConfig) RealmHostname() string
RealmHostname returns the configured realm hostname.
func (GlobalConfig) SetDefaultAppID ¶
func (c GlobalConfig) SetDefaultAppID(cfg *viper.Viper)
SetDefaultAppID sets the default app in the command's configuration.
func (GlobalConfig) SetDefaultTableID ¶
func (c GlobalConfig) SetDefaultTableID(cfg *viper.Viper)
SetDefaultTableID sets the default table in the command's configuration.
func (GlobalConfig) SetDefaultTableIDs ¶ added in v0.2.0
func (c GlobalConfig) SetDefaultTableIDs(cfg *viper.Viper, key string)
SetDefaultTableIDs sets the default table in the command's configuration as the key option.
func (GlobalConfig) UserToken ¶
func (c GlobalConfig) UserToken() string
UserToken returns the configured log level.
func (*GlobalConfig) Validate ¶
func (c *GlobalConfig) Validate() error
Validate reads the configuration file and validates the global configuration options.
type GroupOption ¶
type GroupOption struct {
// contains filtered or unexported fields
}
GroupOption implements Option for string options that contain queries.
type ImportOptions ¶ added in v0.2.0
type ImportOptions struct { TableID string `validate:"required" cliutil:"option=table-id"` Filepath string `cliutil:"option=file usage='file the data is imported from'"` BatchSize int `cliutil:"option=batch-size default=10000"` Map map[string]string `cliutil:"option=map"` Delay int `cliutil:"option=delay"` Timeout int `cliutil:"option=timeout default=5 usage='timeout in seconds waiting for data to be read from stdin'"` MergeFieldID int `cliutil:"option=merge-field-id"` }
ImportOptions are the options read through the command line.
type LoggerPlugin ¶
type LoggerPlugin struct {
// contains filtered or unexported fields
}
LoggerPlugin implements qbclient.Plugin and logs requests.
func (LoggerPlugin) PostResponse ¶
func (p LoggerPlugin) PostResponse(resp *http.Response)
PostResponse implements qbclient.Plugin.PostResponse.
func (LoggerPlugin) PreRequest ¶
func (p LoggerPlugin) PreRequest(req *http.Request)
PreRequest implements qbclient.Plugin.PreRequest.
type QueryOption ¶
type QueryOption struct {
// contains filtered or unexported fields
}
QueryOption implements Option for string options that contain queries.
type QuickbaseFile ¶ added in v0.2.4
type QuickbaseFile struct { Test *QuickbaseFileTest `yaml:"test"` Deploy *QuickbaseFileDeploy `yaml:"deploy"` }
QuickbaseFile models a quickbase.yml file.
func ParseQuickbaseFile ¶ added in v0.2.4
func ParseQuickbaseFile(file string) (f *QuickbaseFile, err error)
type QuickbaseFileDeploy ¶ added in v0.2.4
type QuickbaseFileDeploy struct {
Formulas []*QuickbaseFileDeployFormula `yaml:"formulas"`
}
type QuickbaseFileDeployFormula ¶ added in v0.2.4
type QuickbaseFileTest ¶ added in v0.2.7
type QuickbaseFileTest struct {
Formulas []*QuickbaseFileTestFormula `yaml:"formulas"`
}
type QuickbaseFileTestFormula ¶ added in v0.2.7
type RecordOption ¶
type RecordOption struct {
// contains filtered or unexported fields
}
RecordOption implements Option for string options that contain record datas.
type SortOption ¶
type SortOption struct {
// contains filtered or unexported fields
}
SortOption implements Option for string options that contain queries.
type TestFormulaInput ¶ added in v0.2.7
type TestFormulaInput struct {
File string `cliutil:"option=file default=quickbase.yml"`
}
type TestFormulaOutput ¶ added in v0.2.7
type TestFormulaOutput struct { Passed []int `json:"passed"` Failed map[int]string `json:"failed"` }
func TestFormula ¶ added in v0.2.7
func TestFormula(qb *qbclient.Client, in *TestFormulaInput) (out *TestFormulaOutput, err error)