Documentation
¶
Overview ¶
Notifiarr package provides a standard interface for sending data to notifiarr.com. This includes crontabs that run
Index ¶
- Constants
- Variables
- type Config
- func (c *Config) CheckAPIKey() error
- func (c *Config) GetMetaSnap(ctx context.Context) *snapshot.Snapshot
- func (c *Config) SendData(url string, payload interface{}) ([]byte, []byte, error)
- func (c *Config) SendJSON(url string, data []byte) ([]byte, error)
- func (c *Config) SendMeta(eventType, url string, hook *plex.Webhook, wait time.Duration) ([]byte, error)
- func (c *Config) Start(mode string)
- func (c *Config) Stop()
- type Payload
Constants ¶
const ( BaseURL = "https://notifiarr.com" ProdURL = BaseURL + "/notifier.php" TestURL = BaseURL + "/notifierTest.php" DevURL = "http://dev.notifiarr.com/notifier.php" )
Notifiarr URLs.
const ( PlexCron = "plexcron" SnapCron = "snapcron" PlexHook = "plexhook" LogLocal = "loglocal" )
Variables ¶
var ErrNon200 = fmt.Errorf("return code was not 200")
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Apps *apps.Apps // has API key Plex *plex.Server // plex sessions Snap *snapshot.Config // system snapshot data URL string Timeout time.Duration *logs.Logger // log file writer // contains filtered or unexported fields }
Config is the input data needed to send payloads to notifiarr.
func (*Config) CheckAPIKey ¶
CheckAPIKey returns an error if the API key is wrong.
func (*Config) GetMetaSnap ¶
GetMetaSnap grabs some basic system info: cpu, memory, username.
func (*Config) SendJSON ¶
SendJSON posts a JSON payload to a URL. Returns the response body or an error. The response status code is lost.
func (*Config) SendMeta ¶
func (c *Config) SendMeta(eventType, url string, hook *plex.Webhook, wait time.Duration) ([]byte, error)
SendMeta is kicked off by the webserver in go routine. It's also called by the plex cron (with webhook set to nil). This runs after Plex drops off a webhook telling us someone did something. This gathers cpu/ram, and waits 10 seconds, then grabs plex sessions. It's all POSTed to notifiarr. May be used with a nil Webhook.
type Payload ¶
type Payload struct { Type string `json:"eventType"` Plex *plex.Sessions `json:"plex,omitempty"` Snap *snapshot.Snapshot `json:"snapshot,omitempty"` Load *plex.Webhook `json:"payload,omitempty"` }
Payload is the outbound payload structure that is sent to Notifiarr. No other payload formats are used for data sent to notifiarr.com.