Sha256: e1db1ed49bf79af8830c73f6aaa40a148b744fe8505eddfbfd1fa476f58e5270

Contents?: true

Size: 1.5 KB

Versions: 1

Compression:

Stored size: 1.5 KB

Contents

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
conjur-asset-deployment-api-0.2.2 lib/conjur/deployment.rb