Documentation
¶
Index ¶
- func SignInOf(err error) *authclient.SignIn
- type Client
- func (c *Client) CallAction(ctx context.Context, volume, action string, input json.RawMessage) (*schema.Object, error)
- func (c *Client) CreateVolume(ctx context.Context, volume schema.VolumeCreateRequest) (*schema.Volume, error)
- func (c *Client) DeleteObjects(ctx context.Context, req schema.DeleteObjectsRequest) (*schema.DeleteObjectsResponse, error)
- func (c *Client) DeleteVolume(ctx context.Context, name string) (*schema.Volume, error)
- func (c *Client) GetObject(ctx context.Context, req schema.GetObjectRequest, w io.Writer) (*schema.Object, error)
- func (c *Client) GetVolume(ctx context.Context, name string) (*schema.Volume, error)
- func (c *Client) HeadObject(ctx context.Context, name, key string) (*schema.Object, error)
- func (c *Client) ListActions(ctx context.Context, volume string) (*schema.ActionList, error)
- func (c *Client) ListObjects(ctx context.Context, req schema.ObjectListRequest) (*schema.ObjectList, error)
- func (c *Client) ListVolumes(ctx context.Context) (*schema.VolumeList, error)
- func (c *Client) PutObject(ctx context.Context, req schema.CreateObjectRequest) (*schema.Object, error)
- func (c *Client) Search(ctx context.Context, query string, page schema.OffsetLimit) (*schema.SearchResponse, error)
- func (c *Client) UpdateVolume(ctx context.Context, name string, patch schema.VolumePatch, enabled *bool) (*schema.Volume, error)
- func (c *Client) UploadObjects(ctx context.Context, name, dir string, files []UploadFile, overwrite bool) (*schema.ObjectUploadResponse, error)
- type UploadFile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SignInOf ¶
func SignInOf(err error) *authclient.SignIn
SignInOf returns what's needed to sign in, of an error of a request which is 401, as a volume's backend needs its user to sign in, or nil
Types ¶
type Client ¶
Client is a filer HTTP client that wraps the base HTTP client and provides typed methods for interacting with the filer API.
func New ¶
New creates a new filer HTTP client with the given base URL and options. The url parameter should point to the API endpoint, e.g. "http://localhost:8084/api".
func (*Client) CallAction ¶
func (c *Client) CallAction(ctx context.Context, volume, action string, input json.RawMessage) (*schema.Object, error)
CallAction calls an action of a volume, of its name, with its input, which is JSON of its schema, or {} when it's empty, and returns the object it created or changed
func (*Client) CreateVolume ¶
func (c *Client) CreateVolume(ctx context.Context, volume schema.VolumeCreateRequest) (*schema.Volume, error)
CreateVolume creates a volume with a name, from the URL of its backend, which is enabled, unless its Enabled is false, and returns it, with the URL of its backend, which has each of its options, defaults too
func (*Client) DeleteObjects ¶
func (c *Client) DeleteObjects(ctx context.Context, req schema.DeleteObjectsRequest) (*schema.DeleteObjectsResponse, error)
DeleteObjects deletes the file of the request, or a directory, when it's recursive, and every object beneath it, and returns the objects deleted, which are files, not directories. Returns ErrBadParameter, without a request, when the path is outside the volume, or is the root.
func (*Client) DeleteVolume ¶
DeleteVolume deletes a volume by its name, and returns it, with the URL of its backend, which it can be created again from. The volume's files aren't deleted.
func (*Client) GetObject ¶
func (c *Client) GetObject(ctx context.Context, req schema.GetObjectRequest, w io.Writer) (*schema.Object, error)
GetObject writes the content of the file of the request to w, and returns its metadata, from the X-Meta header. Its IfModifiedSince and IfNoneMatch conditions are sent, and when the file meets them, gofiler.ErrNotModified is returned, and nothing is written. A directory can't be got. The request isn't timed out, as a file can be large, so it's cancelled with ctx.
func (*Client) HeadObject ¶
HeadObject returns the metadata of the object at the path in the volume, which is a file, a directory, or the root of the volume, when it's empty, from the X-Meta header of a HEAD request. Returns ErrBadParameter, without a request, when the path is outside the volume.
func (*Client) ListActions ¶
ListActions returns the actions of a volume, in order of their names, or, when it's empty, of every volume which is mounted, and online, in order of their volumes
func (*Client) ListObjects ¶
func (c *Client) ListObjects(ctx context.Context, req schema.ObjectListRequest) (*schema.ObjectList, error)
ListObjects returns a page of the objects beneath a path in the volume named by the request. When there are more, Next is the key of the last object, which the next page starts after, with StartAfter.
func (*Client) ListVolumes ¶
ListVolumes returns the volumes which are registered, with the URLs of their backends, and the schemes of the URLs which volumes can be created from
func (*Client) PutObject ¶
func (c *Client) PutObject(ctx context.Context, req schema.CreateObjectRequest) (*schema.Object, error)
PutObject uploads the request's body to the file at its path in its volume, creating it, and the directories it's in, or replacing it. With IfNotExists, a file which exists isn't replaced, and with IfExists, a file which doesn't exist isn't created, which are gofiler.ErrPreconditionFailed. The file's modified time is ModTime, when it's set, its metadata is Meta, and a nil body is an empty file. Returns the file. The request isn't timed out, as a file can be large, so it's cancelled with ctx.
func (*Client) Search ¶
func (c *Client) Search(ctx context.Context, query string, page schema.OffsetLimit) (*schema.SearchResponse, error)
Search returns the objects of the mounted volumes which match the query, of its text, best first, of the page, and how many match, of every page (see schema.Query)
func (*Client) UpdateVolume ¶
func (c *Client) UpdateVolume(ctx context.Context, name string, patch schema.VolumePatch, enabled *bool) (*schema.Volume, error)
UpdateVolume changes the options of a volume by its name, and whether it's enabled, so it's mounted, when enabled isn't nil, and returns it, with the URL of its backend. An option which is null is removed, so it's the default, and those which aren't in the patch are kept.
func (*Client) UploadObjects ¶
func (c *Client) UploadObjects(ctx context.Context, name, dir string, files []UploadFile, overwrite bool) (*schema.ObjectUploadResponse, error)
UploadObjects uploads the files into the directory at the path in the volume, or its root, when it's empty, in one request, whose multipart form is written as it's sent, opening each file as it is, so they aren't buffered. A file which exists is skipped, unless overwrite is set, as is one which can't be stored, such as a hidden file. Returns the files which were written, and those which were skipped, and why. The request isn't timed out, as the files can be large, so it's cancelled with ctx.
type UploadFile ¶
type UploadFile struct {
Path string
ModTime time.Time // the file's modification time, when it isn't zero
Meta []schema.Meta // the file's metadata, when it has any
Open func() (io.ReadCloser, error)
}
UploadFile is a file to upload into a directory, by its path in it, which can have directories, which is opened as it's uploaded