Skip to content

Commit

Permalink
Add StorageContentGet function (#111)
Browse files Browse the repository at this point in the history
* feat: Add StorageContentGet function

* fix: Move getContent function to storage

* fix: update GetContent method include node parameter

---------

Co-authored-by: alperencelik <alp.celik@axon-networks.com>
  • Loading branch information
alperencelik and alperencelik committed Feb 5, 2024
1 parent 7eebddd commit 7d43d0f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions storage.go
Expand Up @@ -107,6 +107,11 @@ func (s *Storage) downloadURL(ctx context.Context, content, filename, url string
return NewTask(upid, s.client), nil
}

func (s *Storage) GetContent(ctx context.Context) (content *StorageContent, err error) {
err = s.client.Get(ctx, fmt.Sprintf("/nodes/%s/storage/%s/content", s.Node, s.Name), &content)
return content, err
}

func (s *Storage) ISO(ctx context.Context, name string) (iso *ISO, err error) {
err = s.client.Get(ctx, fmt.Sprintf("/nodes/%s/storage/%s/content/%s:%s/%s", s.Node, s.Name, s.Name, "iso", name), &iso)
if err != nil {
Expand Down
14 changes: 14 additions & 0 deletions types.go
Expand Up @@ -1145,3 +1145,17 @@ type StorageDownloadURLOptions struct {
Compression string `json:"compression,omitempty"`
VerifyCertificates IntOrBool `json:"verify-certificates,omitempty"`
}

type StorageContent struct {
Format string `json:"format,omitempty"`
Size uint64 `json:"size,omitempty"`
Volid string `json:"volid,omitempty"`
Ctime uint64 `json:"ctime,omitempty"`
Encryption string `json:"encryption,omitempty"`
Notes string `json:"notes,omitempty"`
Parent string `json:"parent,omitempty"`
Protection bool `json:"protection,omitempty"`
Used uint64 `json:"used,omitempty"`
Verification string `json:"verification,omitempty"`
VMID uint64 `json:"vmid,omitempty"`
}

0 comments on commit 7d43d0f

Please sign in to comment.