Documentation ¶
Index ¶
- Constants
- Variables
- type AppConfig
- type AppConfigs
- type ClientInfo
- type Config
- type CronConfig
- type DashConfig
- type EventType
- type GapsConfig
- type IntList
- type Payload
- type PlexConfig
- type Request
- type Response
- type Route
- type Server
- func (s *Server) DelValue(keys ...string) error
- func (s *Server) DelValueContext(ctx context.Context, keys ...string) error
- func (s *Server) GetClientInfo() (*ClientInfo, error)
- func (s *Server) GetData(req *Request) (*Response, error)
- func (s *Server) GetHostInfo() (*host.InfoStat, error)
- func (s *Server) GetValue(keys ...string) (map[string][]byte, error)
- func (s *Server) GetValueContext(ctx context.Context, keys ...string) (map[string][]byte, error)
- func (s *Server) HaveClientInfo() bool
- func (s *Server) Info() map[string]interface{}
- func (s *Server) PollForReload(event EventType)
- func (s *Server) RawGetData(req *Request) (*Response, time.Duration, error)
- func (s *Server) ReloadCh(sighup chan os.Signal)
- func (s *Server) SendData(req *Request)
- func (s *Server) SetValue(key string, value []byte) error
- func (s *Server) SetValueContext(ctx context.Context, key string, value []byte) error
- func (s *Server) SetValues(values map[string][]byte) error
- func (s *Server) SetValuesContext(ctx context.Context, values map[string][]byte) error
- func (s *Server) Start()
- func (s *Server) Stop()
- type SyncConfig
Constants ¶
const ( // DefaultRetries is the number of times to attempt a request to notifiarr.com. // 4 means 5 total tries: 1 try + 4 retries. DefaultRetries = 4 // RetryDelay is how long to Sleep between retries. RetryDelay = 222 * time.Millisecond )
const ( ModeDev = "development" ModeProd = "production" )
Possible application modes.
Variables ¶
var ( ErrNon200 = fmt.Errorf("return code was not 200") ErrInvalidResponse = fmt.Errorf("invalid response") ErrNoChannel = fmt.Errorf("the website send-data channel is closed") )
Errors returned by this library.
Functions ¶
This section is empty.
Types ¶
type AppConfig ¶
type AppConfig struct { Instance int `json:"instance"` Name string `json:"name"` Stuck bool `json:"stuck"` Corrupt string `json:"corrupt"` Backup string `json:"backup"` Interval cnfg.Duration `json:"interval"` }
AppConfig is the data that comes from the website for each Starr app.
type AppConfigs ¶
type AppConfigs struct { Lidarr []*AppConfig `json:"lidarr"` Prowlarr []*AppConfig `json:"prowlarr"` Radarr []*AppConfig `json:"radarr"` Readarr []*AppConfig `json:"readarr"` Sonarr []*AppConfig `json:"sonarr"` }
AppConfigs is the configuration returned from the notifiarr website for Starr apps.
type ClientInfo ¶
type ClientInfo struct { User struct { WelcomeMSG string `json:"welcome"` Subscriber bool `json:"subscriber"` Patron bool `json:"patron"` DevAllowed bool `json:"devAllowed"` } `json:"user"` Actions struct { Poll bool `json:"poll"` Plex PlexConfig `json:"plex"` // Site Config for Plex. Apps AppConfigs `json:"apps"` // Site Config for Starr. Dashboard DashConfig `json:"dashboard"` // Site Config for Dashboard. Sync SyncConfig `json:"sync"` // Site Config for TRaSH Sync. Gaps GapsConfig `json:"gaps"` // Site Config for Radarr Gaps. Custom []*CronConfig `json:"custom"` // Site config for Custom Crons. Snapshot *snapshot.Config `json:"snapshot"` // Site Config for System Snapshot. } `json:"actions"` }
ClientInfo is the client's startup data received from the website.
func (*ClientInfo) IsPatron ¶
func (c *ClientInfo) IsPatron() bool
IsPatron returns true if the client is a patron. False otherwise.
func (*ClientInfo) IsSub ¶
func (c *ClientInfo) IsSub() bool
IsSub returns true if the client is a subscriber. False otherwise.
func (*ClientInfo) String ¶
func (c *ClientInfo) String() string
String returns the message text for a client info response.
type Config ¶
type Config struct { Apps *apps.Apps Plex *plex.Server // plex sessions Serial bool Retries int BaseURL string Timeout cnfg.Duration MaxBody int Sighup chan os.Signal Mode string HostID string mnd.Logger // log file writer }
Config is the input data needed to send payloads to notifiarr.
type CronConfig ¶
type CronConfig struct { Name string `json:"name"` // name of action. Interval cnfg.Duration `json:"interval"` // how often to GET this URI. URI string `json:"endpoint"` // endpoint for the URI. Desc string `json:"description"` }
CronConfig defines a custom GET timer from the website. Used to offload crons to clients.
type DashConfig ¶
type DashConfig struct {
Interval cnfg.Duration `json:"interval"` // how often to fire in minutes.
}
DashConfig is the configuration returned from the notifiarr website for the dashboard configuration.
type EventType ¶
type EventType string
EventType identifies the type of event that sent a paylaod to notifiarr.
const ( EventCron EventType = "cron" EventGUI EventType = "gui" EventUser EventType = "user" EventAPI EventType = "api" EventHook EventType = "webhook" EventStart EventType = "start" EventMovie EventType = "movie" EventEpisode EventType = "episode" EventPoll EventType = "poll" EventSignal EventType = "signal" EventFile EventType = "file" )
These are all our known event types.
type GapsConfig ¶
type GapsConfig struct { Instances IntList `json:"instances"` Interval cnfg.Duration `json:"interval"` }
GapsConfig is the configuration returned from the notifiarr website for Radarr Collection Gaps.
type Payload ¶
type Payload struct { Plex *plex.Sessions `json:"plex,omitempty"` Snap *snapshot.Snapshot `json:"snapshot,omitempty"` Load *plex.IncomingWebhook `json:"payload,omitempty"` }
Payload is the outbound payload structure that is sent to Notifiarr for Plex and system snapshot data.
type PlexConfig ¶
type PlexConfig struct { Interval cnfg.Duration `json:"interval"` TrackSess bool `json:"trackSessions"` AccountMap string `json:"accountMap"` NoActivity bool `json:"noActivity"` Delay cnfg.Duration `json:"activityDelay"` Cooldown cnfg.Duration `json:"cooldown"` SeriesPC uint `json:"seriesPc"` MoviesPC uint `json:"moviesPc"` }
PlexConfig is the website-derived configuration for Plex.
type Request ¶
type Request struct { Route Route Event EventType Params []string // optional. Payload interface{} // data to send. LogMsg string // if empty, nothing is logged. LogPayload bool // debug log the sent payload ErrorsOnly bool // only log errors. // contains filtered or unexported fields }
Request is used when sending data through a channel.
type Response ¶
type Response struct { Result string `json:"result"` Details struct { Response json.RawMessage `json:"response"` // can be anything. type it out later. Help string `json:"help"` Started time.Time `json:"started"` Finished time.Time `json:"finished"` Elapsed cnfg.Duration `json:"elapsed"` } `json:"details"` }
Response is what notifiarr replies to our requests with.
try this
{ "response": "success", "message": { "response": { "instance": 1, "debug": null }, "started": "23:57:03", "finished": "23:57:03", "elapsed": "0s" } }
{ "response": "success", "message": { "response": "Service status cron processed.", "started": "00:04:15", "finished": "00:04:15", "elapsed": "0s" } }
{ "response": "success", "message": { "response": "Channel stats cron processed.", "started": "00:04:31", "finished": "00:04:36", "elapsed": "5s" } }
{ "response": "success", "message": { "response": "Dashboard payload processed.", "started": "00:02:04", "finished": "00:02:11", "elapsed": "7s" } }
nitsua: all responses should be that way.. but response might not always be an object.
type Route ¶
type Route string
Route is used to give us methods on our route paths.
const ( BaseURL = "https://notifiarr.com" DevBaseURL = "https://dev.notifiarr.com" TestBaseURL = "https://test.notifiarr.com" ClientRoute Route = userRoute2 + "/client" CFSyncRoute Route = userRoute1 + "/trash" GapsRoute Route = userRoute1 + "/gaps" DashRoute Route = notifiRoute + "/dashboard" StuckRoute Route = notifiRoute + "/stuck" PlexRoute Route = notifiRoute + "/plex" SnapRoute Route = notifiRoute + "/snapshot" SvcRoute Route = notifiRoute + "/services" CorruptRoute Route = notifiRoute + "/corruption" BackupRoute Route = notifiRoute + "/backup" TestRoute Route = notifiRoute + "/test" PkgRoute Route = notifiRoute + "/packageManager" LogLineRoute Route = notifiRoute + "/logWatcher" CommandRoute Route = notifiRoute + "/command" )
Notifiarr URLs. Data sent to these URLs:
api/v1/notification/plex?event=...
api (was plexcron) user (was plexcron) cron (was plexcron) webhook (was plexhook) movie episode
api/v1/notification/services?event=...
api user cron start (only fires on startup)
api/v1/notification/snapshot?event=...
api user cron
api/v1/notification/dashboard?event=... (requires interval from website/client endpoint)
api user cron
api/v1/notification/stuck?event=...
api user cron
api/v1/user/gaps?app=radarr&event=...
api user cron
api/v2/user/client?event=start
see description https://github.com/Notifiarr/notifiarr/pull/115
api/v1/user/trash?app=...
radarr sonarr
type Server ¶
type Server struct { Mode string // contains filtered or unexported fields }
Server is what you get for providing a Config to New().
func (*Server) DelValueContext ¶
DelValueContext deletes a value stored in the website database.
func (*Server) GetClientInfo ¶
func (s *Server) GetClientInfo() (*ClientInfo, error)
GetClientInfo returns an error if the API key is wrong. Returns client info otherwise.
func (*Server) GetHostInfo ¶
GetHostInfo attempts to make a unique machine identifier...
func (*Server) GetValueContext ¶
GetValueContext gets a value stored in the website database.
func (*Server) HaveClientInfo ¶
func (*Server) PollForReload ¶
func (*Server) RawGetData ¶
RawGetData sends a request to the website without using a channel. Avoid this method.
func (*Server) SetValueContext ¶
SetValueContext sets a value stored in the website database.
func (*Server) SetValuesContext ¶
SetValuesContext sets values stored in the website database.
type SyncConfig ¶
type SyncConfig struct { Interval cnfg.Duration `json:"interval"` // how often to fire in minutes. Radarr int64 `json:"radarr"` // items in sync RadarrInstances IntList `json:"radarrInstances"` // which instance IDs we sync Sonarr int64 `json:"sonarr"` // items in sync SonarrInstances IntList `json:"sonarrInstances"` // which instance IDs we sync }
SyncConfig is the configuration returned from the notifiarr website for CF/RP TraSH sync.