deluge

package
v0.0.0-...-c199a75 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	Host      string
	Password  string
	AuthToken *string
}

API defines the structure for the API

func (*API) GetAuth

func (d *API) GetAuth() error

GetAuth makes auth.login request to Deluge and sets auth to API

func (*API) GetMetrics

func (d *API) GetMetrics() (*UpdateUIResult, error)

GetMetrics makes web.update_ui request to Deluge and returns the result

type AuthRequest

type AuthRequest struct {
	Params []string `json:"params"`
	BaseRequest
}

AuthRequest defines the structure for the auth.login request to the API

type AuthResponse

type AuthResponse struct {
	Result bool `json:"result"`
	BaseResponse
}

AuthResponse defines the structure for auth.login response

type BaseRequest

type BaseRequest struct {
	Method string `json:"method"`
	ID     int    `json:"id"`
}

BaseRequest defines the structure for the base request to the API

type BaseResponse

type BaseResponse struct {
	Error *Error `json:"error"`
	ID    int    `json:"id"`
}

BaseResponse defines the base response from the API

type Deluge

type Deluge struct {
	Host     string `toml:"host"`
	Password string `toml:"password"`
	Log      telegraf.Logger
	API      *API
}

Deluge defines the data structure for plugin

func (*Deluge) Description

func (d *Deluge) Description() string

Description returns the plugin description

func (*Deluge) Gather

func (d *Deluge) Gather(acc telegraf.Accumulator) error

Gather gathers and sends metrics to output

func (*Deluge) Init

func (d *Deluge) Init() error

Init is for setup, and validating config.

func (*Deluge) SampleConfig

func (d *Deluge) SampleConfig() string

SampleConfig returns the sample config for the plugin

type Error

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

Error defines the structure for the error returned from API

type FilterInfo

type FilterInfo struct {
	Key    string
	Number int
}

FilterInfo defines the structure for a filter info in the result

func (*FilterInfo) UnmarshalJSON

func (f *FilterInfo) UnmarshalJSON(p []byte) error

UnmarshalJSON unmarshalls a FilterInfo object

type Filters

type Filters struct {
	State       []FilterInfo `json:"state"`
	TrackerHost []FilterInfo `json:"tracker_host"`
	Owner       []FilterInfo `json:"owner"`
	Label       []FilterInfo `json:"label"`
}

Filters defines the structure for filters in the result

type NoAuthError

type NoAuthError struct{}

NoAuthError defines the structure for the Unauthenticated error

func (*NoAuthError) Error

func (e *NoAuthError) Error() string

Error returns the Unauthenticated error

type Stats

type Stats struct {
	MaxDownload            float64 `json:"max_download"`
	MaxUpload              float64 `json:"max_upload"`
	MaxNumConnections      int     `json:"max_num_connections"`
	NumConnections         int     `json:"num_connections"`
	UploadRate             float64 `json:"upload_rate"`
	DownloadRate           float64 `json:"download_rate"`
	DownloadProtocolRate   float64 `json:"download_protocol_rate"`
	UploadProtocolRate     float64 `json:"upload_protocol_rate"`
	DhtNodes               int     `json:"dht_nodes"`
	HasIncomingConnections int     `json:"has_incoming_connections"`
	FreeSpace              int64   `json:"free_space"`
	ExternalIP             string  `json:"external_ip"`
}

Stats defines the structure for the overall stats in the result

type TorrentInfo

type TorrentInfo struct {
	TimeAdded     int     `json:"time_added"`
	Name          string  `json:"name"`
	TotalDone     int     `json:"total_done"`
	Progress      float64 `json:"progress"`
	State         string  `json:"state"`
	Ratio         float64 `json:"ratio"`
	TotalSize     int     `json:"total_size"`
	TotalUploaded int64   `json:"total_uploaded"`
	TrackerHost   string  `json:"tracker_host"`
}

TorrentInfo defines the structure for torrent info in the result

type Torrents

type Torrents map[string]TorrentInfo

Torrents defines the structure for torrents info map in the result

type UpdateUIRequest

type UpdateUIRequest struct {
	Params UpdateUIRequestParams `json:"params"`
	BaseRequest
}

UpdateUIRequest defines the structure for the web.update_ui request to the API

type UpdateUIRequestParams

type UpdateUIRequestParams struct {
	Keys    []string
	Filters *map[string]string
}

UpdateUIRequestParams defines the structure for the web.update_ui request params

func (*UpdateUIRequestParams) MarshalJSON

func (p *UpdateUIRequestParams) MarshalJSON() ([]byte, error)

MarshalJSON marshalls a UpdateUIRequestParams object to json

type UpdateUIResponse

type UpdateUIResponse struct {
	Result *UpdateUIResult `json:"result"`
	BaseResponse
}

UpdateUIResponse defines the structure for web.update_ui response

type UpdateUIResult

type UpdateUIResult struct {
	Connected bool     `json:"connected"`
	Torrents  Torrents `json:"torrents"`
	Filters   Filters  `json:"filters"`
	Stats     Stats    `json:"stats"`
}

UpdateUIResult defines the structure for web.update_ui result in the response

Jump to

Keyboard shortcuts

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