mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
42 lines
1.1 KiB
Ruby
42 lines
1.1 KiB
Ruby
|
module Fog
|
||
|
module Compute
|
||
|
class Ecloud
|
||
|
module Shared
|
||
|
|
||
|
def validate_edit_node_service_options(options)
|
||
|
required_opts = [:name, :enabled]
|
||
|
unless required_opts.all? { |opt| options.has_key?(opt) }
|
||
|
raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}")
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def build_node_service_body_edit(options)
|
||
|
xml = Builder::XmlMarkup.new
|
||
|
xml.NodeService(:name => options[:name]) do
|
||
|
xml.Enabled options[:enabled]
|
||
|
if options[:description]
|
||
|
xml.Description options[:description]
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
class Real
|
||
|
|
||
|
def node_service_edit(options)
|
||
|
validate_edit_node_service_options(options)
|
||
|
body = build_node_service_body_edit(options)
|
||
|
request(
|
||
|
:expects => 202,
|
||
|
:method => 'PUT',
|
||
|
:headers => {},
|
||
|
:body => body,
|
||
|
:uri => options[:uri],
|
||
|
:parse => true
|
||
|
)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|