Documentation ¶
Overview ¶
Package paperless implements variables, functions, and types to interact with a Paperless instance.
Index ¶
- Variables
- func ReturnAuthenticatedRequest(u, p string) *http.Request
- type Color
- type Correspondent
- type CorrespondentList
- type Document
- type DocumentList
- type MatchingAlgorithm
- type Paperless
- func (p Paperless) DownloadFiles(filename string)
- func (p Paperless) DownloadString(documentPath string) string
- func (p Paperless) GetCorrespondent(s string, caseSensitive bool) (CorrespondentList, error)
- func (p Paperless) GetCorrespondents() (CorrespondentList, error)
- func (p Paperless) GetDocument(s string, caseSensitive bool) (DocumentList, error)
- func (p Paperless) GetDocuments() (DocumentList, error)
- func (p Paperless) GetTag(s string, caseSensitive bool) (TagList, error)
- func (p Paperless) GetTags() (TagList, error)
- func (p Paperless) MakeGetRequest(urlString string) ([]gjson.Result, error)
- func (p Paperless) ShowInstanceInformation()
- func (p Paperless) String() string
- type Tag
- type TagList
Constants ¶
This section is empty.
Variables ¶
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.
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.
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
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 ¶
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 ¶
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.
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
DownloadFiles pulls either a paperless document or allows selection from a list
func (Paperless) DownloadString ¶ added in v0.7.0
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) GetCorrespondents ¶
func (p Paperless) GetCorrespondents() (CorrespondentList, error)
GetCorrespondents returns a https://godoc.org/github.com/stgarf/paperless-cli/paperless/#CorrespondentList.
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) GetDocuments ¶
func (p Paperless) GetDocuments() (DocumentList, error)
GetDocuments returns a https://godoc.org/github.com/stgarf/paperless-cli/paperless/#DocumentList.
func (Paperless) GetTag ¶
GetTag returns a https://godoc.org/github.com/stgarf/paperless-cli/paperless/#TagList matching the search string.
func (Paperless) GetTags ¶
GetTags returns a https://godoc.org/github.com/stgarf/paperless-cli/paperless/#TagList.
func (Paperless) MakeGetRequest ¶
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).
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.
type TagList ¶
type TagList []Tag
TagList is a slice of https://godoc.org/github.com/stgarf/paperless-cli/paperless/#Tag structs.