deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@redhat.com
Subject [PATCH 06/10] CIMI (Collection): advertise 'add' operation if supported
Date Thu, 08 Nov 2012 04:05:32 GMT
From: David Lutterkort <lutter@redhat.com>

---
 server/lib/cimi/models/collection.rb |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/server/lib/cimi/models/collection.rb b/server/lib/cimi/models/collection.rb
index 48c9ccb..49c36ff 100644
--- a/server/lib/cimi/models/collection.rb
+++ b/server/lib/cimi/models/collection.rb
@@ -115,9 +115,16 @@ module CIMI::Model
         entries = find(:all, context)
         desc = "#{self.name.split("::").last} Collection for the #{context.driver.name.capitalize}
driver"
         id = context.send("#{collection_class.entry_name}_url")
+        ops = []
+        create = "create_#{collection_class.entry_name.to_s.singularize}_url"
+        if context.respond_to?(create)
+          url = context.send(create)
+          ops << { :rel => "add", :href => url }
+        end
         collection_class.new(:id => id, :name => 'default',
                              :count => entries.size,
                              :entries => entries,
+                             :operations => ops,
                              :description => desc)
       end
     end
-- 
1.7.7.6


Mime
View raw message