notifiarr

package
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Notifiarr package provides a standard interface for sending data to notifiarr.com. This includes crontabs that run

Index

Constants

View Source
const (
	BaseURL = "https://notifiarr.com"
	ProdURL = BaseURL + "/notifier.php"
	TestURL = BaseURL + "/notifierTest.php"
	DevURL  = "http://dev.notifiarr.com/notifier.php"
)

Notifiarr URLs.

View Source
const (
	PlexCron = "plexcron"
	SnapCron = "snapcron"
	PlexHook = "plexhook"
	LogLocal = "loglocal"
)

Variables

View Source
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

func (c *Config) CheckAPIKey() error

CheckAPIKey returns an error if the API key is wrong.

func (*Config) GetMetaSnap

func (c *Config) GetMetaSnap(ctx context.Context) *snapshot.Snapshot

GetMetaSnap grabs some basic system info: cpu, memory, username.

func (*Config) SendData

func (c *Config) SendData(url string, payload interface{}) ([]byte, []byte, error)

func (*Config) SendJSON

func (c *Config) SendJSON(url string, data []byte) ([]byte, error)

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.

func (*Config) Start

func (c *Config) Start(mode string)

Start (and log) snapshot and plex cron jobs if they're configured.

func (*Config) Stop

func (c *Config) Stop()

Stop snapshot and plex cron jobs.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL