schema

package
v0.0.1-alpha.5 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2017 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultCommandCategory = &Category{
	Key:         "default",
	DisplayName: "",
	Order:       math.MaxInt32,
}
View Source
var DefaultParamCategory = &Category{
	Key:         "default",
	DisplayName: "Other options",
	Order:       math.MaxInt32,
}
View Source
var DefaultResourceCategory = &Category{
	Key:         "default",
	DisplayName: "",
	Order:       math.MaxInt32,
}

Functions

This section is empty.

Types

type Category

type Category struct {
	Key         string
	DisplayName string
	Order       int
}

type Command

type Command struct {
	Type      CommandType
	Aliases   []string
	Usage     string
	ArgsUsage string

	Category string
	Order    int

	Params              map[string]*Schema
	ParamCategories     []Category
	AltResource         string // 空の場合はResourceのキーをCamelizeしてsacloud.XXXを対象とする。
	ListResultFieldName string
	SkipAuth            bool
	UseCustomCommand    bool

	TableType          output.OutputTableType
	IncludeFields      []string           // for output.TableDetail
	ExcludeFields      []string           // for output.TableDetail
	TableColumnDefines []output.ColumnDef // for output.TableSimple
}

func (*Command) ParamCategory

func (c *Command) ParamCategory(key string) *Category

func (*Command) SortedParams

func (c *Command) SortedParams() SortableParams

func (*Command) Validate

func (c *Command) Validate() []error

type CommandType

type CommandType int //go:generate stringer -type=CommandType :: manual

CommandType is an enum of the type that can be represented by a schema.

const (
	CommandInvalid CommandType = iota
	CommandList
	CommandCreate
	CommandRead
	CommandUpdate
	CommandDelete
	CommandManipulate // power-on/power-off
	CommandCustom
)

func (CommandType) IsRequiredIDType

func (c CommandType) IsRequiredIDType() bool

func (CommandType) String

func (i CommandType) String() string

type HandlerType

type HandlerType int //go:generate stringer -type=HandlerType :: manual

HandlerType is an enum of the type that can be represented by a schema.

const (
	HandlerPathThrough HandlerType = iota
	HandlerPathThroughEach
	HandlerSort
	HandlerFilterBy
	HandlerAndParams
	HandlerOrParams
	HandlerCustomFunc
	HandlerNoop
)

func (HandlerType) CanSetDestinationProp

func (h HandlerType) CanSetDestinationProp() bool

CanSetDestinationProp return true when HandlerType is able to have DestinationProp

func (HandlerType) IsNeedSliceValue

func (h HandlerType) IsNeedSliceValue() bool

IsNeedSliceValue return true when HandlerType is need Slice ValueType

func (HandlerType) IsWhenListOnly

func (h HandlerType) IsWhenListOnly() bool

IsWhenListOnly return true when HandlerType is able to use with CommandList

func (HandlerType) String

func (i HandlerType) String() string

type Resource

type Resource struct {
	Aliases           []string
	Usage             string
	Commands          map[string]*Command
	AltResource       string // 空の場合はResourceのキーをCamelizeしてsacloud.XXXを対象とする。
	CommandCategories []Category
	ResourceCategory  Category
}

func (*Resource) CommandCategory

func (r *Resource) CommandCategory(key string) *Category

func (*Resource) SortedCommands

func (c *Resource) SortedCommands() SortableCommands

type Schema

type Schema struct {
	Type ValueType

	DefaultValue interface{}
	DefaultText  string
	EnvVars      []string
	InputDefault interface{}
	Aliases      []string
	Description  string // Usage -> cli

	Category string
	Order    int

	Required      bool
	ConflictsWith []string
	ValidateFunc  SchemaValidateFunc

	MaxItems int
	MinItems int

	HandlerType     HandlerType
	DestinationProp string
	CustomHandler   SchemaValueHandlerFunc
}

func (*Schema) Validate

func (s *Schema) Validate(name string) []error

type SchemaValidateFunc

type SchemaValidateFunc func(string, interface{}) []error

type SchemaValueHandlerFunc

type SchemaValueHandlerFunc func(name string, src interface{}, dest interface{})

type SortableCommand

type SortableCommand struct {
	Category   *Category
	Command    *Command
	CommandKey string
}

type SortableCommands

type SortableCommands []SortableCommand

func (SortableCommands) Len

func (s SortableCommands) Len() int

func (SortableCommands) Less

func (s SortableCommands) Less(i, j int) bool

func (SortableCommands) Swap

func (s SortableCommands) Swap(i, j int)

type SortableParam

type SortableParam struct {
	Category *Category
	Param    *Schema
	ParamKey string
}

type SortableParams

type SortableParams []SortableParam

func (SortableParams) Len

func (s SortableParams) Len() int

func (SortableParams) Less

func (s SortableParams) Less(i, j int) bool

func (SortableParams) Swap

func (s SortableParams) Swap(i, j int)

type ValueType

type ValueType int //go:generate stringer -type=ValueType :: manual

ValueType is an enum of the type that can be represented by a schema.

const (
	TypeInvalid ValueType = iota
	TypeBool
	TypeInt
	TypeInt64
	TypeFloat
	TypeString
	TypeIntList
	TypeStringList
)

func (ValueType) IsSliceType

func (v ValueType) IsSliceType() bool

IsSliceType return true if type is TypeIntList or TypeStringList

func (ValueType) String

func (i ValueType) String() string

Jump to

Keyboard shortcuts

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