Skip to content
Permalink
Browse files

Merge pull request #1104 from TrevorBramble/bluebox_create_box_post_body

Submit password/ssh_key/username through POST body
  • Loading branch information...
geemus committed Aug 20, 2012
2 parents a0a23f7 + 9ff8ccf commit e0dbefaf967c6495a8c1a769ce84113a401e4f7e
Showing with 18 additions and 4 deletions.
  1. +18 −4 lib/fog/bluebox/requests/compute/create_block.rb
@@ -6,8 +6,9 @@ class Real
# Create a new block
#
# ==== Parameters
# * product_id<~Integer> - Id of product to create block with
# * template_id<~Integer> - Id of template to create block with
# * product_id<~String> - ID of product to create block with
# * template_id<~String> - ID of template to create block with
# * location_id<~String> - ID of location to create block in
# * options<~Hash>:
# * password<~String> - Password for block
# or
@@ -17,13 +18,26 @@ class Real
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash>:
# TODO
def create_block(product_id, template_id, location_id, options = {})

unless options.has_key?(:password) || options.has_key?(:ssh_key)
raise ArgumentError, 'Either password or ssh_key must be supplied'
end

query = {
'product' => product_id,
'template' => template_id,
'location' => location_id
}

body = URI.encode options.map {|k,v| "#{k}=#{v}"}.join('&')

request(
:expects => 200,
:method => 'POST',
:path => '/api/blocks.json',
:query => {'product' => product_id, 'template' => template_id, 'location' => location_id}.merge!(options)
:query => query,
:body => URI.encode(body)
)
end

0 comments on commit e0dbefa

Please sign in to comment.
You can’t perform that action at this time.