Sha256: fae22d2d743f356c125a4349394986fb37394866a06d33830ebbe29679451f9e

Contents?: true

Size: 1.34 KB

Versions: 13

Compression:

Stored size: 1.34 KB

Contents

require 'fog/core/model'

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

        attribute :description
        attribute :enabled
        attribute :name

        def to_s
          self.name
        end

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

        def users
          requires :id
          connection.users(:tenant => self)
        end

        def destroy
          requires :id
          connection.delete_tenant(self.id)
          true
        end

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

        def save
          requires :name
          identity ? update : create
        end

        def create
          merge_attributes(
            connection.create_tenant(attributes).body['tenant'])
          self
        end

        def grant_user_role(user_id, role_id)
          connection.add_user_to_tenant(self.id, user_id, role_id)
        end

        def revoke_user_role(user_id, role_id)
          connection.remove_user_from_tenant(self.id, user_id, role_id)
        end
      end # class Tenant
    end # class OpenStack
  end # module Identity
end # module Fog

Version data entries

13 entries across 13 versions & 7 rubygems

Version Path
fog-nirvanix-1.8.2 lib/fog/openstack/models/identity/tenant.rb
fog-nirvanix-1.8.1 lib/fog/openstack/models/identity/tenant.rb
fog-parser-fix-1.6.1 lib/fog/openstack/models/identity/tenant.rb
fog-test-again-1.6.0 lib/fog/openstack/models/identity/tenant.rb
fog-parser-fix-1.6.0 lib/fog/openstack/models/identity/tenant.rb
ey-vendored-backup-3.0.27 vendor/gems/fog/lib/fog/openstack/models/identity/tenant.rb
fog-sgonyea-1.8.1 lib/fog/openstack/models/identity/tenant.rb
fog-1.8.0 lib/fog/openstack/models/identity/tenant.rb
fog-maestrodev-1.7.0.20121114190951 lib/fog/openstack/models/identity/tenant.rb
fog-1.7.0 lib/fog/openstack/models/identity/tenant.rb
fog-1.6.0 lib/fog/openstack/models/identity/tenant.rb
fog-1.5.0 lib/fog/openstack/models/identity/tenant.rb
fog-1.4.0 lib/fog/openstack/models/identity/tenant.rb