Sha256: 6e4ba591609c93976b8cbe64872b2e7dbacb652de144ffbe8f9ca5eb6711ae8b

Contents?: true

Size: 900 Bytes

Versions: 6

Compression:

Stored size: 900 Bytes

Contents

require File.expand_path("../role", __FILE__)

module Fog
  module Compute
    class Ecloud
      class Roles < Fog::Ecloud::Collection
        identity :href

        model Fog::Compute::Ecloud::Role

        def all
          data = service.get_roles(href).body
          if data[:OrganizationRole]
            load(data[:OrganizationRole])
          else
            r_data = []
            data[:EnvironmentRoles][:EnvironmentRole].each do |d|
              d[:Environment][:EnvironmentName] = d[:Environment][:name]
              d[:Environment] = d[:Environment].merge(d[:Role]) if d[:Role]
              r_data << d[:Environment]
            end
            load(r_data)
          end
        end

        def get(uri)
          if data = service.get_role(uri)
            new(data.body)
          end
        rescue Fog::Errors::NotFound
          nil
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/roles.rb
fog-ecloud-0.2.0 lib/fog/compute/ecloud/models/roles.rb
fog-ecloud-0.1.3 lib/fog/compute/ecloud/models/roles.rb
fog-ecloud-0.1.2 lib/fog/compute/ecloud/models/roles.rb
fog-ecloud-0.1.1 lib/fog/compute/ecloud/models/roles.rb
fog-ecloud-0.1.0 lib/fog/compute/ecloud/models/roles.rb