class Fog::Identity::OpenStack::V2::Role

Public Instance Methods

add_to_user(user, tenant) click to toggle source
# File lib/fog/openstack/models/identity_v2/role.rb, line 24
def add_to_user(user, tenant)
  add_remove_to_user(user, tenant, :add)
end
destroy() click to toggle source
# File lib/fog/openstack/models/identity_v2/role.rb, line 18
def destroy
  requires :id
  service.delete_role(id)
  true
end
remove_to_user(user, tenant) click to toggle source
# File lib/fog/openstack/models/identity_v2/role.rb, line 28
def remove_to_user(user, tenant)
  add_remove_to_user(user, tenant, :remove)
end
save() click to toggle source
# File lib/fog/openstack/models/identity_v2/role.rb, line 11
def save
  requires :name
  data = service.create_role(name)
  merge_attributes(data.body['role'])
  true
end

Private Instance Methods

add_remove_to_user(user, tenant, ops) click to toggle source
# File lib/fog/openstack/models/identity_v2/role.rb, line 33
def add_remove_to_user(user, tenant, ops)
  requires :id
  user_id = get_id(user)
  tenant_id = get_id(tenant)
  case ops
    when :add
      service.create_user_role(tenant_id, user_id, id).status == 200
    when :remove
      service.delete_user_role(tenant_id, user_id, id).status == 204
  end
end
get_id(_) click to toggle source
# File lib/fog/openstack/models/identity_v2/role.rb, line 45
def get_id(_)
  _.is_a?(String) ? _ : _.id
end