From c9272eabcbd3327e3ca143317e3944095309483b Mon Sep 17 00:00:00 2001 From: alperencelik Date: Mon, 15 Jan 2024 00:15:06 +0300 Subject: [PATCH 1/2] feat: Add function for download-url support on node storage --- nodes.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/nodes.go b/nodes.go index f5e668c..91e3677 100644 --- a/nodes.go +++ b/nodes.go @@ -172,6 +172,16 @@ func (n *Node) Storage(ctx context.Context, name string) (storage *Storage, err return } +func (n *Node) StorageDownloadObject(ctx context.Context, storage, filename, content, url string) (ret string, err error) { + return ret, n.client.Post(ctx, fmt.Sprintf("/nodes/%s/storage/%s/download-url", n.Name, storage), map[string]string{ + "content": content, + "filename": filename, + "node": n.Name, + "storage": storage, + "url": url, + }, &ret) +} + func (n *Node) StorageISO(ctx context.Context) (*Storage, error) { return n.findStorageByContent(ctx, "iso") } From 23c37ac22c3b656f2d905239369b4e885b9f932d Mon Sep 17 00:00:00 2001 From: alperencelik Date: Fri, 19 Jan 2024 21:10:21 +0300 Subject: [PATCH 2/2] feat: Add StorageDownloadURL struct & rename function --- nodes.go | 11 +++-------- types.go | 12 ++++++++++++ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/nodes.go b/nodes.go index 91e3677..751b7b8 100644 --- a/nodes.go +++ b/nodes.go @@ -172,14 +172,9 @@ func (n *Node) Storage(ctx context.Context, name string) (storage *Storage, err return } -func (n *Node) StorageDownloadObject(ctx context.Context, storage, filename, content, url string) (ret string, err error) { - return ret, n.client.Post(ctx, fmt.Sprintf("/nodes/%s/storage/%s/download-url", n.Name, storage), map[string]string{ - "content": content, - "filename": filename, - "node": n.Name, - "storage": storage, - "url": url, - }, &ret) +func (n *Node) StorageDownloadURL(ctx context.Context, StorageDownloadURLOptions *StorageDownloadURLOptions) (ret string, err error) { + err = n.client.Post(ctx, fmt.Sprintf("/nodes/%s/storage/%s/download-url", n.Name, StorageDownloadURLOptions.Storage), StorageDownloadURLOptions, &ret) + return ret, err } func (n *Node) StorageISO(ctx context.Context) (*Storage, error) { diff --git a/types.go b/types.go index 80bc591..7bacc8c 100644 --- a/types.go +++ b/types.go @@ -1133,3 +1133,15 @@ type ACLOptions struct { Propagate IntOrBool `json:",omitempty"` Delete IntOrBool `json:",omitempty"` // true to delete the ACL } + +type StorageDownloadURLOptions struct { + Content string `json:"content,omitempty"` + Filename string `json:"filename,omitempty"` + Node string `json:"node,omitempty"` + Storage string `json:"storage,omitempty"` + URL string `json:"url,omitempty"` + Checksum string `json:"checksum,omitempty"` + ChecksumAlgorithm string `json:"checksum-algorithm,omitempty"` + Compression string `json:"compression,omitempty"` + VerifyCertificates IntOrBool `json:"verify-certificates,omitempty"` +}