Class: Fog::Proxmox::Identity::User

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

Overview

class User model

Instance Method Summary collapse

Constructor Details

#initialize(new_attributes = {}) ⇒ User

Returns a new instance of User.



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

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

Instance Method Details

#change_passwordObject



64
65
66
67
# File 'lib/fog/proxmox/identity/models/user.rb', line 64

def change_password
  requires :userid, :password
  service.change_password(userid, password)
end

#destroyObject



52
53
54
55
56
# File 'lib/fog/proxmox/identity/models/user.rb', line 52

def destroy
  requires :userid
  service.delete_user(userid)
  true
end

#permissions(path = nil) ⇒ Object



69
70
71
72
# File 'lib/fog/proxmox/identity/models/user.rb', line 69

def permissions(path = nil)
  requires :userid
  attributes[:permissions] = service.list_user_permissions(userid, path)
end

#save(options = {}) ⇒ Object



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

def save(options = {})
  service.create_user((attributes.reject { |attribute| [:tokens].include? attribute }).merge(options))
  reload
end

#updateObject



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

def update
  requires :userid
  service.update_user(userid, attributes.reject { |attribute| %i[userid tokens].include? attribute })
  reload
end