Class: ServerTemplate
- Inherits:
-
Object
- Object
- ServerTemplate
- Extended by:
- RightScale::Api::BaseExtend, RightScale::Api::TaggableExtend
- Includes:
- RightScale::Api::Base, RightScale::Api::Taggable
- Defined in:
- lib/rest_connection/rightscale/server_template.rb
Overview
API 1.0
Instance Attribute Summary collapse
-
#internal ⇒ Object
Returns the value of attribute internal.
Attributes included from RightScale::Api::Base
Instance Method Summary collapse
- #alert_specs ⇒ Object
- #clone ⇒ Object
-
#duplicate ⇒ Object
The RightScale api calls this ‘duplicate’ but is more popularly known as ‘clone’ from a users perspective.
- #executables ⇒ Object
- #fetch_alert_specs ⇒ Object
- #fetch_executables ⇒ Object
- #fetch_multi_cloud_images ⇒ Object
-
#initialize(*args, &block) ⇒ ServerTemplate
constructor
A new instance of ServerTemplate.
- #multi_cloud_images ⇒ Object
- #reload ⇒ Object
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, resource_plural_name, resource_singular_name
Methods included from RightScale::Api::BaseConnection
Methods included from RightScale::Api::TaggableExtend
Methods included from RightScale::Api::Taggable
#add_tags, #clear_tags, #get_info_tags, #get_tags_by_namespace, #remove_info_tags, #remove_tags, #remove_tags_by_namespace, #set_info_tags, #set_tags_by_namespace, #set_tags_to, #tags
Methods included from RightScale::Api::Base
#[], #[]=, #destroy, #method_missing, #resource_plural_name, #resource_singular_name, #rs_id, #save
Constructor Details
#initialize(*args, &block) ⇒ ServerTemplate
Returns a new instance of ServerTemplate.
35 36 37 38 39 40 |
# File 'lib/rest_connection/rightscale/server_template.rb', line 35 def initialize(*args, &block) super(*args, &block) if RightScale::Api::api0_1? @internal = ServerTemplateInternal.new(*args, &block) end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class RightScale::Api::Base
Instance Attribute Details
#internal ⇒ Object
Returns the value of attribute internal.
33 34 35 |
# File 'lib/rest_connection/rightscale/server_template.rb', line 33 def internal @internal end |
Instance Method Details
#alert_specs ⇒ Object
57 58 59 60 61 62 |
# File 'lib/rest_connection/rightscale/server_template.rb', line 57 def alert_specs unless @params["alert_specs"] fetch_alert_specs end @params["alert_specs"] end |
#clone ⇒ Object
113 114 115 |
# File 'lib/rest_connection/rightscale/server_template.rb', line 113 def clone duplicate end |
#duplicate ⇒ Object
The RightScale api calls this ‘duplicate’ but is more popularly known as ‘clone’ from a users perspective
108 109 110 111 |
# File 'lib/rest_connection/rightscale/server_template.rb', line 108 def duplicate my_href = URI.parse(self.href) ServerTemplate.new(:href => connection.post(my_href.path + "/duplicate")) end |
#executables ⇒ Object
50 51 52 53 54 55 |
# File 'lib/rest_connection/rightscale/server_template.rb', line 50 def executables unless @params["executables"] fetch_executables end @params["executables"] end |
#fetch_alert_specs ⇒ Object
64 65 66 67 68 69 70 71 |
# File 'lib/rest_connection/rightscale/server_template.rb', line 64 def fetch_alert_specs my_href = URI.parse(self.href) as = [] connection.get(my_href.path + "/alert_specs").each do |e| as << AlertSpec.new(e) end @params["alert_specs"] = as end |
#fetch_executables ⇒ Object
80 81 82 83 84 85 86 87 |
# File 'lib/rest_connection/rightscale/server_template.rb', line 80 def fetch_executables my_href = URI.parse(self.href) ex = [] connection.get(my_href.path + "/executables").each do |e| ex << Executable.new(e) end @params["executables"] = ex end |
#fetch_multi_cloud_images ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/rest_connection/rightscale/server_template.rb', line 89 def fetch_multi_cloud_images @params["multi_cloud_images"] = [] if connection.settings[:legacy_shard] ServerTemplateInternal.new(:href => self.href).multi_cloud_images.each { |mci_params| @params["multi_cloud_images"] << MultiCloudImageInternal.new(mci_params) } mcis = McServerTemplate.find(self.rs_id.to_i).multi_cloud_images @params["multi_cloud_images"].each_index { |i| @params["multi_cloud_images"][i]["multi_cloud_image_cloud_settings"] += mcis[i].settings } else McServerTemplate.find(self.rs_id.to_i).multi_cloud_images.each { |mci| @params["multi_cloud_images"] << McMultiCloudImage.new(mci.params) } end @params["multi_cloud_images"] end |
#multi_cloud_images ⇒ Object
73 74 75 76 77 78 |
# File 'lib/rest_connection/rightscale/server_template.rb', line 73 def multi_cloud_images unless @params["multi_cloud_images"] fetch_multi_cloud_images end @params["multi_cloud_images"] end |
#reload ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/rest_connection/rightscale/server_template.rb', line 42 def reload ret = connection.get(URI.parse(self.href).path, :include_mcis => true) @params ? @params.merge!(ret) : @params = ret @params["multi_cloud_images"].map! { |mci_params| MultiCloudImage.new(mci_params) } @params["default_multi_cloud_image"] = MultiCloudImage.new(@params["default_multi_cloud_image"]) @params end |