mirror of https://github.com/ceph/go-ceph
rgw/admin: include stat information to User Struct
The stat information gives idea about current storage consumption. Include that info to the user struct Signed-off-by: Jiffin Tony Thottan <thottanjiffin@gmail.com>
This commit is contained in:
parent
53d742d7ce
commit
8d946bafeb
|
@ -31,6 +31,8 @@ type User struct {
|
|||
Tenant string `url:"tenant"`
|
||||
GenerateKey *bool `url:"generate-key"`
|
||||
PurgeData *int `url:"purge-data"`
|
||||
GenerateStat *bool `url:"stats"`
|
||||
Stat UserStat `json:"stats"`
|
||||
}
|
||||
|
||||
// UserCapSpec represents a user capability which gives access to certain ressources
|
||||
|
@ -46,6 +48,13 @@ type UserKeySpec struct {
|
|||
SecretKey string `json:"secret_key" url:"secret-key"`
|
||||
}
|
||||
|
||||
// UserStat contains information about storage consumption by the ceph user
|
||||
type UserStat struct {
|
||||
Size *uint64 `json:"size"`
|
||||
SizeRounded *uint64 `json:"size_rounded"`
|
||||
NumObjects *uint64 `json:"num_objects"`
|
||||
}
|
||||
|
||||
// GetUser retrieves a given object store user
|
||||
func (api *API) GetUser(ctx context.Context, user User) (User, error) {
|
||||
if user.ID == "" {
|
||||
|
|
|
@ -145,6 +145,13 @@ func (suite *RadosGWTestSuite) TestUser() {
|
|||
assert.Equal(suite.T(), int64(100), *q.MaxObjects)
|
||||
})
|
||||
|
||||
suite.T().Run("get user stat", func(t *testing.T) {
|
||||
statEnable := true
|
||||
user, err := co.GetUser(context.Background(), User{ID: "leseb", GenerateStat: &statEnable})
|
||||
assert.NoError(suite.T(), err)
|
||||
assert.NotNil(suite.T(), user.Stat.Size)
|
||||
})
|
||||
|
||||
suite.T().Run("remove user", func(t *testing.T) {
|
||||
err = co.RemoveUser(context.Background(), User{ID: "leseb"})
|
||||
assert.NoError(suite.T(), err)
|
||||
|
|
Loading…
Reference in New Issue