deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core] Core: Added constraints to JSON output (DTACLOUD-410)
Date Thu, 03 Jan 2013 12:06:22 GMT
From: Michal Fojtik <mfojtik@redhat.com>


Signed-off-by: Michal fojtik <mfojtik@redhat.com>
---
 server/lib/deltacloud/helpers/deltacloud_helper.rb | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/server/lib/deltacloud/helpers/deltacloud_helper.rb b/server/lib/deltacloud/helpers/deltacloud_helper.rb
index 1ae34d7..4575ae2 100644
--- a/server/lib/deltacloud/helpers/deltacloud_helper.rb
+++ b/server/lib/deltacloud/helpers/deltacloud_helper.rb
@@ -29,7 +29,7 @@ module Deltacloud::Helpers
             :href => self.send(:"#{c.collection_name}_url"),
             :features => c.features.select { |f| driver.class.has_feature?(c.collection_name,
f.name) }.map { |f|
               f.operations.map { |o|
-                { :name => f.name, :rel => o.name, :params => o.params_array }
+                { :name => f.name, :rel => o.name, :params => o.params_array, :constraints
=> constraints_hash_for(c.collection_name, f.name) }
               }
             }
           }
@@ -39,6 +39,10 @@ module Deltacloud::Helpers
       JSON::dump(:api => r)
     end
 
+    def constraints_hash_for(collection_name, feature_name)
+      driver.class.constraints(:collection => collection_name, :feature => feature_name).inject({})
{ |r, v| r[v[0]]=v[1];r }
+    end
+
     def request_headers
       env.inject({}){|acc, (k,v)| acc[$1.downcase] = v if k =~ /^http_(.*)/i; acc}
     end
-- 
1.8.0.2


Mime
View raw message