lib/runcible/resources/repository.rb in runcible-0.0.7 vs lib/runcible/resources/repository.rb in runcible-0.1.0

- old
+ new

@@ -19,15 +19,14 @@ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -require 'runcible/base' +require 'active_support/core_ext/hash' - module Runcible - module Pulp + module Resources class Repository < Runcible::Base def self.path(id=nil) (id == nil) ? "repositories/" : "repositories/#{id}/" end @@ -35,12 +34,12 @@ def self.create(id, optional={}) required = required_params(binding.send(:local_variables), binding) call(:post, path, :payload => { :required => required, :optional => optional }) end - def self.retrieve(id, params={}) - call(:get, path(id), :params => params) + def self.retrieve(id, details=true) + call(:get, path(id) + "?details=#{details}") end def self.update(id, optional={}) call(:put, path(id), :payload => { :delta => optional }) end @@ -70,12 +69,35 @@ def self.sync(id, optional={}) call(:post, "#{path(id)}actions/sync/", :payload => { :optional => optional }) end - def self.unit_copy(destination_repo_id, source_repo_id, optional={}) + def self.sync_history(id) + call(:get, "#{path(id)}/history/sync/") + end + + def self.unit_copy(destination_repo_id, source_repo_id, optional={:criteria=>{}}) required = required_params(binding.send(:local_variables), binding, ["destination_repo_id"]) - call(:post, "#{path(destination_repo_id)}actions/associate/", :payload => { :required => required, :optional=> optional }) + call(:post, "#{path(destination_repo_id)}actions/associate/", + :payload => { :required => required, :optional=> optional }) + end + + def self.unassociate_units(source_repo_id, optional={}) + required = required_params(binding.send(:local_variables), binding, ["source_repo_id"]) + call(:post, "#{path(source_repo_id)}actions/unassociate/", + :payload => { :required => required, :optional=> optional }) + end + + def self.unit_search(id, criteria={}) + call(:post, "#{path(id)}search/units/", :payload=>{:required=>{:criteria=>criteria}}) + end + + def self.publish(repo_id, distributor_id) + call(:post, "#{path(repo_id)}actions/publish/", :payload=>{:required=>{:id=>distributor_id}}) + end + + def self.delete_distributor(repo_id, distributor_id) + call(:delete, "#{path(repo_id)}/distributors/#{distributor_id}/") end end end end