Sha256: 71c82db7a79999269faba999f2b817229c4307874d178be51df0aa9ca0f53fb4

Contents?: true

Size: 1.33 KB

Versions: 20

Compression:

Stored size: 1.33 KB

Contents

require 'fog/openstack/models/collection'
require 'fog/openstack/identity/v3/models/role'

module Fog
  module OpenStack
    class Identity
      class V3
        class Roles < Fog::OpenStack::Collection
          model Fog::OpenStack::Identity::V3::Role

          def all(options = {})
            load_response(service.list_roles(options), 'roles')
          end

          def assignments(options = {})
            # TODO(lsmola) this method doesn't make much sense, it should be moved to role.rb and automatically add
            # role.id filter. Otherwise it's just duplication.
            Fog::Logger.deprecation("Calling OpenStack[:keystone].roles.assignments(options) method which"\
                                    " deprecated, call OpenStack[:keystone].role_assignments.all(options) instead")
            load(service.list_role_assignments(options).body['role_assignments'])
          end

          def find_by_id(id)
            cached_role = find { |role| role.id == id }
            return cached_role if cached_role
            role_hash = service.get_role(id).body['role']
            Fog::OpenStack::Identity::V3.role.new(
              role_hash.merge(:service => service)
            )
          end

          def destroy(id)
            role = find_by_id(id)
            role.destroy
          end
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 3 rubygems

Version Path
fog-openstack-1.1.3 lib/fog/openstack/identity/v3/models/roles.rb
fog-openstack-1.1.2 lib/fog/openstack/identity/v3/models/roles.rb
fog-openstack-fork-99 lib/fog/openstack/identity/v3/models/roles.rb
fog-openstack-1.1.0 lib/fog/openstack/identity/v3/models/roles.rb
fog-openstack-1.1.0.pre lib/fog/openstack/identity/v3/models/roles.rb
fog-openstack-apibank-1.0.102 lib/fog/openstack/identity/v3/models/roles.rb
fog-openstack-1.0.11 lib/fog/openstack/identity/v3/models/roles.rb
fog-openstack-apibank-1.0.101 lib/fog/openstack/identity/v3/models/roles.rb
fog-openstack-1.0.10 lib/fog/openstack/identity/v3/models/roles.rb
fog-openstack-1.0.9 lib/fog/openstack/identity/v3/models/roles.rb
fog-openstack-1.0.8 lib/fog/openstack/identity/v3/models/roles.rb
fog-openstack-1.0.7 lib/fog/openstack/identity/v3/models/roles.rb
fog-openstack-1.0.6 lib/fog/openstack/identity/v3/models/roles.rb
fog-openstack-1.0.5 lib/fog/openstack/identity/v3/models/roles.rb
fog-openstack-1.0.4 lib/fog/openstack/identity/v3/models/roles.rb
fog-openstack-1.0.3 lib/fog/openstack/identity/v3/models/roles.rb
fog-openstack-1.0.2 lib/fog/openstack/identity/v3/models/roles.rb
fog-openstack-1.0.1 lib/fog/openstack/identity/v3/models/roles.rb
fog-openstack-1.0.0 lib/fog/openstack/identity/v3/models/roles.rb
fog-openstack-0.3.1 lib/fog/openstack/identity/v3/models/roles.rb