Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureConfigDefaults ¶
func EnsureWebConfigDefaults ¶
EnsureWebConfigDefaults handles setting sane defaults and migrating the config forward. It returns `true` if any changes were made.
func SaveConfig ¶
Types ¶
type CliAuthenticator ¶
type CliAuthenticator struct { }
func (*CliAuthenticator) Prompt2FACode ¶
func (*CliAuthenticator) Prompt2FACode() (string, error)
Prompt2FACode implements `ringapi.Authenticator` interface
func (*CliAuthenticator) PromptCredentials ¶
func (*CliAuthenticator) PromptCredentials() (string, string, error)
PromptCredentials implements `ringapi.Authenticator` interface
type Config ¶
type Config struct { ApiConfig ringapi.ApiConfig `json:"api_config"` WebConfig WebConfig `json:"web_config"` PollIntervalSeconds uint32 `json:"poll_interval_seconds"` SaveIntervalSeconds uint32 `json:"save_interval_seconds"` }
func LoadConfig ¶
type Monitor ¶
type Monitor struct { StateHandler *RingStateHandler Session *ringapi.AuthorizedSession Config *Config // contains filtered or unexported fields }
Monitor performs the ringapi query calls and population into prometheus metrics
func NewMonitor ¶
func NewMonitor(cfgFile string, metrics *prometheus.Registry) (*Monitor, error)
NewMonitor creates a new Monitor instance with the required parameters
type RingState ¶
type RingState struct { Token *oauth2.Token `json:"token"` DingCounts []dingCount `json:"ding_counts"` }
RingState is a serializable object for holding state
type RingStateHandler ¶
type RingStateHandler struct {
// contains filtered or unexported fields
}
RingStateHandler exposes persistence of the `RingState` and also implements `ringapi.TokenHandler`
func NewRingStateHandler ¶
func NewRingStateHandler(cfgFile string) *RingStateHandler
NewRingStateHandler creates a new RingStateHandler instance
func (*RingStateHandler) FetchToken ¶
func (s *RingStateHandler) FetchToken() *oauth2.Token
Fetch implements `ringapi.TokenHandler` interface
func (*RingStateHandler) Save ¶
func (s *RingStateHandler) Save()
func (*RingStateHandler) StoreToken ¶
func (s *RingStateHandler) StoreToken(token *oauth2.Token)
Fetch implements `ringapi.TokenHandler` interface
func (*RingStateHandler) UpdateDingCount ¶
func (s *RingStateHandler) UpdateDingCount(bot *ring_types.DoorBot, dings *[]ring_types.DoorBotDing) (uint32, error)
UpdateDingCount updates the `RingState` with the historical set of dings and updates the gauge reprsenting the ding counter appropriate. This returns the current count (across restart) for the device as seen by this exporter and state.