Sha256: d24cea5d3a95b1aa071e4df5f4b5da24d832ebd13931430c47a5c97ce1910202

Contents?: true

Size: 1.63 KB

Versions: 14

Compression:

Stored size: 1.63 KB

Contents

module Fog
  module Terremark
    module Shared
      module Real
        # Get list of organizations
        #
        # ==== Returns
        # * response<~Excon::Response>:
        #   * body<~Array>:
        #     * 'description'<~String> - Description of organization
        #     * 'links'<~Array> - An array of links to entities in the organization
        #     * 'name'<~String> - Name of organization
        def get_organizations
          request({
            :expects  => 200,
            :headers  => {
              'Authorization' => "Basic #{Base64.encode64("#{@terremark_username}:#{@terremark_password}").chomp!}",
              # Terremark said they're going to remove passing in the Content-Type to login in a future release
              'Content-Type'  => "application/vnd.vmware.vcloud.orgList+xml"
            },
            :method   => 'POST',
            :parser   => Fog::Parsers::Terremark::Shared::GetOrganizations.new,
            :path     => 'login'
          })
        end
      end

      module Mock
        def get_organizations
          response = Excon::Response.new
          org_list = self.data[:organizations].map do |organization|
            { "name" => organization[:info][:name],
              "href" => "#{@base_url}/org/#{organization[:info][:id]}",
              "type" => "application/vnd.vmware.vcloud.org+xml"
            }
          end
          response.body = { "OrgList" => org_list }
          response.status = 200
          response.headers = Fog::Terremark::Shared::Mock.headers(response.body, "application/vnd.vmware.vcloud.orgList+xml")
          response
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 4 rubygems

Version Path
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/terremark/requests/shared/get_organizations.rb
nsidc-fog-1.24.1 lib/fog/terremark/requests/shared/get_organizations.rb
fog-1.24.0 lib/fog/terremark/requests/shared/get_organizations.rb
ns-fog-1.22.11 lib/fog/terremark/requests/shared/get_organizations.rb
ns-fog-1.22.10 lib/fog/terremark/requests/shared/get_organizations.rb
ns-fog-1.22.9 lib/fog/terremark/requests/shared/get_organizations.rb
ns-fog-1.22.8 lib/fog/terremark/requests/shared/get_organizations.rb
ns-fog-1.22.7 lib/fog/terremark/requests/shared/get_organizations.rb
ns-fog-1.22.6 lib/fog/terremark/requests/shared/get_organizations.rb
fog-1.23.0 lib/fog/terremark/requests/shared/get_organizations.rb
ns-fog-1.22.4 lib/fog/terremark/requests/shared/get_organizations.rb
ns-fog-1.22.3 lib/fog/terremark/requests/shared/get_organizations.rb
ns-fog-1.22.2 lib/fog/terremark/requests/shared/get_organizations.rb
fog-1.22.1 lib/fog/terremark/requests/shared/get_organizations.rb