Class: Conjur::Layer

Inherits:
RestClient::Resource
  • Object
show all
Includes:
ActsAsAsset, ActsAsRole
Defined in:
lib/conjur/layer.rb

Instance Method Summary collapse

Methods included from ActsAsRole

#can, #cannot, #role, #role_kind, #roleid

Methods included from ActsAsAsset

#add_member, included, #remove_member

Instance Method Details

#add_host(hostid) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/conjur/layer.rb', line 6

def add_host(hostid)
  hostid = cast(hostid, :roleid)
  log do |logger|
    logger << "Adding host #{hostid} to layer #{id}"
  end
  invalidate do
    RestClient::Resource.new(self['hosts'].url, options).post(hostid: hostid) 
  end
end

#hostsObject



31
32
33
34
35
# File 'lib/conjur/layer.rb', line 31

def hosts
  self.attributes['hosts'].collect do |id|
    Conjur::Host.new(Conjur::API.core_asset_host, options)["hosts/#{fully_escape id}"]
  end
end

#hosts_members(role_name) ⇒ Object

Lists the roles that have been granted access to the hosts owned roles.



27
28
29
# File 'lib/conjur/layer.rb', line 27

def hosts_members(role_name)
  owned_role(role_name).members
end

#remove_host(hostid) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/conjur/layer.rb', line 16

def remove_host(hostid)
  hostid = cast(hostid, :roleid)
  log do |logger|
    logger << "Removing host #{hostid} from layer #{id}"
  end
  invalidate do
    RestClient::Resource.new(self["hosts/#{fully_escape hostid}"].url, options).delete
  end
end