Project

General

Profile

Download (902 Bytes) Statistics
| Branch: | Tag: | Revision:

runcible / lib / runcible / resources / unit.rb @ 27b106f4

1
module Runcible
2
  module Resources
3
    # @see https://docs.pulpproject.org/dev-guide/integration/rest-api/content/index.html
4
    class Unit < Runcible::Base
5
      # Generates the API path for Units
6
      #
7
      # @param  [String]  type  the unit type
8
      # @return [String]        the unit search path
9
      def path(type)
10
        "content/units/#{type}/search/"
11
      end
12

    
13
      # Searches a given unit type based on criteria
14
      #
15
      # @param  [String]                type      the unit type
16
      # @param  [Hash]                  criteria  criteria object containing Mongo syntax
17
      # @param  [Hash]                  optional  container for all optional parameters
18
      # @return [RestClient::Response]
19
      def search(type, criteria, optional = {})
20
        call(:post, path(type), :payload => {:required => {:criteria => criteria}, :optional => optional})
21
      end
22
    end
23
  end
24
end