Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoDataObjectInResponse = errors.New("the server did not include a data object in the response")
ErrNoDataObjectInResponse is returned when the server does not include a data object in the response.
Functions ¶
This section is empty.
Types ¶
type AuthenticationResponseBody ¶
type AuthenticationResponseBody struct {
Data *AuthenticationResponseData `json:"data,omitempty"`
}
AuthenticationResponseBody contains the body from an authentication response.
type AuthenticationResponseCapabilities ¶
type AuthenticationResponseCapabilities struct {
Access *types.CustomPrivileges `json:"access,omitempty"`
Datacenter *types.CustomPrivileges `json:"dc,omitempty"`
Nodes *types.CustomPrivileges `json:"nodes,omitempty"`
Storage *types.CustomPrivileges `json:"storage,omitempty"`
VMs *types.CustomPrivileges `json:"vms,omitempty"`
}
AuthenticationResponseCapabilities contains the supported capabilities for a session.
type AuthenticationResponseData ¶
type AuthenticationResponseData struct {
ClusterName *string `json:"clustername,omitempty"`
CSRFPreventionToken *string `json:"CSRFPreventionToken,omitempty"`
Capabilities *AuthenticationResponseCapabilities `json:"cap,omitempty"`
Ticket *string `json:"ticket,omitempty"`
Username string `json:"username"`
}
AuthenticationResponseData contains the data from an authentication response.
type Authenticator ¶
type Authenticator interface {
// IsRoot returns true if the authenticator is configured to use the root
IsRoot() bool
// IsRootTicket returns true if the authenticator is configured to use the root directly using a login ticket.
// (root using token is weaker, cannot change VM arch)
IsRootTicket() bool
// AuthenticateRequest adds authentication data to a new request.
AuthenticateRequest(ctx context.Context, req *http.Request) error
}
Authenticator is an interface for adding authentication data to a request. The authenticator is also aware of the authentication context, e.g. if it is configured to use the root user.
func NewTicketAuthenticator ¶
func NewTicketAuthenticator(conn *Connection, creds *Credentials) (Authenticator, error)
NewTicketAuthenticator returns a new ticket authenticator.
func NewTokenAuthenticator ¶
func NewTokenAuthenticator(token string) (Authenticator, error)
NewTokenAuthenticator creates a new authenticator that uses a PVE API Token for authentication.
type Client ¶
type Client interface {
// DoRequest performs a request against the Proxmox API.
DoRequest(
ctx context.Context,
method, path string,
requestBody, responseBody interface{},
) error
// ExpandPath expands a path relative to the client's base path.
// For example, if the client is configured for a VM and the
// path is "firewall/options", the returned path will be
// "/nodes/<node>/qemu/<vmid>/firewall/options".
ExpandPath(path string) string
// IsRoot returns true if the client is configured with the root user.
IsRoot() bool
// IsRootTicket returns true if the authenticator is configured to use the root directly using a login ticket.
// (root using token is weaker, cannot change VM arch)
IsRootTicket() bool
}
Client is an interface for performing requests against the Proxmox API.
func NewClient ¶
func NewClient(creds *Credentials, conn *Connection) (Client, error)
NewClient creates and initializes a VirtualEnvironmentClient instance.
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection represents a connection to the Proxmox Virtual Environment API.
func NewConnection ¶
func NewConnection(endpoint string, insecure bool) (*Connection, error)
NewConnection creates and initializes a Connection instance.
type Credentials ¶
Credentials is a struct that holds the credentials for the Proxmox Virtual Environment API.
func NewCredentials ¶
func NewCredentials(username, password, otp, apiToken string) (*Credentials, error)
NewCredentials creates a new Credentials struct.
type ErrorResponseBody ¶
type ErrorResponseBody struct {
Data *string `json:"data"`
Errors *map[string]string `json:"errors"`
}
ErrorResponseBody contains the body of an error response.
type FileUploadRequest ¶
FileUploadRequest is a request for uploading a file.