rest

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2021 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 ParseConfig

func ParseConfig(s string) (interface{}, error)

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

func StripPassword added in v0.11.0

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 added in v0.9.0

type Backend struct {
	backend.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(cfg Config, rt http.RoundTripper) (*Backend, error)

Open opens the REST backend with the given config.

func (*Backend) Close added in v0.9.0

func (b *Backend) Close() error

Close closes all open files.

func (*Backend) Delete added in v0.9.0

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

Delete removes all data in the backend.

func (*Backend) IsNotExist added in v0.9.0

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

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

func (*Backend) List added in v0.9.0

func (b *Backend) List(ctx context.Context, t restic.FileType, fn func(restic.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 added in v0.9.0

func (b *Backend) Load(ctx context.Context, h restic.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) Location added in v0.9.0

func (b *Backend) Location() string

Location returns this backend's location (the server's URL).

func (*Backend) Remove added in v0.9.0

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

Remove removes the blob with the given name and type.

func (*Backend) Save added in v0.9.0

Save stores data in the backend at the handle.

func (*Backend) Stat added in v0.9.0

func (b *Backend) Stat(ctx context.Context, h restic.Handle) (restic.FileInfo, error)

Stat returns information about a blob.

func (*Backend) Test added in v0.9.0

func (b *Backend) Test(ctx context.Context, h restic.Handle) (bool, error)

Test returns true if a blob of the given type and name exists in the backend.

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.

type ErrIsNotExist

type ErrIsNotExist struct {
	restic.Handle
}

ErrIsNotExist is returned whenever the requested file does not exist on the server.

func (ErrIsNotExist) Error

func (e ErrIsNotExist) Error() string

Jump to

Keyboard shortcuts

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