api

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2025 License: ISC Imports: 42 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InvalidArgument ParamErrorType = "invalid_argument"
	BadNumber                      = "bad_number"
	MissingArgument                = "missing_argument"
)

Variables

View Source
var (
	ErrNumberOutOfRange = errors.New("Number out of range")
	ErrMissingField     = errors.New("Missing field")
	ErrInvalidID        = errors.New("Invalid ID")
	ErrInvalidSortKey   = errors.New("Invalid sort key")
)
View Source
var SERVICES_ENDPOINT = "https://api.plakar.io"

Functions

func PathParamToID

func PathParamToID(r *http.Request, param string) (id [32]byte, err error)

func QueryParamToInt64

func QueryParamToInt64(r *http.Request, param string, min, def int64) (int64, error)

func QueryParamToSortKeys

func QueryParamToSortKeys(r *http.Request, param, def string) ([]string, error)

func QueryParamToString

func QueryParamToString(r *http.Request, param string) (string, bool, error)

func QueryParamToUint32

func QueryParamToUint32(r *http.Request, param string, min, def uint32) (uint32, error)

func SetupRoutes

func SetupRoutes(server *http.ServeMux, repo *repository.Repository, ctx *appcontext.AppContext, token string)

func SnapshotPathParam

func SnapshotPathParam(r *http.Request, repo *repository.Repository, param string) (objects.MAC, string, error)

Parse a URL parameter with the format "snapshotID:path".

func TokenAuthMiddleware

func TokenAuthMiddleware(token string) func(http.Handler) http.Handler

TokenAuthMiddleware is a middleware that checks for the token in the request. If the token is empty, the middleware is a no-op.

Types

type APIView

type APIView func(w http.ResponseWriter, r *http.Request) error

func (APIView) ServeHTTP

func (view APIView) ServeHTTP(w http.ResponseWriter, r *http.Request)

type AlertServiceConfiguration

type AlertServiceConfiguration struct {
	Enabled     bool `json:"enabled"`
	EmailReport bool `json:"email_report"`
}

type ApiError

type ApiError struct {
	HttpCode int                       `json:"-"`
	ErrCode  string                    `json:"code"`
	Message  string                    `json:"message"`
	Params   map[string]ParameterError `json:"params,omitempty"`
}

func (*ApiError) Error

func (a *ApiError) Error() string

type ApiErrorRes

type ApiErrorRes struct {
	Error *ApiError `json:"error"`
}

type DownloadItem

type DownloadItem struct {
	Pathname string `json:"pathname"`
}

type DownloadQuery

type DownloadQuery struct {
	Name   string         `json:"name"`
	Items  []DownloadItem `json:"items"`
	Rebase bool           `json:"rebase,omitempty"`
}

type IntegrationsInstallRequest added in v1.0.3

type IntegrationsInstallRequest struct {
	Id      string `json:"id"`
	Version string `json:"version"`
}

type IntegrationsMessage added in v1.0.3

type IntegrationsMessage struct {
	Date    time.Time `json:"date"`
	Message string    `json:"message"`
}

type IntegrationsResponse added in v1.0.3

type IntegrationsResponse struct {
	Type       string                `json:"type"`
	Status     string                `json:"status"`
	StartedAt  time.Time             `json:"started_at"`
	FinishedAt time.Time             `json:"finished_at"`
	Messages   []IntegrationsMessage `json:"messages"`
}

func NewIntegrationsResponse added in v1.0.3

func NewIntegrationsResponse(Type string) *IntegrationsResponse

func (*IntegrationsResponse) AddMessage added in v1.0.3

func (r *IntegrationsResponse) AddMessage(msg string)

type Item

type Item[T any] struct {
	Item T `json:"item"`
}

type Items

type Items[T any] struct {
	Total int `json:"total"`
	Items []T `json:"items"`
}

type ItemsPage

type ItemsPage[T any] struct {
	HasNext bool `json:"has_next"`
	Items   []T  `json:"items"`
}

type JSONAPIView

type JSONAPIView func(w http.ResponseWriter, r *http.Request) error

func (JSONAPIView) ServeHTTP

func (view JSONAPIView) ServeHTTP(w http.ResponseWriter, r *http.Request)

type LoginRequestEmail

type LoginRequestEmail struct {
	Email    string `json:"email"`
	Redirect string `json:"redirect"`
}

type LoginRequestGithub

type LoginRequestGithub struct {
	Redirect string `json:"redirect"`
}

type ParamErrorType

type ParamErrorType string

type ParameterError

type ParameterError struct {
	Code    ParamErrorType `json:"code"`
	Message string         `json:"message"`
}

type RepositoryInfoResponse

type RepositoryInfoResponse struct {
	Location      string                  `json:"location"`
	Snapshots     RepositoryInfoSnapshots `json:"snapshots"`
	Configuration storage.Configuration   `json:"configuration"`
	OS            string                  `json:"os"`
	Arch          string                  `json:"arch"`
}

type RepositoryInfoSnapshots

type RepositoryInfoSnapshots struct {
	Total           int     `json:"total"`
	StorageSize     int64   `json:"storage_size"`
	LogicalSize     int64   `json:"logical_size"`
	Efficiency      float64 `json:"efficiency"`
	SnapshotsPerDay []int   `json:"snapshots_per_day"`
}

type SnapshotReaderURLSigner

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

func NewSnapshotReaderURLSigner

func NewSnapshotReaderURLSigner(ui *uiserver, token string) SnapshotReaderURLSigner

func (SnapshotReaderURLSigner) Sign

func (SnapshotReaderURLSigner) VerifyMiddleware

func (signer SnapshotReaderURLSigner) VerifyMiddleware(next http.Handler) http.Handler

VerifyMiddleware is a middleware that checks if the request to read the file content is authorized. It checks if the ?signature query parameter is valid. If it is not valid, it falls back to the Authorization header.

type SnapshotSignedURLClaims

type SnapshotSignedURLClaims struct {
	SnapshotID string `json:"snapshot_id"`
	Path       string `json:"path"`
	jwt.RegisteredClaims
}

type TimelineLocation

type TimelineLocation struct {
	Snapshot header.Header `json:"snapshot"`
	Entry    vfs.Entry     `json:"vfs_entry"`
}

type TokenResponse

type TokenResponse struct {
	Token string `json:"token"`
}

Jump to

Keyboard shortcuts

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