Class: Fog::Identity::Proxmox::Real

Inherits:
Object
  • Object
show all
Includes:
Proxmox::Core
Defined in:
lib/fog/identity/proxmox.rb,
lib/fog/identity/proxmox/requests/get_pool.rb,
lib/fog/identity/proxmox/requests/get_role.rb,
lib/fog/identity/proxmox/requests/get_user.rb,
lib/fog/identity/proxmox/requests/get_group.rb,
lib/fog/identity/proxmox/requests/get_domain.rb,
lib/fog/identity/proxmox/requests/list_pools.rb,
lib/fog/identity/proxmox/requests/list_roles.rb,
lib/fog/identity/proxmox/requests/list_users.rb,
lib/fog/identity/proxmox/requests/create_pool.rb,
lib/fog/identity/proxmox/requests/create_role.rb,
lib/fog/identity/proxmox/requests/create_user.rb,
lib/fog/identity/proxmox/requests/delete_pool.rb,
lib/fog/identity/proxmox/requests/delete_role.rb,
lib/fog/identity/proxmox/requests/delete_user.rb,
lib/fog/identity/proxmox/requests/list_groups.rb,
lib/fog/identity/proxmox/requests/update_pool.rb,
lib/fog/identity/proxmox/requests/update_role.rb,
lib/fog/identity/proxmox/requests/update_user.rb,
lib/fog/identity/proxmox/requests/create_group.rb,
lib/fog/identity/proxmox/requests/delete_group.rb,
lib/fog/identity/proxmox/requests/list_domains.rb,
lib/fog/identity/proxmox/requests/read_version.rb,
lib/fog/identity/proxmox/requests/update_group.rb,
lib/fog/identity/proxmox/requests/create_domain.rb,
lib/fog/identity/proxmox/requests/delete_domain.rb,
lib/fog/identity/proxmox/requests/update_domain.rb,
lib/fog/identity/proxmox/requests/add_permission.rb,
lib/fog/identity/proxmox/requests/change_password.rb,
lib/fog/identity/proxmox/requests/list_permissions.rb,
lib/fog/identity/proxmox/requests/check_permissions.rb,
lib/fog/identity/proxmox/requests/remove_permission.rb

Overview

class Real remove_permission request

Instance Attribute Summary

Attributes included from Proxmox::Core

#deadline, #principal, #pve_csrftoken, #pve_ticket, #pve_username

Instance Method Summary collapse

Methods included from Proxmox::Core

#credentials, #initialize_identity, not_found_class, #reload

Constructor Details

#initialize(options = {}) ⇒ Real


110
111
112
113
114
115
116
117
118
# File 'lib/fog/identity/proxmox.rb', line 110

def initialize(options = {})
  initialize_identity(options)
  @connection_options = options[:connection_options] || {}
  @path_prefix = URI.parse(options[:pve_url]).path
  authenticate
  @persistent = options[:persistent] || false
  url = "#{@scheme}://#{@host}:#{@port}"
  @connection = Fog::Core::Connection.new(url, @persistent, @connection_options.merge(path_prefix: @path_prefix))
end

Instance Method Details

#add_permission(permission) ⇒ Object


26
27
28
29
30
31
32
33
# File 'lib/fog/identity/proxmox/requests/add_permission.rb', line 26

def add_permission(permission)
  request(
    expects: [200],
    method: 'PUT',
    path: 'access/acl',
    body: URI.encode_www_form(permission)
  )
end

#change_password(userid, password) ⇒ Object


26
27
28
29
30
31
32
33
# File 'lib/fog/identity/proxmox/requests/change_password.rb', line 26

def change_password(userid, password)
  request(
    expects: [200],
    method: 'PUT',
    path: 'access/password',
    body: "userid=#{userid}&password=#{password}"
  )
end

#check_permissions(principal) ⇒ Object


26
27
28
29
30
31
32
33
34
35
36
# File 'lib/fog/identity/proxmox/requests/check_permissions.rb', line 26

def check_permissions(principal)
  response = request(
    expects: [200],
    method: 'POST',
    path: 'access/ticket',
    body: URI.encode_www_form(principal)
  )
  body = JSON.decode(response.body)
  data = body['data']
  data
end

#configObject


120
121
122
# File 'lib/fog/identity/proxmox.rb', line 120

def config
  self
end

#configure(source) ⇒ Object


124
125
126
127
128
# File 'lib/fog/identity/proxmox.rb', line 124

def configure(source)
  source.instance_variables.each do |v|
    instance_variable_set(v, source.instance_variable_get(v))
  end
end

#create_domain(domain) ⇒ Object


25
26
27
28
29
30
31
32
# File 'lib/fog/identity/proxmox/requests/create_domain.rb', line 25

def create_domain(domain)
  request(
    expects: [200],
    method: 'POST',
    path: 'access/domains',
    body: URI.encode_www_form(domain)
  )
end

#create_group(group) ⇒ Object


25
26
27
28
29
30
31
32
# File 'lib/fog/identity/proxmox/requests/create_group.rb', line 25

def create_group(group)
  request(
    expects: [200],
    method: 'POST',
    path: 'access/groups',
    body: URI.encode_www_form(group)
  )
end

#create_pool(pool) ⇒ Object


25
26
27
28
29
30
31
32
# File 'lib/fog/identity/proxmox/requests/create_pool.rb', line 25

def create_pool(pool)
  request(
    expects: [200],
    method: 'POST',
    path: 'pools',
    body: URI.encode_www_form(pool)
  )
end

#create_role(role) ⇒ Object


25
26
27
28
29
30
31
32
# File 'lib/fog/identity/proxmox/requests/create_role.rb', line 25

def create_role(role)
  request(
    expects: [200],
    method: 'POST',
    path: 'access/roles',
    body: URI.encode_www_form(role)
  )
end

#create_user(user) ⇒ Object


25
26
27
28
29
30
31
32
# File 'lib/fog/identity/proxmox/requests/create_user.rb', line 25

def create_user(user)
  request(
    expects: [200],
    method: 'POST',
    path: 'access/users',
    body: URI.encode_www_form(user)
  )
end

#delete_domain(realm) ⇒ Object


26
27
28
29
30
31
32
# File 'lib/fog/identity/proxmox/requests/delete_domain.rb', line 26

def delete_domain(realm)
  request(
    expects: [200],
    method: 'DELETE',
    path: "access/domains/#{realm}"
  )
end

#delete_group(groupid) ⇒ Object


26
27
28
29
30
31
32
# File 'lib/fog/identity/proxmox/requests/delete_group.rb', line 26

def delete_group(groupid)
  request(
    expects: [200],
    method: 'DELETE',
    path: "access/groups/#{groupid}"
  )
end

#delete_pool(poolid) ⇒ Object


25
26
27
28
29
30
31
# File 'lib/fog/identity/proxmox/requests/delete_pool.rb', line 25

def delete_pool(poolid)
  request(
    expects: [200],
    method: 'DELETE',
    path: "pools/#{poolid}"
  )
end

#delete_role(roleid) ⇒ Object


26
27
28
29
30
31
32
# File 'lib/fog/identity/proxmox/requests/delete_role.rb', line 26

def delete_role(roleid)
  request(
    expects: [200],
    method: 'DELETE',
    path: "access/roles/#{roleid}"
  )
end

#delete_user(userid) ⇒ Object


25
26
27
28
29
30
31
# File 'lib/fog/identity/proxmox/requests/delete_user.rb', line 25

def delete_user(userid)
  request(
    expects: [200],
    method: 'DELETE',
    path: "access/users/#{userid}"
  )
end

#get_domain(realm) ⇒ Object


26
27
28
29
30
31
32
# File 'lib/fog/identity/proxmox/requests/get_domain.rb', line 26

def get_domain(realm)
  request(
    expects: [200],
    method: 'GET',
    path: "access/domains/#{realm}"
  )
end

#get_group(groupid) ⇒ Object


26
27
28
29
30
31
32
# File 'lib/fog/identity/proxmox/requests/get_group.rb', line 26

def get_group(groupid)
  request(
    expects: [200],
    method: 'GET',
    path: "access/groups/#{groupid}"
  )
end

#get_pool(poolid) ⇒ Object


26
27
28
29
30
31
32
# File 'lib/fog/identity/proxmox/requests/get_pool.rb', line 26

def get_pool(poolid)
  request(
    expects: [200],
    method: 'GET',
    path: "pools/#{poolid}"
  )
end

#get_role(roleid) ⇒ Object


26
27
28
29
30
31
32
# File 'lib/fog/identity/proxmox/requests/get_role.rb', line 26

def get_role(roleid)
  request(
    expects: [200],
    method: 'GET',
    path: "access/roles/#{roleid}"
  )
end

#get_user(userid) ⇒ Object


26
27
28
29
30
31
32
# File 'lib/fog/identity/proxmox/requests/get_user.rb', line 26

def get_user(userid)
  request(
    expects: [200],
    method: 'GET',
    path: "access/users/#{userid}"
  )
end

#list_domainsObject


26
27
28
29
30
31
32
# File 'lib/fog/identity/proxmox/requests/list_domains.rb', line 26

def list_domains
  request(
    expects: [200],
    method: 'GET',
    path: 'access/domains'
  )
end

#list_groupsObject


26
27
28
29
30
31
32
# File 'lib/fog/identity/proxmox/requests/list_groups.rb', line 26

def list_groups
  request(
    expects: [200],
    method: 'GET',
    path: 'access/groups'
  )
end

#list_permissionsObject


26
27
28
29
30
31
32
# File 'lib/fog/identity/proxmox/requests/list_permissions.rb', line 26

def list_permissions
  request(
    expects: [200],
    method: 'GET',
    path: 'access/acl'
  )
end

#list_poolsObject


26
27
28
29
30
31
32
# File 'lib/fog/identity/proxmox/requests/list_pools.rb', line 26

def list_pools
  request(
    expects: [200],
    method: 'GET',
    path: 'pools'
  )
end

#list_rolesObject


26
27
28
29
30
31
32
# File 'lib/fog/identity/proxmox/requests/list_roles.rb', line 26

def list_roles
  request(
    expects: [200],
    method: 'GET',
    path: 'access/roles'
  )
end

#list_users(options = {}) ⇒ Object


26
27
28
29
30
31
32
33
# File 'lib/fog/identity/proxmox/requests/list_users.rb', line 26

def list_users(options = {})
  request(
    expects: [200],
    method: 'GET',
    path: 'access/users',
    query: options
  )
end

#read_versionObject


26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/identity/proxmox/requests/read_version.rb', line 26

def read_version
  response = request(
    expects: [200],
    method: 'GET',
    path: 'version'
  )
  body = JSON.decode(response.body)
  data = body['data']
  data
end

#remove_permission(permission) ⇒ Object


26
27
28
29
30
31
32
33
34
# File 'lib/fog/identity/proxmox/requests/remove_permission.rb', line 26

def remove_permission(permission)
  permission.store('delete', 1)
  request(
    expects: [200],
    method: 'PUT',
    path: 'access/acl',
    body: URI.encode_www_form(permission)
  )
end

#update_domain(realm, attributes) ⇒ Object


26
27
28
29
30
31
32
33
# File 'lib/fog/identity/proxmox/requests/update_domain.rb', line 26

def update_domain(realm, attributes)
  request(
    expects: [200],
    method: 'PUT',
    path: "access/domains/#{realm}",
    body: URI.encode_www_form(attributes)
  )
end

#update_group(groupid, attributes) ⇒ Object


26
27
28
29
30
31
32
33
# File 'lib/fog/identity/proxmox/requests/update_group.rb', line 26

def update_group(groupid, attributes)
  request(
    expects: [200],
    method: 'PUT',
    path: "access/groups/#{groupid}",
    body: URI.encode_www_form(attributes)
  )
end

#update_pool(poolid, attributes) ⇒ Object


26
27
28
29
30
31
32
33
# File 'lib/fog/identity/proxmox/requests/update_pool.rb', line 26

def update_pool(poolid, attributes)
  request(
    expects: [200],
    method: 'PUT',
    path: "pools/#{poolid}",
    body: URI.encode_www_form(attributes)
  )
end

#update_role(roleid, attributes) ⇒ Object


26
27
28
29
30
31
32
33
# File 'lib/fog/identity/proxmox/requests/update_role.rb', line 26

def update_role(roleid, attributes)
  request(
    expects: [200],
    method: 'PUT',
    path: "access/roles/#{roleid}",
    body: URI.encode_www_form(attributes)
  )
end

#update_user(userid, attributes) ⇒ Object


26
27
28
29
30
31
32
33
# File 'lib/fog/identity/proxmox/requests/update_user.rb', line 26

def update_user(userid, attributes)
  request(
    expects: [200],
    method: 'PUT',
    path: "access/users/#{userid}",
    body: URI.encode_www_form(attributes)
  )
end