Class: DeltaCloud::Operation::POST

Inherits:
Object
  • Object
show all
Defined in:
lib/deltacloud-cli.rb

Instance Method Summary collapse

Constructor Details

#initialize(operation, resource, options) ⇒ POST

Returns a new instance of POST.



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/deltacloud-cli.rb', line 84

def initialize(operation, resource, options)
  @operation, @resource, @options = operation, resource, options
  instance_options = parse_opts(options)
  puts instance_options.inspect
  #begin
  ap resource
    @collection=case @operation
      when :create then DeltaCloud::Operation::client.send(:"create_#{resource}", instance_options)
      when :start, :stop, :reboot then DeltaCloud::Operation::client.send(:"#{resource}", options.strip).send(:"#{@operation}!")
    end
  #rescue NoMethodError
  #  ap "ERROR: Unknown resource #{resource}. Type 'resources' to list all resources"
  #end
  return self
end

Instance Method Details

#parse_opts(options) ⇒ Object



100
101
102
103
104
105
106
107
# File 'lib/deltacloud-cli.rb', line 100

def parse_opts(options)
  opts = {}
  options.split(' ').collect do |opt|
    opts[:"#{opt.split(':').first}"] = opt.split(':').last
  end
  ap opts
  opts
end

#to_sObject



109
110
111
112
113
114
115
# File 'lib/deltacloud-cli.rb', line 109

def to_s
  if @operation != :create
    GET::new(:get, @resource, @options).to_s
  else
    @collection.inspect
  end
end