clientinfo

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2023 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetOutboundIP added in v0.5.2

func GetOutboundIP() string

Types

type AllAppConfigs

type AllAppConfigs struct {
	Lidarr   InstanceConfig `json:"lidarr"`
	Prowlarr InstanceConfig `json:"prowlarr"`
	Radarr   InstanceConfig `json:"radarr"`
	Readarr  InstanceConfig `json:"readarr"`
	Sonarr   InstanceConfig `json:"sonarr"`
}

AllAppConfigs is the configuration returned from the notifiarr website for Starr apps.

type AppConfig

type AppConfig struct {
	Instance int           `json:"instance"`
	Name     string        `json:"name"`
	Corrupt  string        `json:"corrupt"`
	Backup   string        `json:"backup"`
	Interval cnfg.Duration `json:"interval"`
	Stuck    bool          `json:"stuck"`
	Finished bool          `json:"finished"`
}

AppConfig is the data that comes from the website for each Starr app.

type AppConfigs

type AppConfigs struct {
	Lidarr   []*AppInfoAppConfig `json:"lidarr"`
	Prowlarr []*AppInfoAppConfig `json:"prowlarr"`
	Radarr   []*AppInfoAppConfig `json:"radarr"`
	Readarr  []*AppInfoAppConfig `json:"readarr"`
	Sonarr   []*AppInfoAppConfig `json:"sonarr"`
	Tautulli *AppInfoTautulli    `json:"tautulli"`
}

AppConfigs contains exported configurations for various integrations.

type AppInfo

type AppInfo struct {
	// Client contains running client information.
	Client *AppInfoClient `json:"client"`
	// Num contains configured application counters.
	Num map[string]int `json:"num"`
	// Config contains running configuration information.
	Config AppInfoConfig `json:"config"`
	// Commands is the list of available commands.
	Commands []*cmdconfig.Config `json:"commands"`
	// Host contains host info.
	Host *host.InfoStat `json:"host"`
	// HostError has data if hostinfo has an error.
	HostError string `json:"hostError"`
	// AppsStatus is only returned on the version endpoint.
	AppsStatus *AppStatuses `json:"appsStatus"`
}

AppInfo contains exported info about this app and its host.

type AppInfoAppConfig

type AppInfoAppConfig struct {
	// The site-ID for the instance (1-index).
	Instance int `json:"instance"`
	// Instance name as configured in the client.
	Name string `json:"name"`
}

AppInfoAppConfig Maps an instance to a name and/or other properties.

type AppInfoClient

type AppInfoClient struct {
	// Architecture.
	Arch string `json:"arch"`
	// Application Build Date.
	BuildDate string `json:"buildDate"`
	// Branch application built from.
	Branch string `json:"branch"`
	// Go Version app built with.
	GoVersion string `json:"goVersion"`
	// OS app is running on.
	OS string `json:"os"`
	// Application Revision (part of the version).
	Revision string `json:"revision"`
	// Application Version.
	Version string `json:"version"`
	// Uptime in seconds.
	UptimeSec int64 `json:"uptimeSec"`
	// Application start time.
	Started time.Time `json:"started"`
	// Running in docker?
	Docker bool `json:"docker"`
	// Application has a GUI? (windows/mac only)
	HasGUI bool `json:"hasGui"`
	// Listen is the IP and port the client has configured.
	Listen string `json:"listen"`
	// Application supports tunnelling.
	Tunnel bool `json:"tunnel"`
}

AppInfoClient contains the client's exported host info.

type AppInfoConfig

type AppInfoConfig struct {
	WebsiteTimeout string      `json:"websiteTimeout"`
	Retries        int         `json:"retries"`
	Apps           *AppConfigs `json:"apps"`
}

AppInfoConfig contains exported running configuration information for this app.

type AppInfoTautulli

type AppInfoTautulli struct {
	// Tautulli userID -> email map.
	Users map[string]string `json:"users"`
}

AppInfoTautulli contains the Tautulli user map, fetched from Tautulli.

type AppStatuses

type AppStatuses struct {
	Lidarr   []*LidarrConTest   `json:"lidarr,omitempty"`
	Radarr   []*RadarrConTest   `json:"radarr,omitempty"`
	Readarr  []*ReadarrConTest  `json:"readarr,omitempty"`
	Sonarr   []*SonarrConTest   `json:"sonarr,omitempty"`
	Prowlarr []*ProwlarrConTest `json:"prowlarr,omitempty"`
	Plex     []*PlexConTest     `json:"plex,omitempty"`
	Tautulli []*TautulliConTest `json:"tautulli,omitempty"`
}

AppStatuses contains some integration up-statuses and versions.

type ClientInfo

type ClientInfo struct {
	User struct {
		ID         any      `json:"id"` // user id from notifiarr db.
		WelcomeMSG string   `json:"welcome"`
		Subscriber bool     `json:"subscriber"`
		Patron     bool     `json:"patron"`
		DevAllowed bool     `json:"devAllowed"`
		DateFormat PHPDate  `json:"dateFormat"`
		StopLogs   bool     `json:"stopLogs"`
		Tunnels    []string `json:"tunnels"`
	} `json:"user"`
	Actions struct {
		Plex      PlexConfig      `json:"plex"`      // Site Config for Plex.
		Apps      AllAppConfigs   `json:"apps"`      // Site Config for Starr.
		Dashboard DashConfig      `json:"dashboard"` // Site Config for Dashboard.
		Sync      SyncConfig      `json:"sync"`      // Site Config for TRaSH Sync.
		Mdblist   MdbListConfig   `json:"mdblist"`   // Site Config for MDB List.
		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 Get

func Get() *ClientInfo

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 {
	// Actions *triggers.Actions
	*apps.Apps
	*website.Server
	CmdList []*cmdconfig.Config
}

Config is the data needed to send and retrieve client info.

func (*Config) Info

func (c *Config) Info(ctx context.Context, startup bool) *AppInfo

Info is used for JSON input for our outgoing app info.

func (*Config) InfoHandler

func (c *Config) InfoHandler(r *http.Request) (int, interface{})

InfoHandler is like the version handler except it doesn't poll all the apps. @Description Returns information about the client's configuration. This endpoint returns all the instance IDs (and instance names if present). Use the returned instance IDs with endpoints that accept an instance ID. @Summary Retrieve client info. @Tags Client @Produce json @Success 200 {object} apps.Respond.apiResponse{message=AppInfo} "contains all info except appStatus" @Failure 404 {object} string "bad token or api key" @Router /api/info [get] @Security ApiKeyAuth

func (*Config) SaveClientInfo

func (c *Config) SaveClientInfo(ctx context.Context, startup bool) (*ClientInfo, error)

SaveClientInfo returns an error if the API key is wrong. Caches and returns client info otherwise.

func (*Config) VersionHandler

func (c *Config) VersionHandler(r *http.Request) (int, interface{})

VersionHandler returns application run and build time data and application statuses. @Description Returns information about the client's configuration, and polls multiple applications for up-status and version. @Summary Retrieve client info + starr/plex info. @Tags Client @Produce json @Success 200 {object} apps.Respond.apiResponse{message=AppInfo} "contains app info included appStatus" @Failure 404 {object} string "bad token or api key" @Router /api/version [get] @Security ApiKeyAuth

func (*Config) VersionHandlerInstance

func (c *Config) VersionHandlerInstance(r *http.Request) (int, interface{})

VersionHandlerInstance returns application run and build time data and the status for the requested instance. @Description Returns information about the client's configuration, and polls 1 application instance for up-status and version. @Description Plex and Tautulli only support app instance 1. @Summary Retrieve client info + 1 app's info. @Tags Client @Produce json @Param app path string true "Application" Enums(lidarr, prowlarr, radarr, readarr, sonarr, plex, tautulli) @Param instance path int64 true "Application instance (1-index)." @Success 200 {object} apps.Respond.apiResponse{message=AppInfo} "contains app info included appStatus" @Failure 404 {object} string "bad token or api key" @Router /api/version/{app}/{instance} [get] @Security ApiKeyAuth

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.
}

DashConfig is the configuration returned from the notifiarr website for the dashboard configuration.

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 InstanceConfig

type InstanceConfig []*AppConfig

InstanceConfig allows binding methods to a list of instance configurations.

func (InstanceConfig) Backup

func (i InstanceConfig) Backup(instance int) string

func (InstanceConfig) Corrupt

func (i InstanceConfig) Corrupt(instance int) string

func (InstanceConfig) Finished

func (i InstanceConfig) Finished(instance int) bool

func (InstanceConfig) Stuck

func (i InstanceConfig) Stuck(instance int) bool

type IntList

type IntList []int

IntList has a method to abstract lookups.

func (IntList) Has

func (l IntList) Has(instance int) bool

Has returns true if the list has an instance ID.

type LidarrConTest

type LidarrConTest struct {
	Status *lidarr.SystemStatus `json:"systemStatus,omitempty"`
	// contains filtered or unexported fields
}

LidarrConTest contains information about connected Lidarrs.

type MdbListConfig added in v0.5.0

type MdbListConfig struct {
	Interval cnfg.Duration `json:"interval"` // how often to fire.
	Radarr   IntList       `json:"radarr"`   // which instance IDs we sync
	Sonarr   IntList       `json:"sonarr"`   // which instance IDs we sync
}

MdbListConfig contains the instances we send libraries for, and the interval we do it in.

type PHPDate

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

PHPDate allows us to easily convert a PHP date format in Go.

func (*PHPDate) Format

func (p *PHPDate) Format(date time.Time) string

Format returns the date, formatted.

func (*PHPDate) PHP

func (p *PHPDate) PHP() string

PHP returns the format for a php date/time.

func (*PHPDate) String

func (p *PHPDate) String() string

String returns the golang date format for a php date/time format.

func (*PHPDate) UnmarshalJSON

func (p *PHPDate) UnmarshalJSON(b []byte) error

UnmarshalJSON turns a php date/time format into a golang struct.

type PlexConTest

type PlexConTest struct {
	Status *PlexInfo `json:"systemStatus,omitempty"`
	// contains filtered or unexported fields
}

PlexConTest contains information about a connected Plex.

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 PlexInfo

type PlexInfo struct {
	FriendlyName       string `json:"friendlyName"`
	Version            string `json:"version"`
	UpdatedAt          int64  `json:"updatedAt"`
	Platform           string `json:"platform"`
	PlatformVersion    string `json:"platformVersion"`
	Size               int64  `json:"size"`
	MyPlexSigninState  string `json:"myPlexSigninState"`
	MyPlexSubscription bool   `json:"myPlexSubscription"`
	PushNotifications  bool   `json:"pushNotifications"`
}

PlexInfo represents a small slice of the Plex Media Server Data. @Description Contains some very basic Plex data, including the name and version.

type ProwlarrConTest

type ProwlarrConTest struct {
	Status *prowlarr.SystemStatus `json:"systemStatus,omitempty"`
	// contains filtered or unexported fields
}

ProwlarrConTest contains information about connected Prowlarrs.

type RadarrConTest

type RadarrConTest struct {
	Status *radarr.SystemStatus `json:"systemStatus,omitempty"`
	// contains filtered or unexported fields
}

RadarrConTest contains information about connected Radarrs.

type ReadarrConTest

type ReadarrConTest struct {
	Status *readarr.SystemStatus `json:"systemStatus,omitempty"`
	// contains filtered or unexported fields
}

ReadarrConTest contains information about connected Readarrs.

type SonarrConTest

type SonarrConTest struct {
	Status *sonarr.SystemStatus `json:"systemStatus,omitempty"`
	// contains filtered or unexported fields
}

SonarrConTest contains information about connected Sonarrs.

type SyncConfig

type SyncConfig struct {
	Interval        cnfg.Duration `json:"interval"`        // how often to fire.
	RadarrInstances IntList       `json:"radarrInstances"` // which instance IDs we sync
	SonarrInstances IntList       `json:"sonarrInstances"` // which instance IDs we sync
	SonarrSync      []string      `json:"sonarrSync"`      // items in sync.
	RadarrSync      []string      `json:"radarrSync"`      // items in sync.
}

SyncConfig is the configuration returned from the notifiarr website for CF/RP TraSH sync.

type TautulliConTest

type TautulliConTest struct {
	Status *tautulli.Info `json:"systemStatus,omitempty"`
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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