1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/bluebox/requests/create_block.rb

53 lines
1.2 KiB
Ruby
Raw Normal View History

module Fog
module Bluebox
class Real
2010-06-02 11:20:38 -04:00
# 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
2010-06-02 11:20:38 -04:00
# * name<~String> - Name of block
# * options<~Hash>:
# * password<~String> - Password for block
# or
# * ssh_key<~String> - ssh public key
#
# ==== Returns
# * response<~Excon::Response>:
2010-06-02 11:20:38 -04:00
# * body<~Hash>:
# TODO
def create_block(product_id, template_id, name, options = {})
data = {
'name' => name,
'product' => product_id,
'template' => template_id
}.merge!(options)
2010-06-02 11:13:22 -04:00
2010-06-04 00:32:59 -04:00
query = ''
for key, value in data
query << "#{key}=#{CGI.escape(value.to_s).gsub(/\+/, '%20')}&"
end
query.chop!
2010-06-02 11:13:22 -04:00
request(
2010-06-04 00:32:59 -04:00
# :body => data.to_json,
:expects => 200,
:method => 'POST',
2010-06-04 00:32:59 -04:00
:path => '/api/blocks.json',
:query => query
)
end
end
class Mock
def create_block(product_id, template_id, name, password)
2010-06-02 11:09:54 -04:00
Fog::Mock.not_implemented
end
end
end
end