format

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var APIKeyFormatter = StructFormatter{
	[]Header{
		{
			FieldName: "Name",
			FieldFn:   getFieldByName,
		},
		{
			DisplayName: "Key ID",
			FieldName:   "Key",
			FieldFn:     getFieldByName,
		},
		{
			DisplayName: "Created By",
			FieldName:   "CreatedBy",
			FieldFn:     getFieldByName,
		},
		{
			DisplayName: "Expiry Time",
			FieldName:   "ExpiryTime",
			FieldFn:     getFieldByName,
		},
		{
			DisplayName: "Last Access Time",
			FieldName:   "LastAccessTime",
			FieldFn:     getFieldByName,
		},
		{
			FieldName: "Role",
			FieldFn:   getFieldByName,
		},
		{
			FieldName: "State",
			FieldFn:   getFieldByName,
		},
	},
}
View Source
var AliasFormatter = StructFormatter{
	[]Header{
		{
			FieldName: "Workspace",
			FieldFn:   getFieldByName,
		},
		{
			FieldName: "Name",
			FieldFn:   getFieldByName,
		},
		{
			FieldName: "Description",
			FieldFn:   getFieldByName,
			Wide:      true,
		},
		{
			DisplayName: "Modified At",
			FieldName:   "ModifiedAt",
			FieldFn:     getFieldByName,
			Wide:        true,
		},
		{
			FieldName: "Collections",
			FieldFn:   getArrayFieldByName,
		},
		{
			FieldName: "State",
			FieldFn:   getFieldByName,
		},
	},
}
View Source
var CollectionFormatter = StructFormatter{
	[]Header{
		{
			FieldName: "Workspace",
			FieldFn:   getFieldByName,
		},
		{
			FieldName: "Name",
			FieldFn:   getFieldByName,
		},
		{
			FieldName: "Description",
			FieldFn:   getFieldByName,
		},
		{
			DisplayName: "Retention",
			FieldName:   "RetentionSecs",
			FieldFn:     getFieldByName,
		},
		{
			FieldName: "Status",
			FieldFn:   getFieldByName,
		},
		{
			DisplayName: "Insert Only",
			FieldName:   "InsertOnly",
			FieldFn:     getFieldByName,
		},
		{
			DisplayName: "Read Only",
			FieldName:   "ReadOnly",
			FieldFn:     getFieldByName,
		},
		{
			DisplayName: "Created By",
			FieldName:   "CreatedBy",
			FieldFn:     getFieldByName,
		},
		{
			DisplayName: "Created At",
			FieldName:   "CreatedAt",
			FieldFn:     getFieldByName,
		},
	},
}
View Source
var OrgFormatter = StructFormatter{
	[]Header{
		{
			DisplayName: "DisplayName",
			FieldName:   "DisplayName",
			FieldFn:     getFieldByName,
		},
		{
			DisplayName: "ID",
			FieldName:   "Id",
			FieldFn:     getFieldByName,
		},
		{
			DisplayName: "User",
			FieldName:   "RocksetUser",
			FieldFn:     getFieldByName,
		},
		{
			DisplayName: "External ID",
			FieldName:   "ExternalId",
			FieldFn:     getFieldByName,
			Wide:        true,
		},
		{
			DisplayName: "Created At",
			FieldName:   "CreatedAt",
			FieldFn:     getFieldByName,
			Wide:        true,
		},
	},
}
View Source
var QueryInfoFormatter = StructFormatter{
	[]Header{
		{
			DisplayName: "Query ID",
			FieldName:   "QueryId",
			FieldFn:     getFieldByName,
		},
		{
			FieldName: "Status",
			FieldFn:   getFieldByName,
		},
		{
			DisplayName: "Executed By",
			FieldName:   "ExecutedBy",
			FieldFn:     getFieldByName,
		},
		{
			DisplayName: "Submitted At",
			FieldName:   "SubmittedAt",
			FieldFn:     getFieldByName,
		},
		{
			DisplayName: "Expires At",
			FieldName:   "ExpiresAt",
			FieldFn:     getFieldByName,
			Wide:        true,
		},
		{
			DisplayName: "SQL",
			FieldName:   "Sql",
			FieldFn:     getFieldByName,
			Wide:        true,
		},
	},
}
View Source
var QueryLambdaFormatter = StructFormatter{
	[]Header{
		{
			FieldName: "Workspace",
			FieldFn:   getFieldByName,
		},
		{
			FieldName: "Name",
			FieldFn:   getFieldByName,
		},
		{
			DisplayName: "Last Updated By",
			FieldName:   "LastUpdatedBy",
			FieldFn:     getFieldByName,
		},
		{
			DisplayName: "Last Updated",
			FieldName:   "LastUpdated",
			FieldFn:     getFieldByName,
		},
		{
			DisplayName: "Latest Version",
			FieldName:   "LatestVersion",
			FieldFn:     getStructFieldByName("Version"),
		},
		{
			DisplayName: "Description",
			FieldName:   "LatestVersion",
			FieldFn:     getStructFieldByName("Description"),
			Wide:        true,
		},
		{
			DisplayName: "Version Count",
			FieldName:   "VersionCount",
			FieldFn:     getFieldByName,
		},
		{
			FieldName: "Collections",
			FieldFn:   getArrayFieldByName,
		},
	},
}
View Source
var QueryLambdaTagFormatter = StructFormatter{
	[]Header{
		{
			FieldName:   "TagName",
			DisplayName: "Tag",
			FieldFn:     getFieldByName,
		},
		{
			FieldName:   "Version",
			DisplayName: "Description",
			FieldFn:     getStructFieldByName("Description"),
			Wide:        true,
		},
		{
			FieldName:   "Version",
			DisplayName: "State",
			FieldFn:     getStructFieldByName("State"),
		},
	},
}
View Source
var SupportedFormats = Formats{CSVFormat, JSONFormat, TableFormat}
View Source
var UserFormatter = StructFormatter{
	[]Header{
		{
			FieldName:   "FirstName",
			DisplayName: "First Name",
			FieldFn:     getFieldByName,
		},
		{
			FieldName:   "LastName",
			DisplayName: "Last Name",
			FieldFn:     getFieldByName,
		},
		{
			FieldName: "Email",
			FieldFn:   getFieldByName,
		},
		{
			FieldName: "State",
			FieldFn:   getFieldByName,
		},
		{
			FieldName:   "CreatedAt",
			DisplayName: "Created At",
			FieldFn:     getFieldByName,
		},
		{
			FieldName: "Roles",
			Wide:      true,
			FieldFn:   getArrayFieldByName,
		},
	},
}
View Source
var ViewFormatter = StructFormatter{
	[]Header{
		{
			FieldName: "Workspace",
			FieldFn:   getFieldByName,
		},
		{
			FieldName: "Name",
			FieldFn:   getFieldByName,
		},
		{
			FieldName: "Description",
			FieldFn:   getFieldByName,
			Wide:      true,
		},
		{
			DisplayName: "Created By",
			FieldName:   "CreatorEmail",
			FieldFn:     getFieldByName,
		},
		{
			DisplayName: "Created At",
			FieldName:   "CreatedAt",
			FieldFn:     getFieldByName,
			Wide:        true,
		},
		{
			FieldName: "State",
			FieldFn:   getFieldByName,
		},
		{
			DisplayName: "SQL",
			FieldName:   "QuerySql",
			FieldFn:     getFieldByName,
		},
	},
}
View Source
var VirtualInstanceFormatter = StructFormatter{
	[]Header{
		{
			FieldName: "Name",
			FieldFn:   getFieldByName,
		},
		{
			FieldName: "Id",
			FieldFn:   getFieldByName,
			Wide:      true,
		},
		{
			FieldName: "Description",
			FieldFn:   getFieldByName,
		},
		{
			FieldName: "State",
			FieldFn:   getFieldByName,
		},
		{
			DisplayName: "Default VI",
			FieldName:   "DefaultVi",
			FieldFn:     getFieldByName,
		},
		{
			DisplayName: "Current Size",
			FieldName:   "CurrentSize",
			FieldFn:     getFieldByName,
		},
		{
			DisplayName: "Desired Size",
			FieldName:   "DesiredSize",
			FieldFn:     getFieldByName,
			Wide:        true,
		},
	},
}
View Source
var WorkspaceFormatter = StructFormatter{
	[]Header{
		{
			FieldName: "Name",
			FieldFn:   getFieldByName,
		},
		{
			FieldName: "Description",
			FieldFn:   getFieldByName,
			Wide:      true,
		},
		{
			DisplayName: "Collections",
			FieldName:   "CollectionCount",
			FieldFn:     getFieldByName,
		},
		{
			DisplayName: "Created By",
			FieldName:   "CreatedBy",
			FieldFn:     getFieldByName,
		},
		{
			DisplayName: "Created At",
			FieldName:   "CreatedAt",
			FieldFn:     getFieldByName,
			Wide:        true,
		},
	},
}

Functions

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, i interface{}) error

func (CSV) FormatList

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

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, item interface{}) error
	FormatList(wide bool, items []interface{}) error
}

func FormatterFor

func FormatterFor(out io.Writer, f Format, header bool) (Formatter, error)
type Header struct {
	FieldName   string
	DisplayName string
	Wide        bool
	FieldFn     func(string, interface{}) string
}

func (Header) Field

func (h Header) Field(i interface{}) string

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, i interface{}) error

func (JSON) FormatList added in v0.0.6

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

type StructFormatter

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

func StructFormatterFor

func StructFormatterFor[T any](f T) (StructFormatter, error)

func (StructFormatter) Fields

func (s StructFormatter) Fields(wide bool, i interface{}) []string

func (StructFormatter) Headers

func (s StructFormatter) Headers(wide bool) []string

Headers returns the list of header names

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, i interface{}) error

func (Table) FormatList

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

Jump to

Keyboard shortcuts

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