paperless

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2023 License: MIT Imports: 3 Imported by: 0

README

Paperless API Client

Go client for the Paperless NGX REST API.

This is in no way feature complete, or even all that well written. It exists to support a small paperless automation project idea of mine.

Documentation

Overview

*

  • Types & Functions for interacting with the paperless search interface

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Correspondent

type Correspondent struct {
	Id            int    `json:"id"`
	Name          string `json:"name"`
	Slug          string `json:"slug"`
	DocumentCount int    `json:"document_count"`
}

type CorrespondentResult

type CorrespondentResult struct {
	SearchResult
	Results []Correspondent `json:"results"`
}

type Document

type Document struct {
	Id                    int       `json:"id"`
	Correspondent         int       `json:"correspondent"`
	Document_type         int       `json:"document_type"`
	Storage_path          string    `json:"storage_path"`
	Title                 string    `json:"title"`
	Content               string    `json:"content"`
	Tags                  []int     `json:"tags"`
	Created               time.Time `json:"created"`
	Created_date          string    `json:"created_date"`
	Modified              time.Time `json:"modified"`
	Added                 time.Time `json:"added"`
	Archive_serial_number string    `json:"archive_serial_number"`
	Original_file_name    string    `json:"original_file_name"`
	Archived_file_name    string    `json:"archived_file_name"`
	Owner                 int       `json:"owner"`
	User_can_change       bool      `json:"user_can_change"`
	Notes                 []string  `json:"notes"`
	// contains filtered or unexported fields
}

Paperless Document

func (*Document) AddTag

func (d *Document) AddTag(tag int) error

Add a tag to the document

func (*Document) DownloadUrl

func (d *Document) DownloadUrl() string

Get the download URL for the document

func (*Document) PreviewUrl

func (d *Document) PreviewUrl() string

Get the preview URL for the document

func (*Document) RemoveTag

func (d *Document) RemoveTag(tag int) error

Remove a tag from the document

func (*Document) ThumbnailUrl

func (d *Document) ThumbnailUrl() string

Get the thumbnail URL for the document

func (*Document) Update

func (d *Document) Update() error

Update the document

type DocumentResult

type DocumentResult struct {
	SearchResult
	Results []Document `json:"results"`
}

Result of a document search query

type PaperlessClient

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

PaperlessClient is the main struct for the paperless client

func New

func New(url string, token string) *PaperlessClient

New creates a new PaperlessClient

func (*PaperlessClient) GetDocument

func (p *PaperlessClient) GetDocument(id int) (Document, error)

func (*PaperlessClient) GetDocumentsByTag

func (p *PaperlessClient) GetDocumentsByTag(tag string) ([]Document, error)

func (*PaperlessClient) GetDocumentsByTagId

func (p *PaperlessClient) GetDocumentsByTagId(tag int) ([]Document, error)

func (*PaperlessClient) SearchDocuments

func (p *PaperlessClient) SearchDocuments(query SearchQuery) ([]Document, error)

type SearchQuery

type SearchQuery []SearchTerm

func Query

func Query(key string, value string) SearchQuery

func (SearchQuery) Add

func (q SearchQuery) Add(term SearchTerm) SearchQuery

func (SearchQuery) Encode

func (q SearchQuery) Encode() string

Create URL encoded string from search query

type SearchResult

type SearchResult struct {
	Count    int    `json:"count"`
	Next     string `json:"next"`
	Previous string `json:"previous"`
	All      []int  `json:"all"`
}

SearchResult is the result of a search query This will be overridden by the specific search result

type SearchTerm

type SearchTerm struct {
	Key   string
	Value string
}

Jump to

Keyboard shortcuts

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