Categorygithub.com/starttoaster/go-proxmox
modulepackage
0.0.4
Repository: https://github.com/starttoaster/go-proxmox.git
Documentation: pkg.go.dev

# README

go-proxmox

Go Report Card codecov Go Reference

This is an API client library for Proxmox VE servers. It aims to be simple to use and consume in your own Go programs, make very little assumptions about how the user would consume it, and use as few non-stdlib dependencies to do so as possible.

This is currently tested against Proxmox VE 8.1.4 systems.

This library is in its early development phase. Minor changes may be made in its usage, and only a portion of API methods are currently supported. See the CONTRIBUTING.md for details on contributing new methods to this library. Or make an Issue to discuss it.

Usage

This API client library currently supports API tokens for authentication.

import proxmox "github.com/starttoaster/go-proxmox"

// Create a new API client using a Proxmox API token
c, _ := proxmox.NewClient(tokenID, token, proxmox.WithBaseURL("https://10.0.0.10:8006/"))

// Retrieve cluster nodes
nodes, _, _ := c.Nodes.GetNodes()

// Retrieve the status of a node named server1
node, _, _ := c.Nodes.GetNodeStatus("server1")

// Retrieve the version of a node named server1
version, _, _ := c.Nodes.GetNodeVersion("server1")

Insecure API servers

If your PVE server's TLS can't be verified, you can pass an insecure HTTP client to the library.

httpClient := http.Client{
	Transport: &http.Transport{
		TLSClientConfig: &tls.Config{
			InsecureSkipVerify: tlsVerify,
		},
	},
}

c, _ := proxmox.NewClient(tokenID, token, 
    proxmox.WithBaseURL("https://10.0.0.10:8006/"), 
    proxmox.WithHTTPClient(&httpClient),
)

# Functions

NewClient returns a new Proxmox API client.
WithBaseURL sets the URL for API requests to something other than localhost.
WithHTTPClient sets the HTTP client for API requests to something other than the default Go http Client.

# Structs

BootInfo info about host boot.
Client for the Proxmox API.
ClusterService is the service that encapsulates node API methods.
CPUInfo info about host CPU.
CurrentKernel info about host kernel.
GetClusterResourcesData contains data of a cluster's resources from GetClusterResources.
GetClusterResourcesResponse contains the response for the /cluster/resources endpoint.
GetClusterStatusData contains data of a cluster's status from GetClusterStatus.
GetClusterStatusResponse contains the response for the /cluster/status endpoint.
GetNodeCertificatesInfoData contains data of certificates from a GetNodeCertificatesInfo response.
GetNodeCertificatesInfoResponse contains the response for the /nodes/{node}/disks/list endpoint.
GetNodeDisksListData contains data of disks from a GetNodeDisksList response.
GetNodeDisksListResponse contains the response for the /nodes/{node}/disks/list endpoint.
GetNodeLxcData contains data of one VM from a GetNodeLxc response.
GetNodeLxcResponse contains the response for the /nodes/{node}/lxc endpoint.
GetNodeQemuData contains data of one VM from a GetNodeQemu response.
GetNodeQemuResponse contains the response for the /nodes/{node}/qemu endpoint.
GetNodesData contains data of one node from a GetNodes response.
GetNodesResponse contains the response for the /nodes endpoint.
GetNodeStatusData contains data of one node from a GetNode response.
GetNodeStatusResponse contains the response for the /nodes/{node}/status endpoint.
GetNodeStorageData contains data of certificates from a GetNodeStorage response.
GetNodeStorageResponse contains the response for the /nodes/{node}/storage endpoint.
GetNodeVersionData contains the version data for one node from a GetNodeVersion request.
GetNodeVersionResponse contains the response for the /nodes/{node}/version endpoint.
KSM info about Kernel same-page merging.
Memory info about host memory.
NodeService is the service that encapsulates node API methods.
RootFS info about the host root filesystem.
Swap info about swap.

# Type aliases

ClientOptionFunc can be used to customize a new Proxmox API client.
IntOrString is an alias for some returns from the Proxmox API where we've identified that some versions return a string, and others return an integer For example, LXC VMIDs were a string return in PVE 8.1.x, and are an integer in 8.2.x Since it can be either depending on the version of Proxmox queried, we're going to return the looser type.