lib/yao/resources/keypair.rb in yao-0.7.0 vs lib/yao/resources/keypair.rb in yao-0.8.0

- old
+ new

@@ -4,12 +4,31 @@ self.service = "compute" self.resource_name = "os-keypair" self.resources_name = "os-keypairs" + # os-keypairs API returns very complicated JSON. + # For example. + # { + # "keypairs": [ + # { + # "keypair": { + # "fingerprint": "...", + # } + # }, + # { + # "keypair": { + # "fingerprint": "...", + # } + # }, + # ] + # + # @param query [Hash] + # @return [Array<Yao::Resources::Keypairs>] def self.list(query={}) - return_resources( - resources_from_json(GET(resources_name, query).body).map{|r| resource_from_json(r)} - ) + res = GET(resources_name, query) + res.body['keypairs'].map { |attribute| + new(attribute['keypair']) + } end end end