1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

organization model working

This commit is contained in:
Rodrigo Estebanez 2013-06-18 17:29:42 +02:00
parent 045c089ee9
commit 4966ecc69a
4 changed files with 50 additions and 0 deletions

View file

@ -42,6 +42,12 @@ module Fog
requires :vcloudng_username, :vcloudng_password, :vcloudng_host
secrets :vcloudng_password
model_path 'fog/vcloudng/models/compute'
model :organization
collection :organizations
request_path 'fog/vcloudng/requests/compute'
request :get_organizations
request :get_organization

View file

@ -0,0 +1,19 @@
require 'fog/core/model'
module Fog
module Compute
class Vcloudng
class Organization < Fog::Model
identity :id
attribute :name
attribute :type
attribute :href
attribute :description, :aliases => 'Description'
attribute :links, :aliases => 'Links'
end
end
end
end

View file

@ -0,0 +1,24 @@
require 'fog/core/collection'
require 'fog/vcloudng/models/compute/organization'
module Fog
module Compute
class Vcloudng
class Organizations < Fog::Collection
model Fog::Compute::Vcloudng::Organization
def all
data = service.get_organizations.body
load(data['OrgList'])
end
def get(organization_id)
if organization_id
self.class.new(:service => service).all.detect {|org| org.id == organization_id}
end
end
end
end
end
end

View file

@ -113,6 +113,7 @@ module Fog
end
end
@response['href'] = org['href']
@response['id'] = org['href'].split('/').last
@response['name'] = org['name']
end
end