Sha256: 5234dfeb0390f2c2c74bfdd88762b5a6fb89019751001dfbc90b807d05778948

Contents?: true

Size: 1.49 KB

Versions: 2

Compression:

Stored size: 1.49 KB

Contents

module Conjur
  class ServiceGateway < RestClient::Resource
    include ActsAsAsset
    
    def add_proxy(role)
      log do |logger|
        logger << "Adding proxy #{role} to service gateway #{id}"
      end
      invalidate do
        RestClient::Resource.new(self['proxies'].url, options).post(role: role) 
      end
    end
    
    def remove_proxy(role)
      log do |logger|
        logger << "Removing proxy #{role} from service gateway #{id}"
      end
      invalidate do
        RestClient::Resource.new(self["proxies/#{fully_escape role}"].url, self.options).delete
      end
    end

    def remove_web_service(id)
      log do |logger|
        logger << "Removing web service #{id} from service gateway #{id}"
      end
      invalidate do
        RestClient::Resource.new(self["web_services/#{fully_escape id}"].url, self.options).delete
      end
    end
    
    def web_services
      self.attributes['web_services'].values.collect do |attrs|
        Conjur::WebService.new("#{Conjur::WebServices::API.host}/web_services/#{path_escape attrs['id']}", options).tap do |d|
          d.attributes = attrs
        end
      end
    end
    
    def encrypt(data)
      raise ArgumentError.new("data must not be nil") unless data
      self["encrypt"].post(data, content_type: 'application/octet-stream').body
    end
    
    def decrypt(data)
      raise ArgumentError.new("data must not be nil") unless data
      self["decrypt"].post(data, content_type: 'application/octet-stream').body
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
conjur-asset-service-gateway-api-0.5.3 lib/conjur/service_gateway.rb
conjur-asset-service-gateway-api-0.5.2 lib/conjur/service_gateway.rb