Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GetObjectStoreStats method to retrieve object store statistics #176

Merged
merged 1 commit into from
Jan 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
}