fluke/devops-service/app/api2/routes/flavor.rb
2015-10-27 12:55:51 +03:00

54 lines
1.5 KiB
Ruby

module Devops
module API2_0
module Routes
module FlavorRoutes
def self.registered(app)
# Get list of flavors for :provider
#
# * *Request*
# - method : GET
# - headers :
# - Accept: application/json
#
# * *Returns* : array of objects
# - ec2:
# [
# {
# "id": "t1.micro",
# "cores": 2,
# "disk": 0,
# "name": "Micro Instance",
# "ram": 613
# }
# ]
# - openstack:
# [
# {
# "id": "m1.small",
# "v_cpus": 1,
# "ram": 2048,
# "disk": 20
# }
# ]
app.get_with_headers "/flavors/:provider", :headers => [:accept] do |provider|
check_privileges("flavor", "r")
check_provider(provider)
json Devops::API2_0::Handler::Flavor.new(request).flavors(provider)
end
# TODO: check account
app.get_with_headers "/flavors/:provider/:account", :headers => [:accept] do |provider, account|
check_privileges("flavor", "r")
check_provider(provider)
json Devops::API2_0::Handler::Flavor.new(request).flavors_with_account(provider, account)
end
puts "Flavor routes initialized"
end
end
end
end
end