proxmox-sdk 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c7fa64e7b8d1feec0ae521242312a0c2d46d122435b15b6053bebe6105661dbc
4
- data.tar.gz: e2cd741a0e09a87b78416d39bfb55d6f9815c95a9fd83d62a6e7bf80386c47fe
3
+ metadata.gz: 18becda6b3edf4aba2a1146a3f889e618c9c49ad9d476f45197b63bae0930f5e
4
+ data.tar.gz: bc2b3f12e06eb9ef9941acf1035a81bdad3be29627fbdec33ee520e374ddb221
5
5
  SHA512:
6
- metadata.gz: 96a721ba56f055791c9281e9dd0d007944c3ee0de6e2889c7a5dc2675a70724a9b2dea4da79eb001597e6c6a9b190347379089bdcc90648780f454eeccdc8edc
7
- data.tar.gz: 104b3087f769b3a3da6a15ca6a5e2e2f5049a8a07fbf0da719b54475bc80741b38ba7b6edd50a699f0760ea31ecb2f381270e74a09bbf4cc2f9bbfa4b03b62b3
6
+ metadata.gz: 4aa011f0cb9ea2ca0694a095e549a410f572cd96325d3cf4886bc1a9ba80536e8d4f64ea9005bdf9836368c2b8a5c823e8d28cc81da77601958a96cd27132865
7
+ data.tar.gz: 3628b92158ebb7288bdd9f231e9db71eb180789df6e36fc7faa69d744b41bcde25535efc90bec9f0b48c1c959a5d9f0811a9aa54850a4a83ab75af6c4016ccb5
data/CHANGELOG.md CHANGED
@@ -3,3 +3,8 @@
3
3
  ## [0.1.0] - 2025-09-30
4
4
 
5
5
  - Initial release
6
+
7
+ ## [0.1.1] - 2025-09-30
8
+
9
+ - Add Cluster functionallity
10
+ - Add Node functionallity
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # Proxmox
2
2
 
3
+ A lightweight Ruby gem that provides a clean, idiomatic interface to the Proxmox VE REST API. It handles authentication, token management, and all common API endpoints (nodes, virtual machines, storage, containers, etc.) so you can focus on building automation, orchestration, or custom tooling without dealing with raw HTTP calls.
3
4
 
4
5
  ## Installation
5
6
 
@@ -22,21 +22,54 @@ module Proxmox
22
22
  end
23
23
 
24
24
  def request(method, path, params = {}, body = nil)
25
- response = http.send(method) do |req|
26
- req.url "/api2/json#{path}"
27
- req.headers["Cookie"] = "PVEAuthCookie=#{ticket}"
28
- req.headers["CSRFPreventionToken"] = csrf_token if %i[post put delete].include?(method)
29
- req.params.update(params) if method == :get
30
- req.body = body.to_json if body
25
+ response = perform_http_call(method, path, params, body)
26
+
27
+ ensure_success!(response)
28
+ extract_data(response)
29
+ end
30
+
31
+ private
32
+
33
+ def perform_http_call(method, path, params, body)
34
+ http.send(method) do |req|
35
+ set_url(req, path)
36
+ add_cookie_header(req)
37
+ set_csrf_header(req, method)
38
+ set_query_params(req, method, params)
39
+ set_body(req, body)
31
40
  end
41
+ end
42
+
43
+ def set_url(req, path)
44
+ req.url "/api2/json#{path}"
45
+ end
46
+
47
+ def add_cookie_header(req)
48
+ req.headers["Cookie"] = "PVEAuthCookie=#{ticket}"
49
+ end
32
50
 
51
+ def set_csrf_header(req, method)
52
+ return unless %i[post put delete].include?(method)
53
+
54
+ req.headers["CSRFPreventionToken"] = csrf_token
55
+ end
56
+
57
+ def set_query_params(req, method, params)
58
+ req.params.update(params) if method == :get && params.any?
59
+ end
60
+
61
+ def set_body(req, body)
62
+ req.body = body.to_json if body
63
+ end
64
+
65
+ def ensure_success!(response)
33
66
  raise ApiError, response.body unless response.success?
67
+ end
34
68
 
69
+ def extract_data(response)
35
70
  JSON.parse(response.body)["data"]
36
71
  end
37
72
 
38
- private
39
-
40
73
  def http
41
74
  @http ||= Faraday.new(url: @base_url, ssl: { verify: @verify_ssl }) do |f|
42
75
  f.request :url_encoded
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Proxmox
4
+ module Resources
5
+ # Proxmox Cluster Class
6
+ class Cluster
7
+ def initialize(client)
8
+ @client = client
9
+ end
10
+
11
+ def log(max: nil)
12
+ params = {}
13
+ params[:max] = max unless max.nil?
14
+
15
+ @client.request(:get, "/cluster/log", params)
16
+ end
17
+
18
+ def nextid(vmid: nil)
19
+ params = {}
20
+ params[:vmid] = vmid unless vmid.nil?
21
+
22
+ @client.request(:get, "/cluster/nextid", params)
23
+ end
24
+
25
+ def options
26
+ @client.request(:get, "/cluster/options")
27
+ end
28
+
29
+ def resources
30
+ @client.request(:get, "/cluster/resources")
31
+ end
32
+
33
+ def status
34
+ @client.request(:get, "/cluster/status")
35
+ end
36
+
37
+ def tasks
38
+ @client.request(:get, "/cluster/tasks")
39
+ end
40
+
41
+ # Getting all Nodes
42
+ def nodes
43
+ @client.request(:get, "/nodes")
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Proxmox
4
+ module Resources
5
+ module Clusters
6
+ # Proxmox Cluster Acme class
7
+ class Acme
8
+ def initialize(client)
9
+ @client = client
10
+ end
11
+
12
+ def tos
13
+ @client.request(:get, "/cluster/acme/tos")
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -9,10 +9,17 @@ module Proxmox
9
9
  @node = node_name
10
10
  end
11
11
 
12
+ # Getting status of the Node
12
13
  def status
13
14
  @client.request(:get, "/nodes/#{@node}/status")
14
15
  end
15
16
 
17
+ # Getting a list of updates for the Node
18
+ def updates
19
+ @client.request(:get, "/nodes/#{@node}/apt/update")
20
+ end
21
+
22
+ # Creating Resources
16
23
  def create_vm(params)
17
24
  @client.request(:post, "/nodes/#{@node}/qemu", {}, params)
18
25
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Proxmox
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
data/lib/proxmox.rb CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  require "proxmox/version"
4
4
  require "proxmox/client"
5
+ require "proxmox/resources/cluster"
6
+ require "proxmox/resources/clusters/acme"
5
7
  require "proxmox/resources/node"
6
8
 
7
9
  module Proxmox
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proxmox-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Wellnitz
@@ -36,6 +36,8 @@ files:
36
36
  - Rakefile
37
37
  - lib/proxmox.rb
38
38
  - lib/proxmox/client.rb
39
+ - lib/proxmox/resources/cluster.rb
40
+ - lib/proxmox/resources/clusters/acme.rb
39
41
  - lib/proxmox/resources/node.rb
40
42
  - lib/proxmox/version.rb
41
43
  - sig/proxmox.rbs