From: Michal Fojtik <[email protected]>
Signed-off-by: Michal fojtik <[email protected]> --- server/lib/deltacloud/helpers.rb | 3 ++- server/lib/deltacloud/helpers/json_helper.rb | 23 +++++++++++++++++++++++ server/server.rb | 4 +++- 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 server/lib/deltacloud/helpers/json_helper.rb diff --git a/server/lib/deltacloud/helpers.rb b/server/lib/deltacloud/helpers.rb index 5e90bab..6f8c168 100644 --- a/server/lib/deltacloud/helpers.rb +++ b/server/lib/deltacloud/helpers.rb @@ -15,7 +15,8 @@ # under the License. require 'deltacloud/helpers/application_helper' +require 'deltacloud/helpers/json_helper' require 'deltacloud/helpers/conversion_helper' require 'deltacloud/helpers/hardware_profiles_helper' -helpers ApplicationHelper, ConversionHelper, HardwareProfilesHelper +helpers ApplicationHelper, ConversionHelper, HardwareProfilesHelper, JSONHelper diff --git a/server/lib/deltacloud/helpers/json_helper.rb b/server/lib/deltacloud/helpers/json_helper.rb new file mode 100644 index 0000000..170b118 --- /dev/null +++ b/server/lib/deltacloud/helpers/json_helper.rb @@ -0,0 +1,23 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +module JSONHelper + + def json_features_for_entrypoint(entrypoint) + features = driver.features(entrypoint.first).collect { |feature| feature.name } + features.empty? ? {} : { :features => features } + end + +end diff --git a/server/server.rb b/server/server.rb index 4da8357..7998de7 100644 --- a/server/server.rb +++ b/server/server.rb @@ -77,7 +77,9 @@ get '/api\/?' do { :api => { :version => settings.version, :driver => driver_symbol, - :links => entry_points.collect { |l| { :rel => l[0], :href => l[1]} } + :links => entry_points.collect do |l| + { :rel => l[0], :href => l[1] }.merge(json_features_for_entrypoint(l)) + end } }.to_json end -- 1.7.4.1
