fluke/devops-service/app/api2/routes/group.rb

68 lines
1.8 KiB
Ruby
Raw Normal View History

2014-05-08 15:34:26 +04:00
# encoding: UTF-8
2014-12-15 14:26:54 +03:00
module Devops
2015-07-16 17:18:55 +03:00
module API2_0
2014-12-22 14:22:04 +03:00
module Routes
2014-12-15 14:26:54 +03:00
module GroupRoutes
2014-05-08 15:34:26 +04:00
2014-12-15 14:26:54 +03:00
def self.registered(app)
2014-12-22 14:22:04 +03:00
2014-12-15 14:26:54 +03:00
# Get security groups for :provider
#
# * *Request*
# - method : GET
# - headers :
# - Accept: application/json
#
2015-11-17 12:14:02 +03:00
# * Params:
# vpc-id - string
#
2014-12-15 14:26:54 +03:00
# * *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
# }
# ]
# }
# }
2015-07-30 15:37:43 +03:00
app.get_with_headers "/groups/:provider", :headers => [:accept] do |provider|
2015-07-16 17:18:55 +03:00
check_privileges("group", "r")
check_provider(provider)
2015-07-30 15:37:43 +03:00
json Devops::API2_0::Handler::Group.new(request).groups(provider)
2015-07-16 17:18:55 +03:00
end
2014-05-08 15:34:26 +04:00
2015-10-27 12:55:51 +03:00
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
2014-12-15 14:26:54 +03:00
puts "Group routes initialized"
end
2014-05-08 15:34:26 +04:00
2014-12-15 14:26:54 +03:00
end
end
2014-05-08 15:34:26 +04:00
end
end