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=#{[:token]}=#{[:secret]}" } end @connection = RestClient::Resource.new( "https://#{cluster}:#{[: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
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 |