apps

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: May 26, 2024 License: MIT Imports: 33 Imported by: 0

Documentation

Overview

Package apps provides the _incoming_ HTTP methods for notifiarr.com integrations. Methods are included for Radarr, Readrr, Lidarr and Sonarr. This library also holds the site API Key and the base HTTP server abstraction used throughout the Notifiarr client application. The configuration should be derived from a config file; a Router and an Error Log logger must also be provided.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoTMDB     = fmt.Errorf("TMDB ID must not be empty")
	ErrNoGRID     = fmt.Errorf("GRID ID must not be empty")
	ErrNoTVDB     = fmt.Errorf("TVDB ID must not be empty")
	ErrNoMBID     = fmt.Errorf("MBID ID must not be empty")
	ErrNoRadarr   = fmt.Errorf("configured %s ID not found", starr.Radarr)
	ErrNoSonarr   = fmt.Errorf("configured %s ID not found", starr.Sonarr)
	ErrNoLidarr   = fmt.Errorf("configured %s ID not found", starr.Lidarr)
	ErrNoReadarr  = fmt.Errorf("configured %s ID not found", starr.Readarr)
	ErrNoProwlarr = fmt.Errorf("configured %s ID not found", starr.Prowlarr)
	ErrNotFound   = fmt.Errorf("the request returned an empty payload")
	ErrNonZeroID  = fmt.Errorf("provided ID must be non-zero")
	// ErrWrongCount is returned when an app returns the wrong item count.
	ErrWrongCount = fmt.Errorf("wrong item count returned")
	ErrInvalidApp = fmt.Errorf("invalid application configuration provided")
	ErrRateLimit  = fmt.Errorf("rate limit reached")
)

Errors sent to client web requests.

Functions

func NewFakeCloser added in v0.4.1

func NewFakeCloser(app, method string, body io.ReadCloser) io.ReadCloser

Types

type APIHandler

type APIHandler func(r *http.Request) (int, interface{})

APIHandler is our custom handler function for APIs. The powers the middleware procedure that stores the app interface in a request context. And the procedures to save and fetch an app interface into/from a request content.

type Apps

type Apps struct {
	APIKey       string            `json:"apiKey" toml:"api_key" xml:"api_key" yaml:"apiKey"`
	ExKeys       []string          `json:"extraKeys" toml:"extra_keys" xml:"extra_keys" yaml:"extraKeys"`
	URLBase      string            `json:"urlbase" toml:"urlbase" xml:"urlbase" yaml:"urlbase"`
	MaxBody      int               `toml:"max_body" xml:"max_body" json:"maxBody"`
	Serial       bool              `json:"serial" toml:"serial" xml:"serial" yaml:"serial"`
	Sonarr       []*SonarrConfig   `json:"sonarr,omitempty" toml:"sonarr" xml:"sonarr" yaml:"sonarr,omitempty"`
	Radarr       []*RadarrConfig   `json:"radarr,omitempty" toml:"radarr" xml:"radarr" yaml:"radarr,omitempty"`
	Lidarr       []*LidarrConfig   `json:"lidarr,omitempty" toml:"lidarr" xml:"lidarr" yaml:"lidarr,omitempty"`
	Readarr      []*ReadarrConfig  `json:"readarr,omitempty" toml:"readarr" xml:"readarr" yaml:"readarr,omitempty"`
	Prowlarr     []*ProwlarrConfig `json:"prowlarr,omitempty" toml:"prowlarr" xml:"prowlarr" yaml:"prowlarr,omitempty"`
	Deluge       []*DelugeConfig   `json:"deluge,omitempty" toml:"deluge" xml:"deluge" yaml:"deluge,omitempty"`
	Qbit         []*QbitConfig     `json:"qbit,omitempty" toml:"qbit" xml:"qbit" yaml:"qbit,omitempty"`
	Rtorrent     []*RtorrentConfig `json:"rtorrent,omitempty" toml:"rtorrent" xml:"rtorrent" yaml:"rtorrent,omitempty"`
	SabNZB       []*SabNZBConfig   `json:"sabnzbd,omitempty" toml:"sabnzbd" xml:"sabnzbd" yaml:"sabnzbd,omitempty"`
	NZBGet       []*NZBGetConfig   `json:"nzbget,omitempty" toml:"nzbget" xml:"nzbget" yaml:"nzbget,omitempty"`
	Transmission []*XmissionConfig `json:"transmission,omitempty" toml:"transmission" xml:"transmission" yaml:"transmission,omitempty"`
	Tautulli     *TautulliConfig   `json:"tautulli,omitempty" toml:"tautulli" xml:"tautulli" yaml:"tautulli,omitempty"`
	Plex         *PlexConfig       `json:"plex" toml:"plex" xml:"plex" yaml:"plex"`
	Router       *mux.Router       `json:"-" toml:"-" xml:"-" yaml:"-"`
	mnd.Logger   `toml:"-" xml:"-" json:"-"`
	// contains filtered or unexported fields
}

Apps is the input configuration to relay requests to Starr apps.

func (*Apps) CheckAPIKey

func (a *Apps) CheckAPIKey(next http.Handler) http.HandlerFunc

CheckAPIKey drops a 403 if the API key doesn't match, otherwise run next handler.

func (*Apps) HandleAPIpath

func (a *Apps) HandleAPIpath(app starr.App, uri string, api APIHandler, method ...string) *mux.Route

HandleAPIpath makes adding APIKey authenticated API paths a little cleaner. An empty App may be passed in, but URI, API and at least one method are required. Automatically adds an id route to routes with an app name. In case you have > 1 of that app.

func (*Apps) InitHandlers

func (a *Apps) InitHandlers()

InitHandlers activates all our handlers. This is part of the web server init.

func (*Apps) Respond

func (a *Apps) Respond(w http.ResponseWriter, stat int, msg interface{}) int64

Respond sends a standard response to our caller. JSON encoded blobs. Returns size of data sent.

func (*Apps) Setup

func (a *Apps) Setup() error

Setup creates request interfaces and sets the timeout for each server. This is part of the config/startup init.

type DelugeConfig added in v0.1.13

type DelugeConfig struct {
	ExtraConfig
	*deluge.Config
	*deluge.Deluge `toml:"-" xml:"-" json:"-"`
}

func (*DelugeConfig) Enabled added in v0.4.1

func (c *DelugeConfig) Enabled() bool

Enabled returns true if the instance is enabled and usable.

type ExtraConfig added in v0.5.2

type ExtraConfig struct {
	Name     string        `toml:"name" xml:"name" json:"name"`
	Timeout  cnfg.Duration `toml:"timeout" xml:"timeout" json:"timeout"`
	Interval cnfg.Duration `toml:"interval" xml:"interval" json:"interval"`
	ValidSSL bool          `toml:"valid_ssl" xml:"valid_ssl" json:"validSsl"`
	Deletes  int           `toml:"deletes" xml:"deletes" json:"deletes"`
	// contains filtered or unexported fields
}

func (*ExtraConfig) DelOK added in v0.7.0

func (e *ExtraConfig) DelOK() bool

DelOK returns true if the delete limit isn't reached.

type LidarrConfig

type LidarrConfig struct {
	ExtraConfig
	*starr.Config
	*lidarr.Lidarr `toml:"-" xml:"-" json:"-"`
	// contains filtered or unexported fields
}

LidarrConfig represents the input data for a Lidarr server.

func (*LidarrConfig) Enabled added in v0.3.3

func (l *LidarrConfig) Enabled() bool

Enabled returns true if the Lidarr instance is enabled and usable.

type LoggingRoundTripper added in v0.4.1

type LoggingRoundTripper struct {
	// contains filtered or unexported fields
}

LoggingRoundTripper allows us to use a data counter to log http request data.

func NewMetricsRoundTripper added in v0.4.1

func NewMetricsRoundTripper(app string, next http.RoundTripper) *LoggingRoundTripper

NewMetricsRoundTripper returns a round tripper to log requests counts and response sizes.

func (*LoggingRoundTripper) RoundTrip added in v0.4.1

func (rt *LoggingRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip satisfies the http.RoundTripper interface. This is where our logging takes place.

type NZBGetConfig added in v0.3.2

type NZBGetConfig struct {
	ExtraConfig
	*nzbget.Config
	*nzbget.NZBGet `toml:"-" xml:"-" json:"-"`
}

func (*NZBGetConfig) Enabled added in v0.4.1

func (c *NZBGetConfig) Enabled() bool

Enabled returns true if the instance is enabled and usable.

type PlexConfig added in v0.4.1

type PlexConfig struct {
	*plex.Config
	*plex.Server
	ExtraConfig
}

func (*PlexConfig) Enabled added in v0.4.1

func (c *PlexConfig) Enabled() bool

Enabled returns true if the server is configured, false otherwise.

func (*PlexConfig) Setup added in v0.4.1

func (c *PlexConfig) Setup(maxBody int, logger mnd.Logger)

type ProwlarrConfig added in v0.2.5

type ProwlarrConfig struct {
	ExtraConfig
	*starr.Config
	*prowlarr.Prowlarr `toml:"-" xml:"-" json:"-"`
	// contains filtered or unexported fields
}

ProwlarrConfig represents the input data for a Prowlarr server.

func (*ProwlarrConfig) Enabled added in v0.3.3

func (p *ProwlarrConfig) Enabled() bool

Enabled returns true if the Prowlarr instance is enabled and usable.

type QbitConfig added in v0.1.13

type QbitConfig struct {
	ExtraConfig
	*qbit.Config
	*qbit.Qbit `toml:"-" xml:"-" json:"-"`
}

func (*QbitConfig) Enabled added in v0.4.1

func (c *QbitConfig) Enabled() bool

Enabled returns true if the instance is enabled and usable.

func (*QbitConfig) Setup added in v0.4.1

func (c *QbitConfig) Setup(maxBody int, logger mnd.Logger) error

type RadarrConfig

type RadarrConfig struct {
	ExtraConfig
	*starr.Config
	*radarr.Radarr `toml:"-" xml:"-" json:"-"`
	// contains filtered or unexported fields
}

RadarrConfig represents the input data for a Radarr server.

func (*RadarrConfig) Enabled added in v0.3.3

func (r *RadarrConfig) Enabled() bool

Enabled returns true if the Radarr instance is enabled and usable.

type ReadarrConfig

type ReadarrConfig struct {
	ExtraConfig
	*starr.Config
	*readarr.Readarr `toml:"-" xml:"-" json:"-"`
	// contains filtered or unexported fields
}

ReadarrConfig represents the input data for a Readarr server.

func (*ReadarrConfig) Enabled added in v0.3.3

func (r *ReadarrConfig) Enabled() bool

Enabled returns true if the Readarr instance is enabled and usable.

type RtorrentConfig added in v0.3.2

type RtorrentConfig struct {
	ExtraConfig
	*xmlrpc.Client
	URL  string `toml:"url" xml:"url" json:"url"`
	User string `toml:"user" xml:"user" json:"user"`
	Pass string `toml:"pass" xml:"pass" json:"pass"`
}

func (*RtorrentConfig) Enabled added in v0.4.1

func (c *RtorrentConfig) Enabled() bool

Enabled returns true if the instance is enabled and usable.

func (*RtorrentConfig) Setup added in v0.3.2

func (c *RtorrentConfig) Setup(maxBody int, logger mnd.Logger)

type SabNZBConfig added in v0.2.0

type SabNZBConfig struct {
	ExtraConfig
	*sabnzbd.Config
}

func (*SabNZBConfig) Enabled added in v0.4.1

func (c *SabNZBConfig) Enabled() bool

Enabled returns true if the instance is enabled and usable.

func (*SabNZBConfig) Setup added in v0.4.1

func (c *SabNZBConfig) Setup(maxBody int, logger mnd.Logger)

type SonarrConfig

type SonarrConfig struct {
	*sonarr.Sonarr `toml:"-" xml:"-" json:"-"`
	ExtraConfig
	*starr.Config
	// contains filtered or unexported fields
}

SonarrConfig represents the input data for a Sonarr server.

func (*SonarrConfig) Enabled added in v0.3.3

func (s *SonarrConfig) Enabled() bool

Enabled returns true if the Sonarr instance is enabled and usable.

type TautulliConfig added in v0.2.0

type TautulliConfig struct {
	ExtraConfig
	tautulli.Config
}

func (*TautulliConfig) Enabled added in v0.4.1

func (c *TautulliConfig) Enabled() bool

Enabled returns true if the instance is enabled and usable.

func (*TautulliConfig) Setup added in v0.4.1

func (c *TautulliConfig) Setup(maxBody int, logger mnd.Logger)

type XmissionConfig added in v0.7.0

type XmissionConfig struct {
	URL  string `toml:"url" xml:"url" json:"url"`
	User string `toml:"user" xml:"user" json:"user"`
	Pass string `toml:"pass" xml:"pass" json:"pass"`
	ExtraConfig
	*transmissionrpc.Client `toml:"-" xml:"-" json:"-"`
}

XmissionConfig is the Transmission input configuration.

func (*XmissionConfig) Enabled added in v0.7.0

func (c *XmissionConfig) Enabled() bool

Enabled returns true if the instance is enabled and usable.

Directories

Path Synopsis
apppkg
plex
Package plex provides the methods the Notifiarr client uses to interface with Plex.
Package plex provides the methods the Notifiarr client uses to interface with Plex.

Jump to

Keyboard shortcuts

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