Documentation ¶
Index ¶
- Constants
- Variables
- type Config
- type EventType
- type Payload
- type Request
- type Response
- type Route
- type Server
- func (s *Server) DelState(_ context.Context, keys ...string) error
- func (s *Server) GetData(req *Request) (*Response, error)
- func (s *Server) GetHostInfo(ctx context.Context) (*host.InfoStat, error)
- func (s *Server) GetState(_ context.Context, keys ...string) (map[string][]byte, error)
- func (s *Server) RawGetData(ctx context.Context, req *Request) (*Response, time.Duration, error)
- func (s *Server) SendData(req *Request)
- func (s *Server) SetState(ctx context.Context, key string, value []byte) error
- func (s *Server) SetStates(_ context.Context, values map[string][]byte) error
- func (s *Server) Start(ctx context.Context)
- func (s *Server) Stop()
- type UploadFile
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 // APIKeyLength is the string length of a valid notifiarr API key. APIKeyLength = 36 )
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") ErrInvalidAPIKey = fmt.Errorf("configured notifiarr API key is invalid") )
Errors returned by this library.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Apps *apps.Apps Retries int BaseURL string Timeout cnfg.Duration HostID string BindAddr string mnd.Logger // log file writer }
Config is the input data needed to send payloads to notifiarr.
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" EventSet EventType = "setStates" EventGet EventType = "getStates" )
These are all our known event types.
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 Request ¶
type Request struct { Route Route Event EventType Params []string // optional. Payload interface{} // data to send. UploadFile *UploadFile // file to send (instead of payload). 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"` // contains filtered or unexported fields }
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" CFSyncRoute Route = userRoute1 + "/trash" GapsRoute Route = userRoute1 + "/gaps" MdbListRoute Route = userRoute1 + "/mdblist" TunnelRoute Route = userRoute1 + "/tunnel" ClientRoute Route = userRoute2 + "/client" DashRoute Route = notifiRoute + "/dashboard" StuckRoute Route = notifiRoute + "/stuck" DownloadRoute Route = notifiRoute + "/downloads" 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" UploadRoute Route = systemRoute + "/upload" )
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 { Config *Config // contains filtered or unexported fields }
Server is what you get for providing a Config to New().
func (*Server) GetHostInfo ¶
GetHostInfo attempts to make a unique machine identifier...
func (*Server) RawGetData ¶
RawGetData sends a request to the website without using a channel. Avoid this method.
type UploadFile ¶ added in v0.7.0
type UploadFile struct { FileName string io.ReadCloser }
UploadFile is the file upload identifier in a request.