Documentation ¶
Index ¶
- Constants
- Variables
- func DebugInterceptor(log logger.Logger, original http.RoundTripper) http.RoundTripper
- func ParsePublicKeyBase64(publicKeyBase64 string) *rsa.PublicKey
- func RequestInterceptor(original http.RoundTripper) http.RoundTripper
- type Authenticator
- type DefaultEventHandler
- func (h *DefaultEventHandler) AddEventHandler(handler PredicateEventHandler)
- func (h *DefaultEventHandler) BuildHandler() Handler
- func (h *DefaultEventHandler) DoOnError(onError OnError)
- func (h *DefaultEventHandler) DoOnSuccess(onSuccess OnSuccess)
- func (h *DefaultEventHandler) GetChainSize() int
- func (h *DefaultEventHandler) Handle(params *SmartAppParams) (*smartapp.ExecutionResponse, error)
- func (h *DefaultEventHandler) SetFailOnErrorPredicate(failOnError FailOnError)
- func (h *DefaultEventHandler) SetHandlerChain(chain []PredicateEventHandler)
- func (h *DefaultEventHandler) Test(params *SmartAppParams) bool
- type DefaultPredicateHandler
- type DefaultSmartApp
- type DefaultSmartAppDefinition
- func (h *DefaultSmartAppDefinition) AddHandler(handler PredicateHandler)
- func (h *DefaultSmartAppDefinition) BuildChain() []PredicateHandler
- func (h *DefaultSmartAppDefinition) SetConfigurationHandler(handler Handler)
- func (h *DefaultSmartAppDefinition) SetEventHandler(handler Handler)
- func (h *DefaultSmartAppDefinition) SetInstallHandler(handler Handler)
- func (h *DefaultSmartAppDefinition) SetOAuthCallbackHandler(handler Handler)
- func (h *DefaultSmartAppDefinition) SetPingHandler(handler Handler)
- func (h *DefaultSmartAppDefinition) SetUninstallHandler(handler Handler)
- func (h *DefaultSmartAppDefinition) SetUpdateHandler(handler Handler)
- type DefaultSmartThingsApi
- func (s *DefaultSmartThingsApi) CreateDeviceEvents(params *devices.CreateDeviceEventsParams) error
- func (s *DefaultSmartThingsApi) CreateSchedule(params *schedules.CreateScheduleParams) (*models.Schedule, error)
- func (s *DefaultSmartThingsApi) ExecuteDeviceCommands(params *devices.ExecuteDeviceCommandsParams) error
- func (s *DefaultSmartThingsApi) ExecuteScene(params *scenes.ExecuteSceneParams) error
- func (s *DefaultSmartThingsApi) GetLocation(params *locations.GetLocationParams) (*models.Location, error)
- func (s *DefaultSmartThingsApi) InstallDevice(params *devices.InstallDeviceParams) (*models.Device, error)
- func (s *DefaultSmartThingsApi) SaveSubscription(params *subscriptions.SaveSubscriptionParams) error
- type EventHandler
- type FailOnError
- type Handle
- type Handler
- type KeyResolver
- type NoopLifecycleHandler
- type NotFoundHandler
- type OnError
- type OnSuccess
- type PingHandler
- type PredicateEventHandler
- type PredicateHandler
- type SmartApp
- type SmartAppDefinition
- type SmartAppParams
- type SmartThingsApi
- type SmartThingsApiParams
- type Test
Constants ¶
View Source
const ( CorrelationHeader = "X-ST-CORRELATION" CorrelationKey = "loggingId" MediaTypeJsonV1 = "application/vnd.smartthings+json;v=1" SmartThingsHost = "api.smartthings.com" )
Variables ¶
View Source
var ( UnsupportedLifecyleError = errors.New("unsupported_app_lifecycle") IllegalArgumentPingChallengeError = errors.New("illegal_argument_ping_challenge") )
Functions ¶
func DebugInterceptor ¶
func DebugInterceptor(log logger.Logger, original http.RoundTripper) http.RoundTripper
func ParsePublicKeyBase64 ¶
*
- Builds an rsa.PublicKey object for a pem formatted base64 encoded public key string.
func RequestInterceptor ¶
func RequestInterceptor(original http.RoundTripper) http.RoundTripper
Types ¶
type Authenticator ¶
func NewAuthenticator ¶
func NewAuthenticator(publicKey *rsa.PublicKey) *Authenticator
type DefaultEventHandler ¶
type DefaultEventHandler struct { Chain []PredicateEventHandler OnSuccess OnSuccess OnError OnError FailOnError FailOnError }
func (*DefaultEventHandler) AddEventHandler ¶
func (h *DefaultEventHandler) AddEventHandler(handler PredicateEventHandler)
func (*DefaultEventHandler) BuildHandler ¶
func (h *DefaultEventHandler) BuildHandler() Handler
func (*DefaultEventHandler) DoOnError ¶
func (h *DefaultEventHandler) DoOnError(onError OnError)
func (*DefaultEventHandler) DoOnSuccess ¶
func (h *DefaultEventHandler) DoOnSuccess(onSuccess OnSuccess)
func (*DefaultEventHandler) GetChainSize ¶
func (h *DefaultEventHandler) GetChainSize() int
func (*DefaultEventHandler) Handle ¶
func (h *DefaultEventHandler) Handle(params *SmartAppParams) (*smartapp.ExecutionResponse, error)
func (*DefaultEventHandler) SetFailOnErrorPredicate ¶
func (h *DefaultEventHandler) SetFailOnErrorPredicate(failOnError FailOnError)
func (*DefaultEventHandler) SetHandlerChain ¶
func (h *DefaultEventHandler) SetHandlerChain(chain []PredicateEventHandler)
func (*DefaultEventHandler) Test ¶
func (h *DefaultEventHandler) Test(params *SmartAppParams) bool
type DefaultPredicateHandler ¶
func (*DefaultPredicateHandler) Handle ¶
func (h *DefaultPredicateHandler) Handle(params *SmartAppParams) (*smartapp.ExecutionResponse, error)
func (*DefaultPredicateHandler) Test ¶
func (h *DefaultPredicateHandler) Test(params *SmartAppParams) bool
type DefaultSmartApp ¶
type DefaultSmartApp struct {
Chain []PredicateHandler
}
func (*DefaultSmartApp) Handle ¶
func (s *DefaultSmartApp) Handle(params *SmartAppParams) (*smartapp.ExecutionResponse, error)
type DefaultSmartAppDefinition ¶
type DefaultSmartAppDefinition struct { InstallHandler PredicateHandler UpdateHandler PredicateHandler UninstallHandler PredicateHandler EventHandler PredicateHandler PingHandler PredicateHandler ConfigurationHandler PredicateHandler OAuthCallbackHandler PredicateHandler AdditionalHandlers []PredicateHandler }
func (*DefaultSmartAppDefinition) AddHandler ¶
func (h *DefaultSmartAppDefinition) AddHandler(handler PredicateHandler)
func (*DefaultSmartAppDefinition) BuildChain ¶
func (h *DefaultSmartAppDefinition) BuildChain() []PredicateHandler
func (*DefaultSmartAppDefinition) SetConfigurationHandler ¶
func (h *DefaultSmartAppDefinition) SetConfigurationHandler(handler Handler)
func (*DefaultSmartAppDefinition) SetEventHandler ¶
func (h *DefaultSmartAppDefinition) SetEventHandler(handler Handler)
func (*DefaultSmartAppDefinition) SetInstallHandler ¶
func (h *DefaultSmartAppDefinition) SetInstallHandler(handler Handler)
func (*DefaultSmartAppDefinition) SetOAuthCallbackHandler ¶
func (h *DefaultSmartAppDefinition) SetOAuthCallbackHandler(handler Handler)
func (*DefaultSmartAppDefinition) SetPingHandler ¶
func (h *DefaultSmartAppDefinition) SetPingHandler(handler Handler)
func (*DefaultSmartAppDefinition) SetUninstallHandler ¶
func (h *DefaultSmartAppDefinition) SetUninstallHandler(handler Handler)
func (*DefaultSmartAppDefinition) SetUpdateHandler ¶
func (h *DefaultSmartAppDefinition) SetUpdateHandler(handler Handler)
type DefaultSmartThingsApi ¶
type DefaultSmartThingsApi struct { Client *apiclient.SmartThings RequestTimeout time.Duration Logger logger.Logger }
func (*DefaultSmartThingsApi) CreateDeviceEvents ¶
func (s *DefaultSmartThingsApi) CreateDeviceEvents(params *devices.CreateDeviceEventsParams) error
func (*DefaultSmartThingsApi) CreateSchedule ¶
func (s *DefaultSmartThingsApi) CreateSchedule(params *schedules.CreateScheduleParams) (*models.Schedule, error)
func (*DefaultSmartThingsApi) ExecuteDeviceCommands ¶
func (s *DefaultSmartThingsApi) ExecuteDeviceCommands(params *devices.ExecuteDeviceCommandsParams) error
func (*DefaultSmartThingsApi) ExecuteScene ¶
func (s *DefaultSmartThingsApi) ExecuteScene(params *scenes.ExecuteSceneParams) error
func (*DefaultSmartThingsApi) GetLocation ¶
func (s *DefaultSmartThingsApi) GetLocation(params *locations.GetLocationParams) (*models.Location, error)
func (*DefaultSmartThingsApi) InstallDevice ¶
func (s *DefaultSmartThingsApi) InstallDevice(params *devices.InstallDeviceParams) (*models.Device, error)
func (*DefaultSmartThingsApi) SaveSubscription ¶
func (s *DefaultSmartThingsApi) SaveSubscription(params *subscriptions.SaveSubscriptionParams) error
type EventHandler ¶
type EventHandler interface { SetHandlerChain(chain []PredicateEventHandler) AddEventHandler(handler PredicateEventHandler) DoOnSuccess(onSuccess OnSuccess) DoOnError(onError OnError) SetFailOnErrorPredicate(failOnError FailOnError) GetChainSize() int BuildHandler() Handler }
func NewEventHandler ¶
func NewEventHandler() EventHandler
type FailOnError ¶
type Handle ¶
type Handle func(params *SmartAppParams) (*smartapp.ExecutionResponse, error)
type Handler ¶
type Handler func(params *SmartAppParams) (*smartapp.ExecutionResponse, error)
type KeyResolver ¶
func (KeyResolver) GetKey ¶
func (k KeyResolver) GetKey(id string) interface{}
type NoopLifecycleHandler ¶
type NoopLifecycleHandler struct {
Lifecycle smartapp.AppLifecycle
}
func (*NoopLifecycleHandler) Handle ¶
func (h *NoopLifecycleHandler) Handle(params *SmartAppParams) (*smartapp.ExecutionResponse, error)
func (*NoopLifecycleHandler) Test ¶
func (h *NoopLifecycleHandler) Test(params *SmartAppParams) bool
type NotFoundHandler ¶
type NotFoundHandler struct { }
func (*NotFoundHandler) Handle ¶
func (h *NotFoundHandler) Handle(params *SmartAppParams) (*smartapp.ExecutionResponse, error)
func (*NotFoundHandler) Test ¶
func (h *NotFoundHandler) Test(params *SmartAppParams) bool
type OnError ¶
type OnError func(params *SmartAppParams, err error) (*smartapp.ExecutionResponse, error)
type OnSuccess ¶
type OnSuccess func(params *SmartAppParams) (*smartapp.ExecutionResponse, error)
type PingHandler ¶
type PingHandler struct { }
func (*PingHandler) Handle ¶
func (h *PingHandler) Handle(params *SmartAppParams) (*smartapp.ExecutionResponse, error)
func (*PingHandler) Test ¶
func (h *PingHandler) Test(params *SmartAppParams) bool
type PredicateEventHandler ¶
type PredicateHandler ¶
type PredicateHandler interface { Test(params *SmartAppParams) bool Handle(params *SmartAppParams) (*smartapp.ExecutionResponse, error) }
type SmartApp ¶
type SmartApp interface {
Handle(request *SmartAppParams) (*smartapp.ExecutionResponse, error)
}
func NewSmartApp ¶
func NewSmartApp(definition SmartAppDefinition) SmartApp
type SmartAppDefinition ¶
type SmartAppDefinition interface { SetInstallHandler(handler Handler) SetUpdateHandler(handler Handler) SetUninstallHandler(handler Handler) SetEventHandler(handler Handler) SetPingHandler(handler Handler) SetConfigurationHandler(handler Handler) SetOAuthCallbackHandler(handler Handler) AddHandler(handler PredicateHandler) BuildChain() []PredicateHandler }
func NewSmartAppDefinition ¶
func NewSmartAppDefinition() SmartAppDefinition
type SmartAppParams ¶
type SmartAppParams struct { Request *smartapp.ExecutionRequest Context context.Context }
func (*SmartAppParams) GetSetting ¶
func (p *SmartAppParams) GetSetting(key string) string
type SmartThingsApi ¶
type SmartThingsApi interface { CreateSchedule(params *schedules.CreateScheduleParams) (*models.Schedule, error) SaveSubscription(params *subscriptions.SaveSubscriptionParams) error InstallDevice(params *devices.InstallDeviceParams) (*models.Device, error) CreateDeviceEvents(params *devices.CreateDeviceEventsParams) error ExecuteDeviceCommands(params *devices.ExecuteDeviceCommandsParams) error GetLocation(params *locations.GetLocationParams) (*models.Location, error) ExecuteScene(params *scenes.ExecuteSceneParams) error }
func NewSmartThingsApi ¶
func NewSmartThingsApi(params *SmartThingsApiParams) SmartThingsApi
type SmartThingsApiParams ¶
type Test ¶
type Test func(params *SmartAppParams) bool
Click to show internal directories.
Click to hide internal directories.