Sha256: a8f1ff47aa4e6168130d40e200d94c5e01a5b575cce3526103fc155b94a8380f

Contents?: true

Size: 1.5 KB

Versions: 10

Compression:

Stored size: 1.5 KB

Contents

module Ridley
  # @author Jamie Winsor <reset@riotgames.com>
  class EncryptedDataBagItemResource
    class << self
      # Finds a data bag item and decrypts it.
      #
      # @param [Ridley::Client] client
      # @param [Ridley::DataBagResource] data_bag
      # @param [String, #chef_id] object
      #
      # @return [nil, Ridley::DataBagItemResource]
      def find(client, data_bag, object)
        find!(client, data_bag, object)
      rescue Errors::HTTPNotFound
        nil
      end

      # Finds a data bag item and decrypts it. Throws an exception if the item doesn't exist.
      #
      # @param [Ridley::Client] client
      # @param [Ridley::DataBagResource] data_bag
      # @param [String, #chef_id] object
      #
      # @raise [Errors::HTTPNotFound]
      #   if a resource with the given chef_id is not found
      #
      # @return [nil, Ridley::DataBagItemResource]
      def find!(client, data_bag, object)
        data_bag_item = DataBagItemResource.find!(client, data_bag, object)
        data_bag_item.decrypt
        new(client, data_bag, data_bag_item.attributes)
      end
    end

    attr_reader :data_bag
    attr_reader :attributes

    # @param [Ridley::Client] client
    # @param [Ridley::DataBagResource] data_bag
    # @param [#to_hash] attributes
    def initialize(client, data_bag, attributes = {})
      @client     = client
      @data_bag   = data_bag
      @attributes = attributes
    end

    def to_s
      self.attributes
    end

    private

      attr_reader :client
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ridley-0.10.2 lib/ridley/resources/encrypted_data_bag_item_resource.rb
ridley-0.9.1 lib/ridley/resources/encrypted_data_bag_item_resource.rb
ridley-0.10.1 lib/ridley/resources/encrypted_data_bag_item_resource.rb
ridley-0.10.0 lib/ridley/resources/encrypted_data_bag_item_resource.rb
ridley-0.10.0.rc3 lib/ridley/resources/encrypted_data_bag_item_resource.rb
ridley-0.10.0.rc2 lib/ridley/resources/encrypted_data_bag_item_resource.rb
ridley-0.10.0.rc1 lib/ridley/resources/encrypted_data_bag_item_resource.rb
ridley-0.9.0 lib/ridley/resources/encrypted_data_bag_item_resource.rb
ridley-0.8.6 lib/ridley/resources/encrypted_data_bag_item_resource.rb
ridley-0.8.5 lib/ridley/resources/encrypted_data_bag_item_resource.rb