rest

package
v0.17.2 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 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 added in v0.16.0

func NewFactory() location.Factory

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

func (b *Backend) Close() error

Close closes all open files.

func (*Backend) Connections added in v0.14.0

func (b *Backend) Connections() uint

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) HasAtomicReplace added in v0.14.0

func (b *Backend) HasAtomicReplace() bool

HasAtomicReplace returns whether Save() can atomically replace files

func (*Backend) Hasher added in v0.13.0

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

Hasher may return a hash function for calculating a content hash for 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) IsPermanentError added in v0.17.0

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

func (*Backend) List added in v0.9.0

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

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

func (b *Backend) Remove(ctx context.Context, h backend.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

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

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