Sha256: 0b7b9ea85dd3e1132659b81b8796e1f51a7d099a172afad48a60f385c95e539e

Contents?: true

Size: 1.51 KB

Versions: 1

Compression:

Stored size: 1.51 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'].values.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.1 lib/conjur/deployment.rb