mirror of
https://github.com/rclone/rclone.git
synced 2026-02-18 18:33:36 +00:00
drime: implement About
This commit is contained in:
@@ -235,3 +235,11 @@ type MultiPartAbort struct {
|
||||
UploadID string `json:"uploadId"`
|
||||
Key string `json:"key"`
|
||||
}
|
||||
|
||||
// SpaceUsageResponse is returned by GET /user/space-usage
|
||||
type SpaceUsageResponse struct {
|
||||
Used int64 `json:"used"`
|
||||
Available int64 `json:"available"`
|
||||
Status string `json:"status"`
|
||||
SEO any `json:"seo"`
|
||||
}
|
||||
|
||||
@@ -1344,6 +1344,37 @@ func (s *drimeChunkWriter) Abort(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// About gets quota information
|
||||
func (f *Fs) About(ctx context.Context) (*fs.Usage, error) {
|
||||
opts := rest.Opts{
|
||||
Method: "GET",
|
||||
Path: "/user/space-usage",
|
||||
Parameters: url.Values{},
|
||||
}
|
||||
if f.opt.WorkspaceID != "" {
|
||||
opts.Parameters.Set("workspaceId", f.opt.WorkspaceID)
|
||||
}
|
||||
|
||||
var resp *http.Response
|
||||
var result api.SpaceUsageResponse
|
||||
var err error
|
||||
err = f.pacer.Call(func() (bool, error) {
|
||||
resp, err = f.srv.CallJSON(ctx, &opts, nil, &result)
|
||||
return shouldRetry(ctx, resp, err)
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get Drime Quota: %w", err)
|
||||
}
|
||||
|
||||
usage := &fs.Usage{
|
||||
Total: fs.NewUsageValue(result.Available),
|
||||
Used: fs.NewUsageValue(result.Used),
|
||||
Free: fs.NewUsageValue(result.Available - result.Used),
|
||||
}
|
||||
|
||||
return usage, nil
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------
|
||||
|
||||
// Fs returns the parent Fs
|
||||
@@ -1555,6 +1586,7 @@ var (
|
||||
_ fs.Mover = (*Fs)(nil)
|
||||
_ fs.DirMover = (*Fs)(nil)
|
||||
_ fs.DirCacheFlusher = (*Fs)(nil)
|
||||
_ fs.Abouter = (*Fs)(nil)
|
||||
_ fs.OpenChunkWriter = (*Fs)(nil)
|
||||
_ fs.Object = (*Object)(nil)
|
||||
_ fs.IDer = (*Object)(nil)
|
||||
|
||||
@@ -12,6 +12,7 @@ security: High
|
||||
virtual: false
|
||||
remote: 'TestDrime:'
|
||||
features:
|
||||
- About
|
||||
- CanHaveEmptyDirectories
|
||||
- Copy
|
||||
- DirCacheFlush
|
||||
|
||||
Reference in New Issue
Block a user