Class: ProxmoxAPI
- Inherits:
-
Object
- Object
- ProxmoxAPI
- Defined in:
- lib/proxmox_api.rb
Overview
This class is wrapper for Proxmox PVE APIv2. See README for usage examples.
Defined Under Namespace
Classes: ApiException, ApiPath
Constant Summary collapse
- AUTH_PARAMS =
i[username realm password otp].freeze
- RESOURCE_OPTIONS =
i[headers].freeze
- REST_METHODS =
i[get post put delete].freeze
Class Method Summary collapse
-
.connection_options ⇒ Object
The list of options to be passed to RestClient object.
Instance Method Summary collapse
- #[](index) ⇒ Object
-
#initialize(cluster, options) ⇒ ProxmoxAPI
constructor
Constructor method for ProxmoxAPI.
- #method_missing(method, *args) ⇒ Object
- #respond_to_missing? ⇒ Boolean
Constructor Details
#initialize(cluster, options) ⇒ ProxmoxAPI
Constructor method for ProxmoxAPI
You can also pass here all ssl options supported by rest-client gem
76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/proxmox_api.rb', line 76 def initialize(cluster, ) if .key?(:token) && .key?(:secret) [:headers] = { Authorization: "PVEAPIToken=#{options[:token]}=#{options[:secret]}" } end @connection = RestClient::Resource.new( "https://#{cluster}:#{options[:port] || 8006}/api2/json/", .select { |k, _v| .include?(k.to_s) } ) @auth_ticket = .key?(:token) ? {} : create_auth_ticket(.select { |k, _v| AUTH_PARAMS.include? k }) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
92 93 94 |
# File 'lib/proxmox_api.rb', line 92 def method_missing(method, *args) ApiPath.new(self).__send__(method, *args) end |
Class Method Details
.connection_options ⇒ Object
The list of options to be passed to RestClient object
101 102 103 |
# File 'lib/proxmox_api.rb', line 101 def self. RestClient::Request::SSLOptionList.unshift('verify_ssl') + RESOURCE_OPTIONS end |
Instance Method Details
#[](index) ⇒ Object
88 89 90 |
# File 'lib/proxmox_api.rb', line 88 def [](index) ApiPath.new(self)[index] end |
#respond_to_missing? ⇒ Boolean
96 97 98 |
# File 'lib/proxmox_api.rb', line 96 def respond_to_missing?(*) true end |