pve

package
v0.0.0-...-4cf3db6 Latest Latest
Warning

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

Go to latest
Published: May 4, 2023 License: MIT Imports: 12 Imported by: 3

Documentation

Overview

Package pve is a module for the ProxmoxVE APIs

Index

Constants

View Source
const PveGoVersion = "0.0.0"

PveGoVersion represents the current version of the pve-go library It is used in the default user agent

Variables

This section is empty.

Functions

func BoolPtr

func BoolPtr(v bool) *bool

func BoolPtrToIntPtr

func BoolPtrToIntPtr(v *bool) *int

func BoolToInt

func BoolToInt(v bool) int

func BoolValue

func BoolValue(v *bool) bool

func IntPtr

func IntPtr(v int) *int

func IntPtrToBoolPtr

func IntPtrToBoolPtr(v *int) *bool

func IntValue

func IntValue(v *int) int

func NewAPIError

func NewAPIError(code int, err error, shortMessage, message string) error

NewAPIError creates a new APIError

func StringPtr

func StringPtr(v string) *string

func StringValue

func StringValue(v *string) string

Types

type APIError

type APIError struct {
	Code         int    // HTTP Status code
	Message      string // Error message
	ShortMessage string // Brief explanation of the error
	Err          error  // The original error
}

APIError represents an error from the Proxmox APIs

func (APIError) Dig

func (err APIError) Dig() APIError

returns the inner most APIError

func (APIError) Error

func (err APIError) Error() string

Error returns the error message

func (APIError) Unwrap

func (err APIError) Unwrap() error

Unwrap returns the inner error

type Client

type Client struct {
	Node    NodeClient
	Storage StorageClient
	Version VersionClient
	// contains filtered or unexported fields
}

Client represents a client for the Proxmox APIs.

func NewClient

func NewClient(endpoint string, options ...ClientOption) *Client

NewClient creates a new API client.

func (*Client) Delete

func (c *Client) Delete(path string, value any) error

Delete executes a delete request to Proxmox's API server

func (*Client) Do

func (c *Client) Do(req *http.Request, result any) (*http.Response, error)

Do execute an HTTP request

func (*Client) Get

func (c *Client) Get(path string, value any) error

Get executes a get request to Proxmox's API server

func (*Client) NewRequest

func (c *Client) NewRequest(method string, path string, body any, ctx context.Context) (*http.Request, error)

NewRequest creates a new authorized request

func (*Client) Post

func (c *Client) Post(path string, data any, value any) error

Post executes a post request to Proxmox's API server

func (*Client) Put

func (c *Client) Put(path string, data any, value any) error

Put executes a put request to Proxmox's API server

type ClientOption

type ClientOption func(*Client)

ClientOption represent an option of a Client

func AllowInsecureConnection

func AllowInsecureConnection() ClientOption

AllowInsecureConnection edits the httpClient instance in order to allow TLS certificates signed by an unknown CA. Alternatively, you can use WithHttpClient to set a custom istance of HttpClient that has TLSClientConfig.InsecureSkipVerify set to true.

func WithApiToken

func WithApiToken(tokenId, secret string) ClientOption

WithApiToken configures a client to authenticate using an API Token

func WithHttpClient

func WithHttpClient(httpClient *http.Client) ClientOption

WithHttpClient configures a custom HTTP client

func WithLogger

func WithLogger(logger leveledLogger) ClientOption

WithLogger set the logger to use

func WithUserAgent

func WithUserAgent(userAgent string) ClientOption

WithUserAgent set the user agent to use in each HTTP request.

type Node

type Node struct {
	ID     string
	Node   string
	Status string
	Name   string

	NodeID  int
	IP      string
	Level   string
	Local   bool
	Online  bool
	Nodes   int
	Quorate bool
	Version int

	CPU            int
	MaxCPU         int
	MaxMemory      int
	Memory         int
	Disk           int
	MaxDisk        int
	SSLFingerprint string
	Uptime         int
	Type           string
}

type NodeClient

type NodeClient struct {
	// contains filtered or unexported fields
}

NodeClient is a client for the node APIs

func (*NodeClient) List

func (nc *NodeClient) List() ([]Node, error)

List gets all the nodes in a Proxmox cluster

func (*NodeClient) Reboot

func (nc *NodeClient) Reboot(nodeName string) error

Reboot sends a reboot signal to the given node

func (*NodeClient) Shutdown

func (nc *NodeClient) Shutdown(nodeName string) error

Reboot sends a shutdown signal to the given node

type Storage

type Storage struct {
	Storage string // Name of the storage
	Type    string // Type of storage

	Nodes    *string // List of cluster node names where this storage is usable/accessible
	Content  *string // Allowed content types
	Shared   *bool   // Whether the storage is  accessible from all nodes or not
	Disabled *bool   // Flag to disable the storage.

	Path *string // Absolute filesystem path for the storage

	LVMGroup *string // LVM volume group name. This must point to an existing volume group.
	Thinpool *string // Name of the LVM Thinpool

	Server  *string // NFS endpoint
	Export  *string // NFS export path
	Options *string // NFS mount options
}

Storage represents a storage object

type StorageClient

type StorageClient struct {
	// contains filtered or unexported fields
}

StorageClient is a client for the storage APIs

func (*StorageClient) Create

func (sc *StorageClient) Create(storageId, storageType string, opts StorageCreateOpts) (Storage, error)

Create creates a new storage

func (*StorageClient) Delete

func (sc *StorageClient) Delete(storageID string) error

Delete deletes the specified storage

func (*StorageClient) GetByID

func (sc *StorageClient) GetByID(storageId string) (Storage, error)

GetByID gets a single storage pool

func (*StorageClient) List

func (sc *StorageClient) List(options StorageListOpts) ([]Storage, error)

List gets all the storage pools in a Proxmox cluster

func (*StorageClient) Update

func (sc *StorageClient) Update(storageId string, opts StorageUpdateOpts) (Storage, error)

Create creates a new storage

type StorageCreateOpts

type StorageCreateOpts struct {
	Path string

	LVMGroup string
	Thinpool string

	Server  string
	Export  string
	Options string
}

type StorageListOpts

type StorageListOpts struct {
	Type string
}

type StorageUpdateOpts

type StorageUpdateOpts struct {
	Disabled *bool
	Shared   *bool
}

type VersionClient

type VersionClient struct {
	// contains filtered or unexported fields
}

VersionClient is a client for retrieving Proxmox and API version

func (*VersionClient) Get

func (vc *VersionClient) Get() (schema.Version, error)

Directories

Path Synopsis
Package schema contains the definitions of the Proxmox API objects
Package schema contains the definitions of the Proxmox API objects

Jump to

Keyboard shortcuts

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