Class: StudioApi::Gallery::Appliance

Inherits:
ActiveResource::Base
  • Object
show all
Extended by:
StudioResource
Defined in:
lib/studio_api/gallery.rb

Instance Method Summary collapse

Methods included from StudioResource

collection_path, element_path, extended, studio_connection, studio_connection=

Instance Method Details

#backgroundObject

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

#commentsArray[StudioApi::Comment]

Retrieves all comments to appliance

Returns:



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

#logoObject

Retrieves content of logo image



63
64
65
66
# File 'lib/studio_api/gallery.rb', line 63

def 
  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, options={}
  request_str = "/gallery/appliances/#{id.to_i}/comments"
  request_str = Util.add_options request_str, options
  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

Posts own rating of appliance @param value in range 0..5 @return TODO



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

#ratingObject

Gets rating details as hash #return TODO



18
19
20
21
22
# File 'lib/studio_api/gallery.rb', line 18

def rating
  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 options = {}
  request_str = "/gallery/appliances/#{id.to_i}/software"
  request_str = Util.add_options request_str, options
  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 options = {}
  request_str = "/gallery/appliances/#{id.to_i}/testdrive"
  request_str = Util.add_options request_str, options
  response = GenericRequest.new(self.class.studio_connection).post request_str
  tree = XmlSimple.xml_in response, "ForceArray" => false
  tree["testdrive"]
end

#unpublishObject

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

#versionsObject

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