Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

get_organization implemented

  • Loading branch information...
commit 4bbf46ebe24ccc564b9f9f8477bc6bd9ebfbceb7 1 parent f9e28e4
@restebanez restebanez authored
View
51 lib/fog/vcloudng/parsers/compute/get_organization.rb
@@ -0,0 +1,51 @@
+module Fog
+ module Parsers
+ module Vcloudng
+ module Compute
+
+ class GetOrganization < VcloudngParser
+
+ def reset
+ @response = { 'Links' => [] }
+ end
+
+ def start_element(name, attributes)
+ super
+ case name
+ when 'Link'
+ link = extract_attributes(attributes)
+ until attributes.empty?
+ if attributes.first.is_a?(Array)
+ attribute = attributes.shift
+ link[attribute.first] = attribute.last
+ else
+ link[attributes.shift] = attributes.shift
+ end
+ end
+ @response['Links'] << link
+ when 'Org'
+ org = extract_attributes(attributes)
+ until attributes.empty?
+ if attributes.first.is_a?(Array)
+ attribute = attributes.shift
+ org[attribute.first] = attribute.last
+ else
+ org[attributes.shift] = attributes.shift
+ end
+ end
+ @response['href'] = org['href']
+ @response['name'] = org['name']
+ end
+ end
+
+ def end_element(name)
+ if name == 'Description'
+ @response[name] = value
+ end
+ end
+
+ end
+ end
+ end
+ end
+end
View
39 lib/fog/vcloudng/requests/compute/get_organization.rb
@@ -0,0 +1,39 @@
+module Fog
+ module Vcloudng
+ module Compute
+ class Real
+
+ require 'fog/vcloudng/parsers/compute/get_organization'
+
+ # Get details of an organization
+ #
+ # ==== Parameters
+ # * organization_id<~Integer> - Id of organization to lookup
+ #
+ # ==== Returns
+ # * response<~Excon::Response>:
+ # * body<~Hash>:
+ # * 'description'<~String> - Description of organization
+ # * 'links'<~Array> - An array of links to entities in the organization
+ # * 'href'<~String> - location of link
+ # * 'name'<~String> - name of link
+ # * 'rel'<~String> - action to perform
+ # * 'type'<~String> - type of link
+ # * 'name'<~String> - Name of organization
+ def get_organization(organization_id)
+
+ request({
+ :expects => 200,
+ :headers => { 'Accept' => 'application/*+xml;version=1.5' },
+ :method => 'GET',
+ :parser => Fog::Parsers::Vcloudng::Compute::GetOrganization.new,
+ :path => "org/#{organization_id}"
+ })
+ end
+
+ end
+
+
+ end
+ end
+end
View
4 lib/fog/vcloudng/shared.rb
@@ -257,8 +257,6 @@ def shared_requires
#require 'fog/vcloudng/parsers/compute/get_internet_services'
#require 'fog/vcloudng/parsers/compute/get_network_ips'
#require 'fog/vcloudng/parsers/compute/get_node_services'
- #require 'fog/vcloudng/parsers/compute/get_organization'
- require 'fog/vcloudng/parsers/compute/get_organizations'
#require 'fog/vcloudng/parsers/compute/get_public_ips'
#require 'fog/vcloudng/parsers/compute/get_tasks_list'
#require 'fog/vcloudng/parsers/compute/get_keys_list'
@@ -285,7 +283,7 @@ def shared_requires
#require 'fog/vcloudng/requests/compute/get_network'
#require 'fog/vcloudng/requests/compute/get_network_ips'
#require 'fog/vcloudng/requests/compute/get_node_services'
- #require 'fog/vcloudng/requests/compute/get_organization'
+ require 'fog/vcloudng/requests/compute/get_organization'
require 'fog/vcloudng/requests/compute/get_organizations'
#require 'fog/vcloudng/requests/compute/get_public_ip'
#require 'fog/vcloudng/requests/compute/get_public_ips'
Please sign in to comment.
Something went wrong with that request. Please try again.