mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-07-01 11:02:59 +00:00
* feat(core): add query url metadata endpoint to nodes client api Signed-off-by: Rafał Safin <rafal.safin@rafsaf.pl> * feat(core): move storage api code to nodestorage folder Signed-off-by: Rafał Safin <rafal.safin@rafsaf.pl> * feat(core): add download url api Signed-off-by: Rafał Safin <rafal.safin@rafsaf.pl> * feat(storage): add resource_download_file Signed-off-by: Rafał Safin <rafal.safin@rafsaf.pl> * feat(storage): finish new resource_download_file Signed-off-by: Rafał Safin <rafal.safin@rafsaf.pl> * feat(storage): generate docs for new download file resource, update other docs and examples Signed-off-by: Rafał Safin <rafal.safin@rafsaf.pl> * feat(storage): add basic acc tests for resource download_file Signed-off-by: Rafał Safin <rafal.safin@rafsaf.pl> * fix(test): lint new test file Signed-off-by: Rafał Safin <rafal.safin@rafsaf.pl> * feat(storage): warning instead of error when file already exists on resource download file Signed-off-by: Rafał Safin <rafal.safin@rafsaf.pl> * feat(storage): better validation in resource download file, delete upload task on error Signed-off-by: Rafał Safin <rafal.safin@rafsaf.pl> * feat(storage): better err message in resource download file Signed-off-by: Rafał Safin <rafal.safin@rafsaf.pl> * fix(core): removed unnecessary toint in custom type bool Signed-off-by: Rafał Safin <rafal.safin@rafsaf.pl> * fix(storage): typo in resource download file error Signed-off-by: Rafał Safin <rafal.safin@rafsaf.pl> * feat(storage): download file resource review - 1 Signed-off-by: Rafał Safin <rafal.safin@rafsaf.pl> * feat(storage): finish resource download file after review Signed-off-by: Rafał Safin <rafal.safin@rafsaf.pl> * fix(storage): error instead of warnings in parse int errors in sizeRequiresReplaceModifier Signed-off-by: Rafał Safin <rafal.safin@rafsaf.pl> * fix(docs): remove unwanted changes in virtual_environment_file.md Signed-off-by: Rafał Safin <rafal.safin@rafsaf.pl> * fix(test): fix download file base acceptance tests Signed-off-by: Rafał Safin <rafal.safin@rafsaf.pl> * fix(test): fix resource download file acc tests Signed-off-by: Rafał Safin <rafal.safin@rafsaf.pl> * fix(test): last fix resource download file acc test Signed-off-by: Rafał Safin <rafal.safin@rafsaf.pl> * fix: use PVE-compatible jammy LXC image, fix few typos Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com> --------- Signed-off-by: Rafał Safin <rafal.safin@rafsaf.pl> Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com> Co-authored-by: Rafał Safin <rafal.safin@rafsaf.pl> Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
49 lines
1.1 KiB
Go
49 lines
1.1 KiB
Go
/*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
package tasks
|
|
|
|
import (
|
|
"fmt"
|
|
"net/url"
|
|
|
|
"github.com/bpg/terraform-provider-proxmox/proxmox/api"
|
|
)
|
|
|
|
// Client is an interface for performing requests against the Proxmox 'tasks' API.
|
|
type Client struct {
|
|
api.Client
|
|
}
|
|
|
|
// ExpandPath expands a path relative to the client's base path.
|
|
func (c *Client) ExpandPath(_ string) string {
|
|
panic("ExpandPath of tasks.Client must not be used. Use BuildPath instead.")
|
|
}
|
|
|
|
func (c *Client) baseTaskPath(taskID string) (string, error) {
|
|
tid, err := ParseTaskID(taskID)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
return fmt.Sprintf("nodes/%s/tasks/%s",
|
|
url.PathEscape(tid.NodeName),
|
|
url.PathEscape(taskID),
|
|
), nil
|
|
}
|
|
|
|
// BuildPath builds a path using information from Task ID.
|
|
func (c *Client) BuildPath(taskID string, path string) (string, error) {
|
|
basePath, err := c.baseTaskPath(taskID)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
return fmt.Sprintf("%s/%s",
|
|
basePath, url.PathEscape(path),
|
|
), nil
|
|
}
|