Class: Sc
Instance Method Summary collapse
-
#hashtoarray(structure) ⇒ Object
debug_output $stderr.
- #instances(token, serviceroot) ⇒ Object
- #plans(token, serviceroot) ⇒ Object
Instance Method Details
#hashtoarray(structure) ⇒ Object
debug_output $stderr
76 77 78 79 80 81 82 83 84 |
# File 'lib/modules/vca-be.rb', line 76 def hashtoarray(structure) #this function work arounds an issue of httparty (and other REST clients apparently) that do not comply to the XML Schema correctly #in some circumstances the httparty response contains a hash whereas it should be an array of hash with one item #this function takes input a JSON structure and check if it's a hash. If it is, it will turn it into an array of hash with one element #if the input is already an Array of hash it will do nothing #for further reference: http://stackoverflow.com/questions/28282125/httparty-response-interpretation-in-ruby/ structure = [structure] unless structure.is_a? Array return structure end |
#instances(token, serviceroot) ⇒ Object
95 96 97 98 99 100 101 |
# File 'lib/modules/vca-be.rb', line 95 def instances(token, serviceroot) self.class.base_uri serviceroot self.class.[:headers] = { "Accept" => "application/xml;version=5.7", "Authorization" => "Bearer " + token } instancesarray = self.class.get('/api/sc/instances') instancesarray["InstanceList"]["instances"] = hashtoarray(instancesarray["InstanceList"]["instances"]) return instancesarray end |
#plans(token, serviceroot) ⇒ Object
87 88 89 90 91 92 |
# File 'lib/modules/vca-be.rb', line 87 def plans(token, serviceroot) self.class.base_uri serviceroot self.class.[:headers] = { "Accept" => "application/xml;version=5.7", "Authorization" => "Bearer " + token } plansarray = self.class.get('/api/sc/plans') return plansarray end |