proxmox-go

module
v0.59.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 19, 2023 License: Apache-2.0

README

Proxmox Go Client

This is a Go client library for the Proxmox API. It is automatically generated from my Proxmox Smithy Model.

This library is not yet complete, but it is functional. Supported operations can be found in docs or in the model package.

Use

You can create a client for your proxmox instance with the following code.

import (
	"fmt"
	"net/http"
	"os"
	"time"

	"github.com/awlsring/proxmox-go/proxmox"
)

func main() {
	endpoint := os.Getenv("PROXMOX_ENDPOINT")
	token := os.Getenv("PROXMOX_TOKEN")
	cfg := proxmox.NewConfiguration()
	cfg.Servers[0] = proxmox.ServerConfiguration{
		URL: fmt.Sprintf("%s/api2/json", endpoint),
	}
	cfg.HTTPClient = &http.Client{
		Timeout: 10 * time.Second,
		Transport: &http.Transport{
			MaxIdleConns:        10,
			MaxIdleConnsPerHost: 10,
			TLSClientConfig:    &tls.Config{InsecureSkipVerify: true},
		},
	}
	
	cfg.AddDefaultHeader("Authorization", fmt.Sprintf("PVEAPIToken=%s", token))

	// this is a client that can call methods on the API
	client := proxmox.NewAPIClient(cfg)
}

The client in this example will have methods for all of the operations supported in the model.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL