api

package
v0.0.0-...-435c8fa Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeVM   = "qemu"
	TypeNode = "node"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client http.Client and connection information

func NewClient

func NewClient(i connection.Info, transportSettings *http.Transport) *Client

NewClient create new client with TLS check disabled and information to log with a token to the API

func (*Client) GetClusterFirewallRules

func (c *Client) GetClusterFirewallRules(nodeName string) ([]FirewallRule, error)

GetClusterFirewallRules query the /nodes/<node name>/network URL on the Proxmox API

func (*Client) GetClusterResources

func (c *Client) GetClusterResources() ([]Resource, error)

GetClusterResources query the /cluster/resources URL on the Proxmox API

func (*Client) GetFirewallRules

func (c *Client) GetFirewallRules(res Resource) ([]FirewallRule, error)

GetFirewallRules query the /nodes/<node name>/firewall/rules or the /nodes/<node name>/qemu/<VMID>/firewall/rules URL on the Proxmox API

func (*Client) GetNodeNetwork

func (c *Client) GetNodeNetwork(nodeName string) ([]NodeNetworkInterface, error)

GetNodeNetwork query the /nodes/<node name>/network URL on the Proxmox API

func (*Client) GetNodes

func (c *Client) GetNodes() ([]Node, error)

GetNodes query the /nodes URL on the Proxmox API

func (*Client) GetRawResponse

func (c *Client) GetRawResponse(url string) (interface{}, error)

GetRawResponse query the API endpoint and return a map containing the response body

func (*Client) SendRequest

func (c *Client) SendRequest(req *http.Request) (responseBody []byte, err error)

SendRequest Send request and return body as []byte

type FirewallRule

type FirewallRule struct {
	//Mandatory
	Action   string `json:"action"` //ACCEPT, DROP, REJECT or security group
	RuleType string `json:"type"`   //in, out or group
	//Optional
	Comment          string `json:"comment"`
	Destination      string `json:"dest"`
	DestinationPort  string `json:"dport"`
	Enable           string `json:"enable"`
	NetworkInterface string `json:"iface"`
	LogLevel         string `json:"log"` // emerg, alert, crit, err, warning, notice, info, debug or nolog
	Position         int    `json:"pos"`
	Protocol         string `json:"prot"`
	Source           string `json:"source"`
	SourcePort       string `json:"sport"`
}

FirewallRuleVM VM firewall rule following iptables-based firewall service

type Node

type Node struct {
	Name           string `json:"node,omitempty"`
	Status         string `json:"status"`
	SslFingerprint string `json:"ssl_fingerprint,omitempty"`
}

Node Node resource type at /nodes

type NodeNetworkInterface

type NodeNetworkInterface struct {
	Name          string   `json:"iface"`
	InterfaceType string   `json:"type"`
	Active        int      `json:"active"`
	IPAddress     string   `json:"address"`
	Gateway       string   `json:"gateway"`
	Autostart     int      `json:"autostart"`
	BridgePorts   string   `json:"bridge_ports"`
	CIDR          string   `json:"cidr"`
	Families      []string `json:"families"`
	Options       []string `json:"options"`
}

NodeNetworkInterface Network interface for a given Node at /nodes/<node name>/network

type Resource

type Resource struct {
	AllocatedCPU      float64 `json:"maxcpu"`
	AllocatedRAMBytes int     `json:"maxmem"` // bytes
	CPU               float64 `json:"cpu"`    // %
	ID                string  `json:"id"`
	Name              string  `json:"name,omitempty"`
	Node              string  `json:"node"`
	Pool              string  `json:"pool,omitempty"`
	RAM               int     `json:"mem"` // bytes
	Status            string  `json:"status"`
	Template          int     `json:"template,omitempty"`
	Type              string  `json:"type,omitempty"`
	Uptime            int     `json:"uptime"` // sec
	VMID              int     `json:"vmid,omitempty"`
}

Resource resource at /cluster/resources

Jump to

Keyboard shortcuts

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