Documentation ¶
Index ¶
- func GetMinTLSVersion(version string) (uint16, error)
- type AuthenticationResponseBody
- type AuthenticationResponseCapabilities
- type AuthenticationResponseData
- type Authenticator
- type Client
- type Connection
- type Credentials
- type Error
- type ErrorResponseBody
- type FileUploadRequest
- type HTTPError
- type MultiPartData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetMinTLSVersion ¶ added in v0.44.0
GetMinTLSVersion returns the minimum TLS version constant for the given string. If the string is empty, the default TLS version is returned. For unsupported TLS versions, an error is returned.
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 // HTTP returns a lower-level HTTP client. HTTP() *http.Client }
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, minTLS string) (*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 Error ¶ added in v0.30.2
type Error string
Error is a sentinel error type for API errors.
const ErrNoDataObjectInResponse Error = "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.
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.