mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-06-29 18:21:10 +00:00
* wip * experimenting with terraform plugin framework * cleaning up poc and adding tests * adding read / update / delete * update bridge_vlan_aware and MTU * add ipv6 and simplify IP support * fix provider's schema * add docs * run linter from cmdline * disable TF acceptance tests * add VLAN * update docs * add examole * cleanup
52 lines
1.3 KiB
Go
52 lines
1.3 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 nodes
|
|
|
|
import (
|
|
"fmt"
|
|
"net/url"
|
|
|
|
"github.com/bpg/terraform-provider-proxmox/proxmox/api"
|
|
"github.com/bpg/terraform-provider-proxmox/proxmox/nodes/containers"
|
|
"github.com/bpg/terraform-provider-proxmox/proxmox/nodes/tasks"
|
|
"github.com/bpg/terraform-provider-proxmox/proxmox/nodes/vms"
|
|
)
|
|
|
|
// Client is an interface for accessing the Proxmox node API.
|
|
type Client struct {
|
|
api.Client
|
|
NodeName string
|
|
}
|
|
|
|
// ExpandPath expands a relative path to a full node API path.
|
|
func (c *Client) ExpandPath(path string) string {
|
|
return fmt.Sprintf("nodes/%s/%s", url.PathEscape(c.NodeName), path)
|
|
}
|
|
|
|
// Container returns a client for managing a specific container.
|
|
func (c *Client) Container(vmID int) *containers.Client {
|
|
return &containers.Client{
|
|
Client: c,
|
|
VMID: vmID,
|
|
}
|
|
}
|
|
|
|
// VM returns a client for managing a specific VM.
|
|
func (c *Client) VM(vmID int) *vms.Client {
|
|
return &vms.Client{
|
|
Client: c,
|
|
VMID: vmID,
|
|
}
|
|
}
|
|
|
|
// Tasks returns a client for managing VM tasks.
|
|
func (c *Client) Tasks() *tasks.Client {
|
|
return &tasks.Client{
|
|
Client: c,
|
|
}
|
|
}
|