fluke/devops-service/routes/v2.0/image.rb

133 lines
4.0 KiB
Ruby
Raw Normal View History

2014-12-15 14:26:54 +03:00
module Devops
module Version2_0
2014-12-22 14:22:04 +03:00
module Routes
2014-12-15 14:26:54 +03:00
module ImageRoutes
2014-05-08 15:34:26 +04:00
2014-12-15 14:26:54 +03:00
def self.registered(app)
app.after %r{\A/image(/[\w]+)?\z} do
statistic
end
2014-05-08 15:34:26 +04:00
2014-12-15 14:26:54 +03:00
# Get devops images list
#
# * *Request*
# - method : GET
# - headers :
# - Accept: application/json
# - parameters:
# - provider=ec2|openstack -> return images for provider
#
# * *Returns* :
# [
# {
# "provider": "openstack",
# "name": "centos-6.4-x86_64",
# "remote_user": "root",
# "bootstrap_template": null,
# "id": "36dc7618-4178-4e29-be43-286fbfe90f50"
# }
# ]
2015-02-18 13:15:25 +03:00
app.get "/images", :headers => [:accept], &Devops::Version2_0::Handler::Image.get_images
2014-12-22 14:22:04 +03:00
2014-12-15 14:26:54 +03:00
# Get raw images for :provider
#
# * *Request*
# - method : GET
# - headers :
# - Accept: application/json
#
# * *Returns* :
# - ec2
# [
# {
# "id": "ami-83e4bcea",
# "name": "amzn-ami-pv-2013.09.1.x86_64-ebs",
# "status": "available"
# }
# ]
# - openstack
# [
# {
# "id": "36dc7618-4178-4e29-be43-286fbfe90f50",
# "name": "centos-6.4-x86_64",
# "status": "ACTIVE"
# }
# ]
2015-02-18 13:15:25 +03:00
app.get "/images/provider/:provider", :headers => [:accept], &Devops::Version2_0::Handler::Image.get_provider_images
2014-05-08 15:34:26 +04:00
2014-12-15 14:26:54 +03:00
# Get devops image by id
#
# * *Request*
# - method : GET
# - headers :
# - Accept: application/json
#
# * *Returns* :
# {
# "provider": "openstack",
# "name": "centos-6.4-x86_64",
# "remote_user": "root",
# "bootstrap_template": null,
# "id": "36dc7618-4178-4e29-be43-286fbfe90f50"
# }
2015-02-18 13:15:25 +03:00
app.get "/image/:image_id", :headers => [:accept], &Devops::Version2_0::Handler::Image.get_image
2014-05-08 15:34:26 +04:00
2014-12-15 14:26:54 +03:00
# Create devops image
#
# * *Request*
# - method : POST
# - headers :
# - Accept: application/json
# - Content-Type: application/json
# - body :
# {
# "id": "image id",
# "provider": "image provider",
# "remote_user": "user", -> the ssh username
# "bootstrap_template": null, -> specific bootstrap template name or nil
# "name": "image name"
# }
#
# * *Returns* :
# 201 - Created
2014-12-22 14:22:04 +03:00
app.post "/image", &Devops::Version2_0::Handler::Image.create_image
2014-05-08 15:34:26 +04:00
2014-12-15 14:26:54 +03:00
# Update devops image
#
# * *Request*
# - method : PUT
# - headers :
# - Accept: application/json
# - Content-Type: application/json
# - body :
# {
# "id": "image id",
# "provider": "image provider",
# "remote_user": "user" -> the ssh username
# "bootstrap_template": null -> specific bootstrap template name or nil
# "name": "image name"
# }
#
# * *Returns* :
# 200 - Updated
2014-12-22 14:22:04 +03:00
app.put "/image/:image_id", &Devops::Version2_0::Handler::Image.update_image
2014-05-08 15:34:26 +04:00
2014-12-15 14:26:54 +03:00
# Delete devops image
#
# * *Request*
# - method : DELETE
# - headers :
# - Accept: application/json
#
# * *Returns* :
# 200 - Deleted
2014-12-22 14:22:04 +03:00
app.delete "/image/:image_id", &Devops::Version2_0::Handler::Image.delete_image
2014-05-08 15:34:26 +04:00
2014-12-15 14:26:54 +03:00
puts "Image routes initialized"
2014-05-08 15:34:26 +04:00
end
2014-12-15 14:26:54 +03:00
end
2014-05-08 15:34:26 +04:00
end
end
end