Documentation
¶
Index ¶
- Constants
- func EncodeOptions(starlarkOptions starlark.Value) (string, error)
- func LoadModule() (starlark.StringDict, error)
- type Color
- func (s *Color) AsSchemaField() SchemaField
- func (s *Color) Attr(name string) (starlark.Value, error)
- func (s *Color) AttrNames() []string
- func (s *Color) Freeze()
- func (s *Color) Hash() (uint32, error)
- func (s *Color) String() string
- func (s *Color) Truth() starlark.Bool
- func (s *Color) Type() string
- type DateTime
- func (s *DateTime) AsSchemaField() SchemaField
- func (s *DateTime) Attr(name string) (starlark.Value, error)
- func (s *DateTime) AttrNames() []string
- func (s *DateTime) Freeze()
- func (s *DateTime) Hash() (uint32, error)
- func (s *DateTime) String() string
- func (s *DateTime) Truth() starlark.Bool
- func (s *DateTime) Type() string
- type Dropdown
- func (s *Dropdown) AsSchemaField() SchemaField
- func (s *Dropdown) Attr(name string) (starlark.Value, error)
- func (s *Dropdown) AttrNames() []string
- func (s *Dropdown) Freeze()
- func (s *Dropdown) Hash() (uint32, error)
- func (s *Dropdown) String() string
- func (s *Dropdown) Truth() starlark.Bool
- func (s *Dropdown) Type() string
- type Field
- type Generated
- func (s *Generated) AsSchemaField() SchemaField
- func (s *Generated) Attr(name string) (starlark.Value, error)
- func (s *Generated) AttrNames() []string
- func (s *Generated) Freeze()
- func (s *Generated) Hash() (uint32, error)
- func (s *Generated) String() string
- func (s *Generated) Truth() starlark.Bool
- func (s *Generated) Type() string
- type Handler
- func (s *Handler) AsSchemaHandler() SchemaHandler
- func (s *Handler) Attr(name string) (starlark.Value, error)
- func (s *Handler) AttrNames() []string
- func (s *Handler) Freeze()
- func (s *Handler) Hash() (uint32, error)
- func (s *Handler) String() string
- func (s *Handler) Truth() starlark.Bool
- func (s *Handler) Type() string
- type HandlerReturnType
- type Location
- func (s *Location) AsSchemaField() SchemaField
- func (s *Location) Attr(name string) (starlark.Value, error)
- func (s *Location) AttrNames() []string
- func (s *Location) Freeze()
- func (s *Location) Hash() (uint32, error)
- func (s *Location) String() string
- func (s *Location) Truth() starlark.Bool
- func (s *Location) Type() string
- type LocationBased
- func (s *LocationBased) AsSchemaField() SchemaField
- func (s *LocationBased) Attr(name string) (starlark.Value, error)
- func (s *LocationBased) AttrNames() []string
- func (s *LocationBased) Freeze()
- func (s *LocationBased) Hash() (uint32, error)
- func (s *LocationBased) String() string
- func (s *LocationBased) Truth() starlark.Bool
- func (s *LocationBased) Type() string
- type Notification
- func (s *Notification) AsSchemaField() SchemaField
- func (s *Notification) Attr(name string) (starlark.Value, error)
- func (s *Notification) AttrNames() []string
- func (s *Notification) Freeze()
- func (s *Notification) Hash() (uint32, error)
- func (s *Notification) String() string
- func (s *Notification) Truth() starlark.Bool
- func (s *Notification) Type() string
- type OAuth2
- func (s *OAuth2) AsSchemaField() SchemaField
- func (s *OAuth2) Attr(name string) (starlark.Value, error)
- func (s *OAuth2) AttrNames() []string
- func (s *OAuth2) Freeze()
- func (s *OAuth2) Hash() (uint32, error)
- func (s *OAuth2) String() string
- func (s *OAuth2) Truth() starlark.Bool
- func (s *OAuth2) Type() string
- type Option
- func (s *Option) AsSchemaOption() SchemaOption
- func (s *Option) Attr(name string) (starlark.Value, error)
- func (s *Option) AttrNames() []string
- func (s *Option) Freeze()
- func (s *Option) Hash() (uint32, error)
- func (s *Option) String() string
- func (s *Option) Truth() starlark.Bool
- func (s *Option) Type() string
- type PhotoSelect
- func (s *PhotoSelect) AsSchemaField() SchemaField
- func (s *PhotoSelect) Attr(name string) (starlark.Value, error)
- func (s *PhotoSelect) AttrNames() []string
- func (s *PhotoSelect) Freeze()
- func (s *PhotoSelect) Hash() (uint32, error)
- func (s *PhotoSelect) String() string
- func (s *PhotoSelect) Truth() starlark.Bool
- func (s *PhotoSelect) Type() string
- type Schema
- type SchemaField
- type SchemaHandler
- type SchemaOption
- type SchemaSound
- type SchemaVisibility
- type Sound
- func (s *Sound) AsSchemaSound() SchemaSound
- func (s *Sound) Attr(name string) (starlark.Value, error)
- func (s *Sound) AttrNames() []string
- func (s *Sound) Freeze()
- func (s *Sound) Hash() (uint32, error)
- func (s *Sound) String() string
- func (s *Sound) Truth() starlark.Bool
- func (s *Sound) Type() string
- type StarlarkSchema
- func (s StarlarkSchema) Attr(name string) (starlark.Value, error)
- func (s StarlarkSchema) AttrNames() []string
- func (s StarlarkSchema) Freeze()
- func (s StarlarkSchema) Hash() (uint32, error)
- func (s StarlarkSchema) String() string
- func (s StarlarkSchema) Truth() starlark.Bool
- func (s StarlarkSchema) Type() string
- type Text
- type Toggle
- func (s *Toggle) AsSchemaField() SchemaField
- func (s *Toggle) Attr(name string) (starlark.Value, error)
- func (s *Toggle) AttrNames() []string
- func (s *Toggle) Freeze()
- func (s *Toggle) Hash() (uint32, error)
- func (s *Toggle) String() string
- func (s *Toggle) Truth() starlark.Bool
- func (s *Toggle) Type() string
- type Typeahead
- func (s *Typeahead) AsSchemaField() SchemaField
- func (s *Typeahead) Attr(name string) (starlark.Value, error)
- func (s *Typeahead) AttrNames() []string
- func (s *Typeahead) Freeze()
- func (s *Typeahead) Hash() (uint32, error)
- func (s *Typeahead) String() string
- func (s *Typeahead) Truth() starlark.Bool
- func (s *Typeahead) Type() string
Constants ¶
const (
ModuleName = "schema"
)
const ( // SchemaFunctionName is the name of the function in Starlark that we expect // to be able to call to get the schema for an applet. SchemaFunctionName = "get_schema" )
Variables ¶
This section is empty.
Functions ¶
func EncodeOptions ¶
EncodeOptions encodes a list of schema options into validated json.
func LoadModule ¶
func LoadModule() (starlark.StringDict, error)
Types ¶
type Color ¶
type Color struct {
SchemaField
// contains filtered or unexported fields
}
func (*Color) AsSchemaField ¶
func (s *Color) AsSchemaField() SchemaField
type DateTime ¶
type DateTime struct {
SchemaField
}
func (*DateTime) AsSchemaField ¶
func (s *DateTime) AsSchemaField() SchemaField
type Dropdown ¶
type Dropdown struct {
SchemaField
// contains filtered or unexported fields
}
func (*Dropdown) AsSchemaField ¶
func (s *Dropdown) AsSchemaField() SchemaField
type Field ¶
type Field interface {
AsSchemaField() SchemaField
}
type Generated ¶
type Generated struct {
SchemaField
}
func (*Generated) AsSchemaField ¶
func (s *Generated) AsSchemaField() SchemaField
type Handler ¶
type Handler struct {
SchemaHandler
}
func (*Handler) AsSchemaHandler ¶
func (s *Handler) AsSchemaHandler() SchemaHandler
type HandlerReturnType ¶
type HandlerReturnType int8
HandlerReturnType defines an enum for the type of information we expect to get back from the schema function.
const ( ReturnSchema HandlerReturnType = iota ReturnOptions ReturnString ReturnField )
type Location ¶
type Location struct {
SchemaField
}
func (*Location) AsSchemaField ¶
func (s *Location) AsSchemaField() SchemaField
type LocationBased ¶
type LocationBased struct {
SchemaField
}
func (*LocationBased) AsSchemaField ¶
func (s *LocationBased) AsSchemaField() SchemaField
func (*LocationBased) AttrNames ¶
func (s *LocationBased) AttrNames() []string
func (*LocationBased) Freeze ¶
func (s *LocationBased) Freeze()
func (*LocationBased) Hash ¶
func (s *LocationBased) Hash() (uint32, error)
func (*LocationBased) String ¶
func (s *LocationBased) String() string
func (*LocationBased) Truth ¶
func (s *LocationBased) Truth() starlark.Bool
func (*LocationBased) Type ¶
func (s *LocationBased) Type() string
type Notification ¶
type Notification struct {
SchemaField
Builder *starlark.Function `json:"-"`
// contains filtered or unexported fields
}
func (*Notification) AsSchemaField ¶
func (s *Notification) AsSchemaField() SchemaField
func (*Notification) AttrNames ¶
func (s *Notification) AttrNames() []string
func (*Notification) Freeze ¶
func (s *Notification) Freeze()
func (*Notification) Hash ¶
func (s *Notification) Hash() (uint32, error)
func (*Notification) String ¶
func (s *Notification) String() string
func (*Notification) Truth ¶
func (s *Notification) Truth() starlark.Bool
func (*Notification) Type ¶
func (s *Notification) Type() string
type OAuth2 ¶
type OAuth2 struct {
SchemaField
// contains filtered or unexported fields
}
func (*OAuth2) AsSchemaField ¶
func (s *OAuth2) AsSchemaField() SchemaField
type Option ¶
type Option struct {
SchemaOption
}
func (*Option) AsSchemaOption ¶
func (s *Option) AsSchemaOption() SchemaOption
type PhotoSelect ¶
type PhotoSelect struct {
SchemaField
}
func (*PhotoSelect) AsSchemaField ¶
func (s *PhotoSelect) AsSchemaField() SchemaField
func (*PhotoSelect) AttrNames ¶
func (s *PhotoSelect) AttrNames() []string
func (*PhotoSelect) Freeze ¶
func (s *PhotoSelect) Freeze()
func (*PhotoSelect) Hash ¶
func (s *PhotoSelect) Hash() (uint32, error)
func (*PhotoSelect) String ¶
func (s *PhotoSelect) String() string
func (*PhotoSelect) Truth ¶
func (s *PhotoSelect) Truth() starlark.Bool
func (*PhotoSelect) Type ¶
func (s *PhotoSelect) Type() string
type Schema ¶
type Schema struct {
Version string `json:"version" validate:"required"`
Fields []SchemaField `json:"schema" validate:"dive"`
Notifications []Notification `json:"notifications,omitempty" validate:"dive"`
Handlers map[string]SchemaHandler `json:"-"`
}
Schema holds a configuration object for an applet. It holds a list of fields that are exported from an applet.
func FromStarlark ¶
FromStarlark creates a new Schema from a Starlark schema object.
func (Schema) MarshalJSON ¶
type SchemaField ¶
type SchemaField struct {
Type string `` /* 169-byte string literal not displayed */
ID string `json:"id" validate:"required,excludesall=$"`
Name string `json:"name,omitempty" validate:"required_for=datetime dropdown location locationbased onoff radio text typeahead png"`
Description string `json:"description,omitempty"`
Icon string `json:"icon,omitempty" validate:"forbidden_for=generated"`
Visibility *SchemaVisibility `json:"visibility,omitempty" validate:"omitempty"`
Default string `json:"default,omitempty" validate:"required_for=dropdown onoff radio"`
Options []SchemaOption `json:"options,omitempty" validate:"required_for=dropdown radio,dive"`
Palette []string `json:"palette,omitempty"`
Sounds []SchemaSound `json:"sounds,omitempty" validate:"required_for=notification,dive"`
Source string `json:"source,omitempty" validate:"required_for=generated"`
Handler string `json:"handler,omitempty" validate:"required_for=generated locationbased typeahead oauth2"`
StarlarkHandler *starlark.Function `json:"-"`
ClientID string `json:"client_id,omitempty" validate:"required_for=oauth2"`
AuthorizationEndpoint string `json:"authorization_endpoint,omitempty" validate:"required_for=oauth2"`
Scopes []string `json:"scopes,omitempty" validate:"required_for=oauth2"`
Secret bool `json:"secret,omitempty" validate:"allowed_for=text"`
}
SchemaField represents an item in the config used to confgure an applet.
type SchemaHandler ¶
type SchemaHandler struct {
Function *starlark.Function
ReturnType HandlerReturnType
}
SchemaHandler defines a function and return type for getting the schema for an applet. This can both be the predefined schema function we expect all applets to have for config, but can also be used as a callback for.
type SchemaOption ¶
type SchemaOption struct {
Display string `json:"display"`
Text string `json:"text" validate:"required"` // The same as display, for legacy reasons.
Value string `json:"value" validate:"required"`
}
SchemaOption represents an option in a field. For example, an item in a drop down menu.
type SchemaSound ¶
type SchemaSound struct {
ID string `json:"id" validate:"required"`
Title string `json:"title" validate:"required"`
Path string `json:"path" validate:"required"`
}
SchemaSound represents a sound that can be played by the applet.
type SchemaVisibility ¶
type SchemaVisibility struct {
Type string `json:"type" validate:"required,oneof=invisible disabled"`
Condition string `json:"condition" validate:"required,oneof=equal not_equal"`
Variable string `json:"variable" validate:"required"`
Value string `json:"value"`
}
SchemaVisibility enables conditional fields inside of the mobile app. For example, if a field should be invisible until a login is provided.
type Sound ¶
type Sound struct {
SchemaSound
// contains filtered or unexported fields
}
func (*Sound) AsSchemaSound ¶
func (s *Sound) AsSchemaSound() SchemaSound
type StarlarkSchema ¶
type StarlarkSchema struct {
Schema
Handlers map[string]SchemaHandler
// contains filtered or unexported fields
}
func (StarlarkSchema) AttrNames ¶
func (s StarlarkSchema) AttrNames() []string
func (StarlarkSchema) Freeze ¶
func (s StarlarkSchema) Freeze()
func (StarlarkSchema) Hash ¶
func (s StarlarkSchema) Hash() (uint32, error)
func (StarlarkSchema) String ¶
func (s StarlarkSchema) String() string
func (StarlarkSchema) Truth ¶
func (s StarlarkSchema) Truth() starlark.Bool
func (StarlarkSchema) Type ¶
func (s StarlarkSchema) Type() string
type Text ¶
type Text struct {
SchemaField
}
func (*Text) AsSchemaField ¶
func (s *Text) AsSchemaField() SchemaField
type Toggle ¶
type Toggle struct {
SchemaField
}
func (*Toggle) AsSchemaField ¶
func (s *Toggle) AsSchemaField() SchemaField
type Typeahead ¶
type Typeahead struct {
SchemaField
}
func (*Typeahead) AsSchemaField ¶
func (s *Typeahead) AsSchemaField() SchemaField