Sha256: 3ad879ad49506cf9cd4925057600fd5e48d9cfb44a226073d7558d0a34e4e76e

Contents?: true

Size: 1.34 KB

Versions: 20

Compression:

Stored size: 1.34 KB

Contents

require 'fog/openstack/models/model'

module Fog
  module OpenStack
    class Identity
      class V2
        class Tenant < Fog::OpenStack::Model
          identity :id

          attribute :description
          attribute :enabled
          attribute :name

          def to_s
            name
          end

          def roles_for(user)
            service.roles(
              :tenant => self,
              :user   => user
            )
          end

          def users
            requires :id
            service.users(:tenant_id => id)
          end

          def destroy
            requires :id
            service.delete_tenant(id)
            true
          end

          def update(attr = nil)
            requires :id, :name
            merge_attributes(
              service.update_tenant(id, attr || attributes).body['tenant']
            )
            self
          end

          def create
            requires :name
            merge_attributes(
              service.create_tenant(attributes).body['tenant']
            )
            self
          end

          def grant_user_role(user_id, role_id)
            service.add_user_to_tenant(id, user_id, role_id)
          end

          def revoke_user_role(user_id, role_id)
            service.remove_user_from_tenant(id, user_id, role_id)
          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/v2/models/tenant.rb
fog-openstack-1.1.2 lib/fog/openstack/identity/v2/models/tenant.rb
fog-openstack-fork-99 lib/fog/openstack/identity/v2/models/tenant.rb
fog-openstack-1.1.0 lib/fog/openstack/identity/v2/models/tenant.rb
fog-openstack-1.1.0.pre lib/fog/openstack/identity/v2/models/tenant.rb
fog-openstack-apibank-1.0.102 lib/fog/openstack/identity/v2/models/tenant.rb
fog-openstack-1.0.11 lib/fog/openstack/identity/v2/models/tenant.rb
fog-openstack-apibank-1.0.101 lib/fog/openstack/identity/v2/models/tenant.rb
fog-openstack-1.0.10 lib/fog/openstack/identity/v2/models/tenant.rb
fog-openstack-1.0.9 lib/fog/openstack/identity/v2/models/tenant.rb
fog-openstack-1.0.8 lib/fog/openstack/identity/v2/models/tenant.rb
fog-openstack-1.0.7 lib/fog/openstack/identity/v2/models/tenant.rb
fog-openstack-1.0.6 lib/fog/openstack/identity/v2/models/tenant.rb
fog-openstack-1.0.5 lib/fog/openstack/identity/v2/models/tenant.rb
fog-openstack-1.0.4 lib/fog/openstack/identity/v2/models/tenant.rb
fog-openstack-1.0.3 lib/fog/openstack/identity/v2/models/tenant.rb
fog-openstack-1.0.2 lib/fog/openstack/identity/v2/models/tenant.rb
fog-openstack-1.0.1 lib/fog/openstack/identity/v2/models/tenant.rb
fog-openstack-1.0.0 lib/fog/openstack/identity/v2/models/tenant.rb
fog-openstack-0.3.1 lib/fog/openstack/identity/v2/models/tenant.rb