Sha256: dadc131fdc397bbde03a46a3cacb23ede6dcaa1f7957706a801391655f3f1cf2

Contents?: true

Size: 1.41 KB

Versions: 17

Compression:

Stored size: 1.41 KB

Contents

require 'fog/openstack/models/model'

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

          attribute :description
          attribute :enabled
          attribute :name

          def to_s
            self.name
          end

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

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

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

          def update(attr = nil)
            requires :id, :name
            merge_attributes(
                service.update_tenant(self.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(self.id, user_id, role_id)
          end

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

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
fog-openstack-0.1.10 lib/fog/openstack/models/identity_v2/tenant.rb
fog-openstack-0.1.9 lib/fog/openstack/models/identity_v2/tenant.rb
fog-openstack-0.1.8 lib/fog/openstack/models/identity_v2/tenant.rb
fog-openstack-0.1.7 lib/fog/openstack/models/identity_v2/tenant.rb
fog-openstack-0.1.6 lib/fog/openstack/models/identity_v2/tenant.rb
fog-openstack-0.1.5 lib/fog/openstack/models/identity_v2/tenant.rb
fog-openstack-0.1.4 lib/fog/openstack/models/identity_v2/tenant.rb
fog-openstack-0.1.3 lib/fog/openstack/models/identity_v2/tenant.rb
fog-openstack-0.1.2 lib/fog/openstack/models/identity_v2/tenant.rb
fog-openstack-0.1.1 lib/fog/openstack/models/identity_v2/tenant.rb
fog-openstack-0.1.0 lib/fog/openstack/models/identity_v2/tenant.rb
fog-1.37.0 lib/fog/openstack/models/identity_v2/tenant.rb
fog-1.36.0 lib/fog/openstack/models/identity_v2/tenant.rb
fog-1.35.0 lib/fog/openstack/models/identity_v2/tenant.rb
fog-2.0.0.pre.0 lib/fog/openstack/models/identity_v2/tenant.rb
fog-1.34.0 lib/fog/openstack/models/identity_v2/tenant.rb
fog-1.33.0 lib/fog/openstack/models/identity_v2/tenant.rb