fluke/devops-service/app/api2/routes/group.rb
2015-11-17 12:14:02 +03:00

68 lines
1.8 KiB
Ruby

# encoding: UTF-8
module Devops
module API2_0
module Routes
module GroupRoutes
def self.registered(app)
# Get security groups for :provider
#
# * *Request*
# - method : GET
# - headers :
# - Accept: application/json
#
# * Params:
# vpc-id - string
#
# * *Returns* :
# - ec2:
# {
# "default": {
# "description": "default group",
# "id": "sg-565cf93f",
# "rules": [
# {
# "protocol": "tcp",
# "from": 22,
# "to": 22,
# "cidr": "0.0.0.0/0"
# }
# ]
# }
# }
# - openstack:
# {
# "default": {
# "description": "default",
# "rules": [
# {
# "protocol": null,
# "from": null,
# "to": null,
# "cidr": null
# }
# ]
# }
# }
app.get_with_headers "/groups/:provider", :headers => [:accept] do |provider|
check_privileges("group", "r")
check_provider(provider)
json Devops::API2_0::Handler::Group.new(request).groups(provider)
end
app.get_with_headers "/groups/:provider/:account", :headers => [:accept] do |provider, account|
check_privileges("group", "r")
check_provider(provider)
json Devops::API2_0::Handler::Group.new(request).groups_with_account(provider, account)
end
puts "Group routes initialized"
end
end
end
end
end