Class: Fog::Proxmox::Identity::Token

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/proxmox/identity/models/token.rb

Overview

class Token model

Instance Method Summary collapse

Constructor Details

#initialize(new_attributes = {}) ⇒ Token

Returns a new instance of Token.



34
35
36
37
38
39
40
41
# File 'lib/fog/proxmox/identity/models/token.rb', line 34

def initialize(new_attributes = {})
  prepare_service_value(new_attributes)
  Fog::Proxmox::Attributes.set_attr_and_sym('tokenid', attributes, new_attributes)
  Fog::Proxmox::Attributes.set_attr_and_sym('userid', attributes, new_attributes)
  requires :userid, :tokenid
  initialize_info
  super(new_attributes)
end

Instance Method Details

#destroyObject



50
51
52
53
54
# File 'lib/fog/proxmox/identity/models/token.rb', line 50

def destroy
  requires :tokenid, :userid
  service.delete_token(userid, tokenid)
  true
end

#save(options = {}) ⇒ Object



43
44
45
46
47
48
# File 'lib/fog/proxmox/identity/models/token.rb', line 43

def save(options = {})
  requires :tokenid, :userid
  token_hash = (attributes.reject { |attribute| %i[userid tokenid info].include? attribute }).merge(options)
  service.create_token(userid, tokenid, token_hash)
  reload
end

#updateObject



56
57
58
59
60
61
62
# File 'lib/fog/proxmox/identity/models/token.rb', line 56

def update
  requires :tokenid, :userid
  service.update_token(userid, tokenid, attributes.reject do |attribute|
                                          %i[userid tokenid info].include? attribute
                                        end)
  reload
end