Class: MultiCloudImageInternal

Inherits:
Object
  • Object
show all
Extended by:
RightScale::Api::BaseExtend, RightScale::Api::InternalExtend
Includes:
RightScale::Api::Base, RightScale::Api::Internal
Defined in:
lib/rest_connection/rightscale/multi_cloud_image_internal.rb

Overview

API 0.1

Instance Attribute Summary

Attributes included from RightScale::Api::Base

#params

Class Method Summary collapse

Instance Method Summary collapse

Methods included from RightScale::Api::BaseExtend

[], create, deny_methods, filters, find, find_all, find_by, find_by_cloud_id, find_by_id, find_by_nickname, find_by_nickname_speed, find_with_filter

Methods included from RightScale::Api::BaseConnection

#connection

Methods included from RightScale::Api::InternalConnection

#connection

Methods included from RightScale::Api::Base

#[], #[]=, #destroy, #method_missing, #reload, #rs_id, #save

Constructor Details

#initialize(params = {}) ⇒ MultiCloudImageInternal

Returns a new instance of MultiCloudImageInternal.



70
71
72
73
# File 'lib/rest_connection/rightscale/multi_cloud_image_internal.rb', line 70

def initialize(params={})
  @params = params
  transform_settings
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RightScale::Api::Base

Class Method Details

.resource_plural_nameObject



41
42
43
# File 'lib/rest_connection/rightscale/multi_cloud_image_internal.rb', line 41

def self.resource_plural_name
  "multi_cloud_images"
end

.resource_singular_nameObject



45
46
47
# File 'lib/rest_connection/rightscale/multi_cloud_image_internal.rb', line 45

def self.resource_singular_name
  "multi_cloud_image"
end

Instance Method Details

#cloneObject



54
55
56
57
# File 'lib/rest_connection/rightscale/multi_cloud_image_internal.rb', line 54

def clone
  t = URI.parse(self.href)
  MultiCloudImage.new(:href => connection.post(t.path + "/clone"))
end

#commit(message) ⇒ Object



49
50
51
52
# File 'lib/rest_connection/rightscale/multi_cloud_image_internal.rb', line 49

def commit(message)
  t = URI.parse(self.href)
  MultiCloudImage.new(:href => connection.post(t.path + "/commit"))
end

#resource_plural_nameObject



33
34
35
# File 'lib/rest_connection/rightscale/multi_cloud_image_internal.rb', line 33

def resource_plural_name
  "multi_cloud_images"
end

#resource_singular_nameObject



37
38
39
# File 'lib/rest_connection/rightscale/multi_cloud_image_internal.rb', line 37

def resource_singular_name
  "multi_cloud_image"
end

#settingsObject



75
76
77
78
# File 'lib/rest_connection/rightscale/multi_cloud_image_internal.rb', line 75

def settings
  transform_settings
  @params["multi_cloud_image_cloud_settings"]
end

#supported_cloud_idsObject



80
81
82
# File 'lib/rest_connection/rightscale/multi_cloud_image_internal.rb', line 80

def supported_cloud_ids
  @params["multi_cloud_image_cloud_settings"].map { |mcics| mcics.cloud_id }
end

#transform_settingsObject



59
60
61
62
63
64
65
66
67
68
# File 'lib/rest_connection/rightscale/multi_cloud_image_internal.rb', line 59

def transform_settings
  if @params["multi_cloud_image_cloud_settings"] && @params["multi_cloud_image_cloud_settings"].first.is_a?(Hash)
    @params["multi_cloud_image_cloud_settings"].map! { |setting|
      # Have to reject because API0.1 returns all clouds
      next if setting["fingerprint"] || setting["cloud_id"] > 10
      MultiCloudImageCloudSettingInternal.new(setting)
    }
    @params["multi_cloud_image_cloud_settings"].compact!
  end
end