api

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2024 License: AGPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidatePassword

func ValidatePassword(password string) error

Types

type AdminAddUserRequest

type AdminAddUserRequest struct {
	UserName      string `json:"user_name" valid:"username"`
	Email         string `json:"email" valid:"email,optional"`
	Password      string `json:"password" valid:"required"`
	Active        bool   `json:"is_active" valid:"optional"`
	Administrator bool   `json:"is_admin" valid:"optional"`
}

type AdminUpdateUserRequest

type AdminUpdateUserRequest struct {
	Email         string `json:"email" valid:"optional,email"`
	Password      string `json:"password" valid:"optional"`
	Active        bool   `json:"is_active" valid:"optional"`
	Administrator bool   `json:"is_admin" valid:"optional"`
}

type Api

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

func NewApi

func NewApi(database *storage.Database) (*Api, error)

NewApi initializes new api instance. It connects to database and opens http port.

func (*Api) AuthorizeAdminV2

func (a *Api) AuthorizeAdminV2() echo.MiddlewareFunc

func (*Api) ConfirmAuthentication

func (a *Api) ConfirmAuthentication(c echo.Context) error

func (*Api) ConfirmAuthorizedToken

func (a *Api) ConfirmAuthorizedToken() echo.MiddlewareFunc

func (*Api) CreateResetPasswordToken

func (a *Api) CreateResetPasswordToken(c echo.Context) error

func (*Api) GetUsers added in v0.6.0

func (a *Api) GetUsers(c echo.Context) error

func (*Api) LoginV2

func (a *Api) LoginV2(c echo.Context) error

func (*Api) Logout

func (a *Api) Logout(c echo.Context) error

func (*Api) ResetPassword

func (a *Api) ResetPassword(c echo.Context) error

func (*Api) Serve

func (a *Api) Serve() error

type AuthConfirmationRequest

type AuthConfirmationRequest struct {
	Password string `json:"password" valid:"stringlength(8|150)"`
}

type BulkEditDocumentsRequest

type BulkEditDocumentsRequest struct {
	Documents      []string              `json:"documents" valid:"required"`
	AddMetadata    MetadataUpdateRequest `json:"add_metadata" valid:"-"`
	RemoveMetadata MetadataUpdateRequest `json:"remove_metadata" valid:"-"`
	Lang           string                `json:"lang" valid:"language, optional"`
	Date           int64                 `json:"date" valid:"optional,range(0|4106139691000)"` // year 2200 in ms
}

type Context

type Context struct {
	echo.Context
	// contains filtered or unexported fields
}

type DocumentExistsResponse

type DocumentExistsResponse struct {
	Error string `json:"error"`
	Id    string `json:"id"`
	Name  string `json:"name"`
}

type DocumentFilter

type DocumentFilter struct {
	Query    string `json:"q" valid:"-"`
	Tag      string `json:"tag" valid:"-"`
	After    int64  `json:"after" valid:"-"`
	Before   int64  `json:"before" valid:"-"`
	Metadata string `json:"metadata" valid:"-"`
}

type DocumentProcessStep

type DocumentProcessStep struct {
	DocumentId string `json:"id"`
	Step       string `json:"step"`
}

type DocumentUpdateRequest

type DocumentUpdateRequest struct {
	Name        string            `json:"name" valid:"required,stringlength(1|200)"`
	Description string            `json:"description" valid:"maxstringlength(1000),optional"`
	Filename    string            `json:"filename" valid:"optional"`
	Date        int64             `json:"date" valid:"optional,range(0|4106139691000)"` // year 2200 in ms
	Metadata    []MetadataRequest `json:"metadata" valid:"-"`
	Lang        string            `json:"lang" valid:"language, optional"`
	Favorite    bool              `json:"favorite" valid:"-"`
}

DocumentUpdateRequest swagger:model DocumentUpdateRequestBody

type ForceDocumentProcessingRequest

type ForceDocumentProcessingRequest struct {
	UserId     int    `json:"user_id" valid:"-"`
	DocumentId string `json:"document_id" valid:"-"`
	FromStep   string `json:"from_step" valid:"process_step~invalid process step"`
}

ForceDocumentsProcessingRequest describes request to force processing of documents. swagger:model ForceDocumumentsProcessing

type ForgottenPasswordRequest

type ForgottenPasswordRequest struct {
	Email string `json:"email" valid:"email"`
}

type LoginRequest

type LoginRequest struct {
	Username string `valid:"username,required"`
	Password string `valid:"required"`
}

type LoginResponse

type LoginResponse struct {
	UserId int
	Token  string
}

type MetadataKeyRequest

type MetadataKeyRequest struct {
	Key     string `json:"key" valid:"required,metadata,stringlength(1|30)"`
	Comment string `json:"comment" valid:"maxstringlength(1000),optional"`
	Icon    string `json:"icon" valid:"optional"`
	Style   string `json:"style" valid:"json,optional"`
}

type MetadataRequest

type MetadataRequest struct {
	KeyId   int `valid:"required" json:"key_id"`
	ValueId int `valid:"required" json:"value_id"`
}

func (MetadataRequest) ToMetadata added in v0.6.0

func (m MetadataRequest) ToMetadata() models.Metadata

type MetadataUpdateRequest

type MetadataUpdateRequest struct {
	Metadata []MetadataRequest `valid:"required" json:"metadata"`
}

func (*MetadataUpdateRequest) Keys

func (m *MetadataUpdateRequest) Keys() []int

func (*MetadataUpdateRequest) ToAggregate added in v0.6.0

func (m *MetadataUpdateRequest) ToAggregate() []aggregates.Metadata

func (*MetadataUpdateRequest) ToMetadataArray added in v0.6.0

func (m *MetadataUpdateRequest) ToMetadataArray() []models.Metadata

func (*MetadataUpdateRequest) UniqueKeys

func (m *MetadataUpdateRequest) UniqueKeys() []int

type MetadataValueRequest

type MetadataValueRequest struct {
	// Value of new metadata
	Value string `json:"value" valid:"required,metadata,stringlength(1|30)"`
	// Optional comment
	Comment string `json:"comment" valid:"maxstringlength(1000),optional"`
	// MatchDocuments instructs to try to match documents for this value.
	MatchDocuments bool `json:"match_documents" valid:"-"`
	// validate MatchType when creating, allowing default to be empty string
	MatchType   string `json:"match_type" valid:"in(regex|exact),optional"`
	MatchFilter string `json:"match_filter" valid:"maxstringlength(100),optional"`
}

type MimeTypesSupportedResponse

type MimeTypesSupportedResponse struct {
	Names     []string `json:"names"`
	Mimetypes []string `json:"mimetypes"`
}

MimeTypesSupportedResponse conatains info on mime types that server can extract.

type PrettyTime

type PrettyTime time.Time

PrettyTime prints time as default time string when marshaled as json

func (PrettyTime) MarshalJSON

func (p PrettyTime) MarshalJSON() ([]byte, error)

type ReorderRulesRequest

type ReorderRulesRequest struct {
	Ids []int `json:"ids" valid:"-"`
}

type ReqUserPreferences

type ReqUserPreferences struct {
	Email string `json:"email" valid:"email,optional"`
}

swagger:model UserPreferences

type ResetPasswordRequest

type ResetPasswordRequest struct {
	Token    string `json:"token" valid:"minstringlength(4)"`
	Id       int    `json:"id" valid:"required"`
	Password string `json:"password" valid:"required"`
}

type Rule

type Rule struct {
	Id          int                     `json:"id" valid:"-"`
	Name        string                  `json:"name" valid:"-"`
	Description string                  `json:"description" valid:"-"`
	Enabled     bool                    `json:"enabled" valid:"-"`
	Order       int                     `json:"order" valid:"-"`
	Mode        string                  `json:"mode" valid:"-"`
	CreatedAt   int64                   `json:"created_at" valid:"-"`
	UpdatedAt   int64                   `json:"updated_at" valid:"-"`
	Triggers    models.RuleTriggerArray `json:"triggers" valid:"rule_trigger_type"`

	Conditions []RuleCondition `json:"conditions" valid:"-"`
	Actions    []RuleAction    `json:"actions" valid:"-"`
}

func (*Rule) ToRule

func (r *Rule) ToRule() (*models.Rule, error)

type RuleAction

type RuleAction struct {
	Id          int             `json:"id" valid:"-"`
	RuleId      int             `json:"rule_id" valid:"-"`
	Enabled     bool            `json:"enabled" valid:"-"`
	OnCondition bool            `json:"on_condition" valid:"-"`
	Action      string          `json:"action" valid:"-"`
	Value       string          `json:"value" valid:"-"`
	Metadata    models.Metadata `json:"metadata" valid:"-"`
}

func (*RuleAction) ToAction

func (r *RuleAction) ToAction() *models.RuleAction

type RuleCondition

type RuleCondition struct {
	Id              int             `json:"id" valid:"-"`
	RuleId          int             `json:"rule_id" valid:"-"`
	Enabled         bool            `json:"enabled" valid:"-"`
	CaseInsensitive bool            `json:"case_insensitive" valid:"-"`
	Inverted        bool            `json:"inverted_match" valid:"-"`
	ConditionType   string          `json:"condition_type" valid:"-"`
	IsRegex         bool            `json:"is_regex" valid:"-"`
	Value           string          `json:"value" valid:"-"`
	DateFmt         string          `json:"date_fmt" valid:"-"`
	Metadata        models.Metadata `json:"metadata" valid:"-"`
}

func (*RuleCondition) ToCondition

func (r *RuleCondition) ToCondition() *models.RuleCondition

type RuleTest

type RuleTest struct {
	DocumentId string `json:"document_id" valid:"required"`
}

type SearchSuggestRequest

type SearchSuggestRequest struct {
	Filter string `json:"filter" valid:"-"`
}

type SearchSuggestResponse

type SearchSuggestResponse struct {
	Suggestions []string `json:"suggestions"`
	Prefix      string   `json:"prefix"`
}

type SortKey added in v0.6.0

type SortKey struct {
	Key             string
	Order           bool
	CaseInsensitive bool
}

func (SortKey) ToKey added in v0.6.0

func (s SortKey) ToKey() storage.SortKey

type SortKeys added in v0.6.0

type SortKeys []SortKey

type UserContext

type UserContext struct {
	Context
	Admin    bool
	UserId   int
	User     *models.User
	TokenKey string
}

type UserPreferences

type UserPreferences struct {
	// user
	Id                  int    `json:"user_id"`
	Name                string `json:"user_name"`
	Email               string `json:"email"`
	UpdatedAt           int64  `json:"updated_at"`
	CreatedAt           int64  `json:"created_at"`
	DocumentsCount      int64  `json:"documents_count"`
	DocumentsSize       int64  `json:"documents_size"`
	DocumentsSizeString string `json:"documents_size_string"`
	IsAdmin             bool   `json:"is_admin"`
}

swagger:model UserPreferences

type VersionResponse

type VersionResponse struct {
	Name    string `json:"name"`
	Version string `json:"version"`
	Commit  string `json:"commit"`
}

VersionResponse contains general server info.

Directories

Path Synopsis
Package Virtualpaper API documentation.
Package Virtualpaper API documentation.

Jump to

Keyboard shortcuts

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