qbcli

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2021 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OptionDumpDirectory  = "dump-dir"
	OptionJMESPathFilter = "filter"
	OptionLogFile        = "log-file"
	OptionLogLevel       = "log-level"
	OptionQuiet          = "quiet"
)

Option* constants contain CLI options.

View Source
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

This section is empty.

Functions

func GetFieldTypeMap

func GetFieldTypeMap(tableID string) (map[int]string, error)

GetFieldTypeMap returns a mapping of field IDs to Quickbase field type for all the fields in a table.

TODO Caching?

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

func HandleError(ctx context.Context, logger *cliutil.LeveledLogger, message string, err error)

HandleError handles an error by logging it and returning a non-zero status. We reserve Fatal errors for internal problems.

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

func NewLoggerPlugin(ctx context.Context, logger *cliutil.LeveledLogger) qbclient.Plugin

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

func ParseQuery(q string) string

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 SetFieldTypeMap

func SetFieldTypeMap(qb *qbclient.Client, tableID string) error

SetFieldTypeMap sets the field type map for a table.

func SetOptionFromArg

func SetOptionFromArg(cfg *viper.Viper, args []string, idx int, option string)

SetOptionFromArg sets an option from an argument.

Types

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 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) 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) SetDefaultTableIDAs

func (c GlobalConfig) SetDefaultTableIDAs(cfg *viper.Viper, key string)

SetDefaultTableIDAs sets the default table in the command's configuration as the key option.

func (GlobalConfig) TemporaryToken

func (c GlobalConfig) TemporaryToken() string

TemporaryToken returns the configured log level.

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.

func (*GroupOption) Read

func (opt *GroupOption) Read(cfg *viper.Viper, field reflect.Value) error

Read implements cliutil.OptionType.Read.

func (*GroupOption) Set

func (opt *GroupOption) Set(f *cliutil.Flagger) error

Set implements cliutil.OptionType.Set.

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.

func (*QueryOption) Read

func (opt *QueryOption) Read(cfg *viper.Viper, field reflect.Value) error

Read implements cliutil.OptionType.Read.

func (*QueryOption) Set

func (opt *QueryOption) Set(f *cliutil.Flagger) error

Set implements cliutil.OptionType.Set.

type RecordOption

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

RecordOption implements Option for string options that contain record datas.

func (*RecordOption) Read

func (opt *RecordOption) Read(cfg *viper.Viper, field reflect.Value) error

Read implements cliutil.OptionType.Read.

func (*RecordOption) Set

func (opt *RecordOption) Set(f *cliutil.Flagger) error

Set implements cliutil.OptionType.Set.

type SortOption

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

SortOption implements Option for string options that contain queries.

func (*SortOption) Read

func (opt *SortOption) Read(cfg *viper.Viper, field reflect.Value) error

Read implements cliutil.OptionType.Read.

func (*SortOption) Set

func (opt *SortOption) Set(f *cliutil.Flagger) error

Set implements cliutil.OptionType.Set.

Jump to

Keyboard shortcuts

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