Documentation
¶
Overview ¶
Package pve is a module for the ProxmoxVE APIs
Index ¶
- Constants
- func BoolPtr(v bool) *bool
- func BoolPtrToIntPtr(v *bool) *int
- func BoolToInt(v bool) int
- func BoolValue(v *bool) bool
- func IntPtr(v int) *int
- func IntPtrToBoolPtr(v *int) *bool
- func IntValue(v *int) int
- func NewAPIError(code int, err error, shortMessage, message string) error
- func StringPtr(v string) *string
- func StringValue(v *string) string
- type APIError
- type Client
- func (c *Client) Delete(path string, value any) error
- func (c *Client) Do(req *http.Request, result any) (*http.Response, error)
- func (c *Client) Get(path string, value any) error
- func (c *Client) NewRequest(method string, path string, body any, ctx context.Context) (*http.Request, error)
- func (c *Client) Post(path string, data any, value any) error
- func (c *Client) Put(path string, data any, value any) error
- type ClientOption
- type Node
- type NodeClient
- type Storage
- type StorageClient
- func (sc *StorageClient) Create(storageId, storageType string, opts StorageCreateOpts) (Storage, error)
- func (sc *StorageClient) Delete(storageID string) error
- func (sc *StorageClient) GetByID(storageId string) (Storage, error)
- func (sc *StorageClient) List(options StorageListOpts) ([]Storage, error)
- func (sc *StorageClient) Update(storageId string, opts StorageUpdateOpts) (Storage, error)
- type StorageCreateOpts
- type StorageListOpts
- type StorageUpdateOpts
- type VersionClient
Constants ¶
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 BoolPtrToIntPtr ¶
func IntPtrToBoolPtr ¶
func NewAPIError ¶
NewAPIError creates a new APIError
func StringValue ¶
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
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) NewRequest ¶
func (c *Client) NewRequest(method string, path string, body any, ctx context.Context) (*http.Request, error)
NewRequest creates a new authorized request
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 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 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 StorageListOpts ¶
type StorageListOpts struct {
Type string
}
type StorageUpdateOpts ¶
type StorageUpdateOpts struct { Disabled *bool }
type VersionClient ¶
type VersionClient struct {
// contains filtered or unexported fields
}
VersionClient is a client for retrieving Proxmox and API version