api

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package api names the wire types handlers still import. The definitions live with the noun they describe.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidBody = errors.New("request body is not valid JSON")

ErrInvalidBody reports a JSON request body that cannot be decoded.

Functions

func Flag added in v0.3.0

func Flag(value *bool) bool

Flag reads an optional request flag, treating an absent one as false.

Parameters:

  • value: Submitted flag, nil when the request omitted the field.

Returns:

  • flag: The value the flag carries, false when it was absent.

func FlagOrDefault added in v0.3.0

func FlagOrDefault(value *bool, fallback bool) bool

FlagOrDefault reads an optional request flag against a configured default.

Parameters:

  • value: Submitted flag, nil when the request omitted the field.
  • fallback: Configured value to use when the field was absent.

Returns:

  • flag: The value the flag carries, otherwise fallback.

Types

type BulkRequest added in v0.4.0

type BulkRequest struct {
	// Action is delete, regenerate, cancel, share, or unshare.
	Action string `json:"action"`
	// Clips are the ids of the clips the action applies to.
	Clips []string `json:"clips"`
}

BulkRequest applies one action to several clips.

type BulkResponse added in v0.4.0

type BulkResponse struct {
	// Action is the action that was applied.
	Action string `json:"action"`
	// Message says what happened, as the page shows it.
	Message string `json:"message"`
	// Done counts the clips the action changed.
	Done int `json:"done"`
	// Skipped counts the clips the action did not apply to, such as a clip the
	// caller may not change or one that is not rendering for a cancel.
	Skipped int `json:"skipped"`
	// Failed counts the clips the action could not change.
	Failed int `json:"failed"`
	// NotStarted counts the clips a reached render limit left alone.
	NotStarted int `json:"notStarted"`
}

BulkResponse reports what a bulk action did.

type ClipRequest

type ClipRequest = clip.Request

ClipRequest is the export request.

type ClipResponse

type ClipResponse = clip.Response

ClipResponse is the clip payload.

type ErrorCode added in v0.3.0

type ErrorCode string

ErrorCode is the machine-readable code an ErrorResponse carries.

const (
	// InvalidRequest reports a request that could not be read or bound.
	InvalidRequest ErrorCode = "invalid_request"

	// NotFound reports a resource nothing is registered under.
	NotFound ErrorCode = "not_found"

	// PersistFailed reports something that could not be saved.
	PersistFailed ErrorCode = "persist_failed"

	// JobActive reports a clip already queued or rendering.
	JobActive ErrorCode = "job_active"

	// MediaPathUnresolved reports a source that could not be resolved.
	MediaPathUnresolved ErrorCode = "media_path"

	// NotShared reports a media item the caller's Plex account cannot see.
	NotShared ErrorCode = "not_shared"

	// Pending reports a request from an account an admin has not approved.
	Pending ErrorCode = "pending"

	// LimitReached reports a render refused by one of the caller's limits.
	LimitReached ErrorCode = "limit_reached"

	// InvalidQuality reports a profile id that names no profile.
	InvalidQuality ErrorCode = "invalid_quality"

	// InvalidClipType reports a clip type the job cannot become.
	InvalidClipType ErrorCode = "invalid_clip_type"

	// NotCancellable reports a clip that is not queued or rendering.
	NotCancellable ErrorCode = "not_cancellable"

	// DeleteFailed reports a clip that could not be removed.
	DeleteFailed ErrorCode = "delete_failed"

	// NotReady reports a clip that has not finished rendering.
	NotReady ErrorCode = "not_ready"

	// FileMissing reports a finished clip whose output is gone.
	FileMissing ErrorCode = "file_missing"

	// PreviewBusy reports a preview refused because every slot is taken.
	PreviewBusy ErrorCode = "preview_busy"

	// PreviewNotRunning reports a preview that was not rendering.
	PreviewNotRunning ErrorCode = "preview_not_running"

	// MissingQuery reports a Plex search carried no query.
	MissingQuery ErrorCode = "missing_query"

	// SearchFailed reports a Plex search that could not be completed.
	SearchFailed ErrorCode = "search_failed"

	// HTTPError reports a request that failed outside a handler's own codes.
	HTTPError ErrorCode = "http_error"

	// PINFailed reports a Plex PIN that could not be created.
	PINFailed ErrorCode = "pin_failed"

	// LogoutFailed reports credentials that could not be cleared.
	LogoutFailed ErrorCode = "logout_failed"

	// PositionFailed reports a Plex position that could not be read.
	PositionFailed ErrorCode = "position_failed"
)

The codes an ErrorResponse may carry.

type ErrorResponse

type ErrorResponse struct {
	Error   ErrorCode `json:"error"`
	Message string    `json:"message"`
	// Details is the technical report behind the message, for debugging or
	// an issue, empty when the message says all there is.
	Details string `json:"details,omitempty"`
}

ErrorResponse represents an error response.

type MediaItemResponse

type MediaItemResponse struct {
	ID           string  `json:"id"`
	Title        string  `json:"title"`
	Type         string  `json:"type"`
	Duration     float64 `json:"duration,omitempty"`
	ThumbPath    string  `json:"thumbPath,omitempty"`
	LibraryTitle string  `json:"libraryTitle,omitempty"`
	Year         int     `json:"year,omitempty"`
	Season       int     `json:"season,omitempty"`
	Episode      int     `json:"episode,omitempty"`
	ShowTitle    string  `json:"showTitle,omitempty"`
}

MediaItemResponse represents a media item in API responses.

type MediaListResponse

type MediaListResponse struct {
	Items []MediaItemResponse `json:"items"`
	Total int                 `json:"total"`
}

MediaListResponse represents a paginated list of media items.

type PlaybackPosition added in v0.4.0

type PlaybackPosition struct {
	// Playing reports a Plex session on the item. Without one the other
	// fields are zero.
	Playing bool `json:"playing"`
	// Paused reports a paused client, whose position is exact.
	Paused bool `json:"paused"`
	// Offset is the position in seconds.
	Offset float64 `json:"offset"`
}

PlaybackPosition is where Plex is in one media item when it was asked.

type SessionResponse

type SessionResponse struct {
	ID         string  `json:"id"`
	MediaID    string  `json:"mediaId,omitempty"`
	Title      string  `json:"title"`
	Duration   float64 `json:"duration"`
	ViewOffset float64 `json:"viewOffset,omitempty"`
}

SessionResponse represents a session in API responses.

Jump to

Keyboard shortcuts

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