Sha256: 03d6d6d1bbc148ff040afa83443db987538448490a0065f4afa101a6bb7ad821

Contents?: true

Size: 848 Bytes

Versions: 4

Compression:

Stored size: 848 Bytes

Contents

module Conjur
  class Layer < RestClient::Resource
    include ActsAsAsset
    include ActsAsRole
    
    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
    
    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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
conjur-asset-layer-api-0.6.0 lib/conjur/layer.rb
conjur-asset-layer-api-0.5.0 lib/conjur/layer.rb
conjur-asset-layer-api-0.4.0 lib/conjur/layer.rb
conjur-asset-layer-api-0.3.1 lib/conjur/layer.rb