paperless

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package paperless implements variables, functions, and types to interact with a Paperless instance.

Index

Constants

This section is empty.

Variables

View Source
var AlgoNameToValue = map[string]int{
	"Any":                1,
	"All":                2,
	"Literal":            2,
	"Regular Expression": 4,
	"Fuzzy Match":        5,
}

AlgoNameToValue is a map[string]int for Paperless matching algorithms.

See https://godoc.org/github.com/stgarf/paperless-cli/paperless/#MatchingAlgorithm.

View Source
var AlgoValueToName = map[int]string{
	1: "Any",
	2: "All",
	3: "Literal",
	4: "Regular Expression",
	5: "Fuzzy Match",
}

AlgoValueToName is a map[string]int for Paperless matching algorithms.

See https://godoc.org/github.com/stgarf/paperless-cli/paperless/#MatchingAlgorithm.

View Source
var ColorNameToValue = map[string]int{
	"RegentStBlue":      1,
	"Matisse":           2,
	"Feijoa":            3,
	"ForestGreen":       4,
	"SweetPink":         5,
	"AlizarinCrimson":   6,
	"MacaroniAndCheese": 7,
	"FlushOrange":       8,
	"LavenderGray":      9,
	"RoyalPurple":       10,
	"Paarl":             11,
	"Black":             12,
	"Silver":            13,
}

ColorNameToValue is a map[string]int for Paperless tag colors.

See https://godoc.org/github.com/stgarf/paperless-cli/paperless/#Color

View Source
var ColorValueToName = map[int]string{
	1:  "Regent St Blue",
	2:  "Matisse",
	3:  "Feijoa",
	4:  "Forest Green",
	5:  "Sweet Pink",
	6:  "Alizarin Crimson",
	7:  "Macaroni and Cheese",
	8:  "Flush Orange",
	9:  "Lavender Gray",
	10: "Royal Purple",
	11: "Paarl",
	12: "Black",
	13: "Silver",
}

ColorValueToName is a map[int]string for Paperless tag colors.

See https://godoc.org/github.com/stgarf/paperless-cli/paperless/#Color

Functions

func ReturnAuthenticatedRequest

func ReturnAuthenticatedRequest(u, p string) *http.Request

ReturnAuthenticatedRequest takes a username and password string and returns a *http.Request with Authorization and User-Agent headers set.

Types

type Color

type Color int

Color is an integer representing the tag color of a paperless tag. There's a map[int]string to resolve the integer to human-readable names and a map[string]int for vice-versa.

See https://godoc.org/github.com/stgarf/paperless-cli/paperless/#pkg-variables for more information and color mappings.

func (Color) String

func (c Color) String() string

How should we represent a Tag color when trying to stringify it? This returns the struct as a string.

See https://godoc.org/github.com/stgarf/paperless-cli/paperless/#pkg-variables for more information and color mappings.

type Correspondent

type Correspondent struct {
	ID                int               `json:"id"`
	Slug              string            `json:"slug"`
	Name              string            `json:"name"`
	Match             string            `json:"match"`
	MatchingAlgorithm MatchingAlgorithm `json:"matching_algorithm"`
	IsInsensitive     bool              `json:"is_insensitive"`
}

Correspondent is a struct representation of Paperless' /api/correspondents/<id> JSON response.

func (Correspondent) String

func (c Correspondent) String() string

How should we represent a Correspondent object when trying to stringify it? This returns the struct as a string.

type CorrespondentList

type CorrespondentList []Correspondent

CorrespondentList is a slice of https://godoc.org/github.com/stgarf/paperless-cli/paperless/#Correspondent structs.

type Document

type Document struct {
	ID            int      `json:"id"`
	Correspondent string   `json:"correspondent"`
	Title         string   `json:"title"`
	Content       string   `json:"content"`
	FileType      string   `json:"file_type"`
	Tags          []string `json:"tags"`
	Checksum      string   `json:"checksum"`
	Created       string   `json:"created"`
	Modified      string   `json:"modified"`
	Added         string   `json:"added"`
	FileName      string   `json:"file_name"`
	DownloadURL   string   `json:"download_url"`
	ThumbnailURL  string   `json:"thumbnail_url"`
}

Document is a struct representation of Paperless' /api/documents/<id> JSON response.

func (Document) String

func (d Document) String() string

How should we represent a Document object when trying to stringify it? This returns the struct as a string.

type DocumentList

type DocumentList []Document

DocumentList is a slice of https://godoc.org/github.com/stgarf/paperless-cli/paperless/#Document structs.

type MatchingAlgorithm

type MatchingAlgorithm int

MatchingAlgorithm is an integer representing the matching algorithm of a paperless tag or correspondent. There's a map[int]string to resolve the integer to human-readable names and a map[string]int for vice-versa.

func (MatchingAlgorithm) String

func (m MatchingAlgorithm) String() string

How should we represent a Match object when trying to stringify it? This returns the struct as a string.

See https://godoc.org/github.com/stgarf/paperless-cli/paperless/#pkg-variables for more information and algorithm mappings.

type Paperless

type Paperless struct {
	Hostname string
	UseHTTPS bool
	Port     string
	Root     string
	Username string
	Password string
}

Paperless is a struct representation to hold a Paperless instances' configuration details.

It also implements a few functions to interact with a Paperless instance such as Get{Correspondent,Document,Tag}{,s}, MakeGetRequest, and ShowInstanceInformation.

func (Paperless) DownloadFiles added in v0.7.0

func (p Paperless) DownloadFiles(filename string)

DownloadFiles pulls either a paperless document or allows selection from a list

func (Paperless) DownloadString added in v0.7.0

func (p Paperless) DownloadString(documentPath string) string

DownloadString returns a string URL to fetch a document from the API.

func (Paperless) GetCorrespondent

func (p Paperless) GetCorrespondent(s string, caseSensitive bool) (CorrespondentList, error)

GetCorrespondent returns a https://godoc.org/github.com/stgarf/paperless-cli/paperless/#CorrespondentList matching the search string.

func (Paperless) GetDocument

func (p Paperless) GetDocument(s string, caseSensitive bool) (DocumentList, error)

GetDocument returns a https://godoc.org/github.com/stgarf/paperless-cli/paperless/#DocumentList matching the search string.

func (Paperless) GetTag

func (p Paperless) GetTag(s string, caseSensitive bool) (TagList, error)

GetTag returns a https://godoc.org/github.com/stgarf/paperless-cli/paperless/#TagList matching the search string.

func (Paperless) MakeGetRequest

func (p Paperless) MakeGetRequest(urlString string) ([]gjson.Result, error)

MakeGetRequest takes a url string and returns a slice of gjson.Result objects and an error if there's one.

func (Paperless) ShowInstanceInformation

func (p Paperless) ShowInstanceInformation()

ShowInstanceInformation shows the currently loaded Paperless instance configuration (sans password).

func (Paperless) String

func (p Paperless) String() string

How should we represent a Paperless object when trying to stringify it? This returns the struct as a string.

type Tag

type Tag struct {
	ID                int               `json:"id"`
	Slug              string            `json:"slug"`
	Name              string            `json:"name"`
	Color             Color             `json:"colour"`
	Match             string            `json:"match"`
	MatchingAlgorithm MatchingAlgorithm `json:"matching_algorithm"`
	IsInsensitive     bool              `json:"is_insensitive"`
}

Tag is a struct representation of Paperless' /api/tags/<id> JSON response.

func (Tag) String

func (t Tag) String() string

How should we represent a Tag object when trying to stringify it? This returns the struct as a string.

type TagList

type TagList []Tag

TagList is a slice of https://godoc.org/github.com/stgarf/paperless-cli/paperless/#Tag structs.

Jump to

Keyboard shortcuts

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