Class: StudioApi::Gallery::Appliance
- Inherits:
-
ActiveResource::Base
- Object
- ActiveResource::Base
- StudioApi::Gallery::Appliance
- Extended by:
- StudioResource
- Defined in:
- lib/studio_api/gallery.rb
Instance Method Summary collapse
-
#background ⇒ Object
Retrieves content of background image.
-
#comments ⇒ Array[StudioApi::Comment]
Retrieves all comments to appliance.
-
#logo ⇒ Object
Retrieves content of logo image.
-
#post_comment(text, options = {}) ⇒ Object
Adds new comment to appliance.
- #rate(value) ⇒ Object
-
#rating ⇒ Object
Gets rating details as hash #return TODO.
-
#release_notes=(text) ⇒ Object
Modifies appliance release notes @param text of release notes.
-
#software(options = {}) ⇒ Object
Retrieves information about software used to create appliance.
-
#testdrive(options = {}) ⇒ Object
Starts testdrive and gets information how to use it.
-
#unpublish ⇒ Object
Removes appliance from gallery.
-
#versions ⇒ Object
Gets all available versions of appliance in gallery.
Methods included from StudioResource
collection_path, element_path, extended, studio_connection, studio_connection=
Instance Method Details
#background ⇒ Object
Retrieves content of background image
69 70 71 72 |
# File 'lib/studio_api/gallery.rb', line 69 def background request_str = "/gallery/appliances/#{id.to_i}/background" response = GenericRequest.new(self.class.studio_connection).get request_str end |
#comments ⇒ Array[StudioApi::Comment]
Retrieves all comments to appliance
85 86 87 88 89 90 91 92 |
# File 'lib/studio_api/gallery.rb', line 85 def comments request_str = "/gallery/appliances/#{id.to_i}/comments" response = GenericRequest.new(self.class.studio_connection).get request_str tree = XmlSimple.xml_in response, "ForceArray" => ["comment"] tree["appliance"]["comments"]["comment"].collect do |c| Comment.parse(self,c) end end |
#logo ⇒ Object
Retrieves content of logo image
63 64 65 66 |
# File 'lib/studio_api/gallery.rb', line 63 def logo request_str = "/gallery/appliances/#{id.to_i}/logo" response = GenericRequest.new(self.class.studio_connection).get request_str end |
#post_comment(text, options = {}) ⇒ Object
Adds new comment to appliance
95 96 97 98 99 100 101 102 103 |
# File 'lib/studio_api/gallery.rb', line 95 def post_comment text, ={} request_str = "/gallery/appliances/#{id.to_i}/comments" request_str = Util. request_str, response = GenericRequest.new(self.class.studio_connection).post request_str, :__raw => text tree = XmlSimple.xml_in response, "ForceArray" => ["comment"] tree["appliance"]["comments"]["comment"].collect do |c| Comment.parse(self,c) end end |
#rate(value) ⇒ Object
27 28 29 30 31 |
# File 'lib/studio_api/gallery.rb', line 27 def rate value request_str = "/gallery/appliances/#{id.to_i}/rating?rating=#{value.to_i}" response = GenericRequest.new(self.class.studio_connection).post request_str XmlSimple.xml_in(response, "ForceArray" => false)["appliance"] end |
#rating ⇒ Object
Gets rating details as hash #return TODO
18 19 20 21 22 |
# File 'lib/studio_api/gallery.rb', line 18 def request_str = "/gallery/appliances/#{id.to_i}/rating" response = GenericRequest.new(self.class.studio_connection).get request_str XmlSimple.xml_in(response, "ForceArray" => false)["appliance"] end |
#release_notes=(text) ⇒ Object
Modifies appliance release notes @param text of release notes
35 36 37 38 |
# File 'lib/studio_api/gallery.rb', line 35 def release_notes= (text) request_str = "/gallery/appliances/#{id.to_i}/version/#{CGI.escape version.to_s}" response = GenericRequest.new(studio_connection).put request_str, :__raw => release_notes end |
#software(options = {}) ⇒ Object
Retrieves information about software used to create appliance
55 56 57 58 59 60 |
# File 'lib/studio_api/gallery.rb', line 55 def software = {} request_str = "/gallery/appliances/#{id.to_i}/software" request_str = Util. request_str, response = GenericRequest.new(self.class.studio_connection).get request_str #TODO parse response to something usefull end |
#testdrive(options = {}) ⇒ Object
Starts testdrive and gets information how to use it
75 76 77 78 79 80 81 |
# File 'lib/studio_api/gallery.rb', line 75 def testdrive = {} request_str = "/gallery/appliances/#{id.to_i}/testdrive" request_str = Util. request_str, response = GenericRequest.new(self.class.studio_connection).post request_str tree = XmlSimple.xml_in response, "ForceArray" => false tree["testdrive"] end |
#unpublish ⇒ Object
Removes appliance from gallery
41 42 43 44 |
# File 'lib/studio_api/gallery.rb', line 41 def unpublish request_str = "/gallery/appliances/#{id.to_i}/version/#{CGI.escape version.to_s}" response = GenericRequest.new(studio_connection).delete request_str end |
#versions ⇒ Object
Gets all available versions of appliance in gallery
47 48 49 50 51 52 |
# File 'lib/studio_api/gallery.rb', line 47 def versions request_str = "/gallery/appliances/#{id.to_i}/versions" response = GenericRequest.new(self.class.studio_connection).get request_str tree = XmlSimple.xml_in response, "ForceArray" => ["version"] return tree["appliance"]["versions"]["version"] end |