format

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const SizeName = "size"
View Source
const TimeSince = "time_since"

Variables

View Source
var AliasDefaultSelector = DefaultSelector{
	Normal: []FieldSelection{
		NewFieldSelection("Workspace", "workspace"),
		NewFieldSelection("Name", "name"),
		NewFieldSelection("Collections", "collections"),
		NewFieldSelection("State", "state"),
	},
	Wide: []FieldSelection{
		NewFieldSelection("Workspace", "workspace"),
		NewFieldSelection("Name", "name"),
		NewFieldSelection("Description", "description"),
		NewFieldSelection("Modified At", "modified_at"),
		NewFieldSelection("Collections", "collections"),
		NewFieldSelection("State", "state"),
	},
}
View Source
var ApiKeyDefaultSelector = DefaultSelector{
	Normal: []FieldSelection{
		NewFieldSelection("Name", "name"),
		NewFieldSelection("Key ID", "key"),
		NewFieldSelection("Created By", "created_by"),
		NewFieldSelection("Expiry Time", "expiry_time"),
		NewFieldSelection("Last Access Time", "last_access_time"),
		NewFieldSelection("Role", "role"),
		NewFieldSelection("State", "state"),
	},
}
View Source
var CollectionDefaultSelector = DefaultSelector{
	Normal: []FieldSelection{
		NewFieldSelection("Workspace", "workspace"),
		NewFieldSelection("Name", "name"),
		NewFieldSelection("Status", "status"),
		{
			ColumnName:     "Size",
			Path:           []PathElem{{FieldName: "stats"}, {FieldName: "total_size"}},
			FieldFormatter: SizeFormatter{},
		},
		{
			ColumnName:     "Last Queried",
			Path:           []PathElem{{FieldName: "stats"}, {FieldName: "last_queried_ms"}},
			FieldFormatter: TimeSinceFormatter{},
		},
	},
	Wide: []FieldSelection{
		NewFieldSelection("Workspace", "workspace"),
		NewFieldSelection("Name", "name"),
		NewFieldSelection("Description", "description"),
		NewFieldSelection("Retention", "retention_secs"),
		NewFieldSelection("Status", "status"),
		NewFieldSelection("Insert Only", "insert_only"),
		NewFieldSelection("Read Only", "read_only"),
		NewFieldSelection("Created By", "created_by"),
		NewFieldSelection("Created At", "created_at"),
	},
}
View Source
var FieldFormatters = map[string]FieldFormatter{
	SizeName:  &SizeFormatter{},
	TimeSince: &TimeSinceFormatter{},
}
View Source
var OrganizationDefaultSelector = DefaultSelector{
	Normal: []FieldSelection{
		NewFieldSelection("Name", "display_name"),
		NewFieldSelection("ID", "id"),
		NewFieldSelection("User", "rockset_user"),
	},
	Wide: []FieldSelection{
		NewFieldSelection("Name", "display_name"),
		NewFieldSelection("ID", "id"),
		NewFieldSelection("User", "rockset_user"),
		NewFieldSelection("External ID", "external_id"),
		NewFieldSelection("Created At", "created_at"),
	},
}
View Source
var QueryDefaultSelector = DefaultSelector{
	Normal: []FieldSelection{
		NewFieldSelection("Query ID", "query_id"),
		NewFieldSelection("Status", "status"),
		NewFieldSelection("Executed By", "executed_by"),
		NewFieldSelection("Submitted At", "submitted_at"),
		NewFieldSelection("User", "rockset_user"),
	},
	Wide: []FieldSelection{
		NewFieldSelection("Query ID", "query_id"),
		NewFieldSelection("Status", "status"),
		NewFieldSelection("Executed By", "executed_by"),
		NewFieldSelection("Submitted At", "submitted_at"),
		NewFieldSelection("Expires At", "expires_at"),
		NewFieldSelection("SQL", "sql"),
	},
}
View Source
var QueryLambdaDefaultSelector = DefaultSelector{
	Normal: []FieldSelection{
		NewFieldSelection("Workspace", "workspace"),
		NewFieldSelection("Name", "name"),
		NewFieldSelection("Last Updated By", "last_updated_by"),
		{
			ColumnName:     "Last Updated",
			Path:           []PathElem{{FieldName: "last_updated"}},
			FieldFormatter: TimeSinceFormatter{},
		},
		NewFieldSelection("Latest Version", "latest_version", "version"),
		NewFieldSelection("Version Count", "version_count"),
		NewFieldSelection("Collections", "collections"),
	},
	Wide: []FieldSelection{
		NewFieldSelection("Workspace", "workspace"),
		NewFieldSelection("Name", "name"),
		NewFieldSelection("Last Updated By", "last_updated_by"),
		{
			ColumnName:     "Last Updated",
			Path:           []PathElem{{FieldName: "last_updated"}},
			FieldFormatter: TimeSinceFormatter{},
		},
		NewFieldSelection("Latest Version", "latest_version", "version"),
		NewFieldSelection("Description", "latest_version", "description"),
		NewFieldSelection("Version Count", "version_count"),
		NewFieldSelection("Collections", "collections"),
	},
}
View Source
var QueryLambdaTagDefaultSelector = DefaultSelector{
	Normal: []FieldSelection{
		NewFieldSelection("Tag", "tag_name"),
		NewFieldSelection("State", "version", "state"),
	},
	Wide: []FieldSelection{
		NewFieldSelection("Tag", "tag_name"),
		NewFieldSelection("State", "version", "state"),
		NewFieldSelection("Description", "version", "description"),
	},
}
View Source
var RoleDefaultSelector = DefaultSelector{
	Normal: []FieldSelection{
		NewFieldSelection("Name", "role_name"),
		NewFieldSelection("Created By", "created_by"),
	},
	Wide: []FieldSelection{
		NewFieldSelection("Name", "role_name"),
		NewFieldSelection("Created By", "created_by"),
		NewFieldSelection("Description", "description"),
	},
}
View Source
var SupportedFormats = Formats{CSVFormat, JSONFormat, TableFormat}
View Source
var UserDefaultSelector = DefaultSelector{
	Normal: []FieldSelection{
		NewFieldSelection("First Name", "first_name"),
		NewFieldSelection("Last Name", "last_name"),
		NewFieldSelection("Email", "email"),
		NewFieldSelection("State", "state"),
		NewFieldSelection("Created At", "created_at"),
	},
	Wide: []FieldSelection{
		NewFieldSelection("First Name", "first_name"),
		NewFieldSelection("Last Name", "last_name"),
		NewFieldSelection("Email", "email"),
		NewFieldSelection("State", "state"),
		NewFieldSelection("Created At", "created_at"),
		NewFieldSelection("Roles", "roles"),
	},
}
View Source
var ViewDefaultSelector = DefaultSelector{
	Normal: []FieldSelection{
		NewFieldSelection("Workspace", "workspace"),
		NewFieldSelection("Name", "name"),
		NewFieldSelection("Created By", "creator_email"),
		NewFieldSelection("State", "state"),
	},
	Wide: []FieldSelection{
		NewFieldSelection("Workspace", "workspace"),
		NewFieldSelection("Name", "name"),
		NewFieldSelection("Description", "description"),
		NewFieldSelection("Created By", "creator_email"),
		NewFieldSelection("Created At", "created_at"),
		NewFieldSelection("State", "state"),
		NewFieldSelection("SQL", "query_sql"),
	},
}
View Source
var VirtualInstanceDefaultSelector = DefaultSelector{
	Normal: []FieldSelection{
		NewFieldSelection("Name", "name"),
		NewFieldSelection("Description", "description"),
		NewFieldSelection("State", "state"),
		NewFieldSelection("Default VI", "default_vi"),
		NewFieldSelection("Current Size", "current_size"),
	},
	Wide: []FieldSelection{
		NewFieldSelection("Name", "name"),
		NewFieldSelection("ID", "id"),
		NewFieldSelection("Description", "description"),
		NewFieldSelection("State", "state"),
		NewFieldSelection("Default VI", "default_vi"),
		NewFieldSelection("Current Size", "current_size"),
		NewFieldSelection("Desired Size", "desired_size"),
	},
}
View Source
var WorkspaceDefaultSelector = DefaultSelector{
	Normal: []FieldSelection{
		NewFieldSelection("Name", "name"),
		NewFieldSelection("Collections", "collection_count"),
		NewFieldSelection("Created By", "created_by"),
		NewFieldSelection("Created At", "created_at"),
	},
	Wide: []FieldSelection{
		NewFieldSelection("Name", "name"),
		NewFieldSelection("Description", "description"),
		NewFieldSelection("Collections", "collection_count"),
		NewFieldSelection("Created By", "created_by"),
		NewFieldSelection("Created At", "created_at"),
	},
}

Functions

func AnyAsString added in v0.0.9

func AnyAsString(a any, ff FieldFormatter) (string, error)

func GetPossibleSelectorsFor added in v0.0.9

func GetPossibleSelectorsFor(data any) []string

func ToInterfaceArray

func ToInterfaceArray[T any](list []T) []interface{}

Types

type CSV

type CSV struct {
	Header bool
	// contains filtered or unexported fields
}

func NewCSVFormat

func NewCSVFormat(out io.Writer, header bool) CSV

func (CSV) Format

func (c CSV) Format(wide bool, selector Selector, i interface{}) error

func (CSV) FormatList

func (c CSV) FormatList(wide bool, selector Selector, items []interface{}) error

type DefaultSelector added in v0.0.9

type DefaultSelector struct {
	Normal Selector
	Wide   Selector
}

type FieldFormatter added in v0.0.9

type FieldFormatter interface {
	FormatField(any) (string, error)
	Name() string
}

type FieldSelection added in v0.0.9

type FieldSelection struct {
	Path           []PathElem
	ColumnName     string
	FieldFormatter FieldFormatter
}

func NewFieldSelection added in v0.0.9

func NewFieldSelection(columnName string, path ...string) FieldSelection

func (FieldSelection) Select added in v0.0.9

func (r FieldSelection) Select(obj any) (any, error)

func (FieldSelection) ToString added in v0.0.9

func (r FieldSelection) ToString() string

type Format

type Format string
const (
	CSVFormat   Format = "csv"
	TableFormat Format = "table"
	JSONFormat  Format = "json"
)

type Formats added in v0.0.6

type Formats []Format

func (Formats) ToStringArray added in v0.0.6

func (f Formats) ToStringArray() []string

type Formatter

type Formatter interface {
	Format(wide bool, selector Selector, item interface{}) error
	FormatList(wide bool, selector Selector, items []interface{}) error
}

func FormatterFor

func FormatterFor(out io.Writer, f Format, header bool) (Formatter, error)

type JSON added in v0.0.6

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

func NewJSONFormatter added in v0.0.6

func NewJSONFormatter(out io.Writer, header bool) *JSON

func (JSON) Format added in v0.0.6

func (j JSON) Format(wide bool, selector Selector, i interface{}) error

func (JSON) FormatList added in v0.0.6

func (j JSON) FormatList(wide bool, selector Selector, items []interface{}) error

type PathElem added in v0.0.9

type PathElem struct {
	FieldName string

	HasArraySelector bool
	ArrayIndex       int
}

func (PathElem) ToString added in v0.0.9

func (r PathElem) ToString() string

type Selector added in v0.0.9

type Selector []FieldSelection

func DefaultSelectorFor added in v0.0.9

func DefaultSelectorFor(f any, wide bool) (Selector, error)

func ParseSelectionString added in v0.0.9

func ParseSelectionString(s string) (Selector, error)

func (Selector) Fields added in v0.0.9

func (s Selector) Fields(data any) ([]string, error)

func (Selector) Headers added in v0.0.9

func (s Selector) Headers() []string

func (Selector) String added in v0.0.9

func (s Selector) String() string

type SizeFormatter added in v0.0.9

type SizeFormatter struct{}

func (SizeFormatter) FormatField added in v0.0.9

func (f SizeFormatter) FormatField(a any) (string, error)

func (SizeFormatter) Name added in v0.0.9

func (f SizeFormatter) Name() string

type Table

type Table struct {
	Header bool
	// contains filtered or unexported fields
}

func NewTableFormatter

func NewTableFormatter(out io.Writer, header bool) *Table

func (Table) Format

func (t Table) Format(wide bool, selector Selector, i interface{}) error

func (Table) FormatList

func (t Table) FormatList(wide bool, selector Selector, items []interface{}) error

type TimeSinceFormatter added in v0.0.9

type TimeSinceFormatter struct{}

func (TimeSinceFormatter) FormatField added in v0.0.9

func (f TimeSinceFormatter) FormatField(a any) (string, error)

func (TimeSinceFormatter) Name added in v0.0.9

func (f TimeSinceFormatter) Name() string

Jump to

Keyboard shortcuts

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