netstorage

package
v1.68.2 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: MIT Imports: 28 Imported by: 6

Documentation

Overview

Package netstorage provides an interface to Akamai NetStorage API

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFs

func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, error)

NewFs creates a new Fs object from the name and root. It connects to the host specified in the config file.

If root refers to an existing object, then it should return an Fs which points to the parent of that object and ErrorIsFile.

Types

type Du

type Du struct {
	XMLName   xml.Name `xml:"du"`
	Directory string   `xml:"directory,attr"`
	Duinfo    DuInfo   `xml:"du-info"`
}

Du represents the du xml element of the response

func (Du) GetName

func (d Du) GetName() xml.Name

GetName returns a normalized name of the Du item

type DuInfo

type DuInfo struct {
	XMLName xml.Name `xml:"du-info"`
	Files   int64    `xml:"files,attr"`
	Bytes   int64    `xml:"bytes,attr"`
}

DuInfo represents the du-info xml element of the response

type File

type File struct {
	XMLName    xml.Name `xml:"file"`
	Type       string   `xml:"type,attr"`
	Name       string   `xml:"name,attr"`
	NameBase64 string   `xml:"name_base64,attr"`
	Size       int64    `xml:"size,attr"`
	Md5        string   `xml:"md5,attr"`
	Mtime      int64    `xml:"mtime,attr"`
	Bytes      int64    `xml:"bytes,attr"`
	Files      int64    `xml:"files,attr"`
	Target     string   `xml:"target,attr"`
}

File is an object which holds the information of the file element of the response xml

type Fs

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

Fs stores the interface to the remote HTTP files

func (*Fs) Command

func (f *Fs) Command(ctx context.Context, name string, arg []string, opt map[string]string) (out interface{}, err error)

Command the backend to run a named commands: du and symlink

func (*Fs) Features

func (f *Fs) Features() *fs.Features

Features returns the optional features of this Fs

func (*Fs) Hashes

func (f *Fs) Hashes() hash.Set

Hashes returns the supported hash sets.

func (*Fs) List

func (f *Fs) List(ctx context.Context, dir string) (entries fs.DirEntries, err error)

List the objects and directories in dir into entries. The entries can be returned in any order but should be for a complete directory.

dir should be "" to list the root, and should not have trailing slashes.

This should return ErrDirNotFound if the directory isn't found.

func (*Fs) ListR

func (f *Fs) ListR(ctx context.Context, dir string, callback fs.ListRCallback) (err error)

ListR lists the objects and directories of the Fs starting from dir recursively into out.

dir should be "" to start from the root, and should not have trailing slashes.

This should return ErrDirNotFound if the directory isn't found.

It should call callback for each tranche of entries read. These need not be returned in any particular order. If callback returns an error then the listing will stop immediately.

Don't implement this unless you have a more efficient way of listing recursively that doing a directory traversal.

func (*Fs) Mkdir

func (f *Fs) Mkdir(ctx context.Context, dir string) error

Mkdir makes the root directory of the Fs object Shouldn't return an error if it already exists

func (*Fs) Name

func (f *Fs) Name() string

Name returns the configured name of the file system

func (*Fs) NewObject

func (f *Fs) NewObject(ctx context.Context, remote string) (fs.Object, error)

NewObject creates a new remote http file object NewObject finds the Object at remote If it can't be found returns fs.ErrorObjectNotFound If it isn't a file, then it returns fs.ErrorIsDir

func (*Fs) Precision

func (f *Fs) Precision() time.Duration

Precision return the precision of this Fs

func (*Fs) Purge

func (f *Fs) Purge(ctx context.Context, dir string) error

Purge all files in the directory specified. NetStorage quick-delete is disabled by default AND not instantaneous. Returns fs.ErrorCantPurge when quick-delete fails.

func (*Fs) Put

func (f *Fs) Put(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (fs.Object, error)

Put in to the remote path with the modTime given of the given size

May create the object even if it returns an error - if so will return the object and the error, otherwise will return nil and the error

func (*Fs) PutStream

func (f *Fs) PutStream(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (fs.Object, error)

PutStream uploads to the remote path with the modTime given of indeterminate size

func (*Fs) Rmdir

func (f *Fs) Rmdir(ctx context.Context, dir string) error

Rmdir removes the root directory of the Fs object Return an error if it doesn't exist or isn't empty

func (*Fs) Root

func (f *Fs) Root() string

Root returns the root for the filesystem

func (*Fs) String

func (f *Fs) String() string

String returns the URL for the filesystem

type List

type List struct {
	XMLName xml.Name   `xml:"list"`
	Files   []File     `xml:"file"`
	Resume  ListResume `xml:"resume"`
}

List is an object which holds the information of the list element of the response xml

func (List) GetName

func (l List) GetName() xml.Name

GetName returns a normalized name of the List item

type ListResume

type ListResume struct {
	XMLName xml.Name `xml:"resume"`
	Start   string   `xml:"start,attr"`
}

ListResume represents the resume xml element of the list

type Object

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

Object is a remote object that has been stat'd (so it exists, but is not necessarily open for reading)

func (*Object) Fs

func (o *Object) Fs() fs.Info

Fs is the filesystem this remote http file object is located within

func (*Object) Hash

func (o *Object) Hash(ctx context.Context, t hash.Type) (string, error)

Hash returns the Md5sum of an object returning a lowercase hex string

func (*Object) Md5Sum

func (o *Object) Md5Sum() string

Md5Sum returns the md5 of the object

func (*Object) ModTime

func (o *Object) ModTime(ctx context.Context) time.Time

ModTime returns the modification time of the object

It attempts to read the objects mtime and if that isn't present the LastModified returned in the http headers

func (*Object) Open

func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (in io.ReadCloser, err error)

Open an object for read

func (*Object) Remote

func (o *Object) Remote() string

Remote the name of the remote HTTP file, relative to the fs root

func (*Object) Remove

func (o *Object) Remove(ctx context.Context) error

Remove an object

func (*Object) SetModTime

func (o *Object) SetModTime(ctx context.Context, modTime time.Time) error

SetModTime sets the modification and access time to the specified time

func (*Object) Size

func (o *Object) Size() int64

Size returns the size in bytes of the remote http file

func (*Object) Storable

func (o *Object) Storable() bool

Storable returns whether this object is storable

func (*Object) String

func (o *Object) String() string

String returns the URL to the remote HTTP file

func (*Object) Update

func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) error

Update netstorage with the object

type Options

type Options struct {
	Endpoint string `config:"host"`
	Account  string `config:"account"`
	Secret   string `config:"secret"`
	Protocol string `config:"protocol"`
}

Options defines the configuration for this backend

type Stat

type Stat struct {
	XMLName   xml.Name `xml:"stat"`
	Files     []File   `xml:"file"`
	Directory string   `xml:"directory,attr"`
}

Stat is an object which holds the information of the stat element of the response xml

func (Stat) GetName

func (s Stat) GetName() xml.Name

GetName returns a normalized name of the Stat item

Jump to

Keyboard shortcuts

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