module Conjur class Deployment < RestClient::Resource include ActsAsAsset def add_host(hostid) log do |logger| logger << "Adding host #{hostid} to deployment #{id}" end invalidate do RestClient::Resource.new(self['hosts'].url, options).post(hostid: hostid) end end def remove_host(hostid) log do |logger| logger << "Removing host #{name} from deployment #{id}" end invalidate do RestClient::Resource.new(self["hosts/#{path_escape hostid}"].url, options).delete end end def add_child(childid) log do |logger| logger << "Adding child #{childid} to deployment #{id}" end invalidate do RestClient::Resource.new(self['children'].url, options).post(id: childid) end end def remove_child(childid) log do |logger| logger << "Removing child #{childid} from deployment #{id}" end invalidate do RestClient::Resource.new(self["children/#{path_escape childid}"].url, options).delete end end def hosts self.attributes['hosts'].collect do |id| Conjur::Host.new("#{Conjur::Dep::API.host}/hosts/#{path_escape id}", options) end end def children self.attributes['children'].values.collect do |attrs| Conjur::Deployment.new("#{Conjur::Dep::API.host}/deployments/#{path_escape attrs['id']}", options).tap do |d| d.attributes = attrs end end end end end