Class: Fog::Proxmox::Identity::Tokens

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

Overview

class Tokens model collection

Instance Method Summary collapse

Instance Method Details

#all(_options = {}) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/fog/proxmox/identity/models/tokens.rb', line 38

def all(_options = {})
  load service.list_tokens(userid)
rescue Excon::Error::InternalServerError => e
  raise e unless e.response.status_line.include? 'no such user'

  []
end

#create(new_attributes = {}) ⇒ Object



46
47
48
49
50
# File 'lib/fog/proxmox/identity/models/tokens.rb', line 46

def create(new_attributes = {})
  object = new(new_attributes.select { |key, _value| %i[userid tokenid].include? key.to_sym })
  object.save(new_attributes.reject { |key, _value| %i[userid tokenid].include? key.to_sym })
  object
end

#get(tokenid) ⇒ Object



34
35
36
# File 'lib/fog/proxmox/identity/models/tokens.rb', line 34

def get(tokenid)
  all.find { |token| token.tokenid == tokenid && token.userid == userid }
end

#new(new_attributes = {}) ⇒ Object



30
31
32
# File 'lib/fog/proxmox/identity/models/tokens.rb', line 30

def new(new_attributes = {})
  super({ userid: userid }.merge(new_attributes))
end