Skip to content

Commit

Permalink
Add GetObjectStoreStats method to retrieve object store statistics (#176
Browse files Browse the repository at this point in the history
)

Signed-off-by: Alejandro J. Nuñez Madrazo <alejandrojnm@gmail.com>
  • Loading branch information
alejandrojnm committed Jan 4, 2024
1 parent 1a9dad7 commit 95b9688
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions objectstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ type CreateObjectStoreRequest struct {
Region string `json:"region"`
}

// ObjectStoreStats holds the object store stats
type ObjectStoreStats struct {
SizeKBUtilised int64 `json:"size_kb_utilised"`
MaxSizeKB int64 `json:"max_size_kb"`
NumObjects int64 `json:"num_objects"`
}

// UpdateObjectStoreRequest holds the request to update a specified object storage's details
type UpdateObjectStoreRequest struct {
MaxSizeGB int64 `json:"max_size_gb"`
Expand Down Expand Up @@ -151,3 +158,18 @@ func (c *Client) DeleteObjectStore(id string) (*SimpleResponse, error) {

return c.DecodeSimpleResponse(resp)
}

// GetObjectStoreStats returns the stats for an objectstore
func (c *Client) GetObjectStoreStats(id string) (*ObjectStoreStats, error) {
resp, err := c.SendGetRequest(fmt.Sprintf("/v2/objectstores/%s/stats", id))
if err != nil {
return nil, decodeError(err)
}

var result = &ObjectStoreStats{}
if err := json.NewDecoder(bytes.NewReader(resp)).Decode(result); err != nil {
return nil, err
}

return result, nil
}

0 comments on commit 95b9688

Please sign in to comment.