rest

package
v0.0.0-...-0265167 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2024 License: BSD-2-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentTypeV1 = "application/vnd.x.restic.rest.v1"
	ContentTypeV2 = "application/vnd.x.restic.rest.v2"
)

the REST API protocol version is decided by HTTP request headers, these are the constants.

Variables

This section is empty.

Functions

func NewFactory

func NewFactory() location.Factory

func StripPassword

func StripPassword(s string) string

StripPassword removes the password from the URL If the repository location cannot be parsed as a valid URL, it will be returned as is (it's because this function is used for logging errors)

Types

type Backend

type Backend struct {
	layout.Layout
	// contains filtered or unexported fields
}

Backend uses the REST protocol to access data stored on a server.

func Create

func Create(ctx context.Context, cfg Config, rt http.RoundTripper) (*Backend, error)

Create creates a new REST on server configured in config.

func Open

func Open(_ context.Context, cfg Config, rt http.RoundTripper) (*Backend, error)

Open opens the REST backend with the given config.

func (*Backend) Close

func (b *Backend) Close() error

Close closes all open files.

func (*Backend) Connections

func (b *Backend) Connections() uint

func (*Backend) Delete

func (b *Backend) Delete(ctx context.Context) error

Delete removes all data in the backend.

func (*Backend) HasAtomicReplace

func (b *Backend) HasAtomicReplace() bool

HasAtomicReplace returns whether Save() can atomically replace files

func (*Backend) Hasher

func (b *Backend) Hasher() hash.Hash

Hasher may return a hash function for calculating a content hash for the backend

func (*Backend) IsNotExist

func (b *Backend) IsNotExist(err error) bool

IsNotExist returns true if the error was caused by a non-existing file.

func (*Backend) IsPermanentError

func (b *Backend) IsPermanentError(err error) bool

func (*Backend) List

func (b *Backend) List(ctx context.Context, t backend.FileType, fn func(backend.FileInfo) error) error

List runs fn for each file in the backend which has the type t. When an error occurs (or fn returns an error), List stops and returns it.

func (*Backend) Load

func (b *Backend) Load(ctx context.Context, h backend.Handle, length int, offset int64, fn func(rd io.Reader) error) error

Load runs fn with a reader that yields the contents of the file at h at the given offset.

func (*Backend) Remove

func (b *Backend) Remove(ctx context.Context, h backend.Handle) error

Remove removes the blob with the given name and type.

func (*Backend) Save

Save stores data in the backend at the handle.

func (*Backend) Stat

Stat returns information about a blob.

type Config

type Config struct {
	URL         *url.URL
	Connections uint `option:"connections" help:"set a limit for the number of concurrent connections (default: 5)"`
}

Config contains all configuration necessary to connect to a REST server.

func NewConfig

func NewConfig() Config

NewConfig returns a new Config with the default values filled in.

func ParseConfig

func ParseConfig(s string) (*Config, error)

ParseConfig parses the string s and extracts the REST server URL.

func (*Config) ApplyEnvironment

func (cfg *Config) ApplyEnvironment(prefix string)

ApplyEnvironment saves values from the environment to the config.

Jump to

Keyboard shortcuts

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