From 0af224e0a195e22f7884a756d8c873090283245b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Wed, 29 Jul 2020 15:17:08 +0200 Subject: [PATCH] fake quota as in reva MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- pkg/service/v0/data/user.go | 30 ++++++++++++++++++++---------- pkg/service/v0/users.go | 9 +++++++++ 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/pkg/service/v0/data/user.go b/pkg/service/v0/data/user.go index b882d779e..c43cc9cf5 100644 --- a/pkg/service/v0/data/user.go +++ b/pkg/service/v0/data/user.go @@ -1,20 +1,30 @@ package data -// User holds the payload for a GetUser response -type User struct { - // TODO needs better naming, clarify if we need a userid, a username or both - UserID string `json:"id" xml:"id"` - Username string `json:"username" xml:"username"` - DisplayName string `json:"displayname" xml:"displayname"` - Email string `json:"email" xml:"email"` - Enabled bool `json:"enabled" xml:"enabled"` -} - // Users holds user ids for the user listing type Users struct { Users []string `json:"users" xml:"users>element"` } +// User holds the payload for a GetUser response +type User struct { + // TODO needs better naming, clarify if we need a userid, a username or both + Enabled bool `json:"enabled" xml:"enabled"` + UserID string `json:"id" xml:"id"` + Username string `json:"username" xml:"username"` + DisplayName string `json:"displayname" xml:"displayname"` + Email string `json:"email" xml:"email"` + Quota *Quota `json:"quota" xml:"quota"` +} + +// Quota holds quota information +type Quota struct { + Free int64 `json:"free" xml:"free"` + Used int64 `json:"used" xml:"used"` + Total int64 `json:"total" xml:"total"` + Relative float32 `json:"relative" xml:"relative"` + Definition string `json:"definition" xml:"definition"` +} + // SigningKey holds the Payload for a GetSigningKey response type SigningKey struct { User string `json:"user" xml:"user"` diff --git a/pkg/service/v0/users.go b/pkg/service/v0/users.go index b12d553a5..42b87f38e 100644 --- a/pkg/service/v0/users.go +++ b/pkg/service/v0/users.go @@ -61,6 +61,15 @@ func (o Ocs) GetUser(w http.ResponseWriter, r *http.Request) { DisplayName: account.DisplayName, Email: account.Mail, Enabled: account.AccountEnabled, + // FIXME only return quota for users/{userid} endpoint (not /user) + // TODO query storage registry for free space? of home storage, maybe... + Quota: &data.Quota{ + Free: 2840756224000, + Used: 5059416668, + Total: 2845815640668, + Relative: 0.18, + Definition: "default", + }, })) }